delete(); MarqueFactory::truncate(); }); describe('Brand OpenAPI Conformance', function (): void { it('validates GET /api/v1/brands list response against openapi spec', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; MarqueFactory::new()->create([ 'COD_MARQ' => 1, 'LIB_MARQ' => 'Le Gaulois', ]); MarqueFactory::new()->create([ 'COD_MARQ' => 2, 'LIB_MARQ' => 'Maître CoQ', ]); // WHEN /** @var \Illuminate\Testing\TestResponse<\Symfony\Component\HttpFoundation\Response> $response */ $response = $test->getJson('/api/v1/brands'); // THEN $response->assertStatus(200); $response->assertValidRequest(); $response->assertValidResponse(200); }); it('validates GET /api/v1/brands/{brandCode} detail response by BrandCode against openapi spec', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; $arcadia = MarqueFactory::new()->create([ 'COD_MARQ' => 2, 'LIB_MARQ' => 'Maître CoQ', ]); Brand::factory()->create([ 'id' => Uuid::uuid7()->toString(), 'arcadia_id' => $arcadia['COD_MARQ'], 'uwil_public_id' => 'MCQ02', ]); // WHEN /** @var \Illuminate\Testing\TestResponse<\Symfony\Component\HttpFoundation\Response> $response */ $response = $test->getJson('/api/v1/brands/MCQ02'); // THEN $response->assertStatus(200); $response->assertValidRequest(); $response->assertValidResponse(200); }); it('validates GET /api/v1/brands/{brandCode} not found response against openapi spec', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; $unexistingCode = 'ZZZ98'; // WHEN /** @var \Illuminate\Testing\TestResponse<\Symfony\Component\HttpFoundation\Response> $response */ $response = $test->getJson("/api/v1/brands/{$unexistingCode}"); // THEN $response->assertStatus(404); $response->assertValidRequest(); $response->assertValidResponse(404); }); it('validates GET /api/v1/brands/{brandCode} validation error for invalid identifier', function (): void { // GIVEN /** @var \Tests\TestCase $test */ $test = $this; $invalidId = 'invalid-format-123'; // WHEN /** @var \Illuminate\Testing\TestResponse<\Symfony\Component\HttpFoundation\Response> $response */ $response = $test->getJson("/api/v1/brands/{$invalidId}"); // THEN $response->assertStatus(422); $response->assertValidResponse(422); }); });