function LayoutBuilderFieldBlockEntityReferenceCacheTagsTest::verifyPageCacheContainsTags
Same name in other branches
- 8.9.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderFieldBlockEntityReferenceCacheTagsTest::verifyPageCacheContainsTags()
- 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderFieldBlockEntityReferenceCacheTagsTest::verifyPageCacheContainsTags()
- 11.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderFieldBlockEntityReferenceCacheTagsTest::verifyPageCacheContainsTags()
Verify that when loading a given page, it's a page cache hit or miss.
Parameters
\Drupal\Core\Url $url: The page for this URL will be loaded.
string $hit_or_miss: 'HIT' if a page cache hit is expected, 'MISS' otherwise.
array|false $tags: When expecting a page cache hit, you may optionally specify an array of expected cache tags. While FALSE, the cache tags will not be verified. This tests whether all expected tags are in the page cache tags, not that expected tags and page cache tags are identical.
1 call to LayoutBuilderFieldBlockEntityReferenceCacheTagsTest::verifyPageCacheContainsTags()
- LayoutBuilderFieldBlockEntityReferenceCacheTagsTest::testEntityReferenceFieldBlockCaching in core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php - Tests cache tags on field block for entity reference field.
File
-
core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderFieldBlockEntityReferenceCacheTagsTest.php, line 128
Class
- LayoutBuilderFieldBlockEntityReferenceCacheTagsTest
- Tests cache tags on entity reference field blocks in Layout Builder.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
protected function verifyPageCacheContainsTags(Url $url, $hit_or_miss, $tags = FALSE) {
$this->drupalGet($url);
$this->assertSession()
->responseHeaderEquals('X-Drupal-Cache', $hit_or_miss);
if ($hit_or_miss === 'HIT' && is_array($tags)) {
$cache_tags = explode(' ', $this->getSession()
->getResponseHeader('X-Drupal-Cache-Tags'));
$tags = array_unique($tags);
$this->assertEmpty(array_diff($tags, $cache_tags), 'Page cache tags contains all expected tags.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.