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); } }
/** * 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; }