function NodePerformanceTest::testPromotedContentPage

Same name and namespace in other branches
  1. 11.x core/modules/node/tests/src/FunctionalJavascript/NodePerformanceTest.php \Drupal\Tests\node\FunctionalJavascript\NodePerformanceTest::testPromotedContentPage()

Tests performance for the promoted content page view.

1 call to NodePerformanceTest::testPromotedContentPage()
NodePerformanceTest::testNodePerformance in core/modules/node/tests/src/FunctionalJavascript/NodePerformanceTest.php
Tests performance of node-related functionality.

File

core/modules/node/tests/src/FunctionalJavascript/NodePerformanceTest.php, line 75

Class

NodePerformanceTest
Tests the performance of node functionality including cache invalidation.

Namespace

Drupal\Tests\node\FunctionalJavascript

Code

protected function testPromotedContentPage() : void {
  // Request the promoted content page, then immediately clear all object
  // caches, so that aggregates and image styles are created on disk but
  // otherwise caches are empty.
  $this->drupalGet('node');
  // Give time for big pipe placeholders, asset aggregate requests, and post
  // response tasks to finish processing and write to any caches before
  // clearing caches again.
  sleep(2);
  foreach (Cache::getBins() as $bin) {
    $bin->deleteAll();
  }
  // Now visit a different page to warm some caches.
  $this->drupalGet('user/login');
  // Ensure everything finishes before we collect performance data.
  sleep(2);
  // Test promoted content page.
  $performance_data = $this->collectPerformanceData(function () {
    $this->drupalGet('node');
  }, 'nodePromotedContentPage');
  $this->assertSame(0, $performance_data->getScriptBytes());
  $this->assertQueriesByName('nodePromotedContentPage', $performance_data->getQueries());
  $this->assertMetricsByName('nodePromotedContentPage', $performance_data);
}

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