public function testTablePrefixAdapter() { $this->environment->setOptions(array('table_prefix' => 'tbl_', 'adapter' => 'mysql')); $this->assertInstanceOf('Phinx\\Db\\Adapter\\TablePrefixAdapter', $this->environment->getAdapter()); $tablePrefixAdapter = $this->environment->getAdapter(); $this->assertInstanceOf('Phinx\\Db\\Adapter\\MysqlAdapter', $tablePrefixAdapter->getAdapter()); }
/** * Verify configuration file * * @param InputInterface $input * @param OutputInterface $output * @throws \RuntimeException * @throws \InvalidArgumentException * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $this->loadManager($input, $output); $this->verifyMigrationDirectory($this->getConfig()->getMigrationPath()); $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 Environment($envName, $this->getConfig()->getEnvironment($envName)); // validate environment connection $environment->getAdapter()->connect(); } $output->writeln('<info>success!</info>'); }
/** * @dataProvider badAdapterProvider * @expectedException \RuntimeException */ public function testBadAdapterFactories($adapterName, $adapter) { $env = new Environment('test-' . $adapterName, array()); $env->registerAdapter($adapterName, $adapter); $env->setOptions(array('adapter' => $adapterName)); $env->getAdapter(); }
public function testAdapterFactoryCreatesMysqlAdapter() { $this->environment->setOptions(array('adapter' => 'mysql')); $this->assertTrue($this->environment->getAdapter() instanceof \Phinx\Db\Adapter\MysqlAdapter); }