You are here

public function CacheabilityMetadataConfigOverrideTest::testConfigOverride in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideTest.php \Drupal\config\Tests\CacheabilityMetadataConfigOverrideTest::testConfigOverride()

Tests if config overrides correctly set cacheability metadata.

File

core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideTest.php, line 44
Contains \Drupal\config\Tests\CacheabilityMetadataConfigOverrideTest.

Class

CacheabilityMetadataConfigOverrideTest
Tests if configuration overrides correctly affect cacheability metadata.

Namespace

Drupal\config\Tests

Code

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
    ->assertEqual('pirate', $theme);

  // Check that the cacheability metadata is correct.
  $this
    ->assertEqual([
    'pirate_day',
  ], $config
    ->getCacheContexts());
  $this
    ->assertEqual([
    'config:system.theme',
    'pirate-day-tag',
  ], $config
    ->getCacheTags());
  $this
    ->assertEqual(PirateDayCacheContext::PIRATE_DAY_MAX_AGE, $config
    ->getCacheMaxAge());
}