og.upgrade.test in Organic groups 7
File
tests/upgrade/og.upgrade.test
View source
<?php
abstract class OgUpgradePathTestCase extends UpgradePathTestCase {
protected function setUp() {
global $user, $language, $conf;
require_once DRUPAL_ROOT . '/includes/update.inc';
$this->upgradedSite = FALSE;
$this->upgradeErrors = array();
$this->loadedModules = module_list();
$this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000);
db_update('simpletest_test_id')
->fields(array(
'last_prefix' => $this->databasePrefix,
))
->condition('test_id', $this->testId)
->execute();
$connection_info = Database::getConnectionInfo('default');
Database::renameConnection('default', 'simpletest_original_default');
foreach ($connection_info as $target => $value) {
$connection_info[$target]['prefix'] = array(
'default' => $value['prefix']['default'] . $this->databasePrefix,
);
}
Database::addConnectionInfo('default', 'default', $connection_info['default']);
$this->originalLanguage = $language;
$this->originalLanguageDefault = variable_get('language_default');
$this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files');
$this->originalProfile = drupal_get_profile();
$clean_url_original = variable_get('clean_url', 0);
$public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10);
$private_files_directory = $public_files_directory . '/private';
$temp_files_directory = $private_files_directory . '/temp';
file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
file_prepare_directory($private_files_directory, FILE_CREATE_DIRECTORY);
file_prepare_directory($temp_files_directory, FILE_CREATE_DIRECTORY);
$this->generatedTestFiles = FALSE;
ini_set('log_errors', 1);
ini_set('error_log', $public_files_directory . '/error.log');
$conf = array();
foreach ($this->databaseDumpFiles as $file) {
require $file;
}
$this
->variable_set('file_public_path', $public_files_directory);
$this
->variable_set('file_private_path', $private_files_directory);
$this
->variable_set('file_temporary_path', $temp_files_directory);
$this
->pass('Finished loading the dump.');
$this->originalUser = $user;
drupal_save_session(FALSE);
$user = db_query('SELECT * FROM {users} WHERE uid = :uid', array(
':uid' => 1,
))
->fetchObject();
$this
->variable_set('clean_url', $clean_url_original);
$this
->variable_set('site_mail', 'simpletest@example.com');
drupal_set_time_limit($this->timeLimit);
}
}