public function RegistryLegacyTest::testSuggestionPreprocessFunctions in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Theme/RegistryLegacyTest.php \Drupal\KernelTests\Core\Theme\RegistryLegacyTest::testSuggestionPreprocessFunctions()
Tests the theme registry with theme functions with suggestions.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Theme/ RegistryLegacyTest.php, line 49
Class
- RegistryLegacyTest
- Tests legacy behavior of the ThemeRegistry class.
Namespace
Drupal\KernelTests\Core\ThemeCode
public function testSuggestionPreprocessFunctions() {
$this
->expectDeprecation('Unsilenced deprecation: 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');
$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.');
}