示例#1
0
 /**
  * Executes all executeUpgrade methods of each version
  */
 public function testUpgrade()
 {
     // create a copy of the current schema
     $sm = $this->connection->getSchemaManager();
     $toSchema = $sm->createSchema();
     $this->removeAllTables();
     // execute upgrade
     $path = array_reverse(Installer::getUpgradePath());
     $lastVersion = array_shift($path);
     $installer = new Installer($this->connection);
     $installer->install($lastVersion);
     foreach ($path as $version) {
         $installer->upgrade($lastVersion, $version);
         $lastVersion = $version;
     }
     // @TODO make checks to verify that the installation works
     $this->removeAllTables();
     // restore the schema
     $fromSchema = $sm->createSchema();
     $queries = $fromSchema->getMigrateToSql($toSchema, $this->connection->getDatabasePlatform());
     foreach ($queries as $sql) {
         $this->connection->executeUpdate($sql);
     }
 }
示例#2
0
 /**
  * Checks whether this version is in the upgrade path
  */
 public function testUpgradePath()
 {
     $installer = new Installer($this->connection);
     $path = $installer->getUpgradePath();
     $this->assertEquals(Base::getVersion(), current($path), 'The current version must be in the upgrade path');
 }