You are here

protected function AssertPageCacheContextsAndTagsTrait::assertNoCacheContext in Drupal 8

Same name in this branch
  1. 8 core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait::assertNoCacheContext()
  2. 8 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/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php, line 66

Class

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

Namespace

Drupal\system\Tests\Cache

Code

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