function BigPipeRegressionTest::testMessages_2712935

Same name in other branches
  1. 9 core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php \Drupal\Tests\big_pipe\FunctionalJavascript\BigPipeRegressionTest::testMessages_2712935()
  2. 10 core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php \Drupal\Tests\big_pipe\FunctionalJavascript\BigPipeRegressionTest::testMessages_2712935()
  3. 11.x core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php \Drupal\Tests\big_pipe\FunctionalJavascript\BigPipeRegressionTest::testMessages_2712935()

Ensure messages set in placeholders always appear.

See also

https://www.drupal.org/node/2712935

File

core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php, line 156

Class

BigPipeRegressionTest
BigPipe regression tests.

Namespace

Drupal\Tests\big_pipe\FunctionalJavascript

Code

public function testMessages_2712935() {
    $this->assertTrue($this->container
        ->get('module_installer')
        ->install([
        'render_placeholder_message_test',
    ], TRUE), 'Installed modules.');
    $this->drupalLogin($this->drupalCreateUser());
    $messages_markup = '<div role="contentinfo" aria-label="Status message"';
    $test_routes = [
        // Messages placeholder rendered first.
'render_placeholder_message_test.first',
        // Messages placeholder rendered after one, before another.
'render_placeholder_message_test.middle',
        // Messages placeholder rendered last.
'render_placeholder_message_test.last',
    ];
    $assert = $this->assertSession();
    foreach ($test_routes as $route) {
        // Verify that we start off with zero messages queued.
        $this->drupalGet(Url::fromRoute('render_placeholder_message_test.queued'));
        $assert->responseNotContains($messages_markup);
        // Verify the test case at this route behaves as expected.
        $this->drupalGet(Url::fromRoute($route));
        $assert->elementContains('css', 'p.logged-message:nth-of-type(1)', 'Message: P1');
        $assert->elementContains('css', 'p.logged-message:nth-of-type(2)', 'Message: P2');
        $assert->responseContains($messages_markup);
        $assert->elementExists('css', 'div[aria-label="Status message"] ul');
        $assert->elementContains('css', 'div[aria-label="Status message"] ul li:nth-of-type(1)', 'P1');
        $assert->elementContains('css', 'div[aria-label="Status message"] ul li:nth-of-type(2)', 'P2');
        // Verify that we end with all messages printed, hence again zero queued.
        $this->drupalGet(Url::fromRoute('render_placeholder_message_test.queued'));
        $assert->responseNotContains($messages_markup);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.