You are here

protected function AssertPageCacheContextsAndTagsTrait::assertCacheContext in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait::assertCacheContext()
  2. 9 core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait::assertCacheContext()

Asserts whether an expected cache context was present in the last response.

Parameters

string $expected_cache_context: The expected cache context.

7 calls to AssertPageCacheContextsAndTagsTrait::assertCacheContext()
AccessDeniedTest::testAccessDeniedCustomPageWithAccessDenied in core/modules/system/tests/src/Functional/System/AccessDeniedTest.php
Tests that an inaccessible custom 403 page falls back to the default.
EngineTwigTest::testTwigLinkGenerator in core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php
Tests the link_generator Twig functions.
EngineTwigTest::testTwigUrlGenerator in core/modules/system/tests/src/Functional/Theme/EngineTwigTest.php
Tests the url and url_generate Twig functions.
PageNotFoundTest::testPageNotFoundCustomPageWithAccessDenied in core/modules/system/tests/src/Functional/System/PageNotFoundTest.php
Tests that an inaccessible custom 404 page falls back to the default.
PagerTest::testPagerQueryParametersAndCacheContext in core/modules/system/tests/src/Functional/Pager/PagerTest.php
Tests proper functioning of the query parameters and the pager cache context.

... See full list

File

core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php, line 44

Class

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

Namespace

Drupal\Tests\system\Functional\Cache

Code

protected function assertCacheContext($expected_cache_context) {
  $cache_contexts = explode(' ', $this
    ->getSession()
    ->getResponseHeader('X-Drupal-Cache-Contexts'));
  $this
    ->assertContains($expected_cache_context, $cache_contexts, "'" . $expected_cache_context . "' is present in the X-Drupal-Cache-Contexts header.");
}