function ModuleHandlerTest::testImplementsHookModuleEnabled

Test implementations methods when module is enabled.

@covers ::implementsHook
@covers ::loadAllIncludes

File

core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php, line 314

Class

ModuleHandlerTest
@coversDefaultClass \Drupal\Core\Extension\ModuleHandler[[api-linebreak]] @runTestsInSeparateProcesses

Namespace

Drupal\Tests\Core\Extension

Code

public function testImplementsHookModuleEnabled() {
  $module_handler = $this->getModuleHandler();
  $this->assertTrue($module_handler->implementsHook('module_handler_test', 'hook'), 'Installed module implementation found.');
  $module_handler->addModule('module_handler_test_added', 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_added');
  $this->assertTrue($module_handler->implementsHook('module_handler_test_added', 'hook'), 'Runtime added module with implementation in include found.');
  $module_handler->addModule('module_handler_test_no_hook', 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_no_hook');
  $this->assertFalse($module_handler->implementsHook('module_handler_test_no_hook', 'hook', [
    TRUE,
  ]), 'Missing implementation not found.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.