public function ConfigEntityStaticCacheTest::testConfigOverride in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/config/src/Tests/ConfigEntityStaticCacheTest.php \Drupal\config\Tests\ConfigEntityStaticCacheTest::testConfigOverride()
Tests that the static cache is sensitive to config overrides.
File
- core/
modules/ config/ src/ Tests/ ConfigEntityStaticCacheTest.php, line 85 - Contains \Drupal\config\Tests\ConfigEntityStaticCacheTest.
Class
- ConfigEntityStaticCacheTest
- Tests the entity static cache when used by config entities.
Namespace
Drupal\config\TestsCode
public function testConfigOverride() {
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $storage */
$storage = \Drupal::entityManager()
->getStorage($this->entityTypeId);
// Prime the cache prior to adding a config override.
$storage
->load($this->entityId);
// Add the config override, and ensure that what is loaded is correct
// despite the prior cache priming.
\Drupal::configFactory()
->addOverride(new ConfigOverrider());
$entity_override = $storage
->load($this->entityId);
$this
->assertIdentical($entity_override->label, 'Overridden label');
// Load override free to ensure that loading the config entity again does
// not return the overridden value.
$entity_no_override = $storage
->loadOverrideFree($this->entityId);
$this
->assertNotIdentical($entity_no_override->label, 'Overridden label');
$this
->assertNotIdentical($entity_override->_loadStamp, $entity_no_override->_loadStamp);
// Reload the entity and ensure the cache is used.
$this
->assertIdentical($storage
->loadOverrideFree($this->entityId)->_loadStamp, $entity_no_override->_loadStamp);
// Enable overrides and reload the entity and ensure the cache is used.
$this
->assertIdentical($storage
->load($this->entityId)->_loadStamp, $entity_override->_loadStamp);
}