示例#1
0
 /**
  * tests an upgrade package containing two schema upgrades
  *
  */
 function test_upgradeSchemas()
 {
     $this->_deleteTestAppVarRecord('tables_core', '');
     $this->assertEqual($this->_getTestAppVarValue('tables_core', ''), '', '');
     $this->_createTestAppVarRecord('tables_core', '997');
     $this->assertEqual($this->_getTestAppVarValue('tables_core', '997'), '997', '');
     $this->_createTestAppVarRecord('oa_version', '2.3.00');
     $oUpgrade->versionInitialSchema['tables_core'] = 997;
     $oUpgrade->versionInitialApplication = '2.3.00';
     $oUpgrade = new OA_Upgrade();
     $oUpgrade->upgradePath = MAX_PATH . '/lib/OA/Upgrade/tests/data/';
     $oUpgrade->oDBUpgrader->path_changes = $oUpgrade->upgradePath;
     $oUpgrade->oDBUpgrader->path_schema = $oUpgrade->upgradePath;
     $input_file = 'openads_upgrade_2.3.00_to_2.3.02_beta.xml';
     $oUpgrade->initDatabaseConnection();
     $oUpgrade->_parseUpgradePackageFile($oUpgrade->upgradePath . $input_file);
     $this->assertTrue($oUpgrade->upgradeSchemas(), 'upgradeSchemas');
     $this->_checkTablesUpgraded($oUpgrade);
     $this->assertEqual($this->_getTestAppVarValue('tables_core', '999'), '999', '');
     // remove the fake application variable records
     $this->_deleteTestAppVarRecordAllNames('oa_version');
     $this->_deleteTestAppVarRecordAllNames('tables_core');
     TestEnv::restoreConfig();
     TestEnv::restoreEnv();
 }
 function test_parseUpgradePackageFile()
 {
     $oUpgrade = new OA_Upgrade();
     $aExpected = array();
     $aExpected['db_pkgs'] = array();
     $aExpected['name'] = 'Openads';
     $aExpected['creationDate'] = '2007-01-01';
     $aExpected['author'] = 'Test Author';
     Mock::generatePartial('OA_UpgradePackageParser', $mockParser = 'OA_UpgradePackageParser' . rand(), array('setInputFile', 'parse'));
     $oUpgrade->oParser = new $mockParser($this);
     $oUpgrade->oParser->setReturnValue('setInputFile', true);
     $oUpgrade->oParser->expectOnce('setInputFile');
     $oUpgrade->oParser->setReturnValue('parse', $aExpected);
     $oUpgrade->oParser->expectOnce('parse');
     $this->assertTrue($oUpgrade->_parseUpgradePackageFile('test_file'), 'upgrade package parse method failed');
     $oUpgrade->oParser->tally();
 }