diff --git a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php index 6ca9f85..341ca06 100644 --- a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php +++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php @@ -424,4 +424,18 @@ protected function buildXPathQuery($xpath, array $args = array()) { return $this->assertSession()->buildXPathQuery($xpath, $args); } + /** + * Asserts whether an expected cache context was present in the last response. + * + * @param string $expected_cache_context + * The expected cache context. + * + * @deprecated Scheduled for removal in Drupal 9.0.0. + * Use $this->assertSession()->responseHeaderContains() instead. + */ + protected function assertCacheContext($expected_cache_context) { + $cache_contexts = explode(' ', $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Contexts', $expected_cache_context)); + $this->assertTrue(in_array($expected_cache_context, $cache_contexts), "'" . $expected_cache_context . "' is present in the X-Drupal-Cache-Contexts header."); + } + }