function AssertPageCacheContextsAndTagsTrait::assertNoCacheContext

Same name in this branch
  1. 8.9.x core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait::assertNoCacheContext()
Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait::assertNoCacheContext()
  2. 10 core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait::assertNoCacheContext()
  3. 11.x 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.

3 calls to AssertPageCacheContextsAndTagsTrait::assertNoCacheContext()
MediaAccessTest::testMediaAccess in core/modules/media/tests/src/Functional/MediaAccessTest.php
Test 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 60

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->drupalGetHeader('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.