Split module registry contracts
This commit is contained in:
54
tests/Architecture/ModuleRegistryBootstrapContractTest.php
Normal file
54
tests/Architecture/ModuleRegistryBootstrapContractTest.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Tests\Architecture;
|
||||
|
||||
use MintyPHP\App\Module\ModuleRegistry;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class ModuleRegistryBootstrapContractTest extends TestCase
|
||||
{
|
||||
public function testRegistryIsAvailableInContainer(): void
|
||||
{
|
||||
$registry = app(ModuleRegistry::class);
|
||||
|
||||
self::assertInstanceOf(ModuleRegistry::class, $registry);
|
||||
}
|
||||
|
||||
public function testAddressBookModuleLoadsExpectedRuntimeContributions(): void
|
||||
{
|
||||
$modulesDir = dirname(__DIR__, 2) . '/modules';
|
||||
$registry = ModuleRegistry::boot($modulesDir, ['addressbook']);
|
||||
|
||||
self::assertTrue($registry->hasModule('addressbook'));
|
||||
self::assertNotEmpty($registry->getPermissions());
|
||||
self::assertNotEmpty($registry->getSearchResources());
|
||||
self::assertNotEmpty($registry->getLayoutContextProviders());
|
||||
self::assertNotEmpty($registry->getSessionProviders());
|
||||
self::assertNotEmpty($registry->getSlotContributions('aside.tab_panel'));
|
||||
}
|
||||
|
||||
public function testEmptyEnvDisablesAllConfiguredModules(): void
|
||||
{
|
||||
$modulesDir = dirname(__DIR__, 2) . '/modules';
|
||||
|
||||
putenv('APP_ENABLED_MODULES=');
|
||||
|
||||
try {
|
||||
$enabledModules = ModuleRegistry::resolveEnabledModules([
|
||||
'enabled_modules' => ['addressbook', 'bookmarks'],
|
||||
]);
|
||||
$registry = ModuleRegistry::boot($modulesDir, $enabledModules);
|
||||
} finally {
|
||||
putenv('APP_ENABLED_MODULES');
|
||||
}
|
||||
|
||||
self::assertSame([], $enabledModules, 'APP_ENABLED_MODULES empty string must disable all modules.');
|
||||
self::assertSame([], $registry->getModules());
|
||||
self::assertSame([], $registry->getRoutes());
|
||||
self::assertSame([], $registry->getPermissions());
|
||||
self::assertSame([], $registry->getSearchResources());
|
||||
self::assertSame([], $registry->getLayoutContextProviders());
|
||||
self::assertSame([], $registry->getSessionProviders());
|
||||
self::assertSame([], $registry->getSlotContributions('aside.tab_panel'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user