コード例 #1
0
ファイル: ManagerTest.php プロジェクト: elliotwms/phinx
 public function testReversibleMigrationsWorkAsExpected()
 {
     if (!TESTS_PHINX_DB_ADAPTER_MYSQL_ENABLED) {
         $this->markTestSkipped('Mysql tests disabled. See TESTS_PHINX_DB_ADAPTER_MYSQL_ENABLED constant.');
     }
     $configArray = $this->getConfigArray();
     $adapter = $this->manager->getEnvironment('production')->getAdapter();
     // override the migrations directory to use the reversible migrations
     $configArray['paths']['migrations'] = $this->getCorrectedPath(__DIR__ . '/_files/reversiblemigrations');
     $config = new Config($configArray);
     // ensure the database is empty
     $adapter->dropDatabase(TESTS_PHINX_DB_ADAPTER_MYSQL_DATABASE);
     $adapter->createDatabase(TESTS_PHINX_DB_ADAPTER_MYSQL_DATABASE);
     $adapter->disconnect();
     // migrate to the latest version
     $this->manager->setConfig($config);
     $this->manager->migrate('production');
     // ensure up migrations worked
     $this->assertFalse($adapter->hasTable('info'));
     $this->assertTrue($adapter->hasTable('statuses'));
     $this->assertTrue($adapter->hasTable('users'));
     $this->assertTrue($adapter->hasTable('user_logins'));
     $this->assertTrue($adapter->hasColumn('users', 'biography'));
     $this->assertTrue($adapter->hasForeignKey('user_logins', array('user_id')));
     // revert all changes to the first
     $this->manager->rollback('production', '20121213232502');
     // ensure reversed migrations worked
     $this->assertTrue($adapter->hasTable('info'));
     $this->assertFalse($adapter->hasTable('statuses'));
     $this->assertFalse($adapter->hasTable('user_logins'));
     $this->assertTrue($adapter->hasColumn('users', 'bio'));
     $this->assertFalse($adapter->hasForeignKey('user_logins', array('user_id')));
 }
コード例 #2
0
ファイル: ManagerTest.php プロジェクト: liammartens/xtend
 public function testBreakpointWithInvalidVersion()
 {
     if (!TESTS_PHINX_DB_ADAPTER_MYSQL_ENABLED) {
         $this->markTestSkipped('Mysql tests disabled. See TESTS_PHINX_DB_ADAPTER_MYSQL_ENABLED constant.');
     }
     $configArray = $this->getConfigArray();
     $adapter = $this->manager->getEnvironment('production')->getAdapter();
     $config = new Config($configArray);
     // ensure the database is empty
     $adapter->dropDatabase(TESTS_PHINX_DB_ADAPTER_MYSQL_DATABASE);
     $adapter->createDatabase(TESTS_PHINX_DB_ADAPTER_MYSQL_DATABASE);
     $adapter->disconnect();
     // migrate to the latest version
     $this->manager->setConfig($config);
     $this->manager->migrate('production');
     $this->manager->getOutput()->setDecorated(false);
     // set breakpoint on most recent migration
     $this->manager->toggleBreakpoint('production', 999);
     rewind($this->manager->getOutput()->getStream());
     $output = stream_get_contents($this->manager->getOutput()->getStream());
     $this->assertContains('is not a valid version', $output);
 }