public function CacheabilityMetadataConfigOverrideTest::testConfigOverride in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Config/CacheabilityMetadataConfigOverrideTest.php \Drupal\KernelTests\Core\Config\CacheabilityMetadataConfigOverrideTest::testConfigOverride()
- 9 core/tests/Drupal/KernelTests/Core/Config/CacheabilityMetadataConfigOverrideTest.php \Drupal\KernelTests\Core\Config\CacheabilityMetadataConfigOverrideTest::testConfigOverride()
Tests if config overrides correctly set cacheability metadata.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Config/ CacheabilityMetadataConfigOverrideTest.php, line 40
Class
- CacheabilityMetadataConfigOverrideTest
- Tests if configuration overrides correctly affect cacheability metadata.
Namespace
Drupal\KernelTests\Core\ConfigCode
public function testConfigOverride() {
// It's pirate day today!
$GLOBALS['it_is_pirate_day'] = TRUE;
$config_factory = $this->container
->get('config.factory');
$config = $config_factory
->get('system.theme');
// Check that we are using the Pirate theme.
$theme = $config
->get('default');
$this
->assertEquals('pirate', $theme);
// Check that the cacheability metadata is correct.
$this
->assertEquals([
'pirate_day',
], $config
->getCacheContexts());
$this
->assertEquals([
'config:system.theme',
'pirate-day-tag',
], $config
->getCacheTags());
$this
->assertEquals(PirateDayCacheContext::PIRATE_DAY_MAX_AGE, $config
->getCacheMaxAge());
}