/** * A method for re-parsing the testing environment configuration * file, to restore it in the event it needed to be changed * during a test. * * @todo Remove the audit hack */ static function restoreConfig() { // Destroy cached table classes OA_DB_Table_Core::destroy(); // Restore and Re-parse the config file $backupConfigFilename = $GLOBALS['_MAX']['TEST']['backupConfigFilename']; if (!empty($backupConfigFilename) && is_readable($backupConfigFilename)) { $configFile = TestEnv::getConfigFilename(); copy($backupConfigFilename, $configFile); } else { OA::debug("Could not restore config file from backup: {$backupConfigFilename}"); } $newConf = TestEnv::parseConfigFile(); foreach ($newConf as $configGroup => $configGroupSettings) { foreach ($configGroupSettings as $confName => $confValue) { $GLOBALS['_MAX']['CONF'][$configGroup][$confName] = $confValue; } } // Switch off audit $GLOBALS['_MAX']['CONF']['audit']['enabled'] = false; }
/** 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); }