ldc-arcadia-api/tests/Feature/OpenApi/V1/IncoSheets/IncoSheetOpenApiTest.php
Jérémy Munsch 34b76cb397
test(feature): align feature and openapi tests with replicated Oracle tables
- Update tests to use factory static helpers and avoid hardcoded table/connection names
- Align test data columns with real replicated Oracle schema
- Remove obsolete duplicate IncoSheetsShowTest
2026-08-26 17:29:18 +02:00

136 lines
4.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\OpenApi\V1\IncoSheets;
use Database\ArcadiaReplicate\Factories\Refp\IncoFactory;
use Spectator\Spectator;
beforeEach(function (): void {
/** @var \Tests\TestCase $this */
Spectator::reset();
Spectator::using('openapi.yaml');
IncoFactory::truncate();
});
describe('IncoSheet OpenAPI Conformance', function (): void {
it('validates GET /api/v1/inco-sheets list response against openapi spec', function (): void {
// GIVEN
/** @var \Tests\TestCase $test */
$test = $this;
IncoFactory::new()->create([
'NO_ART' => 10001,
'DENOM_LEG' => '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;
IncoFactory::new()->create([
'NO_ART' => 10002,
'DENOM_LEG' => '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;
IncoFactory::new()->create([
'NO_ART' => 10003,
'DENOM_LEG' => '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%');
IncoFactory::new()->create([
'NO_ART' => 1000401,
'DENOM_LEG' => '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%');
IncoFactory::new()->create([
'NO_ART' => 1000402,
'DENOM_LEG' => '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);
});
});