function HookCollectorPassTest::testHookRemove

Tests hook remove.

File

core/tests/Drupal/KernelTests/Core/Hook/HookCollectorPassTest.php, line 262

Class

HookCollectorPassTest
@coversDefaultClass \Drupal\Core\Hook\HookCollectorPass[[api-linebreak]] @group Hook

Namespace

Drupal\KernelTests\Core\Hook

Code

public function testHookRemove() : void {
  $module_installer = $this->container
    ->get('module_installer');
  $this->assertTrue($module_installer->install([
    'hook_test_remove',
  ]));
  $module_handler = $this->container
    ->get('module_handler');
  // There are two hooks implementing custom_hook1.
  // One is removed with RemoveHook so it should not run.
  $expected_calls = [
    'Drupal\\hook_test_remove\\Hook\\TestHookRemove::hookDoRun',
  ];
  $calls = $module_handler->invokeAll('custom_hook1');
  $this->assertEquals($expected_calls, $calls);
}

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