3 namespace Drupal\Tests\system\Functional\Bootstrap;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests drupal_set_message() and related functions.
12 class DrupalSetMessageTest extends BrowserTestBase {
19 public static $modules = ['system_test'];
22 * Tests drupal_set_message().
24 public function testDrupalSetMessage() {
25 // The page at system-test/drupal-set-message sets two messages and then
26 // removes the first before it is displayed.
27 $this->drupalGet('system-test/drupal-set-message');
28 $this->assertNoText('First message (removed).');
29 $this->assertRaw(t('Second message with <em>markup!</em> (not removed).'));
31 // Ensure duplicate messages are handled as expected.
32 $this->assertUniqueText('Non Duplicated message');
33 $this->assertNoUniqueText('Duplicated message');
35 // Ensure Markup objects are rendered as expected.
36 $this->assertRaw('Markup with <em>markup!</em>');
37 $this->assertUniqueText('Markup with markup!');
38 $this->assertRaw('Markup2 with <em>markup!</em>');
40 // Ensure when the same message is of different types it is not duplicated.
41 $this->assertUniqueText('Non duplicate Markup / string.');
42 $this->assertNoUniqueText('Duplicate Markup / string.');
44 // Ensure that strings that are not marked as safe are escaped.
45 $this->assertEscaped('<em>This<span>markup will be</span> escaped</em>.');