function ModuleHandlerTest::assertHasResetHookImplementations
Asserts whether certain hook implementations exist.
This is used to verify that all internal hook cache properties have been reset and updated.
Parameters
bool $exists: TRUE if the implementations are expected to exist, FALSE if not.
\Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler: The module handler.
See also
\module_test_test_reset_implementations_hook()
\module_test_test_reset_implementations_alter()
1 call to ModuleHandlerTest::assertHasResetHookImplementations()
- ModuleHandlerTest::testResetImplementationsClearsHooks in core/
tests/ Drupal/ KernelTests/ Core/ Extension/ ModuleHandlerTest.php - Tests that resetImplementations() clears the hook memory cache.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Extension/ ModuleHandlerTest.php, line 103
Class
- ModuleHandlerTest
- @coversDefaultClass \Drupal\Core\Extension\ModuleHandler[[api-linebreak]]
Namespace
Drupal\KernelTests\Core\ExtensionCode
protected function assertHasResetHookImplementations(bool $exists, ModuleHandlerInterface $moduleHandler) : void {
$this->assertSame($exists, $moduleHandler->hasImplementations('test_reset_implementations_hook'));
$this->assertSame($exists, $moduleHandler->hasImplementations('test_reset_implementations_alter'));
$expected_list = $exists ? [
'module_test_test_reset_implementations_hook',
] : [];
$this->assertSame($expected_list, $moduleHandler->invokeAll('test_reset_implementations_hook'));
$expected_alter_list = $exists ? [
'module_test_test_reset_implementations_alter',
] : [];
$alter_list = [];
$moduleHandler->alter('test_reset_implementations', $alter_list);
$this->assertSame($expected_alter_list, $alter_list);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.