/** * Verify configuration file * * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $this->loadConfig($input, $output); $this->loadManager($output); $migrationsPath = $this->getConfig()->getMigrationPath(); // validate if migrations path is valid if (!file_exists($migrationsPath)) { throw new \RuntimeException('The migrations path is invalid'); } $envName = $input->getOption('environment'); if ($envName) { if (!$this->getConfig()->hasEnvironment($envName)) { throw new \InvalidArgumentException(sprintf('The environment "%s" does not exist', $envName)); } $output->writeln(sprintf('<info>validating environment</info> %s', $envName)); $environment = new \Phinx\Migration\Manager\Environment($envName, $this->getConfig()->getEnvironment($envName)); // validate environment connection $environment->getAdapter()->connect(); } $output->writeln('<info>success!</info>'); }
public function testConstructorWorksAsExpected() { $env = new \Phinx\Migration\Manager\Environment('testenv', array('foo' => 'bar')); $this->assertEquals('testenv', $env->getName()); $this->assertArrayHasKey('foo', $env->getOptions()); }