mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-09-25 20:01:56 +02:00
Move Core/Container into XcVm\Core\Container (ServiceContainer) and
Core/Container/Psr into XcVm\Core\Container\Psr (ContainerInterface,
ContainerExceptionInterface, NotFoundExceptionInterface, NotFoundException).
- Namespace ServiceContainer + the 4 PSR-11 interfaces/classes.
- ServiceContainer: import the PSR siblings (use ...\Psr\ContainerInterface,
NotFoundException); migrated deps (DatabaseHandler/ModuleInterface/Request/
SettingsManager) keep their use; still-global exceptions/decorators qualified
with leading backslash (\ContainerException, \XcVmException, \Exception, ...).
- Rewrite 'use ServiceContainer;' → FQCN (incl. module fixtures); add use to
referrers across src/ and tests/; fix leading-backslash \ServiceContainer refs.
- Core/Exception/Container/ContainerException: import the moved PSR
ContainerExceptionInterface.
- Router: class_exists('ServiceContainer') → ::class. InterfaceContractTest boot
param-type → FQCN. Repaired use-inserter mis-placement in the two namespace()
fixture tests.
- phpstan-baseline.neon regenerated (292→292).
Verified: php -l clean; PHPStan no errors; PHPUnit 295/295; ServiceContainer
resolves and implements XcVm\Core\Container\Psr\ContainerInterface.
107 lines
4.3 KiB
PHP
107 lines
4.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
use XcVm\Core\Container\Psr\NotFoundException;
|
|
use XcVm\Core\Container\Psr\NotFoundExceptionInterface;
|
|
use XcVm\Core\Container\Psr\ContainerExceptionInterface;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Verifies the exception hierarchy introduced in R3-1.
|
|
*
|
|
* These tests act as a regression guard: if any class is renamed,
|
|
* moved, or changes its parent, the test suite catches it immediately.
|
|
*/
|
|
class ExceptionHierarchyTest extends TestCase
|
|
{
|
|
// ── Base ──────────────────────────────────────────────────
|
|
|
|
public function testXcVmExceptionExtendsRuntimeException(): void {
|
|
$this->assertTrue(
|
|
is_a(XcVmException::class, RuntimeException::class, true),
|
|
'XcVmException must extend RuntimeException for backward compat'
|
|
);
|
|
}
|
|
|
|
// ── Container ─────────────────────────────────────────────
|
|
|
|
public function testContainerExceptionExtendsXcVmException(): void {
|
|
$this->assertTrue(is_a(ContainerException::class, XcVmException::class, true));
|
|
}
|
|
|
|
public function testContainerExceptionImplementsPsr11Interface(): void {
|
|
$this->assertTrue(is_a(ContainerException::class, ContainerExceptionInterface::class, true));
|
|
}
|
|
|
|
public function testCircularDependencyExceptionExtendsContainerException(): void {
|
|
$this->assertTrue(is_a(CircularDependencyException::class, ContainerException::class, true));
|
|
}
|
|
|
|
public function testServiceCreationExceptionExtendsContainerException(): void {
|
|
$this->assertTrue(is_a(ServiceCreationException::class, ContainerException::class, true));
|
|
}
|
|
|
|
public function testNotFoundExceptionExtendsContainerException(): void {
|
|
$this->assertTrue(is_a(NotFoundException::class, ContainerException::class, true));
|
|
}
|
|
|
|
public function testNotFoundExceptionImplementsPsr11Interface(): void {
|
|
$this->assertTrue(is_a(NotFoundException::class, NotFoundExceptionInterface::class, true));
|
|
}
|
|
|
|
// ── Module ────────────────────────────────────────────────
|
|
|
|
public function testModuleExceptionExtendsXcVmException(): void {
|
|
$this->assertTrue(is_a(ModuleException::class, XcVmException::class, true));
|
|
}
|
|
|
|
public function testModuleNotFoundExceptionExtendsModuleException(): void {
|
|
$this->assertTrue(is_a(ModuleNotFoundException::class, ModuleException::class, true));
|
|
}
|
|
|
|
public function testModuleCycleExceptionExtendsModuleException(): void {
|
|
$this->assertTrue(is_a(ModuleCycleException::class, ModuleException::class, true));
|
|
}
|
|
|
|
public function testModuleLoadExceptionExtendsModuleException(): void {
|
|
$this->assertTrue(is_a(ModuleLoadException::class, ModuleException::class, true));
|
|
}
|
|
|
|
public function testModuleManifestExceptionExtendsModuleException(): void {
|
|
$this->assertTrue(is_a(ModuleManifestException::class, ModuleException::class, true));
|
|
}
|
|
|
|
// ── Catchability ──────────────────────────────────────────
|
|
|
|
public function testCircularDependencyIsCatchableAsXcVmException(): void {
|
|
$caught = false;
|
|
try {
|
|
throw new CircularDependencyException('test');
|
|
} catch (XcVmException) {
|
|
$caught = true;
|
|
}
|
|
$this->assertTrue($caught, 'CircularDependencyException must be catchable as XcVmException');
|
|
}
|
|
|
|
public function testModuleCycleIsCatchableAsModuleException(): void {
|
|
$caught = false;
|
|
try {
|
|
throw new ModuleCycleException('test');
|
|
} catch (ModuleException) {
|
|
$caught = true;
|
|
}
|
|
$this->assertTrue($caught);
|
|
}
|
|
|
|
public function testModuleExceptionIsCatchableAsRuntimeException(): void {
|
|
$caught = false;
|
|
try {
|
|
throw new ModuleException('test');
|
|
} catch (RuntimeException) {
|
|
$caught = true;
|
|
}
|
|
$this->assertTrue($caught, 'ModuleException must be catchable as RuntimeException for backward compat');
|
|
}
|
|
}
|