function HookCollectorPassTest::testHookBefore
Tests hook ordering with attributes.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Hook/ HookCollectorPassTest.php, line 202
Class
- HookCollectorPassTest
- @coversDefaultClass \Drupal\Core\Hook\HookCollectorPass[[api-linebreak]] @group Hook
Namespace
Drupal\KernelTests\Core\HookCode
public function testHookBefore() : void {
$module_installer = $this->container
->get('module_installer');
$module_installer->install([
'aaa_hook_collector_test',
]);
$module_installer->install([
'bbb_hook_collector_test',
]);
$module_handler = $this->container
->get('module_handler');
// First alphabetically uses the OrderBefore to place it before
// the implementation it would naturally come after.
$expected_calls = [
'Drupal\\bbb_hook_collector_test\\Hook\\TestHookBefore::hookBefore',
'Drupal\\aaa_hook_collector_test\\Hook\\TestHookBefore::hookBefore',
];
$calls = $module_handler->invokeAll('custom_hook_test_hook_before');
$this->assertEquals($expected_calls, $calls);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.