function RegistryTest::testThemeTemplatesRegisteredByModules

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php \Drupal\KernelTests\Core\Theme\RegistryTest::testThemeTemplatesRegisteredByModules()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php \Drupal\KernelTests\Core\Theme\RegistryTest::testThemeTemplatesRegisteredByModules()
  3. 10 core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php \Drupal\KernelTests\Core\Theme\RegistryTest::testThemeTemplatesRegisteredByModules()

Tests theme-provided templates that are registered by modules.

File

core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php, line 260

Class

RegistryTest
Tests the behavior of the ThemeRegistry class.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testThemeTemplatesRegisteredByModules() : void {
  $theme_handler = \Drupal::service('theme_handler');
  \Drupal::service('theme_installer')->install([
    'test_theme',
  ]);
  $extension_list = \Drupal::service('extension.list.module');
  assert($extension_list instanceof ModuleExtensionList);
  $registry_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), \Drupal::service('cache.bootstrap'), $extension_list, \Drupal::service('kernel'), 'test_theme');
  $registry_theme->setThemeManager(\Drupal::theme());
  $expected = [
    'template_preprocess_theme_test_registered_by_module',
  ];
  $registry = $registry_theme->get();
  $this->assertEquals('Drupal\\Core\\Theme\\ThemePreprocess:preprocessContainer', $registry['theme_test_registered_by_module']['initial preprocess']);
  $this->assertEquals($expected, array_values($registry['theme_test_registered_by_module']['preprocess functions']));
}

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