/**
  * Stores config to yml config
  *
  * @param RestoreJob $job
  * @param OutputInterface $output
  * @author Daniel Wendlandt
  */
 private function storeConfig(RestoreJob $job, OutputInterface $output)
 {
     $mappingActions = array();
     foreach ($job->getStrategy()->getMappings() as $types) {
         /** @var RestoreStrategy\MappingAction $mappingAction */
         foreach ($types as $mappingAction) {
             $mappingActions[] = $mappingAction->toArray();
         }
     }
     $config = array('name' => $job->getName(), 'source' => $job->getSource(), 'host' => $job->getHost(), 'port' => $job->getPort(), 'create_config' => $job->isCreateConfig(), 'config_name' => $job->getConfigName(), 'strategy' => array('strategy' => $job->getStrategy()->getStrategy(), 'mappings' => $mappingActions), 'created_at' => $job->getCreatedAt()->format('Y-m-d H:i:s'));
     $this->filesystem->storeRestoreConfig($job, $config);
     $output->writeln('<info>*** Stored restore-config to file in yaml format ***</info>' . PHP_EOL);
 }
 public function testStoreRestoreConfig()
 {
     $path = '/tmp/test-path';
     $data = ['yaml' => 'data'];
     $yamlString = 'YamlString';
     $configName = 'my-config-name';
     $restoreJob = $this->getMockBuilder('Elastification\\BackupRestore\\Entity\\RestoreJob')->disableOriginalConstructor()->getMock();
     $filepath = $path . DIRECTORY_SEPARATOR . FilesystemRepositoryInterface::DIR_CONFIG . DIRECTORY_SEPARATOR . $configName . FilesystemRepositoryInterface::FILE_EXTENSION_CONFIG;
     $restoreJob->expects($this->once())->method('getPath')->willReturn($path);
     $restoreJob->expects($this->once())->method('getConfigName')->willReturn($configName);
     $this->yamlDumper->expects($this->once())->method('dump')->with($data, 5)->willReturn($yamlString);
     $this->filesystem->expects($this->once())->method('dumpFile')->with($filepath, $yamlString);
     $this->filesystemRepository->storeRestoreConfig($restoreJob, $data);
 }