forked from fa/breadcrumb-the-shire
57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
|
|
<?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']);
|
||
|
|
}
|
||
|
|
}
|