ldc-boutique-cnc-sable/tests/Architecture/ApplicationTest.php
Jérémy Munsch 98e580d327
refactor(tags): implement CRUD actions for tags
- Added CreateTag, UpdateTag, and DeleteTag actions.
- Introduced CreateTagInput and UpdateTagInput for input validation.
- Implemented ActionExecutor for executing actions with logging.
- Added tests for all new actions and input validation.
2026-10-27 09:58:30 +01:00

53 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
use App\Contracts\Action;
use App\Contracts\ActionInput;
use Symfony\Component\Finder\Finder;
describe('application coding rules', function (): void {
arch('No Domain Entities are used in Controllers')
->expect('App\Http\Controllers')
->not->toUse('Domain\Entities');
arch('No Domain Entities are used in Policies')
->expect('App\Policies')
->not->toUse('Domain\Entities');
arch('App Repositories implement App\Contracts\Repository')
->expect('App\Repositories')
->toImplement('App\Contracts\Repository');
arch('App Directories implement App\Contracts\Directory')
->expect('App\Directories')
->toImplement('App\Contracts\Directory');
arch('App DTOs are final readonly classes')
->expect('App\Dto')
->classes()
->toBeFinal()
->toBeReadonly();
arch('App Actions implement App\Contracts\Action and Inputs implement ActionInput', function (): void {
$path = __DIR__ . '/../../app/Actions';
$files = (new Finder())->files()->in($path)->name('*.php');
foreach ($files as $file) {
$subPath = $file->getRelativePathname();
$className = 'App\\Actions\\' . str_replace(['/', '.php'], ['\\', ''], $subPath);
$reflection = new \ReflectionClass($className);
if (str_ends_with($className, 'Input')) {
expect($reflection->implementsInterface(ActionInput::class))
->toBeTrue("{$className} must implement App\Contracts\ActionInput");
} else {
expect($reflection->implementsInterface(Action::class))
->toBeTrue("{$className} must implement App\Contracts\Action");
}
}
});
arch('App Queries implement App\Contracts\Query')
->expect('App\Queries')
->toImplement('App\Contracts\Query');
});