51404ef18d17a9bc61252814918331853a5a90f3
[yaffs-website] / web / core / modules / system / tests / src / Functional / Bootstrap / DrupalMessengerServiceTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Bootstrap;
4
5 use Drupal\Core\Url;
6 use Drupal\Tests\BrowserTestBase;
7
8 /**
9  * Tests the Messenger service.
10  *
11  * @group Bootstrap
12  */
13 class DrupalMessengerServiceTest extends BrowserTestBase {
14
15   /**
16    * Modules to enable.
17    *
18    * @var array
19    */
20   public static $modules = ['system_test'];
21
22   /**
23    * Tests Messenger service.
24    */
25   public function testDrupalMessengerService() {
26     // The page at system_test.messenger_service route sets two messages and
27     // then removes the first before it is displayed.
28     $this->drupalGet(Url::fromRoute('system_test.messenger_service'));
29     $this->assertNoText('First message (removed).');
30     $this->assertRaw(t('Second message with <em>markup!</em> (not removed).'));
31
32     // Ensure duplicate messages are handled as expected.
33     $this->assertUniqueText('Non Duplicated message');
34     $this->assertNoUniqueText('Duplicated message');
35
36     // Ensure Markup objects are rendered as expected.
37     $this->assertRaw('Markup with <em>markup!</em>');
38     $this->assertUniqueText('Markup with markup!');
39     $this->assertRaw('Markup2 with <em>markup!</em>');
40
41     // Ensure when the same message is of different types it is not duplicated.
42     $this->assertUniqueText('Non duplicate Markup / string.');
43     $this->assertNoUniqueText('Duplicate Markup / string.');
44
45     // Ensure that strings that are not marked as safe are escaped.
46     $this->assertEscaped('<em>This<span>markup will be</span> escaped</em>.');
47   }
48
49 }