Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / system / tests / src / Functional / Bootstrap / DrupalSetMessageTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Bootstrap;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Tests drupal_set_message() and related functions.
9  *
10  * @group Bootstrap
11  */
12 class DrupalSetMessageTest extends BrowserTestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = ['system_test'];
20
21   /**
22    * Tests drupal_set_message().
23    */
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).'));
30
31     // Ensure duplicate messages are handled as expected.
32     $this->assertUniqueText('Non Duplicated message');
33     $this->assertNoUniqueText('Duplicated message');
34
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>');
39
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.');
43
44     // Ensure that strings that are not marked as safe are escaped.
45     $this->assertEscaped('<em>This<span>markup will be</span> escaped</em>.');
46   }
47
48 }