You are here

protected function AssertPageCacheContextsAndTagsTrait::assertNoCacheContext 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::assertNoCacheContext()
  2. 9 core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait::assertNoCacheContext()

Asserts that a cache context was not present in the last response.

Parameters

string $not_expected_cache_context: The expected cache context.

File

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

Class

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

Namespace

Drupal\Tests\system\Functional\Cache

Code

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