/**
  * internal function to return an initialised db_upgrade object for testing
  *
  * @param string $timing
  * @return object
  */
 function _newDBUpgradeObject($timing = 'constructive')
 {
     $oDB_Upgrade->initMDB2Schema();
     $oDB_Upgrade->timingStr = $timing;
     $oDB_Upgrade->timingInt = $timing ? 0 : 1;
     $oDB_Upgrade->prefix = $this->prefix;
     $oDB_Upgrade->schema = 'tables_core_326';
     $oDB_Upgrade->versionFrom = 1;
     $oDB_Upgrade->versionTo = 2;
     $oDB_Upgrade->logFile = MAX_PATH . "/var/test.log";
     $oDBAuditor = new OA_DB_UpgradeAuditor();
     $this->assertTrue($oDBAuditor->init($oDB_Upgrade->oSchema->db), 'error initialising upgrade auditor, probable error creating database action table');
     $oDBAuditor->setKeyParams(array('schema_name' => $oDB_Upgrade->schema, 'version' => $oDB_Upgrade->versionTo, 'timing' => $oDB_Upgrade->timingInt));
     $oDB_Upgrade->oAuditor =& $oDBAuditor;
     return $oDB_Upgrade;
 }
Exemplo n.º 2
0
 function upgradeToVersion($version)
 {
     Mock::generatePartial('OA_UpgradeLogger', $mockLogger = 'OA_UpgradeLogger' . rand(), array('logOnly', 'logError', 'log'));
     $oLogger = new $mockLogger($this);
     $oLogger->setReturnValue('logOnly', true);
     $oLogger->setReturnValue('logError', true);
     $oLogger->setReturnValue('log', true);
     $this->oDBUpgrader = new OA_DB_Upgrade($oLogger);
     $this->oDBUpgrader->logFile = MAX_PATH . '/var/DB_Upgrade.test.log';
     $this->oDBUpgrader->initMDB2Schema();
     $auditor = new OA_DB_UpgradeAuditor();
     $this->oDBUpgrader->oAuditor =& $auditor;
     $this->assertTrue($auditor->init($this->oDBUpgrader->oSchema->db), 'error initialising upgrade auditor, probable error creating database action table');
     // execute all database upgrade actions for a given schema version
     // constructive first
     $this->oDBUpgrader->init('constructive', 'tables_core', $version);
     $this->oDBUpgrader->doBackups = false;
     $this->assertTrue($this->oDBUpgrader->upgrade(), 'constructive');
     // use same changeset, switch timing only to execute destructive
     $this->oDBUpgrader->init('destructive', 'tables_core', $version, true);
     $this->assertTrue($this->oDBUpgrader->upgrade(), 'destructive');
 }