function NodePerformanceTest::testPromotedContentCacheInvalidation

Tests the impact of node cache invalidation on the promoted content view.

File

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

Class

NodePerformanceTest
Tests the performance of node functionality including cache invalidation.

Namespace

Drupal\Tests\node\FunctionalJavascript

Code

protected function testPromotedContentCacheInvalidation() : void {
  // Create a new node, this invalidates the node_list cache tag. Need to reset
  // the cache tag checksum service as it did not register a need to
  // invalidate that again.
  \Drupal::service('cache_tags.invalidator.checksum')->reset();
  $this->drupalCreateNode([
    'type' => 'test_content',
    'title' => 'new page 2',
  ]);
  // Visit the promoted content page again.
  $performance_data = $this->collectPerformanceData(function () {
    $this->drupalGet('node');
  }, 'nodePromotedContentAfterInvalidation');
  $this->assertQueriesByName('nodePromotedContentAfterInvalidation', $performance_data->getQueries());
  $this->assertMetricsByName('nodePromotedContentAfterInvalidation', $performance_data);
  $expected_default_cache_cids = [
    'views_data:node_field_data:en',
    'views_data:views:en',
    'views_data:node:en',
  ];
  $this->assertSame($expected_default_cache_cids, $performance_data->getCacheOperations()['get']['default']);
}

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