function RegistryLegacyTest::testSuggestionPreprocessFunctions

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Theme/RegistryLegacyTest.php \Drupal\KernelTests\Core\Theme\RegistryLegacyTest::testSuggestionPreprocessFunctions()

Tests the theme registry with theme functions with suggestions.

@expectedDeprecation Theme functions are deprecated in drupal:8.0.0 and are removed from drupal:10.0.0. Use Twig templates instead of test_legacy_theme_theme_test_preprocess_suggestions__kitten__meerkat(). See https://www.drupal.org/node/1831138

File

core/tests/Drupal/KernelTests/Core/Theme/RegistryLegacyTest.php, line 52

Class

RegistryLegacyTest
Tests legacy behavior of the ThemeRegistry class.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testSuggestionPreprocessFunctions() {
    $theme_handler = \Drupal::service('theme_handler');
    \Drupal::service('theme_installer')->install([
        'test_legacy_theme',
    ]);
    $registry_deprecated_theme = new Registry($this->root, \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_legacy_theme');
    $registry_deprecated_theme->setThemeManager(\Drupal::theme());
    $expected_preprocess_functions = [
        'template_preprocess',
        'theme_test_preprocess_theme_test_preprocess_suggestions',
        'test_theme_preprocess_theme_test_preprocess_suggestions',
        'test_theme_preprocess_theme_test_preprocess_suggestions__kitten',
    ];
    $preprocess_functions = $registry_deprecated_theme->get()['theme_test_preprocess_suggestions__kitten__meerkat']['preprocess functions'];
    $this->assertSame($expected_preprocess_functions, $preprocess_functions, 'Suggestion implemented as a function correctly inherits preprocess functions.');
}

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