ldc-boutique-cnc-sable/tests/Architecture/DomainTest.php
2026-10-27 09:58:12 +01:00

89 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
use Shared\DDD\Directory;
use Shared\DDD\Entity;
use Shared\DDD\Repository;
describe('domain coding rules', function (): void {
arch('Entities implements Entity')
->expect("Domain\Entities")
->toImplement(Entity::class);
arch('Entities are immutable (disabled due to mock-final-classes conflict)')
->expect("Domain\Entities")
->toBeReadonly()
->toBeFinal();
arch('ValueObjects are immutable (disabled due to mock-final-classes conflict)')
->expect("Domain\Models\ValueObjects")
->toBeReadonly()
->toBeFinal();
arch('Ports contains only interfaces')
->expect("Domain\Ports")
->classes()
->toBeInterface();
arch('No App classes are used in Domain')
->expect('Domain')
->not->toUse('App');
arch('No Infrastructure classes are used in Domain')
->expect('Domain')
->not->toUse('Infrastructure');
arch('No Illuminate classes are used in Domain')
->expect('Domain')
->not->toUse('Illuminate');
arch('No Symfony components are used in Domain')
->expect('Domain')
->not->toUse('Symfony');
// * Deny some Laravel Functions in Domain
arch('it has no laravel helper functions')
->expect('Domain')
->not->toUse([
'abort',
'app',
'auth',
'asset',
'back',
'bcrypt',
'broadcast',
'cache',
'config',
'cookie',
'csrf_token',
'dd',
'dump',
'decrypt',
'dispatch',
'event',
'factory',
'logger',
'redirect',
'request',
'response',
'route',
'session',
'storage',
'url',
'throw_if',
'throw_unless',
'__',
'trans',
'trans_choice',
'view',
]);
arch('Port Repositories extend Shared\DDD\Repository')
->expect("Domain\Ports\Repositories")
->toExtend(Repository::class);
arch('Port Directories extend Shared\DDD\Directory')
->expect("Domain\Ports\Directories")
->toExtend(Directory::class);
});