create([ 'id' => '10001', 'name' => 'Poulet Rôti 1kg', ]); // WHEN /** @var \Illuminate\Testing\TestResponse<\Symfony\Component\HttpFoundation\Response> $response */ $response = $test->getJson('/api/v1/inco-sheets'); // THEN $response->assertStatus(200); $response->assertValidRequest(); $response->assertValidResponse(200); }); it('validates GET /api/v1/inco-sheets list response with short projection against openapi spec', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; IncoSheet::factory()->create([ 'id' => '10002', 'name' => 'Salade Niçoise 300g', ]); // WHEN /** @var \Illuminate\Testing\TestResponse<\Symfony\Component\HttpFoundation\Response> $response */ $response = $test->getJson('/api/v1/inco-sheets?short=true'); // THEN $response->assertStatus(200); $response->assertValidRequest(); $response->assertValidResponse(200); }); it('validates GET /api/v1/inco-sheets/{incoId} detail response against openapi spec', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; IncoSheet::factory()->create([ 'id' => '10003', 'name' => 'Lasagnes Bolognaise 400g', ]); // WHEN /** @var \Illuminate\Testing\TestResponse<\Symfony\Component\HttpFoundation\Response> $response */ $response = $test->getJson('/api/v1/inco-sheets/10003'); // THEN $response->assertStatus(200); $response->assertValidRequest(); $response->assertValidResponse(200); }); it('validates GET /api/v1/inco-sheets/{incoId} not found response against openapi spec', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; $unexistingId = '9999999'; // WHEN /** @var \Illuminate\Testing\TestResponse<\Symfony\Component\HttpFoundation\Response> $response */ $response = $test->getJson("/api/v1/inco-sheets/{$unexistingId}"); // THEN $response->assertStatus(404); $response->assertValidRequest(); $response->assertValidResponse(404); }); it('validates GET /api/v1/inco-sheets/search response against openapi spec', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; $query = urlencode('%10004%'); IncoSheet::factory()->create([ 'id' => '1000401', 'name' => 'Pizza Quatre Fromages', ]); // WHEN /** @var \Illuminate\Testing\TestResponse<\Symfony\Component\HttpFoundation\Response> $response */ $response = $test->getJson("/api/v1/inco-sheets/search?incoIdLike={$query}"); // THEN $response->assertStatus(200); $response->assertValidRequest(); $response->assertValidResponse(200); }); it('validates GET /api/v1/inco-sheets/search with short projection against openapi spec', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; $query = urlencode('%10004%'); IncoSheet::factory()->create([ 'id' => '1000402', 'name' => 'Tarte aux Pommes', ]); // WHEN /** @var \Illuminate\Testing\TestResponse<\Symfony\Component\HttpFoundation\Response> $response */ $response = $test->getJson("/api/v1/inco-sheets/search?incoIdLike={$query}&short=true"); // THEN $response->assertStatus(200); $response->assertValidRequest(); $response->assertValidResponse(200); }); });