chore(arch): include shared, domain, and infra in lint/arch checks

This commit is contained in:
Jérémy Munsch 2026-11-16 00:49:51 +01:00
parent 13158d7301
commit 1ad8fc45a0
No known key found for this signature in database
GPG key ID: 2AAECDA6B7330F91
5 changed files with 24 additions and 12 deletions

View file

@ -11,7 +11,10 @@
<file>app/</file>
<file>config/</file>
<file>database/</file>
<file>domain/</file>
<file>infra/</file>
<file>routes/</file>
<file>shared/</file>
<file>tests/</file>
<exclude-pattern>*/vendor/*</exclude-pattern>

View file

@ -8,6 +8,7 @@ parameters:
- app/
- domain/
- infra/
- shared/
- tests/
level: 10

View file

@ -53,4 +53,8 @@ describe('coding standards', function (): void {
arch('all shared source files use strict types')
->expect('Shared')
->toUseStrictTypes();
arch('all infrastructure source files use strict types')
->expect('Infrastructure')
->toUseStrictTypes();
});

View file

@ -71,11 +71,6 @@ describe('naming conventions in app', function (): void {
});
describe('naming conventions in domain', function (): void {
arch('dtos have Dto suffix')
->expect("Domain\Dto")
->toHaveSuffix('Dto');
arch('exceptions have Exception suffix')
->expect("Domain\Exceptions")
->toHaveSuffix('Exception');
@ -98,7 +93,15 @@ describe('naming conventions in domain', function (): void {
});
describe('naming conventions in infrastructure', function (): void {
arch('adapters implement an interface from their domain ports', function (string $folder, string $infraNs, string $domainNs): void {
arch('adapters serializers have Serializer suffix')
->expect("Infrastructure\Adapters\Serializers")
->toHaveSuffix('Serializer');
arch('adapters implement an interface from their domain or shared ports', function (
string $folder,
string $infraNs,
string $portNs
): void {
$path = __DIR__ . '/../../infra/' . $folder;
$files = (new Finder())->files()->in($path)->name('*.php');
@ -110,16 +113,18 @@ describe('naming conventions in infrastructure', function (): void {
}
$interfaces = (new \ReflectionClass($className))->getInterfaceNames();
$hasDomainPort = ! empty(array_filter(
$hasPort = ! empty(array_filter(
$interfaces,
fn ($interface) => str_starts_with($interface, $domainNs)
fn ($interface) => str_starts_with($interface, $portNs)
));
expect($hasDomainPort)
->toBeTrue(message: "La classe {$className} n'implémente aucune interface de {$domainNs}.");
expect($hasPort)
->toBeTrue(message: "La classe {$className} n'implémente aucune interface de {$portNs}.");
}
})->with([
'Directories' => ['Adapters/Directories', 'Infrastructure\Adapters\Directories', 'Domain\Ports\Directories\\'],
'Events' => ['Adapters/Events', 'Infrastructure\Adapters\Events', 'Shared\DDD\\'],
'Locks' => ['Adapters/Locks', 'Infrastructure\Adapters\Locks', 'Shared\Concurrency\\'],
'Repositories' => ['Adapters/Repositories', 'Infrastructure\Adapters\Repositories', 'Domain\Ports\Repositories\\'],
'Services' => ['Adapters/Services', 'Infrastructure\Adapters\Services', 'Domain\Ports\Services\\'],
]);

View file

@ -13,7 +13,6 @@ use LDC\LDCCRM\Models\ClientModel;
use LDC\LDCCRM\Transport\ApiInterface;
use LDC\LDCCRM\Transport\Response as CrmResponse;
use LDC\LDCCRM\Utils;
use Mockery;
abstract class TestCase extends BaseTestCase
{
@ -29,7 +28,7 @@ abstract class TestCase extends BaseTestCase
private function mockCrmTransport(): void
{
$apiInterface = Mockery::mock(ApiInterface::class);
$apiInterface = \Mockery::mock(ApiInterface::class);
$apiInterface->shouldReceive('call')->byDefault()->andReturn(
new CrmResponse(
ApiStatus::OK,