test(Architecture): add namespaces to architecture test files and create integration test suite

- Added namespaces to various architecture test files for consistency.
- Created a new integration test suite in phpunit.xml.
This commit is contained in:
Jérémy Munsch 2026-08-13 11:25:08 +02:00
parent fed1916b24
commit 84e59314a0
Signed by: forge-joniko
GPG key ID: D7EFE2F5CB6CC0E4
8 changed files with 38 additions and 0 deletions

View file

@ -4,6 +4,9 @@
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory>tests/Integration</directory>
</testsuite>
<testsuite name="Feature">
<directory>tests/Feature</directory>
</testsuite>

View file

@ -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')

View file

@ -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<int, string> $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."
);
}
});
});

View file

@ -2,6 +2,8 @@
declare(strict_types=1);
namespace Tests\Architecture;
use Shared\DDD\Directory;
use Shared\DDD\Entity;
use Shared\DDD\Repository;

View file

@ -2,6 +2,8 @@
declare(strict_types=1);
namespace Tests\Architecture;
use Illuminate\Database\Eloquent\Model;
describe('Infra Architecture Rules', function (): void {

View file

@ -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')

View file

@ -2,6 +2,8 @@
declare(strict_types=1);
namespace Tests\Architecture;
use Presentation\Api\V1\Contracts\ApiResponse;
describe('Presentation Architecture Rules', function (): void {

View file

@ -2,6 +2,8 @@
declare(strict_types=1);
namespace Tests\Integration\Shared\Helpers;
use Illuminate\Support\Facades\Date;
use Shared\Helpers\DatesHelper;