You are here

public function RegistryTest::testThemeRegistryAlterByTheme in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php \Drupal\KernelTests\Core\Theme\RegistryTest::testThemeRegistryAlterByTheme()

Tests that the theme registry can be altered by themes.

File

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

Class

RegistryTest
Tests the behavior of the ThemeRegistry class.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testThemeRegistryAlterByTheme() {

  /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
  $theme_handler = \Drupal::service('theme_handler');
  \Drupal::service('theme_installer')
    ->install([
    'test_theme',
  ]);
  $this
    ->config('system.theme')
    ->set('default', 'test_theme')
    ->save();
  $extension_list = $this->container
    ->get('extension.list.module');
  assert($extension_list instanceof ModuleExtensionList);
  $registry = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_theme', NULL, $extension_list);
  $registry
    ->setThemeManager(\Drupal::theme());
  $this
    ->assertEquals('value', $registry
    ->get()['theme_test_template_test']['variables']['additional']);
}