3 namespace Drupal\Tests\system\Functional\Bootstrap;
6 use Drupal\Tests\BrowserTestBase;
9 * Tests the Messenger service.
13 class DrupalMessengerServiceTest extends BrowserTestBase {
20 public static $modules = ['system_test'];
23 * Tests Messenger service.
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).'));
32 // Ensure duplicate messages are handled as expected.
33 $this->assertUniqueText('Non Duplicated message');
34 $this->assertNoUniqueText('Duplicated message');
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>');
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.');
45 // Ensure that strings that are not marked as safe are escaped.
46 $this->assertEscaped('<em>This<span>markup will be</span> escaped</em>.');