function RegistryTest::testMultipleSubThemes

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

Class

RegistryTest
Tests the behavior of the ThemeRegistry class.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testMultipleSubThemes() : void {
    $theme_handler = \Drupal::service('theme_handler');
    \Drupal::service('theme_installer')->install([
        'test_basetheme',
        'test_subtheme',
        'test_subsubtheme',
    ]);
    $module_list = $this->container
        ->get('extension.list.module');
    assert($module_list instanceof ModuleExtensionList);
    $registry_subsub_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), \Drupal::service('cache.bootstrap'), $module_list, \Drupal::service('kernel'), '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'), \Drupal::service('cache.bootstrap'), $module_list, \Drupal::service('kernel'), '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'), \Drupal::service('cache.bootstrap'), $module_list, \Drupal::service('kernel'), '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);
}

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