75 lines
2.4 KiB
PHP
75 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Architecture;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Presentation\Api\V1\Contracts\ApiResponse;
|
|
|
|
describe('Presentation Architecture Rules', function (): void {
|
|
arch('Presentation layer does not depend on Infra or App')
|
|
->expect('Presentation')
|
|
->not->toUse([
|
|
'Infra',
|
|
'Infrastructure',
|
|
'App',
|
|
]);
|
|
|
|
arch('Presentation Controllers are invokable single action controllers and are final')
|
|
->expect([
|
|
'Presentation\Api\V1\Http\Controllers',
|
|
'Presentation\Web\Http\Controllers',
|
|
])
|
|
->toBeInvokable()
|
|
->classes()
|
|
->toBeFinal();
|
|
|
|
arch('Presentation Responses implement Presentation\Api\V1\Contracts\ApiResponse and are final and readonly')
|
|
->expect('Presentation\Api\V1\Http\Responses')
|
|
->toImplement(ApiResponse::class)
|
|
->classes()
|
|
->toBeReadonly()
|
|
->toBeFinal();
|
|
|
|
arch('Presentation FormRequests extend Illuminate\Foundation\Http\FormRequest and are final')
|
|
->expect('Presentation\Api\V1\Http\Requests')
|
|
->toExtend(FormRequest::class)
|
|
->classes()
|
|
->toBeFinal();
|
|
|
|
arch('Presentation FormRequests do not contain toInput method')
|
|
->expect('Presentation\Api\V1\Http\Requests')
|
|
->not->toHaveMethod('toInput');
|
|
|
|
arch('Presentation FormRequests do not contain authorize method (auth is handled in middleware filters)')
|
|
->expect('Presentation\Api\V1\Http\Requests')
|
|
->not->toHaveMethod('authorize');
|
|
|
|
arch('Presentation DTOs are final and readonly')
|
|
->expect('Presentation\Api\V1\Dto')
|
|
->classes()
|
|
->toBeReadonly()
|
|
->toBeFinal();
|
|
|
|
arch('Presentation Middlewares are final')
|
|
->expect('Presentation\Api\V1\Http\Middlewares')
|
|
->classes()
|
|
->toBeFinal();
|
|
|
|
arch('Presentation Console Commands extend Illuminate\Console\Command and are final')
|
|
->expect('Presentation\Console\Commands')
|
|
->toExtend('Illuminate\Console\Command')
|
|
->classes()
|
|
->toBeFinal();
|
|
|
|
arch('Presentation Console Presenters are final and readonly')
|
|
->expect('Presentation\Console\Presenters')
|
|
->classes()
|
|
->toBeReadonly()
|
|
->toBeFinal();
|
|
|
|
arch('Presentation layer uses strict types')
|
|
->expect('Presentation')
|
|
->toUseStrictTypes();
|
|
});
|