function HookCollectorPassTest::testHookFirst
Tests hook ordering with attributes.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Hook/ HookCollectorPassTest.php, line 148
Class
- HookCollectorPassTest
- @coversDefaultClass \Drupal\Core\Hook\HookCollectorPass @group Hook
Namespace
Drupal\KernelTests\Core\HookCode
public function testHookFirst() : 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');
// Last alphabetically uses the Order::First enum to place it before
// the implementation it would naturally come after.
$expected_calls = [
'Drupal\\bbb_hook_collector_test\\Hook\\TestHookFirst::hookFirst',
'Drupal\\aaa_hook_collector_test\\Hook\\TestHookFirst::hookFirst',
];
$calls = $module_handler->invokeAll('custom_hook_test_hook_first');
$this->assertEquals($expected_calls, $calls);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.