test(unit): update application and infra unit tests with Pagination VOs and GWT format

This commit is contained in:
Jérémy Munsch 2026-09-15 12:49:03 +02:00
parent d96f903e1c
commit d94f78dace
Signed by: forge-joniko
GPG key ID: D7EFE2F5CB6CC0E4
14 changed files with 51 additions and 23 deletions

View file

@ -22,6 +22,8 @@ use Ramsey\Uuid\Uuid;
use Shared\DDD\Event\DomainEventDispatcher;
use Shared\DDD\Event\Event;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(
FindAllBrands::class,
@ -63,7 +65,7 @@ describe('FindAllBrands Usecase Unit Tests', function (): void {
$resolver = new BrandResolver($arcadiaDirectory, $brandRepository, $codeGenerator, $dispatcher);
$usecase = new FindAllBrands($arcadiaDirectory, $resolver);
$input = new Input(Pagination::ofPage(1, 25));
$input = new Input(Pagination::ofPage(new PageNumber(1), new PageSize(25)));
// WHEN
$result = $usecase->execute($input);
@ -98,7 +100,7 @@ describe('FindAllBrands Usecase Unit Tests', function (): void {
$resolver = new BrandResolver($arcadiaDirectory, $brandRepository, $codeGenerator, $dispatcher);
$usecase = new FindAllBrands($arcadiaDirectory, $resolver);
$input = new Input(Pagination::ofPage(2, 2));
$input = new Input(Pagination::ofPage(new PageNumber(2), new PageSize(2)));
// WHEN
$result = $usecase->execute($input);
@ -115,7 +117,7 @@ describe('FindAllBrands Usecase Unit Tests', function (): void {
// GIVEN
$resolver = new BrandResolver($arcadiaDirectory, $brandRepository, $codeGenerator, $dispatcher);
$usecase = new FindAllBrands($arcadiaDirectory, $resolver);
$input = new Input(Pagination::ofPage(1, 25));
$input = new Input(Pagination::ofPage(new PageNumber(1), new PageSize(25)));
// WHEN
$result = $usecase->execute($input);

View file

@ -8,6 +8,8 @@ use Application\Arcadia\Usecase\Employees\FindAll\Input;
use Domain\Models\ValueObjects\Employees\EmployeeSortColumn;
use Domain\Models\ValueObjects\Employees\EmployeeSorter;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(
Input::class,
@ -16,7 +18,7 @@ covers(
describe('FindAllEmployees Application DTOs Unit Tests', function (): void {
it('instantiates Input DTO', function (): void {
// GIVEN
$pagination = Pagination::ofPage(1, 25);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(25));
$sorter = new EmployeeSorter(EmployeeSortColumn::arcadiaId, \SortDirection::Ascending);
// WHEN

View file

@ -17,6 +17,8 @@ use Domain\Models\ValueObjects\ServiceId;
use Domain\Models\ValueObjects\SiteId;
use Infra\Adapters\Directories\InMemoryEmployeeDirectory;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(
FindAllEmployees::class,
@ -51,7 +53,7 @@ describe('FindAllEmployees Usecase Unit Tests', function (): void {
$directory->add($employee);
$usecase = new FindAllEmployees($directory);
$pagination = Pagination::ofPage(1, 10);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(10));
$sorter = new EmployeeSorter(
EmployeeSortColumn::arcadiaId,
\SortDirection::Ascending

View file

@ -20,6 +20,8 @@ use Domain\Models\ValueObjects\Inco\IncoSheetSortColumn;
use Domain\Models\ValueObjects\Inco\IncoSheetSorter;
use Domain\Models\ValueObjects\Inco\Ingredients;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(
Input::class,
@ -31,7 +33,7 @@ covers(
describe('FindAllIncoSheets DTOs Instantiation & Logic', function (): void {
it('instantiates Input DTO', function (): void {
// GIVEN
$pagination = Pagination::ofPage(1, 10);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(10));
$sorter = new IncoSheetSorter(IncoSheetSortColumn::incoSheetId, \SortDirection::Ascending);
// WHEN

View file

@ -22,6 +22,8 @@ use Domain\Models\ValueObjects\Inco\Ingredients;
use Infra\Adapters\Directories\InMemoryIncoSheetDirectory;
use Infra\Adapters\Directories\InMemoryIncoShortSheetDirectory;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(
FindAllIncoSheets::class,
@ -69,7 +71,7 @@ describe('FindAllIncoSheets Usecase Unit Tests', function (): void {
$directory->add($incoSheet);
$usecase = new FindAllIncoSheets($directory, $shortDirectory);
$pagination = Pagination::ofPage(1, 10);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(10));
$sorter = new IncoSheetSorter(IncoSheetSortColumn::incoSheetId, \SortDirection::Ascending);
$input = new Input($pagination, $sorter);

View file

@ -22,6 +22,8 @@ use Domain\Models\ValueObjects\Inco\Ingredients;
use Infra\Adapters\Directories\InMemoryIncoSheetDirectory;
use Infra\Adapters\Directories\InMemoryIncoShortSheetDirectory;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(
SearchIncoSheets::class,
@ -71,7 +73,7 @@ describe('SearchIncoSheets Usecase Unit Tests', function (): void {
$input = new Input(
query: new IncoIdQuery('12%'),
short: false,
pagination: Pagination::ofPage(1, 10),
pagination: Pagination::ofPage(new PageNumber(1), new PageSize(10)),
brands: new BrandCode('LGL01'),
);
@ -99,7 +101,7 @@ describe('SearchIncoSheets Usecase Unit Tests', function (): void {
$input = new Input(
query: new IncoIdQuery('12%'),
short: true,
pagination: Pagination::ofPage(1, 10),
pagination: Pagination::ofPage(new PageNumber(1), new PageSize(10)),
);
// WHEN

View file

@ -16,6 +16,8 @@ use Application\Security\Usecases\FindAllClients\PaginatedClient;
use Infra\Adapters\Repositories\InMemoryClientRepository;
use Ramsey\Uuid\Uuid;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(
FindAllClients::class,
@ -50,7 +52,7 @@ describe('FindAllClients Usecase Unit Tests', function (): void {
$repository->add($client1, $client2);
$usecase = new FindAllClients($repository);
$pagination = Pagination::ofPage(1, 10);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(10));
$input = new Input($pagination);
// WHEN
@ -70,7 +72,7 @@ describe('FindAllClients Usecase Unit Tests', function (): void {
it('returns empty clients list when repository is empty', function () use ($repository): void {
// GIVEN
$usecase = new FindAllClients($repository);
$pagination = Pagination::ofPage(1, 10);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(10));
$input = new Input($pagination);
// WHEN

View file

@ -9,6 +9,8 @@ use Domain\Models\ValueObjects\Brand\ArcadiaId;
use Domain\Models\ValueObjects\Brand\BrandName;
use Infra\Adapters\Directories\InMemoryArcadiaBrandDirectory;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(InMemoryArcadiaBrandDirectory::class);
@ -39,7 +41,7 @@ describe('InMemoryArcadiaBrandDirectory Unit Tests', function (): void {
$directory->add($b1, $b2);
// WHEN
$all = $directory->findAll(Pagination::ofPage(1, 25));
$all = $directory->findAll(Pagination::ofPage(new PageNumber(1), new PageSize(25)));
// THEN
expect($all->getItems())->toHaveCount(2)
@ -49,7 +51,7 @@ describe('InMemoryArcadiaBrandDirectory Unit Tests', function (): void {
$directory->clear();
// THEN
expect($directory->findAll(Pagination::ofPage(1, 25))->getItems())->toBeEmpty();
expect($directory->findAll(Pagination::ofPage(new PageNumber(1), new PageSize(25)))->getItems())->toBeEmpty();
});
it('filters out comment and obsolete brands starting with Z -', function (): void {
@ -60,7 +62,7 @@ describe('InMemoryArcadiaBrandDirectory Unit Tests', function (): void {
$directory->add($valid, $comment);
// WHEN
$all = $directory->findAll(Pagination::ofPage(1, 25));
$all = $directory->findAll(Pagination::ofPage(new PageNumber(1), new PageSize(25)));
$found = $directory->find(new ArcadiaId('2'));
// THEN

View file

@ -14,6 +14,8 @@ use Domain\Models\ValueObjects\ServiceId;
use Domain\Models\ValueObjects\SiteId;
use Infra\Adapters\Directories\InMemoryEmployeeDirectory;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(InMemoryEmployeeDirectory::class);
@ -81,7 +83,7 @@ describe('InMemoryEmployeeDirectory Unit Tests', function (): void {
$directory->add($emp1, $emp2);
$pagination = Pagination::ofPage(1, 10);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(10));
$sorter = new EmployeeSorter(EmployeeSortColumn::arcadiaId, \SortDirection::Descending);
$filter = new EmployeeFilter(establishment: new EstablishmentCode('EST01'));
@ -142,7 +144,7 @@ describe('InMemoryEmployeeDirectory Unit Tests', function (): void {
$directory->add($emp1, $emp2, $emp3);
$pagination = Pagination::ofPage(1, 10);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(10));
$sorter = new EmployeeSorter(EmployeeSortColumn::arcadiaId, \SortDirection::Ascending);
$filter = new EmployeeFilter(since: new \DateTimeImmutable('2024-01-01'));

View file

@ -18,6 +18,8 @@ use Domain\Models\ValueObjects\Inco\IncoSheetSorter;
use Domain\Models\ValueObjects\Inco\Ingredients;
use Infra\Adapters\Directories\InMemoryIncoSheetDirectory;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(InMemoryIncoSheetDirectory::class);
@ -71,7 +73,7 @@ describe('InMemoryIncoSheetDirectory Unit Tests', function (): void {
$sheet2 = createSheet('10002', 'MCQ01', 'Maître CoQ', '2');
$directory->add($sheet1, $sheet2);
$pagination = Pagination::ofPage(1, 10);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(10));
$sorter = new IncoSheetSorter(IncoSheetSortColumn::incoSheetId, \SortDirection::Descending);
$filter = new IncoSheetFilter(null, new BrandCode('LGL01'));
@ -93,7 +95,7 @@ describe('InMemoryIncoSheetDirectory Unit Tests', function (): void {
$directory->add($sheet1, $sheet2, $sheet3);
$query = new IncoIdQuery('12%');
$pagination = Pagination::ofPage(1, 10);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(10));
// WHEN
$result = $directory->search($query, $pagination, new BrandCode('LGL01'));

View file

@ -12,6 +12,8 @@ use Domain\Models\ValueObjects\Inco\IncoSheetSortColumn;
use Domain\Models\ValueObjects\Inco\IncoSheetSorter;
use Infra\Adapters\Directories\InMemoryIncoShortSheetDirectory;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(InMemoryIncoShortSheetDirectory::class);
@ -49,7 +51,7 @@ describe('InMemoryIncoShortSheetDirectory Unit Tests', function (): void {
$sheet2 = createShortSheet('10002');
$directory->add($sheet1, $sheet2);
$pagination = Pagination::ofPage(1, 10);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(10));
$sorter = new IncoSheetSorter(IncoSheetSortColumn::incoSheetId, \SortDirection::Descending);
$filter = new IncoSheetFilter(new \DateTimeImmutable('2023-01-01'));
@ -71,7 +73,7 @@ describe('InMemoryIncoShortSheetDirectory Unit Tests', function (): void {
$directory->add($sheet1, $sheet2, $sheet3);
$query = new IncoIdQuery('12%');
$pagination = Pagination::ofPage(1, 10);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(10));
// WHEN
$result = $directory->search($query, $pagination);

View file

@ -12,6 +12,8 @@ use Domain\Models\ValueObjects\Brand\BrandName;
use Infra\Adapters\Repositories\InMemoryBrandRepository;
use Ramsey\Uuid\Uuid;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(InMemoryBrandRepository::class);
@ -53,7 +55,7 @@ describe('InMemoryBrandRepository Unit Tests', function (): void {
$repository->add($b1, $b2);
// WHEN
$paginated = $repository->findAll(Pagination::ofPage(1, 1));
$paginated = $repository->findAll(Pagination::ofPage(new PageNumber(1), new PageSize(1)));
// THEN
expect($paginated->getItems())->toHaveCount(1)

View file

@ -12,6 +12,8 @@ use Application\Security\Models\ValueObjects\Entities\ClientId;
use Infra\Adapters\Repositories\InMemoryClientRepository;
use Ramsey\Uuid\Uuid;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(InMemoryClientRepository::class);
@ -81,7 +83,7 @@ describe('InMemoryClientRepository Unit Tests', function (): void {
$client2 = createClient('arcadia_id_' . str_repeat('2', 32));
$repository->add($client1, $client2);
$pagination = Pagination::ofPage(1, 10);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(10));
// WHEN
$result = $repository->findAll($pagination);

View file

@ -17,6 +17,8 @@ use Ramsey\Uuid\Uuid;
use Domain\Models\ValueObjects\Brand\ArcadiaBrand;
use Shared\Paginated;
use Shared\Pagination;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
covers(BrandCache::class);
@ -317,7 +319,7 @@ describe('BrandCache Unit Tests', function (): void {
it('gets and puts arcadia paginated results to cache', function (): void {
// GIVEN
$pagination = Pagination::ofPage(1, 25);
$pagination = Pagination::ofPage(new PageNumber(1), new PageSize(25));
$brand1 = new ArcadiaBrand(new ArcadiaId('1'), new BrandName('Brand One'));
$brand2 = new ArcadiaBrand(new ArcadiaId('2'), new BrandName('Brand Two'));
$paginated = new Paginated($pagination, [$brand1, $brand2], 2);