You are here

protected function AssertPageCacheContextsAndTagsTrait::assertCacheTags in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait::assertCacheTags()

Ensures that some cache tags are present in the current response.

Parameters

string[] $expected_tags: The expected tags.

bool $include_default_tags: (optional) Whether the default cache tags should be included.

10 calls to AssertPageCacheContextsAndTagsTrait::assertCacheTags()
AssertPageCacheContextsAndTagsTrait::assertPageCacheContextsAndTags in core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php
Asserts page cache miss, then hit for the given URL; checks cache headers.
CacheWebTest::testCacheOutputOnPage in core/modules/views/src/Tests/Plugin/CacheWebTest.php
Tests the output caching on an actual page.
CommentRssTest::testCommentRss in core/modules/comment/src/Tests/CommentRssTest.php
Tests comments as part of an RSS feed.
DisplayBlockTest::testBlockEmptyRendering in core/modules/block/src/Tests/Views/DisplayBlockTest.php
Tests the various testcases of empty block rendering.
DisplayBlockTest::testBlockRendering in core/modules/block/src/Tests/Views/DisplayBlockTest.php
Tests the actual rendering of the views block.

... See full list

File

core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php, line 106
Contains \Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait.

Class

AssertPageCacheContextsAndTagsTrait
Provides test assertions for testing page-level cache contexts & tags.

Namespace

Drupal\system\Tests\Cache

Code

protected function assertCacheTags(array $expected_tags, $include_default_tags = TRUE) {

  // The anonymous role cache tag is only added if the user is anonymous.
  if ($include_default_tags && \Drupal::currentUser()
    ->isAnonymous()) {
    $expected_tags = Cache::mergeTags($expected_tags, [
      'config:user.role.anonymous',
    ]);
  }
  $actual_tags = $this
    ->getCacheHeaderValues('X-Drupal-Cache-Tags');
  sort($expected_tags);
  sort($actual_tags);
  $this
    ->assertIdentical($actual_tags, $expected_tags);
  $this
    ->debugCacheTags($actual_tags, $expected_tags);
}