public function ConfigIgnoreHookTest::testAlterHookStaticCache in Config Ignore 8.3
Test alter hook values are cached unless invalidated.
Its important import/export is called directly, if called by a browser then static cache will not be present.
@covers \Drupal\config_ignore\EventSubscriber\ConfigIgnoreEventSubscriber::getRules @covers \Drupal\config_ignore\EventSubscriber\ConfigIgnoreEventSubscriber::invalidateTags
File
- tests/
src/ Functional/ ConfigIgnoreHookTest.php, line 48
Class
- ConfigIgnoreHookTest
- Test hook implementation of another module.
Namespace
Drupal\Tests\config_ignore\FunctionalCode
public function testAlterHookStaticCache() {
// Each of these are cloned since normally result of transformStorage
// statically cached by \Drupal\Core\Config\ManagedStorage::$manager.
$sourceOriginal = $this->container
->get('config.storage.export');
$destinationOriginal = $this->container
->get('config.storage.sync');
// Never called.
$this
->assertNull($this
->getAlterCallCount());
// Initial call caches.
$this
->copyConfig(clone $sourceOriginal, clone $destinationOriginal);
$this
->assertEquals(1, $this
->getAlterCallCount());
// Subsequent calls read from cache.
$this
->copyConfig(clone $sourceOriginal, clone $destinationOriginal);
$this
->assertEquals(1, $this
->getAlterCallCount());
// Writing a new value to our config triggers cache tag invalidation.
// This value itself is inconsequential.
$this
->config('config_ignore.settings')
->set('ignored_config_entities', [
'foo.bar',
])
->save();
$this
->copyConfig(clone $sourceOriginal, clone $destinationOriginal);
$this
->assertEquals(2, $this
->getAlterCallCount());
}