test(arch): update architecture tests to enforce Mapper conventions and isolation
This commit is contained in:
parent
1c0ecb2bd5
commit
72358cf13e
1 changed files with 29 additions and 13 deletions
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue