diff --git a/tests/Architecture/CodingStandardsTest.php b/tests/Architecture/CodingStandardsTest.php index 7d7ceb2..54b5c91 100644 --- a/tests/Architecture/CodingStandardsTest.php +++ b/tests/Architecture/CodingStandardsTest.php @@ -90,6 +90,17 @@ describe('Coding Standards & Project Rules', function (): void { ->expect('Tests') ->toUseStrictTypes(); + it('ensures every database seeder has a corresponding integration test', function (): void { + $seederFiles = glob(base_path('database/seeders/*Seeder.php')) ?: []; + foreach ($seederFiles as $file) { + $basename = basename($file, '.php'); + $testFile = base_path("tests/Integration/Database/Seeders/{$basename}Test.php"); + expect(file_exists($testFile))->toBeTrue( + "Missing integration test for seeder [{$basename}]. Expected at [{$testFile}]." + ); + } + }); + it('ensures every test file in tests directory has a namespace', function (): void { foreach (getTestFiles(['tests']) as $file) { $content = (string) file_get_contents($file); diff --git a/tests/Architecture/NamingConventionsTest.php b/tests/Architecture/NamingConventionsTest.php index 8631520..7cd7248 100644 --- a/tests/Architecture/NamingConventionsTest.php +++ b/tests/Architecture/NamingConventionsTest.php @@ -4,46 +4,55 @@ declare(strict_types=1); namespace Tests\Architecture; +use Presentation\Api\V1\Contracts\ApiResponse; +use Shared\DDD\Directory; +use Shared\DDD\Repository; + +describe('Naming Conventions in Domain', function (): void { + arch('Port Directory interfaces have Directory suffix') + ->expect('Domain\Ports\Directories') + ->toHaveSuffix('Directory'); + + arch('Port Repository interfaces have Repository suffix') + ->expect('Domain\Ports\Repositories') + ->toHaveSuffix('Repository'); +}); + describe('Naming Conventions in Application', function (): void { arch('Application usecases use strict types') ->expect('Application\Usecase') ->toUseStrictTypes(); }); -describe('Naming Conventions in Domain', function (): void { - arch('Port Directories have Directory suffix') - ->expect('Domain\Ports\Directories') - ->toHaveSuffix('Directory'); - - arch('Port Repositories have Repository suffix') - ->expect('Domain\Ports\Repositories') - ->toHaveSuffix('Repository'); -}); - describe('Naming Conventions in Presentation', function (): void { arch('Controllers have Controller suffix') ->expect('Presentation\Api\V1\Http\Controllers') ->toHaveSuffix('Controller'); - arch('Requests have Request suffix') + arch('Requests extending FormRequest must have Request suffix') ->expect('Presentation\Api\V1\Http\Requests') + ->toExtend('Illuminate\Foundation\Http\FormRequest') ->toHaveSuffix('Request'); - arch('Responses have Response suffix') + arch('Responses implementing ApiResponse must have Response suffix') ->expect('Presentation\Api\V1\Http\Responses') + ->toImplement(ApiResponse::class) ->toHaveSuffix('Response'); }); describe('Naming Conventions in Infra', function (): void { - arch('Infra service providers have Provider suffix') + arch('Infra classes extending ServiceProvider must have Provider suffix') ->expect('Infra\Providers') + ->toExtend('Illuminate\Support\ServiceProvider') ->toHaveSuffix('Provider'); - arch('Infra directory adapters have Directory suffix') + arch('Infra directory adapters implementing Directory port must have Directory suffix') ->expect('Infra\Adapters\Directories') + ->toImplement(Directory::class) ->toHaveSuffix('Directory'); - arch('Infra repository adapters have Repository suffix') + arch('Infra repository adapters implementing Repository port must have Repository suffix') ->expect('Infra\Adapters\Repositories') + ->toImplement(Repository::class) ->toHaveSuffix('Repository'); });