// reference field blocks, test that the cache tags of the referenced entity
// are still bubbled to page cache.
$referencing_node_url =
$referencing_node->
toUrl();
$this->
verifyPageCacheContainsTags($referencing_node_url, 'MISS'
);
$this->
verifyPageCacheContainsTags($referencing_node_url, 'HIT',
$referenced_node->
getCacheTags());
// Since the referenced node is inaccessible, it should not appear on the
// referencing node.
$this->
drupalGet($referencing_node_url);
$assert_session->
linkNotExists('The referenced node title'
);
// Publish the referenced entity.
$referenced_node->
setPublished() ->
save();
// Revisit the node with the reference field without clearing cache. Now
// that the referenced node is published, it should appear.
$this->
verifyPageCacheContainsTags($referencing_node_url, 'MISS'
);
$this->
verifyPageCacheContainsTags($referencing_node_url, 'HIT',
$referenced_node->
getCacheTags());
$this->
drupalGet($referencing_node_url);
$assert_session->
linkExists('The referenced node title'
);
} /**
* Verify that when loading a given page, it's a page cache hit or miss.
*
* @param \Drupal\Core\Url $url
* The page for this URL will be loaded.
* @param string $hit_or_miss
* 'HIT' if a page cache hit is expected, 'MISS' otherwise.
* @param 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.
*/