...
 
Commits (1)
......@@ -76,7 +76,9 @@ public static function generatePlaceholder(array $element) {
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();
......
......@@ -32,6 +32,14 @@ public function testMessages() {
$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');
}
}