Beispiel #1
0
    /**
     * @expectedException \PhpZone\PhpZone\Exception\Config\InvalidFormatException
     * @expectedExceptionCode 1
     */
    public function test_it_should_fail_when_config_has_invalid_format()
    {
        $testFile = 'yamlFile.yml';
        $testFileContent = <<<EOF
imports: string
EOF;
        $this->filesystem->dumpFile($testFile, $testFileContent);
        $this->yamlLoader->load($testFile);
    }
Beispiel #2
0
 /**
  * @param InputInterface $input
  *
  * @throws ConfigNotFoundException
  * @throws InvalidFileTypeException
  * @throws InvalidFormatException
  */
 private function loadConfigurationFile(InputInterface $input)
 {
     $path = 'phpzone.yml';
     if ($input->hasParameterOption(array('--config', '-c'))) {
         $path = $input->getParameterOption(array('--config', '-c'));
     }
     $yamlLoader = new YamlLoader(new FileLocator(getcwd()));
     try {
         $config = $yamlLoader->load($path);
     } catch (ConfigNotFoundException $e) {
         if ($input->hasParameterOption(array('--config', '-c'))) {
             throw $e;
         } else {
             $config = array();
         }
     }
     foreach ($config as $parameterName => $parameterValue) {
         $this->container->setParameter($parameterName, $parameterValue);
     }
 }