first commit

This commit is contained in:
julien
2026-03-20 22:13:41 +01:00
commit 41f8b3afb4
323 changed files with 27222 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
<?php
declare(strict_types=1);
namespace Tests\Architecture;
use Tests\Architecture\Support\ArchitectureTestCase;
final class InstantiationBoundaryTest extends ArchitectureTestCase
{
public function testApplicationServicesDoNotInstantiateUseCasesOrPoliciesDirectly(): void
{
foreach ($this->applicationServiceFiles() as $file) {
$violations = $this->collectInstantiationViolations(
$file,
self::USE_CASE_OR_POLICY_FRAGMENTS,
$this->isUseCaseOrPolicyClass(...),
);
$this->assertNoArchitectureViolations(
$violations,
$this->fileRuleMessage(self::MESSAGE_APPLICATION_SERVICE_DI_ONLY, $file),
);
}
}
public function testControllersDoNotInstantiateApplicationOrDomainDependenciesDirectly(): void
{
foreach ($this->uiControllerFiles() as $file) {
$violations = $this->collectInstantiationViolations(
$file,
self::APPLICATION_OR_DOMAIN_FRAGMENTS,
$this->isApplicationOrDomainClass(...),
);
$this->assertNoArchitectureViolations(
$violations,
$this->fileRuleMessage(self::MESSAGE_CONTROLLER_DI_ONLY, $file),
);
}
}
public function testUiLayerDoesNotInstantiateInfrastructureOrRepositoryImplementationsDirectly(): void
{
foreach ($this->uiFiles() as $file) {
$violations = $this->collectInstantiationViolations(
$file,
self::INFRASTRUCTURE_INSTANTIATION_FRAGMENTS,
$this->isInfrastructureOrRepositoryClass(...),
);
$this->assertNoArchitectureViolations(
$violations,
$this->fileRuleMessage(self::MESSAGE_UI_NO_INFRA_INSTANTIATION, $file),
);
}
}
public function testApplicationLayerDoesNotInstantiateInfrastructureOrRepositoryImplementationsDirectly(): void
{
foreach ($this->applicationFiles() as $file) {
$violations = $this->collectInstantiationViolations(
$file,
self::INFRASTRUCTURE_INSTANTIATION_FRAGMENTS,
$this->isInfrastructureOrRepositoryClass(...),
);
$this->assertNoArchitectureViolations(
$violations,
$this->fileRuleMessage(self::MESSAGE_APPLICATION_NO_INFRA_INSTANTIATION, $file),
);
}
}
}