diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module index 2e6f164..41aa222 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -66,6 +66,10 @@ function theme_test_theme($existing, $type, $theme, $path) { 'bar' => '', ], ]; + $items['theme_test_registered_by_module'] = [ + 'render element' => 'content', + 'base hook' => 'container', + ]; return $items; } diff --git a/core/modules/system/tests/themes/test_theme/templates/theme-test-registered-by-module.html.twig b/core/modules/system/tests/themes/test_theme/templates/theme-test-registered-by-module.html.twig new file mode 100644 index 0000000..3432e01 --- /dev/null +++ b/core/modules/system/tests/themes/test_theme/templates/theme-test-registered-by-module.html.twig @@ -0,0 +1,2 @@ +{# Output for Theme API test #} +Template provided by theme is registered by module. diff --git a/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php b/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php index a962fec..f3bf4ba 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php @@ -192,4 +192,22 @@ public function testThemeSuggestions() { ], $suggestions, 'Found expected page node suggestions.'); } + /** + * Tests theme-provided templates that are registered by modules. + */ + public function testThemeTemplatesRegisteredByModules() { + $theme_handler = \Drupal::service('theme_handler'); + $theme_handler->install(['test_theme']); + + $registry_theme = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $theme_handler, \Drupal::service('theme.initialization'), 'test_theme'); + $registry_theme->setThemeManager(\Drupal::theme()); + + $expected = [ + 'template_preprocess', + 'template_preprocess_container', + ]; + $registry = $registry_theme->get(); + $this->assertEquals($expected, $registry['theme_test_registered_by_module']['preprocess functions']); + } + }