ldc-arcadia-api/tests/Feature/Api/V1/IncoCompositions/IncoCompositionShowTest.php
Jérémy Munsch 91114cb67b
feat(inco-compositions): add IncoCompositionShow feature
- Implemented IncoCompositionShowController to handle requests for inco composition details.
- Created IncoCompositionDto for response data structure.
- Added IncoCompositionShowRequest for request validation.
- Developed IncoCompositionShowResponse for formatting API responses.
- Introduced IncoCompositionShowPresenter and IncoCompositionShowView for presentation logic.
- Added tests for IncoCompositionShow feature and OpenAPI conformance.
2026-08-14 15:56:58 +02:00

58 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Api\V1\IncoCompositions;
use Infra\Database\Models\IncoCompo;
use Infra\Database\Models\IncoSheet;
describe('IncoCompositions Show Feature API', function (): void {
it('returns 200 OK with inco composition details by inco sheet ID', function (): void {
// GIVEN
/** @var \Tests\TestCase $test */
$test = $this;
$sheet = IncoSheet::factory()->create([
'id' => '12345',
'compo_id' => '67890',
]);
IncoCompo::factory()->create([
'id' => '67890',
'id_inco' => '12345',
'identification' => [
'name' => 'Poulet Rôti 1kg Test',
'number' => '12345',
'source' => 'LDC',
],
]);
// WHEN
$response = $test->getJson("/api/v1/inco-sheets/{$sheet->id}/composition");
// THEN
$response->assertStatus(200);
$response->assertJson([
'composition' => [
'id' => '67890',
'incoId' => '12345',
'identification' => [
'name' => 'Poulet Rôti 1kg Test',
],
],
]);
});
it('returns 404 Not Found when composition does not exist', function (): void {
// GIVEN
/** @var \Tests\TestCase $test */
$test = $this;
// WHEN
$response = $test->getJson('/api/v1/inco-sheets/999999/composition');
// THEN
$response->assertStatus(404);
});
});