function ModuleHandlerTest::testSetModuleList
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testSetModuleList()
- 8.9.x core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testSetModuleList()
- 11.x core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testSetModuleList()
Ensure setting the module list replaces the module list and resets internal structures.
@covers ::setModuleList
File
-
core/
tests/ Drupal/ Tests/ Core/ Extension/ ModuleHandlerTest.php, line 180
Class
- ModuleHandlerTest
- @coversDefaultClass \Drupal\Core\Extension\ModuleHandler @runTestsInSeparateProcesses
Namespace
Drupal\Tests\Core\ExtensionCode
public function testSetModuleList() : void {
$fixture_module_handler = $this->getModuleHandler();
$module_handler = $this->getMockBuilder(ModuleHandler::class)
->setConstructorArgs([
$this->root,
[],
$this->cacheBackend,
])
->onlyMethods([
'resetImplementations',
])
->getMock();
// Ensure we reset implementations when settings a new modules list.
$module_handler->expects($this->once())
->method('resetImplementations');
// Make sure we're starting empty.
$this->assertEquals([], $module_handler->getModuleList());
// Replace the list with a prebuilt list.
$module_handler->setModuleList($fixture_module_handler->getModuleList());
// Ensure those changes are stored.
$this->assertEquals($fixture_module_handler->getModuleList(), $module_handler->getModuleList());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.