function HookCollectorPassTest::testHookAfterClassMethod

Tests hook ordering with attributes.

File

core/tests/Drupal/KernelTests/Core/Hook/HookCollectorPassTest.php, line 184

Class

HookCollectorPassTest
@coversDefaultClass \Drupal\Core\Hook\HookCollectorPass @group Hook

Namespace

Drupal\KernelTests\Core\Hook

Code

public function testHookAfterClassMethod() : 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 OrderAfter to place it after
    // the implementation it would naturally come before using call and method.
    $expected_calls = [
        'Drupal\\bbb_hook_collector_test\\Hook\\TestHookAfterClassMethod::hookAfterClassMethod',
        'Drupal\\aaa_hook_collector_test\\Hook\\TestHookAfterClassMethod::hookAfterClassMethod',
    ];
    $calls = $module_handler->invokeAll('custom_hook_test_hook_after_class_method');
    $this->assertEquals($expected_calls, $calls);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.