You are here

public function RegistryTest::testMultipleSubThemes in Drupal 8

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

Tests the theme registry with multiple subthemes.

File

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

Class

RegistryTest
Tests the behavior of the ThemeRegistry class.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testMultipleSubThemes() {
  $theme_handler = \Drupal::service('theme_handler');
  \Drupal::service('theme_installer')
    ->install([
    'test_basetheme',
    'test_subtheme',
    'test_subsubtheme',
  ]);
  $registry_subsub_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_subsubtheme');
  $registry_subsub_theme
    ->setThemeManager(\Drupal::theme());
  $registry_sub_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_subtheme');
  $registry_sub_theme
    ->setThemeManager(\Drupal::theme());
  $registry_base_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_basetheme');
  $registry_base_theme
    ->setThemeManager(\Drupal::theme());
  $preprocess_functions = $registry_subsub_theme
    ->get()['theme_test_template_test']['preprocess functions'];
  $this
    ->assertSame([
    'template_preprocess',
    'test_basetheme_preprocess_theme_test_template_test',
    'test_subtheme_preprocess_theme_test_template_test',
    'test_subsubtheme_preprocess_theme_test_template_test',
  ], $preprocess_functions);
  $preprocess_functions = $registry_sub_theme
    ->get()['theme_test_template_test']['preprocess functions'];
  $this
    ->assertSame([
    'template_preprocess',
    'test_basetheme_preprocess_theme_test_template_test',
    'test_subtheme_preprocess_theme_test_template_test',
  ], $preprocess_functions);
  $preprocess_functions = $registry_base_theme
    ->get()['theme_test_template_test']['preprocess functions'];
  $this
    ->assertSame([
    'template_preprocess',
    'test_basetheme_preprocess_theme_test_template_test',
  ], $preprocess_functions);
}