Overrides Drupal\simpletest\WebTestBase::setUp() for upgrade testing.
Overrides WebTestBase::setUp
Drupal\simpletest\WebTestBase::prepareDatabasePrefix()
Drupal\simpletest\WebTestBase::changeDatabasePrefix()
Drupal\simpletest\WebTestBase::prepareEnvironment()
protected function setUp() {
global $user, $conf;
// Load the Update API.
require_once DRUPAL_ROOT . '/core/includes/update.inc';
// Reset flags.
$this->upgradedSite = FALSE;
$this->upgradeErrors = array();
// 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();
drupal_static_reset();
// Change the database prefix.
// All static variables need to be reset before the database prefix is
// changed, since Drupal\Core\Utility\CacheArray 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 may 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.
drupal_save_session(FALSE);
// Login as uid 1.
$user = db_query('SELECT * FROM {users} WHERE uid = :uid', array(
':uid' => 1,
))
->fetchObject();
// Generate and set a D8-compatible session cookie.
$this
->prepareD8Session();
// Restore necessary variables.
$this
->variable_set('site_mail', 'simpletest@example.com');
drupal_set_time_limit($this->timeLimit);
$this
->rebuildContainer();
$this->setup = TRUE;
}