diff -u b/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php --- b/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -577,7 +577,7 @@ } /** - * This completes the theme registry adding discovered functions and hooks. + * Completes the theme registry adding discovered functions and hooks. * * @param array $cache * The theme registry. @@ -702,7 +702,7 @@ } /** - * Get all user functions grouped by the word before the first underscore. + * Gets all user functions grouped by the word before the first underscore. * * @return array * Functions grouped by the first prefix. diff -u b/core/modules/system/src/Tests/Theme/ThemeTest.php b/core/modules/system/src/Tests/Theme/ThemeTest.php --- b/core/modules/system/src/Tests/Theme/ThemeTest.php +++ b/core/modules/system/src/Tests/Theme/ThemeTest.php @@ -277,7 +277,7 @@ /** * Tests that region attributes can be manipulated via preprocess functions. */ - function testRegionClass() { + public function testRegionClass() { \Drupal::service('module_installer')->install(array('block', 'theme_region_test')); // Place a block. @@ -288,17 +288,14 @@ } /** - * Ensures suggestion preprocess functions run even for default - * implementations. + * Ensures suggestion preprocess functions run for default implementations. * * The theme hook used by this test has its base preprocess function in a * separate file, so this test also ensures that that file is correctly loaded * when needed. */ - function testSuggestionPreprocessForDefaults() { - $this->config('system.theme') - ->set('default', 'test_theme') - ->save(); + public function testSuggestionPreprocessForDefaults() { + \Drupal::service('theme_handler')->setDefault('test_theme'); // Test with both an unprimed and primed theme registry. drupal_theme_rebuild(); for ($i = 0; $i < 2; $i++) { @@ -307,6 +304,7 @@ $expected_values = [ 'Suggestion', 'Kitten', + 'Monkey', 'Kitten', 'Flamingo', ]; diff -u b/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php b/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php --- b/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php +++ b/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php @@ -144,10 +144,9 @@ } /** - * Menu callback for testing preprocess functions are being run for theme - * suggestions. + * Controller for testing preprocess functions with theme suggestions. */ - function preprocessSuggestions() { + public function preprocessSuggestions() { return [ [ '#theme' => 'theme_test_preprocess_suggestions', @@ -157,6 +156,10 @@ '#theme' => 'theme_test_preprocess_suggestions', '#foo' => 'kitten', ], + [ + '#theme' => 'theme_test_preprocess_suggestions', + '#foo' => 'monkey', + ], ['#theme' => 'theme_test_preprocess_suggestions__kitten__flamingo'], ]; } diff -u b/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module --- b/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -110,6 +110,14 @@ } /** + * Tests a module overriding a default hook with a suggestion. + */ +function theme_test_preprocess_theme_test_preprocess_suggestions__monkey(&$variables) { + $variables['foo'] = 'Monkey'; +} + + +/** * Prepares variables for test render element templates. * * Default template: theme-test-render-element.html.twig.