protected function doRedo()
 {
     $dataDir = $this->dataDir->getAbsolutePath();
     $htmlDir = $this->htmlDir->getAbsolutePath();
     define('HTML_REALDIR', rtrim(realpath($htmlDir), '/\\') . '/');
     require_once HTML_REALDIR . '/define.php';
     require_once HTML_REALDIR . HTML2DATA_DIR . '/require_base.php';
     $query = SC_Query_Ex::getSingletonInstance();
     $storage = new Zeclib_DefaultMigrationStorage($query, $this->system);
     $storage->versionTable = $this->versionTable;
     $storage->containerDirectories[] = $this->containerDir->getPath();
     $migrator = new Zeclib_Migrator($storage, $query);
     $migrator->logger = new Zeclib_Phing_TaskMigrationLogger($this);
     $migrations = array();
     $versions = preg_split('/[,\\s]+/', $this->version, 0, PREG_SPLIT_NO_EMPTY);
     foreach ($versions as $version) {
         try {
             $migrations[] = $migrator->loadMigration($version);
         } catch (Zeclib_MigrationException $e) {
             $message = $e->getMessage();
             $this->log($message, Zeclib_MigrationLogger::TYPE_WARNING);
         }
     }
     $num = $migrator->revert($migrations);
     $this->log(sprintf('%d migrations are reverted.', $num));
     $num = $migrator->apply($migrations);
     $this->log(sprintf('%d migrations are applicated.', $num));
 }
Esempio n. 2
0
 public function testRevert()
 {
     $this->storage->expects($this->any())->method('isAppliedVersion')->willReturn(true);
     $migrator = new Zeclib_Migrator($this->storage, $this->query);
     $migras = array();
     $migra01 = $this->getMockForAbstractClass('Zeclib_Migration', array('01', $this->query));
     $migra01->expects($this->once())->method('down');
     $migras[] = $migra01;
     $migra02 = $this->getMockForAbstractClass('Zeclib_Migration', array('02', $this->query));
     $migra02->expects($this->once())->method('down');
     $migras[] = $migra02;
     $migra03 = $this->getMockForAbstractClass('Zeclib_Migration', array('03', $this->query));
     $migra03->expects($this->once())->method('down');
     $migras[] = $migra03;
     $migrator->revert($migras);
     foreach ($migras as $migra) {
         $this->assertFalse($migra->applied, 'Not work migration: ' . $migra->version);
     }
 }