Esempio n. 1
0
 public function __call($name, $arguments)
 {
     $config_path = Registry::get('config.dir.root') . '/app/Tygh/UpgradeCenter/Migrations/config.migrations.php';
     switch ($name) {
         case 'migrate':
             $_SERVER['argv'] = array('phinx', 'migrate', '-c' . $config_path, '-edevelopment');
             break;
         case 'rollback':
             $_SERVER['argv'] = array('phinx', 'rollback', '-c' . $config_path, '-edevelopment');
             break;
         default:
             return false;
     }
     $output = new Output();
     $output->setConfig($this->config);
     $output->setVerbosity(Output::VERBOSITY_VERBOSE);
     $app = new PhinxApplication('0.4.3');
     AdapterFactory::instance()->registerAdapter('mysqli', '\\Tygh\\UpgradeCenter\\Phinx\\MysqliAdapter');
     $app->setAutoExit(false);
     $app->setCatchExceptions(false);
     try {
         $exit_code = $app->run(null, $output);
     } catch (\Exception $e) {
         // Convert PDOException to DatabaseException
         if (class_exists('\\PDOException') && $e instanceof \PDOException) {
             throw new DatabaseException($e->getMessage(), $e->getCode(), $e);
         } else {
             throw $e;
         }
     }
     return $exit_code === 0;
 }
 /**
  * @dataProvider provider
  */
 public function testRun($command, $result)
 {
     $app = new \Phinx\Console\PhinxApplication('testing');
     $app->setAutoExit(false);
     // Set autoExit to false when testing
     $app->setCatchExceptions(false);
     $appTester = new ApplicationTester($app);
     $appTester->run(array('command' => $command));
     $stream = $appTester->getOutput()->getStream();
     rewind($stream);
     $this->assertRegExp($result, stream_get_contents($stream));
 }
Esempio n. 3
0
 protected function migrate()
 {
     $input = new ArgvInput(['phinx', 'migrate', '--environment=memory']);
     $output = new NullOutput();
     $phinx = new PhinxApplication();
     $phinx->setAutoExit(false);
     $phinx->run($input, $output);
     /** @var Migrate $migrateCommand */
     $migrateCommand = $phinx->get('migrate');
     $adapter = $migrateCommand->getManager()->getEnvironment('memory')->getAdapter();
     /** @var PDO $pdo */
     $this->phinxPdo = $adapter->getConnection();
 }
Esempio n. 4
0
 public function __call($name, $arguments)
 {
     $config_path = Registry::get('config.dir.root') . '/app/Tygh/UpgradeCenter/Migrations/config.migrations.php';
     switch ($name) {
         case 'migrate':
             $_SERVER['argv'] = array('phinx', 'migrate', '-c' . $config_path, '-edevelopment');
             break;
         case 'rollback':
             $_SERVER['argv'] = array('phinx', 'rollback', '-c' . $config_path, '-edevelopment');
             break;
         default:
             return false;
     }
     $output = new Output();
     $output->setConfig($this->config);
     $app = new PhinxApplication('0.4.3');
     AdapterFactory::instance()->registerAdapter('mysqli', '\\Tygh\\UpgradeCenter\\Phinx\\MysqliAdapter');
     $app->setAutoExit(false);
     $app->run(null, $output);
 }