43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Shared\DDD\Models\Entity;
|
|
use Shared\DDD\Ports\Repository;
|
|
|
|
describe('domain layer architecture rules', function (): void {
|
|
arch('entities implement Entity and are final readonly')
|
|
->expect('Domain\\Models\\Entities')
|
|
->classes()
|
|
->toImplement(Entity::class)
|
|
->toBeFinal()
|
|
->toBeReadonly();
|
|
|
|
arch('value objects classes are readonly')
|
|
->expect('Domain\\Models\\ValueObjects')
|
|
->classes()
|
|
->toBeReadonly();
|
|
|
|
arch('value objects classes are final')
|
|
->expect('Domain\\Models\\ValueObjects')
|
|
->classes()
|
|
->toBeFinal();
|
|
|
|
arch('domain exceptions extend DomainException and are final')
|
|
->expect('Domain\\Exceptions')
|
|
->classes()
|
|
->toExtend(\DomainException::class)
|
|
->toBeFinal();
|
|
|
|
arch('ports contain only interfaces')
|
|
->expect('Domain\\Ports')
|
|
->toBeInterfaces();
|
|
|
|
arch('repository ports extend Shared Repository')
|
|
->expect('Domain\\Ports\\Repositories')
|
|
->toExtend(Repository::class);
|
|
|
|
arch('domain does not depend on external layers or frameworks')
|
|
->expect('Domain')
|
|
->not->toUse(['Application', 'Infrastructure', 'Illuminate', 'Symfony']);
|
|
});
|