Пример #1
0
 /**
  * A method for restoring the testing environment database setup.
  * This method can normaly be avoided by using transactions to
  * rollback database changes during testing, but sometimes a
  * DROP TEMPORARY TABLE (for example) is used during testing,
  * causing any transaction to be committed. In this case, this
  * method is needed to re-set the testing database.
  */
 static function restoreEnv($dropTmpTables = 'false')
 {
     $oDbh =& OA_DB::singleton();
     // Rollback any transactions that have not been closed
     // (Naughty, naughty test!)
     while ($oDbh->inTransaction(true) || $oDbh->inTransaction()) {
         TestEnv::rollbackTransaction();
     }
     if ($dropTmpTables) {
         TestEnv::dropTempTables();
     }
     // Truncate all known core tables
     $oTable =& OA_DB_Table_Core::singleton();
     $oTable->truncateAllTables();
     // Reset all database sequences
     $oTable->resetAllSequences();
     // Destroy the service locator
     $oServiceLocator =& OA_ServiceLocator::instance();
     unset($oServiceLocator->aService);
     // Re-set up the test environment
     TestRunner::setupEnv($GLOBALS['_MAX']['TEST']['layerEnv'], true);
 }
 /**
  * The master test class that performs the various upgrades of the system,
  * and calls private methods to test various sections of the upgrade.
  */
 function testUpgrade()
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     // Run the tests for every set of preferences that have been defined
     foreach (array_keys($this->aPrefsOld) as $set) {
         if ($set == 1 && $aConf['database']['type'] != 'mysql') {
             // OpenX 2.4.4 is only valid for MySQL
             continue;
         }
         // Initialise the database at schema 542
         $this->initDatabase(542, array('agency', 'affiliates', 'application_variable', 'audit', 'channel', 'clients', 'preference', 'preference_advertiser', 'preference_publisher', 'acls', 'acls_channel', 'banners', 'campaigns', 'tracker_append', 'trackers', 'userlog', 'variables', 'zones'));
         // Set up the database with the standard set of accounts,
         // preferences and settings
         $this->_setupAccounts();
         $this->_setupPreferences($set);
         // Perform the required upgrade on the database
         $this->upgradeToVersion(543);
         $this->upgradeToVersion(544);
         $this->upgradeToVersion(546);
         // Test the results of the upgrade
         $this->_testMigratePrefsToSettings($set);
         $this->_testMigratePrefsToAppVars($set);
         $this->_testMigratePrefsToPrefs($set);
         $this->_testMigrateUsers($set);
         // Restore the testing environment
         TestRunner::setupEnv(null);
         $this->oDbh =& OA_DB::singleton();
     }
 }
Пример #3
0
 /** A method to run a single test file.
  *
  * @param string $layer  The name of a layer group to run.
  * @param string $folder The folder group to run, not including "tests/unit"
  * @param string $file   The file to run, including ".test.php"
  */
 function runFile($layer, $folder, $file)
 {
     $type = $GLOBALS['_MAX']['TEST']['test_type'];
     // Set up the environment for the test
     TestRunner::setupEnv($layer);
     $configBefore = TestEnv::parseConfigFile();
     // Add the test file to a SimpleTest group
     $testName = $this->_testName($layer, $folder, $file);
     $secondaryName = $this->_secondaryTestName($layer);
     $test = new GroupTest($testName, $secondaryName);
     $testFile = MAX_PROJECT_PATH . '/' . $folder . '/' . constant($type . '_TEST_STORE') . '/' . $file;
     $test->addTestFile($testFile);
     $this->runCase($test);
     // Tear down the environment for the test
     $configAfter = TestEnv::parseConfigFile();
     $configDiff = array_diff_assoc_recursive($configBefore, $configAfter);
     if (!empty($configDiff)) {
         OA::debug("Config file was changed by test: {$folder} {$file}", PEAR_LOG_DEBUG);
     }
     TestRunner::teardownEnv($layer);
 }