Beispiel #1
0
 public function testParser()
 {
     $configs = ['php' => 'phoenix.php', 'yml' => 'phoenix.yml', 'neon' => 'phoenix.neon', 'json' => 'phoenix.json'];
     foreach ($configs as $type => $file) {
         $configParser = ConfigParserFactory::instance($type);
         $filename = __DIR__ . '/../../example/' . $file;
         $config = $configParser->parse($filename);
         $this->assertArrayHasKey('migration_dirs', $config);
         $this->assertArrayHasKey('phoenix', $config['migration_dirs']);
         $this->assertArrayHasKey('environments', $config);
         $this->assertArrayHasKey('mysql', $config['environments']);
         $this->assertArrayHasKey('sqlite', $config['environments']);
     }
 }
Beispiel #2
0
 private function loadConfig(InputInterface $input)
 {
     if ($this->config) {
         return;
     }
     $configFile = $input->getOption('config');
     if (!$configFile) {
         $configFile = $this->getDefaultConfig();
     }
     if (!$configFile) {
         throw new ConfigException('No configuration file exists. Create phoenix.php or phoenix.yml or phoenix.neon or phoenix.json in your project root or specify path to your existing config file with --config option');
     }
     if ($configFile && !file_exists($configFile)) {
         throw new ConfigException('Configuration file "' . $configFile . '" doesn\'t exist.');
     }
     $type = $input->getOption('config_type') ?: pathinfo($configFile, PATHINFO_EXTENSION);
     $configParser = ConfigParserFactory::instance($type);
     $configuration = $configParser->parse($configFile);
     $this->config = new Config($configuration);
 }
 public function testUnknownType()
 {
     $this->setExpectedException(ConfigException::class, 'Unknown config type "asdf"');
     ConfigParserFactory::instance('Asdf');
 }