Split module registry contracts
This commit is contained in:
56
tests/Architecture/ModuleRegistryFailFastContractTest.php
Normal file
56
tests/Architecture/ModuleRegistryFailFastContractTest.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Tests\Architecture;
|
||||
|
||||
use MintyPHP\App\Module\ModuleRegistry;
|
||||
use RuntimeException;
|
||||
|
||||
final class ModuleRegistryFailFastContractTest extends AbstractModuleRegistryContractTestCase
|
||||
{
|
||||
public function testMissingDependencyThrowsException(): void
|
||||
{
|
||||
$this->createModuleManifest('mod-dep', [
|
||||
'id' => 'mod-dep',
|
||||
'requires' => ['nonexistent-module'],
|
||||
]);
|
||||
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->expectExceptionMessage("requires module 'nonexistent-module' which is not enabled");
|
||||
|
||||
ModuleRegistry::boot($this->fixturesDir, ['mod-dep']);
|
||||
}
|
||||
|
||||
public function testCircularDependencyThrowsException(): void
|
||||
{
|
||||
$this->createModuleManifest('mod-x', [
|
||||
'id' => 'mod-x',
|
||||
'requires' => ['mod-y'],
|
||||
]);
|
||||
$this->createModuleManifest('mod-y', [
|
||||
'id' => 'mod-y',
|
||||
'requires' => ['mod-x'],
|
||||
]);
|
||||
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->expectExceptionMessage('Circular module dependency');
|
||||
|
||||
ModuleRegistry::boot($this->fixturesDir, ['mod-x', 'mod-y']);
|
||||
}
|
||||
|
||||
public function testPermissionConflictThrowsException(): void
|
||||
{
|
||||
$this->createModuleManifest('mod-a', [
|
||||
'id' => 'mod-a',
|
||||
'permissions' => [['key' => 'shared.perm', 'description' => 'Shared']],
|
||||
]);
|
||||
$this->createModuleManifest('mod-b', [
|
||||
'id' => 'mod-b',
|
||||
'permissions' => [['key' => 'shared.perm', 'description' => 'Shared duplicate']],
|
||||
]);
|
||||
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->expectExceptionMessage('Permission conflict');
|
||||
|
||||
ModuleRegistry::boot($this->fixturesDir, ['mod-a', 'mod-b']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user