diff --git a/phpcs.xml b/phpcs.xml index 4b322cbc..e5858019 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -11,7 +11,10 @@ app/ config/ database/ + domain/ + infra/ routes/ + shared/ tests/ */vendor/* diff --git a/phpstan.neon b/phpstan.neon index 844ae81e..fc32c1bd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -8,6 +8,7 @@ parameters: - app/ - domain/ - infra/ + - shared/ - tests/ level: 10 diff --git a/tests/Architecture/CodingStandardsTest.php b/tests/Architecture/CodingStandardsTest.php index 17cbd9df..6369187c 100644 --- a/tests/Architecture/CodingStandardsTest.php +++ b/tests/Architecture/CodingStandardsTest.php @@ -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(); }); diff --git a/tests/Architecture/NamingConventionsTest.php b/tests/Architecture/NamingConventionsTest.php index 36d64472..ecca490d 100644 --- a/tests/Architecture/NamingConventionsTest.php +++ b/tests/Architecture/NamingConventionsTest.php @@ -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\\'], ]); diff --git a/tests/TestCase.php b/tests/TestCase.php index 7de55c2f..7be6956d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -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,