本文整理汇总了PHP中TestRunner::setupEnv方法的典型用法代码示例。如果您正苦于以下问题:PHP TestRunner::setupEnv方法的具体用法?PHP TestRunner::setupEnv怎么用?PHP TestRunner::setupEnv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestRunner
的用法示例。
在下文中一共展示了TestRunner::setupEnv方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restoreEnv
/**
* 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);
}
示例2: testUpgrade
/**
* 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: runFile
/** 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);
}