function HookCollectorPassTest::testGetHookAttributesInClass

@covers ::getHookAttributesInClass

File

core/tests/Drupal/Tests/Core/Hook/HookCollectorPassTest.php, line 91

Class

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

Namespace

Drupal\Tests\Core\Hook

Code

public function testGetHookAttributesInClass() : void {
    
    /** @phpstan-ignore-next-line */
    $getHookAttributesInClass = fn($class) => $this->getHookAttributesInClass($class);
    $p = new HookCollectorPass();
    $getHookAttributesInClass = $getHookAttributesInClass->bindTo($p, $p);
    $x = new class  {
        function foo() : void {
        }

};
    $this->expectException(\LogicException::class);
    $hooks = $getHookAttributesInClass(get_class($x));
    $x = new class  {
        function foo() : void {
        }

};
    $hooks = $getHookAttributesInClass(get_class($x));
    $hook = reset($hooks);
    $this->assertInstanceOf(Hook::class, $hook);
    $this->assertSame('foo', $hook->hook);
}

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