summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/lib/Drupal/Core/Render/Element/StatusMessages.php4
-rw-r--r--core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php8
2 files changed, 11 insertions, 1 deletions
diff --git a/core/lib/Drupal/Core/Render/Element/StatusMessages.php b/core/lib/Drupal/Core/Render/Element/StatusMessages.php
index a5a2842..d862734 100644
--- a/core/lib/Drupal/Core/Render/Element/StatusMessages.php
+++ b/core/lib/Drupal/Core/Render/Element/StatusMessages.php
@@ -76,7 +76,9 @@ class StatusMessages extends RenderElement {
public static function renderMessages($type = NULL) {
$render = [];
if (isset($type)) {
- $messages = \Drupal::messenger()->deleteByType($type);
+ $messages = [
+ $type => \Drupal::messenger()->deleteByType($type),
+ ];
}
else {
$messages = \Drupal::messenger()->deleteAll();
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php b/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php
index 1b3796e..5552591 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php
@@ -32,6 +32,14 @@ class MessageTest extends KernelTestBase {
$this->render($messages);
$this->assertRaw('messages messages--error');
$this->assertRaw('messages messages--status');
+ // Tests display of only one type of messages.
+ \Drupal::messenger()->addError('An error occurred');
+ $messages = [
+ '#type' => 'status_messages',
+ '#display' => 'error',
+ ];
+ $this->render($messages);
+ $this->assertRaw('messages messages--error');
}
}