/** * @expectedException \RuntimeException */ public function testFromPHPMethodWithoutArray() { $path = __DIR__ . '/_files'; $config = \Phinx\Config\Config::fromPHP($path . '/config_without_array.php'); $this->assertEquals('dev', $config->getDefaultEnvironment()); }
/** * Parse the config file and load it into the config object * * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @return void */ protected function loadConfig(InputInterface $input, OutputInterface $output) { $configFilePath = $this->locateConfigFile($input); $output->writeln('<info>using config file</info> .' . str_replace(getcwd(), '', realpath($configFilePath))); $parser = $input->getOption('parser'); // If no parser is specified try to determine the correct one from the file extension. Defaults to YAML if (null === $parser) { $extension = pathinfo($configFilePath, PATHINFO_EXTENSION); switch (strtolower($extension)) { case 'php': $parser = 'php'; break; case 'yml': default: $parser = 'yaml'; break; } } switch (strtolower($parser)) { case 'php': $config = Config::fromPHP($configFilePath); break; case 'yaml': $config = Config::fromYaml($configFilePath); break; default: throw new \InvalidArgumentException(sprintf('\'%s\' is not a valid parser.', $parser)); } $output->writeln('<info>using config parser</info> ' . $parser); $this->setConfig($config); }
/** * @expectedException \RuntimeException */ public function testFromJSONMethodWithoutJSON() { $path = __DIR__ . '/_files'; $config = \Phinx\Config\Config::fromPHP($path . '/empty.json'); $this->assertEquals('dev', $config->getDefaultEnvironment()); }