Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / system / tests / src / Functional / Render / PlaceholderMessageTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Render;
4
5 use Drupal\Core\Url;
6 use Drupal\Tests\BrowserTestBase;
7
8 /**
9  * Functional test verifying that messages set in placeholders always appear.
10  *
11  * @group Render
12  */
13 class PlaceholderMessageTest extends BrowserTestBase {
14
15   /**
16    * Modules to enable.
17    *
18    * @var array
19    */
20   public static $modules = ['render_placeholder_message_test'];
21
22   /**
23    * Test rendering of message placeholder.
24    */
25   public function testMessagePlaceholder() {
26     $messages_markup = '<div role="contentinfo" aria-label="Status message"';
27
28     $test_routes = [
29       // Messages placeholder rendered first.
30       'render_placeholder_message_test.first',
31       // Messages placeholder rendered after one, before another.
32       'render_placeholder_message_test.middle',
33       // Messages placeholder rendered last.
34       'render_placeholder_message_test.last',
35     ];
36
37     $assert = $this->assertSession();
38     foreach ($test_routes as $route) {
39       // Verify that we start off with zero messages queued.
40       $this->drupalGet(Url::fromRoute('render_placeholder_message_test.queued'));
41       $assert->responseNotContains($messages_markup);
42
43       // Verify the test case at this route behaves as expected.
44       $this->drupalGet(Url::fromRoute($route));
45       $assert->elementContains('css', 'p.logged-message:nth-of-type(1)', 'Message: P1');
46       $assert->elementContains('css', 'p.logged-message:nth-of-type(2)', 'Message: P2');
47       $assert->responseContains($messages_markup);
48       $assert->elementExists('css', 'div[aria-label="Status message"] ul');
49       $assert->elementContains('css', 'div[aria-label="Status message"] ul li:nth-of-type(1)', 'P1');
50       $assert->elementContains('css', 'div[aria-label="Status message"] ul li:nth-of-type(2)', 'P2');
51
52       // Verify that we end with all messages printed, hence again zero queued.
53       $this->drupalGet(Url::fromRoute('render_placeholder_message_test.queued'));
54       $assert->responseNotContains($messages_markup);
55     }
56   }
57
58 }