ldc-arcadia-api/tests/Unit/Presentation/Api/V1/Presenters/IncoSheets/IncoSheetsSearchPresenterTest.php

49 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\Presentation\Api\V1\Presenters\IncoSheets;
use Application\Arcadia\Usecase\IncoSheets\Search\Output;
use Application\Arcadia\Usecase\IncoSheets\Search\PaginatedShortIncoSheet;
use Domain\Models\ValueObjects\Inco\IncoId;
use Presentation\Api\V1\Presenters\IncoSheets\IncoSheetsSearchPresenter;
use Presentation\Api\V1\Presenters\IncoSheets\IncoSheetsSearchView;
covers(
IncoSheetsSearchPresenter::class,
IncoSheetsSearchView::class,
);
describe('IncoSheetsSearchPresenter Unit Tests', function (): void {
it('transforms Output into IncoSheetsSearchView', function (): void {
// GIVEN
$sheet = new PaginatedShortIncoSheet(
id: new IncoId('1000101'),
name: 'Poulet Rôti',
label: 'Le Gaulois',
createdAt: new \DateTimeImmutable('2024-01-01'),
updatedAt: new \DateTimeImmutable('2024-01-02'),
);
$output = new Output(
incoSheets: [$sheet],
total: 1,
page: 1,
perPage: 25,
);
$presenter = new IncoSheetsSearchPresenter();
// WHEN
$view = $presenter->present($output);
// THEN
expect($view)->toBeInstanceOf(IncoSheetsSearchView::class)
->and($view->incoSheets)->toHaveCount(1)
->and($view->incoSheets[0])->toBe($sheet)
->and($view->total)->toBe(1)
->and($view->page)->toBe(1)
->and($view->perPage)->toBe(25);
});
});