Pull merge.
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Theme / MessageTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Theme;
4
5 use Drupal\KernelTests\KernelTestBase;
6
7 /**
8  * Tests built-in message theme functions.
9  *
10  * @group Theme
11  */
12 class MessageTest extends KernelTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static $modules = ['system'];
18
19   /**
20    * Tests setting messages output.
21    */
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();
26
27     \Drupal::messenger()->addError('An error occurred');
28     \Drupal::messenger()->addStatus('But then something nice happened');
29     $messages = [
30       '#type' => 'status_messages',
31     ];
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');
37     $messages = [
38       '#type' => 'status_messages',
39       '#display' => 'error',
40     ];
41     $this->render($messages);
42     $this->assertRaw('messages messages--error');
43   }
44
45 }