function HookCollectorPassTest::testGroupIncludes

Tests group includes.

@legacy-covers ::process @legacy-covers ::collectModuleHookImplementations

File

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

Class

HookCollectorPassTest
Tests Drupal\Core\Hook\HookCollectorPass.

Namespace

Drupal\Tests\Core\Hook

Code

public function testGroupIncludes() : void {
  $module_filenames = self::setupGroupIncludes();
  $container = new ContainerBuilder();
  $container->setParameter('container.modules', $module_filenames);
  (new HookCollectorPass())->process($container);
  $expected_hook_list = [
    'hook_info' => [
      'test_module_hook_info' => 'test_module',
    ],
    'token_info' => [
      'test_module_token_info' => 'test_module',
    ],
  ];
  $hook_data = $container->getParameter('.hook_data');
  $this->assertEquals($expected_hook_list, $hook_data['hook_list']);
  // Assert that the group include is not duplicated into the includes list.
  $this->assertEquals([], $hook_data['includes']);
  $this->assertEquals([
    'token_info' => [
      'vfs://drupal_root/test_module.tokens.inc',
    ],
  ], $hook_data['group_includes']);
}

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