class HookCollectorPassTest

Same name in this branch
  1. 11.x core/tests/Drupal/Tests/Core/Hook/HookCollectorPassTest.php \Drupal\Tests\Core\Hook\HookCollectorPassTest

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

Hierarchy

Expanded class hierarchy of HookCollectorPassTest

File

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

Namespace

Drupal\KernelTests\Core\Hook
View source
class HookCollectorPassTest extends KernelTestBase {
    
    /**
     * VFS does not and can not support symlinks.
     */
    protected function setUpFilesystem() : void {
    }
    
    /**
     * Test that symlinks are properly followed.
     */
    public function testSymlink() : void {
        mkdir($this->siteDirectory);
        foreach (scandir("core/modules/user/tests/modules/user_hooks_test") as $item) {
            $target = "{$this->siteDirectory}/{$item}";
            if (!file_exists($target)) {
                symlink(realpath("core/modules/user/tests/modules/user_hooks_test/{$item}"), $target);
            }
        }
        $container = new ContainerBuilder();
        $module_filenames = [
            'user_hooks_test' => [
                'pathname' => "{$this->siteDirectory}/user_hooks_test.info.yml",
            ],
        ];
        $container->setParameter('container.modules', $module_filenames);
        (new HookCollectorPass())->process($container);
        $implementations = [
            'user_format_name_alter' => [
                'Drupal\\user_hooks_test\\Hook\\UserHooksTest' => [
                    'userFormatNameAlter' => 'user_hooks_test',
                ],
            ],
        ];
        $this->assertSame($implementations, $container->getParameter('hook_implementations_map'));
    }

}

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