Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php \Drupal\KernelTests\Core\Theme\RegistryTest::testThemeTemplatesRegisteredByModules()
  2. 9 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 262

Class

RegistryTest
Tests the behavior of the ThemeRegistry class.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testThemeTemplatesRegisteredByModules() {
  $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, 'test_theme');
  $registry_theme
    ->setThemeManager(\Drupal::theme());
  $expected = [
    'template_preprocess',
    'template_preprocess_container',
    'template_preprocess_theme_test_registered_by_module',
  ];
  $registry = $registry_theme
    ->get();
  $this
    ->assertEquals($expected, array_values($registry['theme_test_registered_by_module']['preprocess functions']));
}