function AssertPageCacheContextsAndTagsTrait::assertCacheContext
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait::assertCacheContext()
- 8.9.x core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait::assertCacheContext()
- 8.9.x core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait::assertCacheContext()
- 10 core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait::assertCacheContext()
Asserts whether an expected cache context was present in the last response.
Parameters
string $expected_cache_context: The expected cache context.
27 calls to AssertPageCacheContextsAndTagsTrait::assertCacheContext()
- AccessDeniedTest::testAccessDeniedCustomPageWithAccessDenied in core/
modules/ system/ tests/ src/ Functional/ System/ AccessDeniedTest.php - Tests that an inaccessible custom 403 page falls back to the default.
- AccessRoleTest::testAccessRole in core/
modules/ user/ tests/ src/ Functional/ Views/ AccessRoleTest.php - Tests role access plugin.
- CacheabilityMetadataConfigOverrideIntegrationTest::testConfigOverride in core/
modules/ config/ tests/ src/ Functional/ CacheabilityMetadataConfigOverrideIntegrationTest.php - Tests if config overrides correctly set cacheability metadata.
- ContactPersonalTest::testPersonalContactAccess in core/
modules/ contact/ tests/ src/ Functional/ ContactPersonalTest.php - Tests access to the personal contact form.
- ContentTranslationWorkflowsTest::testWorkflows in core/
modules/ content_translation/ tests/ src/ Functional/ ContentTranslationWorkflowsTest.php - Tests simple and editorial translation workflows.
File
-
core/
modules/ system/ tests/ src/ Functional/ Cache/ AssertPageCacheContextsAndTagsTrait.php, line 46
Class
- AssertPageCacheContextsAndTagsTrait
- Provides test assertions for testing page-level cache contexts & tags.
Namespace
Drupal\Tests\system\Functional\CacheCode
protected function assertCacheContext($expected_cache_context) {
$cache_contexts = explode(' ', $this->getSession()
->getResponseHeader('X-Drupal-Cache-Contexts'));
$this->assertContains($expected_cache_context, $cache_contexts, "'" . $expected_cache_context . "' is 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.