ldc-arcadia-api/tests/Unit/Presentation/Api/V1/Presenters/IncoSheets/IncoSheetsIndexPresenterTest.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\FindAll\Output;
use Application\Arcadia\Usecase\IncoSheets\FindAll\PaginatedShortIncoSheet;
use Domain\Models\ValueObjects\Inco\IncoId;
use Presentation\Api\V1\Presenters\IncoSheets\IncoSheetsIndexPresenter;
use Presentation\Api\V1\Presenters\IncoSheets\IncoSheetsIndexView;
covers(
IncoSheetsIndexPresenter::class,
IncoSheetsIndexView::class,
);
describe('IncoSheetsIndexPresenter Unit Tests', function (): void {
it('transforms Output into IncoSheetsIndexView', 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 IncoSheetsIndexPresenter();
// WHEN
$view = $presenter->present($output);
// THEN
expect($view)->toBeInstanceOf(IncoSheetsIndexView::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);
});
});