function ModuleHandlerTest::testModuleList in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php \Drupal\Tests\system\Kernel\Extension\ModuleHandlerTest::testModuleList()
The basic functionality of retrieving enabled modules.
File
- core/
modules/ system/ tests/ src/ Kernel/ Extension/ ModuleHandlerTest.php, line 55 - Contains \Drupal\system\Tests\Extension\ModuleHandlerTest.
Class
- ModuleHandlerTest
- Tests ModuleHandler functionality.
Namespace
Drupal\Tests\system\Kernel\ExtensionCode
function testModuleList() {
$module_list = [
'system',
];
$this
->assertModuleList($module_list, 'Initial');
// Try to install a new module.
$this
->moduleInstaller()
->install(array(
'ban',
));
$module_list[] = 'ban';
sort($module_list);
$this
->assertModuleList($module_list, 'After adding a module');
// Try to mess with the module weights.
module_set_weight('ban', 20);
// Move ban to the end of the array.
unset($module_list[array_search('ban', $module_list)]);
$module_list[] = 'ban';
$this
->assertModuleList($module_list, 'After changing weights');
// Test the fixed list feature.
$fixed_list = array(
'system' => 'core/modules/system/system.module',
'menu' => 'core/modules/menu/menu.module',
);
$this
->moduleHandler()
->setModuleList($fixed_list);
$new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list));
$this
->assertModuleList($new_module_list, t('When using a fixed list'));
}