function BigPipeTest::testBigPipeMultiOccurrencePlaceholders
Same name in other branches
- 9 core/modules/big_pipe/tests/src/Functional/BigPipeTest.php \Drupal\Tests\big_pipe\Functional\BigPipeTest::testBigPipeMultiOccurrencePlaceholders()
- 8.9.x core/modules/big_pipe/tests/src/Functional/BigPipeTest.php \Drupal\Tests\big_pipe\Functional\BigPipeTest::testBigPipeMultiOccurrencePlaceholders()
- 11.x core/modules/big_pipe/tests/src/Functional/BigPipeTest.php \Drupal\Tests\big_pipe\Functional\BigPipeTest::testBigPipeMultiOccurrencePlaceholders()
Tests BigPipe with a multi-occurrence placeholder.
File
-
core/
modules/ big_pipe/ tests/ src/ Functional/ BigPipeTest.php, line 295
Class
- BigPipeTest
- Tests BigPipe's no-JS detection & response delivery (with and without JS).
Namespace
Drupal\Tests\big_pipe\FunctionalCode
public function testBigPipeMultiOccurrencePlaceholders() : void {
$this->drupalLogin($this->rootUser);
$this->assertSessionCookieExists('1');
$this->assertBigPipeNoJsCookieExists('0');
// By not calling performMetaRefresh() here, we simulate JavaScript being
// enabled, because as far as the BigPipe module is concerned, JavaScript is
// enabled in the browser as long as the BigPipe no-JS cookie is *not* set.
// @see setUp()
// @see performMetaRefresh()
$this->drupalGet(Url::fromRoute('big_pipe_test_multi_occurrence'));
// cspell:disable-next-line
$big_pipe_placeholder_id = 'callback=Drupal%5CCore%5CRender%5CElement%5CStatusMessages%3A%3ArenderMessages&args%5B0%5D&token=_HAdUpwWmet0TOTe2PSiJuMntExoshbm1kh2wQzzzAA';
$expected_placeholder_replacement = '<script type="application/vnd.drupal-ajax" data-big-pipe-replacement-for-placeholder-with-id="' . $big_pipe_placeholder_id . '">';
$this->assertSession()
->pageTextContains('The count is 1.');
$this->assertSession()
->responseNotContains('The count is 2.');
$this->assertSession()
->responseNotContains('The count is 3.');
$raw_content = $this->getSession()
->getPage()
->getContent();
$this->assertSame(1, substr_count($raw_content, $expected_placeholder_replacement), 'Only one placeholder replacement was found for the duplicate #lazy_builder arrays.');
// By calling performMetaRefresh() here, we simulate JavaScript being
// disabled, because as far as the BigPipe module is concerned, it is
// enabled in the browser when the BigPipe no-JS cookie is set.
// @see setUp()
// @see performMetaRefresh()
$this->performMetaRefresh();
$this->assertBigPipeNoJsCookieExists('1');
$this->drupalGet(Url::fromRoute('big_pipe_test_multi_occurrence'));
$this->assertSession()
->pageTextContains('The count is 1.');
$this->assertSession()
->responseNotContains('The count is 2.');
$this->assertSession()
->responseNotContains('The count is 3.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.