diff --git a/phpunit.xml b/phpunit.xml index 223c0a8..2ab46a1 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -4,6 +4,9 @@ tests/Unit + + tests/Integration + tests/Feature diff --git a/tests/Architecture/ApplicationTest.php b/tests/Architecture/ApplicationTest.php index eeeb528..2907c3c 100644 --- a/tests/Architecture/ApplicationTest.php +++ b/tests/Architecture/ApplicationTest.php @@ -2,6 +2,8 @@ declare(strict_types=1); +namespace Tests\Architecture; + describe('Application Architecture Rules', function (): void { arch('Application layer does not depend on Presentation, Infra, or App') ->expect('Application') diff --git a/tests/Architecture/CodingStandardsTest.php b/tests/Architecture/CodingStandardsTest.php index 8e67f7a..0d51833 100644 --- a/tests/Architecture/CodingStandardsTest.php +++ b/tests/Architecture/CodingStandardsTest.php @@ -2,6 +2,8 @@ declare(strict_types=1); +namespace Tests\Architecture; + describe('Coding Standards & Project Rules', function (): void { arch()->preset()->php(); // Le helper assert natif est interdit en faveur de Webmozart\Assert @@ -58,4 +60,25 @@ describe('Coding Standards & Project Rules', function (): void { arch('all Shared source files use strict types') ->expect('Shared') ->toUseStrictTypes(); + + arch('all test files belong to Tests namespace and use strict types') + ->expect('Tests') + ->toUseStrictTypes(); + + it('ensures every test file in tests directory has a namespace', function (): void { + /** @var array $testFiles */ + $testFiles = glob(base_path('tests/{*,*/*,*/*/*,*/*/*/*}.php'), GLOB_BRACE); + + foreach ($testFiles as $file) { + if (preg_match('/Test\.php$/', basename($file)) !== 1) { + continue; + } + + $content = (string) file_get_contents($file); + expect($content)->toMatch( + '/^\s*namespace\s+Tests/m', + "File [{$file}] is missing a namespace Tests declaration." + ); + } + }); }); diff --git a/tests/Architecture/DomainTest.php b/tests/Architecture/DomainTest.php index 7089882..98a666c 100644 --- a/tests/Architecture/DomainTest.php +++ b/tests/Architecture/DomainTest.php @@ -2,6 +2,8 @@ declare(strict_types=1); +namespace Tests\Architecture; + use Shared\DDD\Directory; use Shared\DDD\Entity; use Shared\DDD\Repository; diff --git a/tests/Architecture/InfraTest.php b/tests/Architecture/InfraTest.php index 664067b..2b26705 100644 --- a/tests/Architecture/InfraTest.php +++ b/tests/Architecture/InfraTest.php @@ -2,6 +2,8 @@ declare(strict_types=1); +namespace Tests\Architecture; + use Illuminate\Database\Eloquent\Model; describe('Infra Architecture Rules', function (): void { diff --git a/tests/Architecture/NamingConventionsTest.php b/tests/Architecture/NamingConventionsTest.php index 67edb8a..8631520 100644 --- a/tests/Architecture/NamingConventionsTest.php +++ b/tests/Architecture/NamingConventionsTest.php @@ -2,6 +2,8 @@ declare(strict_types=1); +namespace Tests\Architecture; + describe('Naming Conventions in Application', function (): void { arch('Application usecases use strict types') ->expect('Application\Usecase') diff --git a/tests/Architecture/PresentationTest.php b/tests/Architecture/PresentationTest.php index e51ee6b..d4efbd6 100644 --- a/tests/Architecture/PresentationTest.php +++ b/tests/Architecture/PresentationTest.php @@ -2,6 +2,8 @@ declare(strict_types=1); +namespace Tests\Architecture; + use Presentation\Api\V1\Contracts\ApiResponse; describe('Presentation Architecture Rules', function (): void { diff --git a/tests/Integration/Shared/Helpers/DateHelperTest.php b/tests/Integration/Shared/Helpers/DateHelperTest.php index c7eb0a3..0210e7a 100644 --- a/tests/Integration/Shared/Helpers/DateHelperTest.php +++ b/tests/Integration/Shared/Helpers/DateHelperTest.php @@ -2,6 +2,8 @@ declare(strict_types=1); +namespace Tests\Integration\Shared\Helpers; + use Illuminate\Support\Facades\Date; use Shared\Helpers\DatesHelper;