function HookOrderTest::testHookOrder

Same name and namespace in other branches
  1. 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.

That order is modified in the hook implementation as follows, and the resulting order asserted in this test.

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\Hook

Code

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.