function HookCollectorPassTest::testHooksImplementedOnBehalfFileCache

Test hooks implemented on behalf of an uninstalled module.

They should be picked up but only executed when the other module is installed.

File

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

Class

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

Namespace

Drupal\KernelTests\Core\Hook

Code

public function testHooksImplementedOnBehalfFileCache() : void {
  $module_installer = $this->container
    ->get('module_installer');
  $this->assertTrue($module_installer->install([
    'hook_collector_on_behalf',
  ]));
  $this->assertTrue($module_installer->install([
    'hook_collector_on_behalf_procedural',
  ]));
  drupal_flush_all_caches();
  $this->assertFalse(isset($GLOBALS['on_behalf_oop']));
  $this->assertFalse(isset($GLOBALS['on_behalf_procedural']));
  $this->assertTrue($module_installer->install([
    'respond_install_uninstall_hook_test',
  ]));
  drupal_flush_all_caches();
  $this->assertTrue(isset($GLOBALS['on_behalf_oop']));
  $this->assertTrue(isset($GLOBALS['on_behalf_procedural']));
}

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