From d94f78dace3d756f0d4c99a490694c1f6358f5c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Tue, 15 Sep 2026 12:49:03 +0200 Subject: [PATCH] test(unit): update application and infra unit tests with Pagination VOs and GWT format --- .../Arcadia/Usecase/Brands/FindAll/FindAllBrandsTest.php | 8 +++++--- .../Arcadia/Usecase/Employees/FindAllEmployeesDtoTest.php | 4 +++- .../Arcadia/Usecase/Employees/FindAllEmployeesTest.php | 4 +++- .../Usecase/IncoSheets/FindAllIncoSheetsDtoTest.php | 4 +++- .../Arcadia/Usecase/IncoSheets/FindAllIncoSheetsTest.php | 4 +++- .../Arcadia/Usecase/IncoSheets/SearchIncoSheetsTest.php | 6 ++++-- .../Usecases/FindAllClients/FindAllClientsTest.php | 6 ++++-- .../Directories/InMemoryArcadiaBrandDirectoryTest.php | 8 +++++--- .../Directories/InMemoryEmployeeDirectoryTest.php | 6 ++++-- .../Directories/InMemoryIncoSheetDirectoryTest.php | 6 ++++-- .../Directories/InMemoryIncoShortSheetDirectoryTest.php | 6 ++++-- .../Adapters/Repositories/InMemoryBrandRepositoryTest.php | 4 +++- .../Repositories/InMemoryClientRepositoryTest.php | 4 +++- tests/Unit/Infra/Cache/BrandCacheTest.php | 4 +++- 14 files changed, 51 insertions(+), 23 deletions(-) diff --git a/tests/Unit/Application/Arcadia/Usecase/Brands/FindAll/FindAllBrandsTest.php b/tests/Unit/Application/Arcadia/Usecase/Brands/FindAll/FindAllBrandsTest.php index 9f4c97e..92727f6 100644 --- a/tests/Unit/Application/Arcadia/Usecase/Brands/FindAll/FindAllBrandsTest.php +++ b/tests/Unit/Application/Arcadia/Usecase/Brands/FindAll/FindAllBrandsTest.php @@ -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); diff --git a/tests/Unit/Application/Arcadia/Usecase/Employees/FindAllEmployeesDtoTest.php b/tests/Unit/Application/Arcadia/Usecase/Employees/FindAllEmployeesDtoTest.php index 7f4bd4f..aea9e47 100644 --- a/tests/Unit/Application/Arcadia/Usecase/Employees/FindAllEmployeesDtoTest.php +++ b/tests/Unit/Application/Arcadia/Usecase/Employees/FindAllEmployeesDtoTest.php @@ -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 diff --git a/tests/Unit/Application/Arcadia/Usecase/Employees/FindAllEmployeesTest.php b/tests/Unit/Application/Arcadia/Usecase/Employees/FindAllEmployeesTest.php index 31d7859..8f16f9c 100644 --- a/tests/Unit/Application/Arcadia/Usecase/Employees/FindAllEmployeesTest.php +++ b/tests/Unit/Application/Arcadia/Usecase/Employees/FindAllEmployeesTest.php @@ -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 diff --git a/tests/Unit/Application/Arcadia/Usecase/IncoSheets/FindAllIncoSheetsDtoTest.php b/tests/Unit/Application/Arcadia/Usecase/IncoSheets/FindAllIncoSheetsDtoTest.php index e8852ae..977c830 100644 --- a/tests/Unit/Application/Arcadia/Usecase/IncoSheets/FindAllIncoSheetsDtoTest.php +++ b/tests/Unit/Application/Arcadia/Usecase/IncoSheets/FindAllIncoSheetsDtoTest.php @@ -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 diff --git a/tests/Unit/Application/Arcadia/Usecase/IncoSheets/FindAllIncoSheetsTest.php b/tests/Unit/Application/Arcadia/Usecase/IncoSheets/FindAllIncoSheetsTest.php index 8ab1c4c..9885009 100644 --- a/tests/Unit/Application/Arcadia/Usecase/IncoSheets/FindAllIncoSheetsTest.php +++ b/tests/Unit/Application/Arcadia/Usecase/IncoSheets/FindAllIncoSheetsTest.php @@ -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); diff --git a/tests/Unit/Application/Arcadia/Usecase/IncoSheets/SearchIncoSheetsTest.php b/tests/Unit/Application/Arcadia/Usecase/IncoSheets/SearchIncoSheetsTest.php index 96934c0..f666290 100644 --- a/tests/Unit/Application/Arcadia/Usecase/IncoSheets/SearchIncoSheetsTest.php +++ b/tests/Unit/Application/Arcadia/Usecase/IncoSheets/SearchIncoSheetsTest.php @@ -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 diff --git a/tests/Unit/Application/Security/Usecases/FindAllClients/FindAllClientsTest.php b/tests/Unit/Application/Security/Usecases/FindAllClients/FindAllClientsTest.php index bcf7f8f..0aae3c4 100644 --- a/tests/Unit/Application/Security/Usecases/FindAllClients/FindAllClientsTest.php +++ b/tests/Unit/Application/Security/Usecases/FindAllClients/FindAllClientsTest.php @@ -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 diff --git a/tests/Unit/Infra/Adapters/Directories/InMemoryArcadiaBrandDirectoryTest.php b/tests/Unit/Infra/Adapters/Directories/InMemoryArcadiaBrandDirectoryTest.php index 930f9f5..b252d0a 100644 --- a/tests/Unit/Infra/Adapters/Directories/InMemoryArcadiaBrandDirectoryTest.php +++ b/tests/Unit/Infra/Adapters/Directories/InMemoryArcadiaBrandDirectoryTest.php @@ -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 diff --git a/tests/Unit/Infra/Adapters/Directories/InMemoryEmployeeDirectoryTest.php b/tests/Unit/Infra/Adapters/Directories/InMemoryEmployeeDirectoryTest.php index 2f97f82..d9ced86 100644 --- a/tests/Unit/Infra/Adapters/Directories/InMemoryEmployeeDirectoryTest.php +++ b/tests/Unit/Infra/Adapters/Directories/InMemoryEmployeeDirectoryTest.php @@ -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')); diff --git a/tests/Unit/Infra/Adapters/Directories/InMemoryIncoSheetDirectoryTest.php b/tests/Unit/Infra/Adapters/Directories/InMemoryIncoSheetDirectoryTest.php index 216f62d..8a69433 100644 --- a/tests/Unit/Infra/Adapters/Directories/InMemoryIncoSheetDirectoryTest.php +++ b/tests/Unit/Infra/Adapters/Directories/InMemoryIncoSheetDirectoryTest.php @@ -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')); diff --git a/tests/Unit/Infra/Adapters/Directories/InMemoryIncoShortSheetDirectoryTest.php b/tests/Unit/Infra/Adapters/Directories/InMemoryIncoShortSheetDirectoryTest.php index c7b7991..456f1cf 100644 --- a/tests/Unit/Infra/Adapters/Directories/InMemoryIncoShortSheetDirectoryTest.php +++ b/tests/Unit/Infra/Adapters/Directories/InMemoryIncoShortSheetDirectoryTest.php @@ -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); diff --git a/tests/Unit/Infra/Adapters/Repositories/InMemoryBrandRepositoryTest.php b/tests/Unit/Infra/Adapters/Repositories/InMemoryBrandRepositoryTest.php index fdfc90f..79a8c8a 100644 --- a/tests/Unit/Infra/Adapters/Repositories/InMemoryBrandRepositoryTest.php +++ b/tests/Unit/Infra/Adapters/Repositories/InMemoryBrandRepositoryTest.php @@ -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) diff --git a/tests/Unit/Infra/Adapters/Repositories/InMemoryClientRepositoryTest.php b/tests/Unit/Infra/Adapters/Repositories/InMemoryClientRepositoryTest.php index f259207..69368ef 100644 --- a/tests/Unit/Infra/Adapters/Repositories/InMemoryClientRepositoryTest.php +++ b/tests/Unit/Infra/Adapters/Repositories/InMemoryClientRepositoryTest.php @@ -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); diff --git a/tests/Unit/Infra/Cache/BrandCacheTest.php b/tests/Unit/Infra/Cache/BrandCacheTest.php index 6acfba6..d6d4386 100644 --- a/tests/Unit/Infra/Cache/BrandCacheTest.php +++ b/tests/Unit/Infra/Cache/BrandCacheTest.php @@ -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);