ldc-arcadia-api/tests/Architecture/SharedTest.php

99 lines
2.4 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Architecture;
use Shared\DDD\Model\EntityId;
describe('Shared Architecture Rules', function (): void {
arch('Shared layer does not depend on Domain, Application, Presentation, Infra, or App')
->expect('Shared')
->not->toUse([
'Domain',
'Application',
'Presentation',
'Infra',
'Infrastructure',
'App',
]);
arch('Shared layer does not depend on Illuminate or Symfony frameworks')
->expect('Shared')
->not->toUse([
'Illuminate',
'Symfony',
]);
arch('Shared layer does not use Laravel helper functions')
->expect('Shared')
->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('Shared Value Objects are final and readonly')
->expect([
'Shared\ValueObjects',
'Shared\Pagination',
])
->classes()
->toBeReadonly()
->toBeFinal();
arch('Shared DDD Ports contain only interfaces')
->expect('Shared\DDD\Port')
->classes()
->toBeInterface();
arch('Shared DDD Models contain interfaces')
->expect('Shared\DDD\Model')
->classes()
->toBeInterface()
->ignoring([
EntityId::class,
]);
arch('Shared DDD Events contain only interfaces')
->expect('Shared\DDD\Event')
->classes()
->toBeInterface();
arch('Shared DDD Security contracts contain only interfaces')
->expect('Shared\DDD\Security')
->classes()
->toBeInterface();
arch('Shared layer uses strict types')
->expect('Shared')
->toUseStrictTypes();
});