protected function UpgradePathTestBase::setUp

Overrides Drupal\simpletest\WebTestBase::setUp() for upgrade testing.

Overrides WebTestBase::setUp

See also

Drupal\simpletest\WebTestBase::prepareDatabasePrefix()

Drupal\simpletest\WebTestBase::changeDatabasePrefix()

Drupal\simpletest\WebTestBase::prepareEnvironment()

13 calls to UpgradePathTestBase::setUp()
BareMinimalUpgradePathTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php
Overrides Drupal\simpletest\WebTestBase::setUp() for upgrade testing.
BareStandardUpgradePathTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareStandardUpgradePathTest.php
Overrides Drupal\simpletest\WebTestBase::setUp() for upgrade testing.
BlockUpgradePathTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php
Overrides Drupal\simpletest\WebTestBase::setUp() for upgrade testing.
FilledMinimalUpgradePathTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledMinimalUpgradePathTest.php
Overrides Drupal\simpletest\WebTestBase::setUp() for upgrade testing.
FilledStandardUpgradePathTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledStandardUpgradePathTest.php
Overrides Drupal\simpletest\WebTestBase::setUp() for upgrade testing.

... See full list

13 methods override UpgradePathTestBase::setUp()
BareMinimalUpgradePathTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php
Overrides Drupal\simpletest\WebTestBase::setUp() for upgrade testing.
BareStandardUpgradePathTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareStandardUpgradePathTest.php
Overrides Drupal\simpletest\WebTestBase::setUp() for upgrade testing.
BlockUpgradePathTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php
Overrides Drupal\simpletest\WebTestBase::setUp() for upgrade testing.
FilledMinimalUpgradePathTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledMinimalUpgradePathTest.php
Overrides Drupal\simpletest\WebTestBase::setUp() for upgrade testing.
FilledStandardUpgradePathTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledStandardUpgradePathTest.php
Overrides Drupal\simpletest\WebTestBase::setUp() for upgrade testing.

... See full list

File

drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/UpgradePathTestBase.php, line 76
Definition of Drupal\system\Tests\Upgrade\UpgradePathTestBase.

Class

UpgradePathTestBase
Perform end-to-end tests of the upgrade path.

Namespace

Drupal\system\Tests\Upgrade

Code

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;
}