function CacheabilityMetadataConfigOverrideIntegrationTest::testConfigOverride
Same name in other branches
- 8.9.x core/modules/config/tests/src/Functional/CacheabilityMetadataConfigOverrideIntegrationTest.php \Drupal\Tests\config\Functional\CacheabilityMetadataConfigOverrideIntegrationTest::testConfigOverride()
- 10 core/modules/config/tests/src/Functional/CacheabilityMetadataConfigOverrideIntegrationTest.php \Drupal\Tests\config\Functional\CacheabilityMetadataConfigOverrideIntegrationTest::testConfigOverride()
- 11.x core/modules/config/tests/src/Functional/CacheabilityMetadataConfigOverrideIntegrationTest.php \Drupal\Tests\config\Functional\CacheabilityMetadataConfigOverrideIntegrationTest::testConfigOverride()
Tests if config overrides correctly set cacheability metadata.
File
-
core/
modules/ config/ tests/ src/ Functional/ CacheabilityMetadataConfigOverrideIntegrationTest.php, line 47
Class
- CacheabilityMetadataConfigOverrideIntegrationTest
- Tests if configuration overrides correctly affect cacheability metadata.
Namespace
Drupal\Tests\config\FunctionalCode
public function testConfigOverride() {
// Check the default (disabled) state of the cache context. The block label
// should not be overridden.
$this->drupalGet('<front>');
$this->assertSession()
->pageTextNotContains('Overridden block label');
// Both the cache context and tag should be present.
$this->assertCacheContext('config_override_integration_test');
$this->assertSession()
->responseHeaderContains('X-Drupal-Cache-Tags', 'config_override_integration_test_tag');
// Flip the state of the cache context. The block label should now be
// overridden.
\Drupal::state()->set('config_override_integration_test.enabled', TRUE);
$this->drupalGet('<front>');
$this->assertSession()
->pageTextContains('Overridden block label');
// Both the cache context and tag should still be present.
$this->assertCacheContext('config_override_integration_test');
$this->assertSession()
->responseHeaderContains('X-Drupal-Cache-Tags', 'config_override_integration_test_tag');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.