From 72358cf13e587b087a7fd79bd0daa7aa3be7a163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Wed, 16 Sep 2026 10:31:13 +0200 Subject: [PATCH] test(arch): update architecture tests to enforce Mapper conventions and isolation --- tests/Architecture/ArchTest.php | 42 +++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/tests/Architecture/ArchTest.php b/tests/Architecture/ArchTest.php index 0c7385f..6f161a1 100644 --- a/tests/Architecture/ArchTest.php +++ b/tests/Architecture/ArchTest.php @@ -16,6 +16,9 @@ use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\EmployeeSortColumn; use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\IncoSortColumn; use Uwil\ArcadiaApiPhpClient\Lib\ApiSorter\SortColumn; use Uwil\ArcadiaApiPhpClient\Lib\LibMiddleware; +use Uwil\ArcadiaApiPhpClient\Lib\Pagination\PageNumber; +use Uwil\ArcadiaApiPhpClient\Lib\Pagination\PageSize; +use Uwil\ArcadiaApiPhpClient\Lib\Pagination\Pagination; use Uwil\ArcadiaApiPhpClient\Lib\ValueObjectId; use Uwil\ArcadiaApiPhpClient\Logger\ApiLoggerMiddleware; use Uwil\ArcadiaApiPhpClient\Repository\AbstractApiRepository; @@ -65,9 +68,9 @@ describe('coding standards', function () use ($libraryNamespace): void { }); describe('naming conventions', function () use ($libraryNamespace): void { - arch('hydrators have Hydrator suffix') - ->expect("{$libraryNamespace}\Hydrator") - ->toHaveSuffix('Hydrator'); + arch('mappers have Mapper suffix') + ->expect("{$libraryNamespace}\Mapper") + ->toHaveSuffix('Mapper'); arch('repositories have Repository suffix') ->expect("{$libraryNamespace}\Repository") @@ -183,8 +186,8 @@ describe('class modifiers and immutability', function () use ($libraryNamespace) AbstractApiError::class, ]); - arch('Hydrators are final') - ->expect("{$libraryNamespace}\Hydrator") + arch('Mappers are final') + ->expect("{$libraryNamespace}\Mapper") ->classes() ->toBeFinal(); @@ -211,32 +214,45 @@ describe('class modifiers and immutability', function () use ($libraryNamespace) ]) ->classes() ->toBeFinal(); + + arch('Pagination Value objects are final and readonly') + ->expect([ + PageNumber::class, + PageSize::class, + ]) + ->classes() + ->toBeReadonly() + ->toBeFinal(); + + arch('Pagination is final') + ->expect(Pagination::class) + ->toBeFinal(); }); describe('layer isolation', function () use ($libraryNamespace): void { - arch('DTOs do not depend on Repositories, Services, or Hydrators') + arch('DTOs do not depend on Repositories, Services, or Mappers') ->expect("{$libraryNamespace}\Lib\ApiDto") ->not->toUse([ "{$libraryNamespace}\Repository", "{$libraryNamespace}\Service", - "{$libraryNamespace}\Hydrator", + "{$libraryNamespace}\Mapper", ]); - arch('Value objects do not depend on Repositories, Services, Hydrators, or DTOs') + arch('Value objects do not depend on Repositories, Services, Mappers, or DTOs') ->expect("{$libraryNamespace}\Lib\ApiValueObject") ->not->toUse([ "{$libraryNamespace}\Repository", "{$libraryNamespace}\Service", - "{$libraryNamespace}\Hydrator", + "{$libraryNamespace}\Mapper", "{$libraryNamespace}\Lib\ApiDto", ]); - arch('Errors do not depend on Repositories, Services, Hydrators, or DTOs') + arch('Errors do not depend on Repositories, Services, Mappers, or DTOs') ->expect("{$libraryNamespace}\Error") ->not->toUse([ "{$libraryNamespace}\Repository", "{$libraryNamespace}\Service", - "{$libraryNamespace}\Hydrator", + "{$libraryNamespace}\Mapper", "{$libraryNamespace}\Lib\ApiDto", ]); @@ -246,8 +262,8 @@ describe('layer isolation', function () use ($libraryNamespace): void { "{$libraryNamespace}\Service", ]); - arch('Hydrators do not depend on Repositories or Services') - ->expect("{$libraryNamespace}\Hydrator") + arch('Mappers do not depend on Repositories or Services') + ->expect("{$libraryNamespace}\Mapper") ->not->toUse([ "{$libraryNamespace}\Repository", "{$libraryNamespace}\Service",