/** * @covers ::rename */ public function testRename() { $old = new Config($this->randomMachineName(), $this->storage, $this->eventDispatcher, $this->typedConfig); $new = new Config($this->randomMachineName(), $this->storage, $this->eventDispatcher, $this->typedConfig); $this->storage->expects($this->exactly(2))->method('readMultiple')->willReturnMap([[[$old->getName()], $old->getRawData()], [[$new->getName()], $new->getRawData()]]); $this->cacheTagsInvalidator->expects($this->once())->method('invalidateTags')->with($old->getCacheTags()); $this->storage->expects($this->once())->method('rename')->with($old->getName(), $new->getName()); $this->configFactory->rename($old->getName(), $new->getName()); }
/** * write configuration back to files. * * @param \Drupal\Core\Config\Config $config * The config object. * @param array $file_names * The file names to which the configuration should be written. */ public function writeBackConfig(Config $config, array $file_names) { if ($file_names) { $data = $config->get(); $config_name = $config->getName(); if ($entity_type_id = $this->configManager->getEntityTypeIdByName($config_name)) { unset($data['uuid']); } foreach ($file_names as $file_name) { try { file_put_contents($file_name, (new InstallStorage())->encode($data)); } catch (DumpException $e) { // Do nothing. What could we do? } } } }
/** * @covers ::getCacheTags */ public function testGetCacheTags() { $this->assertSame(['config:' . $this->config->getName()], $this->config->getCacheTags()); }
/** * {@inheritdoc} */ public function calculateDependencies() { $provider = explode('.', $this->config->getName(), 2)[0]; $this->addDependency('module', $provider); return $this->dependencies; }