function HookOrderTest::testSparseHookOrder
Tests hook order when each module has either OO or procedural listeners.
This test uses the hook, 'sparse_test_hook'.
This detects a possible mistake where we would first collect modules from all procedural and then from all OO implementations, without fixing the order.
See also
\Drupal\bbb_hook_order_test\Hook\BHooks::sparseTestHook()
\Drupal\ddd_hook_order_test\Hook\DHooks::sparseTestHook()
\aaa_hook_order_test_sparse_test_hook()
\ccc_hook_order_test_sparse_test_hook()
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Hook/ HookOrderTest.php, line 226
Class
- HookOrderTest
- Tests Hook Order.
Namespace
Drupal\KernelTests\Core\HookCode
public function testSparseHookOrder() : void {
$this->assertSameCallList([
// OO and procedural listeners are correctly intermixed by module
// order.
'aaa_hook_order_test_sparse_test_hook',
BHooks::class . '::sparseTestHook',
'ccc_hook_order_test_sparse_test_hook',
DHooks::class . '::sparseTestHook',
], \Drupal::moduleHandler()->invokeAll('sparse_test_hook'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.