public function testLoadYamlConfig() { $filepath = FIXTURE_ROOT . DIRECTORY_SEPARATOR . 'Unit' . DIRECTORY_SEPARATOR . 'dummy.yml'; $parsed = ['parsed' => 'stuff']; $yamlContent = file_get_contents($filepath); $this->filesystem->expects($this->once())->method('exists')->with($filepath)->willReturn(true); $this->yamlParser->expects($this->once())->method('parse')->with($yamlContent)->willReturn($parsed); $result = $this->filesystemRepository->loadYamlConfig($filepath); $this->assertSame($parsed, $result); }
/** * Creates a job from given config file in yaml format * * @param string $filepath * @param null|string $host * @param null|string $port * @return BackupJob * @throws \Exception * @author Daniel Wendlandt */ public function createJobFromConfig($filepath, $host = null, $port = null) { $config = $this->filesystem->loadYamlConfig($filepath); if (null === $host) { $host = $config['host']; } if (null === $port) { $port = $config['port']; } return $this->createJob($config['target'], $host, $port, $config['indices']); }
/** * Creates a job from given config file in yaml format * * @param string $filepath * @param null|string $host * @param null|string $port * @return RestoreJob * @throws \Exception * @author Daniel Wendlandt */ public function createJobFromConfig($filepath, $host = null, $port = null) { $config = $this->filesystem->loadYamlConfig($filepath); if (null === $host) { $host = $config['host']; } if (null === $port) { $port = $config['port']; } $source = $config['source'] . DIRECTORY_SEPARATOR . $config['name']; $job = $this->createJob($source, $host, $port); $strategy = new RestoreStrategy(); $strategy->setStrategy($config['strategy']['strategy']); foreach ($config['strategy']['mappings'] as $actionConfig) { $mappingAction = RestoreStrategy\MappingAction::createFromArray($actionConfig); $strategy->addMappingAction($mappingAction); } $job->setStrategy($strategy); return $job; }