You are here

public function ModuleHandlerTest::testImplementsHookModuleEnabled in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testImplementsHookModuleEnabled()

Test implementations methods when module is enabled.

@covers ::implementsHook @covers ::loadAllIncludes

File

core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php, line 299
Contains \Drupal\Tests\Core\Extension\ModuleHandlerTest.

Class

ModuleHandlerTest
@coversDefaultClass \Drupal\Core\Extension\ModuleHandler @group Extension

Namespace

Drupal\Tests\Core\Extension

Code

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