function AssertPageCacheContextsAndTagsTrait::assertNoCacheContext

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

Parameters

string $not_expected_cache_context: The expected cache context.

3 calls to AssertPageCacheContextsAndTagsTrait::assertNoCacheContext()
MediaAccessTest::testMediaAccess in core/modules/media/tests/src/Functional/MediaAccessTest.php
Tests some access control functionality.
MediaAccessTest::testReferencedRendering in core/modules/media/tests/src/Functional/MediaAccessTest.php
Tests access for embedded medias.
NodeAccessCacheabilityTest::testNodeAccessCacheabilitySafeguard in core/modules/node/tests/src/Functional/NodeAccessCacheabilityTest.php
Tests that the node grants cache context is auto-added, only when needed.

File

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

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.");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.