diff --git a/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php b/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php index 6841293..c943c98 100644 --- a/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php +++ b/core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php @@ -25,6 +25,15 @@ protected function enablePageCaching() { $config->save(); } + /** + * Gets a specifc header value as array. + * + * @param string $header_name + * The header name. + * + * @return array + * The header value, potentially exploded by spaces. + */ protected function getCacheHeaderValues($header_name) { $header_value = $this->drupalGetHeader($header_name); if (empty($header_value)) { @@ -73,6 +82,12 @@ protected function assertPageCacheContextsAndTags(Url $url, array $expected_cont } } + /** + * Ensures that some cache tags got sent in the latest response. + * + * @param array $expected_tags + * The expected tags. + */ protected function assertCacheTags(array $expected_tags) { $actual_tags = $this->getCacheHeaderValues('X-Drupal-Cache-Tags'); $this->assertIdentical($actual_tags, $expected_tags); @@ -82,6 +97,12 @@ protected function assertCacheTags(array $expected_tags) { } } + /** + * Ensures that some cache contexts got sent in the latest response. + * + * @param array $expected_contexts + * The expected cache contexts. + */ protected function assertCacheContexts(array $expected_contexts) { $actual_contexts = $this->getCacheHeaderValues('X-Drupal-Cache-Contexts'); $this->assertIdentical($actual_contexts, $expected_contexts);