ldc-arcadia-api/tests/Unit/Application/Arcadia/Usecase/IncoSheets/FindIncoSheetDtoTest.php
Jérémy Munsch 18fb5f8ac2
refactor(find): use polymorphic outputs for not found cases
Replace not-found exceptions in Arcadia find/show flows with typed outputs (Found*/NotFoundOutput) and map not-found results in presenters/responses while preserving HTTP 404 problem details.

Adjust architecture and unit tests to cover concrete output classes, and remove obsolete Arcadia not-found exception classes and their tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-05 15:50:01 +02:00

65 lines
2 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\Application\Arcadia\Usecase\IncoSheets;
use Application\Arcadia\Usecase\IncoSheets\Find\Input;
use Application\Arcadia\Usecase\IncoSheets\Find\FoundIncoSheetOuput;
use Domain\Models\ValueObjects\Brand\ArcadiaId;
use Domain\Models\ValueObjects\Brand\BrandCode;
use Domain\Models\ValueObjects\Brand\BrandName;
use Domain\Models\ValueObjects\Inco\Allegations;
use Domain\Models\ValueObjects\Inco\IncoBrand;
use Domain\Models\ValueObjects\Inco\IncoId;
use Domain\Models\ValueObjects\Inco\Ingredients;
covers(Input::class, FoundIncoSheetOuput::class);
describe('FindIncoSheet DTO Instantiation', function (): void {
it('can instantiate Input DTO', function (): void {
// GIVEN
$id = new IncoId('12345');
// WHEN
$input = new Input($id);
// THEN
expect($input->id)->toBe($id);
});
it('can instantiate Output DTO', function (): void {
// GIVEN
$id = new IncoId('12345');
// WHEN
$output = new FoundIncoSheetOuput(
id: $id,
name: 'Poulet Rôti 1kg',
label: 'Poulet Rôti Classe A',
description: 'Poulet prêt à cuire',
allegations: new Allegations(['Volaille française']),
sellArguments: 'Origine France',
preparationAdvices: 'Cuire 45min',
tips: null,
sellFamilly: 'Volaille',
ingredients: new Ingredients(['main' => ['Viande']]),
portions: null,
allergens: [],
brand: new IncoBrand(new BrandName('Le Gaulois'), new BrandCode('LGL01'), new ArcadiaId('1')),
isSeasonal: true,
weight: null,
nutriscore: null,
storageCondition: null,
additives: [],
compo: null,
createdAt: null,
updatedAt: null,
);
// THEN
expect($output->id)->toBe($id)
->and($output->name)->toBe('Poulet Rôti 1kg')
->and($output->isSeasonal)->toBeTrue();
});
});