Ejemplo n.º 1
0
 public function testSaveConfigFile()
 {
     $configFile = new ConfigFile('/path');
     $this->serializer->expects($this->once())->method('serializeConfigFile')->with($configFile)->willReturn('SERIALIZED');
     $this->backend->expects($this->once())->method('write')->with('/path', 'SERIALIZED');
     $this->storage->saveConfigFile($configFile);
 }
Ejemplo n.º 2
0
 public function testSaveRootPackageFile()
 {
     $baseConfig = new Config();
     $packageFile = new RootPackageFile(null, '/path', $baseConfig);
     $this->serializer->expects($this->once())->method('serializeRootPackageFile')->with($packageFile)->willReturn('SERIALIZED');
     $this->backend->expects($this->once())->method('write')->with('/path', 'SERIALIZED');
     $this->storage->saveRootPackageFile($packageFile);
 }
Ejemplo n.º 3
0
 /**
  * Saves a configuration file.
  *
  * The configuration file is saved to the same path that it was read from.
  *
  * @param ConfigFile $configFile The configuration file to save.
  *
  * @throws StorageException If the file cannot be written.
  */
 public function saveConfigFile(ConfigFile $configFile)
 {
     $serialized = $this->serializer->serializeConfigFile($configFile);
     $this->storage->write($configFile->getPath(), $serialized);
     if ($this->factoryManager) {
         $this->factoryManager->autoGenerateFactoryClass();
     }
 }
Ejemplo n.º 4
0
 private function saveFile($file, $path, array $options = array())
 {
     $className = get_class($file);
     try {
         $jsonData = $this->converterProvider->getJsonConverter($className)->toJson($file, $options);
     } catch (ConversionFailedException $e) {
         throw new InvalidConfigException(sprintf('The data written to %s could not be converted: %s', $path, $e->getMessage()), 0, $e);
     }
     $json = $this->encode($jsonData, $path);
     $this->storage->write($path, $json);
 }
Ejemplo n.º 5
0
 /**
  * Saves a configuration file.
  *
  * The configuration file is saved to the same path that it was read from.
  *
  * @param ConfigFile $configFile The configuration file to save.
  *
  * @throws WriteException         If the file cannot be written.
  * @throws InvalidConfigException If the file contains invalid configuration.
  */
 public function saveConfigFile(ConfigFile $configFile)
 {
     try {
         $jsonData = $this->configFileConverter->toJson($configFile);
     } catch (ConversionFailedException $e) {
         throw new InvalidConfigException(sprintf('The data written to %s could not be converted: %s', $configFile->getPath(), $e->getMessage()), 0, $e);
     }
     $json = $this->encode($jsonData, $configFile->getPath());
     $this->storage->write($configFile->getPath(), $json);
     if ($this->factoryManager) {
         $this->factoryManager->autoGenerateFactoryClass();
     }
 }