3 namespace Drupal\KernelTests\Core\Theme;
5 use Drupal\KernelTests\KernelTestBase;
8 * Tests built-in message theme functions.
12 class MessageTest extends KernelTestBase {
17 public static $modules = ['system'];
20 * Tests setting messages output.
22 public function testMessages() {
23 // Enable the Classy theme.
24 \Drupal::service('theme_handler')->install(['classy']);
25 $this->config('system.theme')->set('default', 'classy')->save();
27 \Drupal::messenger()->addError('An error occurred');
28 \Drupal::messenger()->addStatus('But then something nice happened');
30 '#type' => 'status_messages',
32 $this->render($messages);
33 $this->assertRaw('messages messages--error');
34 $this->assertRaw('messages messages--status');
35 // Tests display of only one type of messages.
36 \Drupal::messenger()->addError('An error occurred');
38 '#type' => 'status_messages',
39 '#display' => 'error',
41 $this->render($messages);
42 $this->assertRaw('messages messages--error');