You are here

public function StandardJavascriptTest::testBigPipe in Drupal 9

Same name and namespace in other branches
  1. 8 core/profiles/standard/tests/src/FunctionalJavascript/StandardJavascriptTest.php \Drupal\Tests\standard\FunctionalJavascript\StandardJavascriptTest::testBigPipe()
  2. 10 core/profiles/standard/tests/src/FunctionalJavascript/StandardJavascriptTest.php \Drupal\Tests\standard\FunctionalJavascript\StandardJavascriptTest::testBigPipe()

Tests BigPipe accelerates particular Standard installation profile routes.

File

core/profiles/standard/tests/src/FunctionalJavascript/StandardJavascriptTest.php, line 23

Class

StandardJavascriptTest
Tests Standard installation profile JavaScript expectations.

Namespace

Drupal\Tests\standard\FunctionalJavascript

Code

public function testBigPipe() {
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'access content',
    'post comments',
    'skip comment approval',
  ]));
  $node = Node::create([
    'type' => 'article',
  ])
    ->setTitle($this
    ->randomMachineName())
    ->setPromoted(TRUE)
    ->setPublished();
  $node
    ->save();

  // Front page: one placeholder, for messages.
  $this
    ->drupalGet('');
  $this
    ->assertBigPipePlaceholderReplacementCount(1);

  // Node page: 2 placeholders:
  // 1. messages
  // 2. comment form
  $this
    ->drupalGet($node
    ->toUrl());
  $this
    ->assertBigPipePlaceholderReplacementCount(2);
}