1 upgrade.test | protected UpgradePathTestCase::setUp() |
Overrides BackdropWebTestCase::setUp() for upgrade testing.
Overrides BackdropWebTestCase::setUp
See also
BackdropWebTestCase::prepareDatabasePrefix()
BackdropWebTestCase::changeDatabasePrefix()
BackdropWebTestCase::prepareEnvironment()
File
- core/
modules/ simpletest/ tests/ upgrade/ upgrade.test, line 48
Class
- UpgradePathTestCase
- Perform end-to-end tests of the upgrade path.
Code
protected function setUp() {
global $user, $language, $conf;
// Load the Update API.
require_once BACKDROP_ROOT . '/core/includes/update.inc';
// Reset flags.
$this->upgradedSite = FALSE;
$this->upgradeErrors = array();
$this->loadedModules = module_list();
// Create the database prefix for this test.
$this->prepareDatabasePrefix();
// Prepare the environment for running tests.
$this->prepareEnvironment();
if (!$this->setupEnvironment) {
return FALSE;
}
// Reset all statics and variables to perform tests in a clean environment.
$conf = array();
backdrop_static_reset();
// Change the database prefix.
// All static variables need to be reset before the database prefix is
// changed, since BackdropCacheArray implementations attempt to
// write back to persistent caches when they are destructed.
$this->changeDatabasePrefix();
if (!$this->setupDatabasePrefix) {
return FALSE;
}
// Load the database from the portable PHP dump.
// The files can be gzipped.
foreach ($this->databaseDumpFiles as $file) {
if (substr($file, -3) == '.gz') {
$file = "compress.zlib://$file";
}
require $file;
}
// Set path variables.
$this->variable_set('file_public_path', $this->public_files_directory);
$this->variable_set('file_private_path', $this->private_files_directory);
$this->variable_set('file_temporary_path', $this->temp_files_directory);
$this->pass('Finished loading the dump.');
// Ensure that the session is not written to the new environment and replace
// the global $user session with uid 1 from the new test site.
backdrop_save_session(FALSE);
// Login as uid 1.
$user = db_query('SELECT * FROM {users} WHERE uid = :uid', array(':uid' => 1))->fetchObject();
// Generate and set a session cookie.
$this->curlInitialize();
$sid = backdrop_hash_base64(uniqid(mt_rand(), TRUE) . backdrop_random_bytes(55));
curl_setopt($this->curlHandle, CURLOPT_COOKIE, rawurlencode(session_name()) . '=' . rawurlencode($sid));
// Force our way into the session of the child site.
backdrop_save_session(TRUE);
_backdrop_session_write($sid, '');
// Remove the temporarily added ssid column.
backdrop_save_session(FALSE);
// Restore necessary variables.
$this->variable_set('clean_url', $this->originalCleanUrl);
$this->variable_set('site_mail', 'simpletest@example.com');
backdrop_set_time_limit($this->timeLimit);
$this->setup = TRUE;
}