コード例 #1
0
ファイル: CreateTest.php プロジェクト: joeymetal/restful-sdti
 protected function setUp()
 {
     @mkdir(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'migrations', 0777, true);
     $this->config = new Config(array('paths' => array('migrations' => sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'migrations'), 'environments' => array('default_migration_table' => 'phinxlog', 'default_database' => 'development', 'development' => array('adapter' => 'mysql', 'host' => 'fakehost', 'name' => 'development', 'user' => '', 'pass' => '', 'port' => 3006))));
     foreach (glob($this->config->getMigrationPath() . '/*.*') as $migration) {
         unlink($migration);
     }
 }
コード例 #2
0
ファイル: Migrations.php プロジェクト: thanghexp/project
 /**
  * Returns an instance of CakeManager
  *
  * @param \Phinx\Config\ConfigInterface|null $config ConfigInterface the Manager needs to run
  * @return \Migrations\CakeManager Instance of CakeManager
  */
 public function getManager($config = null)
 {
     if (!$this->manager instanceof CakeManager) {
         if (!$config instanceof ConfigInterface) {
             throw new \RuntimeException('You need to pass a ConfigInterface object for your first getManager() call');
         }
         $this->manager = new CakeManager($config, $this->output);
     } elseif ($config !== null) {
         $defaultEnvironment = $config->getEnvironment('default');
         try {
             $environment = $this->manager->getEnvironment('default');
             $oldConfig = $environment->getOptions();
             unset($oldConfig['connection']);
             if ($oldConfig == $defaultEnvironment) {
                 $defaultEnvironment['connection'] = $environment->getAdapter()->getConnection();
             }
         } catch (\InvalidArgumentException $e) {
         }
         $config['environments'] = ['default' => $defaultEnvironment];
         $this->manager->setEnvironments([]);
         $this->manager->setConfig($config);
     }
     $this->setAdapter();
     return $this->manager;
 }