function HookOrderTest::testHookOrder
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Hook/HookOrderTest.php \Drupal\KernelTests\Core\Hook\HookOrderTest::testHookOrder()
Tests hook order using OO and procedural implementations of 'test_hook'.
The order of 'test_hook', without modification would be as follows.
- aaa_hook_order_test_test_hook
- \Drupal\aaa_hook_order_test\Hook\AHooks::testHook()
- \Drupal\aaa_hook_order_test\Hook\AHooks::testHookAfterB()
- \Drupal\aaa_hook_order_test\Hook\AHooks::testHookFirst()
- \Drupal\aaa_hook_order_test\Hook\AHooks::testHookLast()
- bbb_hook_order_test_test_hook()
- \Drupal\bbb_hook_order_test\Hook\BHooks::testHook()
- ccc_hook_order_test_test_hook()
- \Drupal\ccc_hook_order_test\Hook\CHooks::testHook()
- \Drupal\ccc_hook_order_test\Hook\CHooks::testHookFirst()
- \Drupal\ccc_hook_order_test\Hook\CHooks::testHookRemoved()
- \Drupal\ccc_hook_order_test\Hook\CHooks::testHookReorderFirst()
- ddd_hook_order_test_test_hook()
- \Drupal\ddd_hook_order_test\Hook\DHooks::testHook()
That order is modified in the hook implementation as follows, and the resulting order asserted in this test.
- The Order attribute is used to move:
- The OrderAfter attribute is used to move
- \Drupal\aaa_hook_order_test\Hook\AHooks::testHookAfterB() to after the module bbb_hook_order_test.
- The Reorder attribute is used to move
- \Drupal\ccc_hook_order_test\Hook\CHooks::testHookReorderFirst() to the first position.
- The Remove attribute is used to remove
See also
\Drupal\aaa_hook_order_test\Hook\AHooks()
\Drupal\bbb_hook_order_test\Hook\BHooks()
\Drupal\ccc_hook_order_test\Hook\CHooks()
\Drupal\ddd_hook_order_test\Hook\DHooks()
\aaa_hook_order_test_test_hook()
\bbb_hook_order_test_test_hook()
\ccc_hook_order_test_test_hook()
\ddd_hook_order_test_test_hook()
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Hook/ HookOrderTest.php, line 98
Class
- HookOrderTest
- Tests Hook Order.
Namespace
Drupal\KernelTests\Core\HookCode
public function testHookOrder() : void {
$this->assertSameCallList([
// Moved to first using the ReorderHook attribute.
CHooks::class . '::testHookReorderFirst',
// Moved to first using Order::First.
CHooks::class . '::testHookFirst',
// Moved to first using Order::First.
AHooks::class . '::testHookFirst',
'aaa_hook_order_test_test_hook',
AHooks::class . '::testHook',
'bbb_hook_order_test_test_hook',
BHooks::class . '::testHook',
// Moved to after BHooks using OrderAfter().
AHooks::class . '::testHookAfterB',
'ccc_hook_order_test_test_hook',
CHooks::class . '::testHook',
'ddd_hook_order_test_test_hook',
DHooks::class . '::testHook',
// Moved to first using Order::Last.
AHooks::class . '::testHookLast',
], \Drupal::moduleHandler()->invokeAll('test_hook'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.