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.

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

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