diff --git a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module index 550b5ca..b3a75e5 100644 --- a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module +++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module @@ -114,3 +114,10 @@ function _test_theme_twig_php_values() { ), ); } + +/** + * Implements template_preprocess_status_messages(). + */ +function twig_theme_test_preprocess_status_messages(&$variables) { + $variables['attributes']['class'][] = 'custom-test-messages-class'; +} diff --git a/core/modules/system/tests/src/Kernel/Render/ClassyTest.php b/core/modules/system/tests/src/Kernel/Render/ClassyTest.php new file mode 100644 index 0000000..76cf23e --- /dev/null +++ b/core/modules/system/tests/src/Kernel/Render/ClassyTest.php @@ -0,0 +1,49 @@ +container->get('theme_installer')->install(['classy']); + $this->container->get('config.factory') + ->getEditable('system.theme') + ->set('default', 'classy') + ->save(); + // Clear the theme registry. + $this->container->set('theme.registry', NULL); + + } + + /** + * Test the classy theme. + */ + function testClassyTheme() { + drupal_set_message('An error occurred', 'error'); + drupal_set_message('But then something nice happened'); + $messages = array( + '#type' => 'status_messages', + ); + $this->render($messages); + $this->assertNoText('custom-test-messages-class', 'The custom class attribute value added in the status messages preprocess function is not displayed as page content.'); + } + +} diff --git a/core/themes/classy/templates/misc/status-messages.html.twig b/core/themes/classy/templates/misc/status-messages.html.twig index 683a111..e98964e 100644 --- a/core/themes/classy/templates/misc/status-messages.html.twig +++ b/core/themes/classy/templates/misc/status-messages.html.twig @@ -50,7 +50,5 @@ {% endif %} - {# Remove type specific classes. #} - {{ attributes.removeClass(classes) }} {% endfor %} {% endblock messages %}