You are here

protected function DrupalWebTestCase::setUpInstall in SimpleTest 7.2

Perform Drupal installation.

1 call to DrupalWebTestCase::setUpInstall()
DrupalWebTestCase::setUp in ./drupal_web_test_case.php
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…
1 method overrides DrupalWebTestCase::setUpInstall()
DrupalCloneTestCase::setUpInstall in ./drupal_web_test_case.php
Perform Drupal installation.

File

./drupal_web_test_case.php, line 1338
Provides DrupalTestCase, DrupalUnitTestCase, and DrupalWebTestCase classes.

Class

DrupalWebTestCase
Test case for typical Drupal tests.

Code

protected function setUpInstall(array $modules, $public_files_directory, $private_files_directory, $temp_files_directory) {
  global $user;
  include_once DRUPAL_ROOT . '/includes/install.inc';
  drupal_install_system();
  $this
    ->preloadRegistry();

  // Set path variables.
  variable_set('file_public_path', $public_files_directory);
  variable_set('file_private_path', $private_files_directory);
  variable_set('file_temporary_path', $temp_files_directory);

  // Include the testing profile.
  variable_set('install_profile', $this->profile);
  $profile_details = install_profile_info($this->profile, 'en');

  // Install the modules specified by the testing profile.
  module_enable($profile_details['dependencies'], FALSE);

  // Install modules needed for this test. This could have been passed in as
  // either a single array argument or a variable number of string arguments.
  // @todo Remove this compatibility layer in Drupal 8, and only accept
  // $modules as a single array argument.
  if (isset($modules[0]) && is_array($modules[0])) {
    $modules = $modules[0];
  }
  if ($modules) {
    module_enable($modules, TRUE);
  }

  // Run the profile tasks.
  $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array(
    ':name' => $this->profile,
  ))
    ->fetchField();
  if ($install_profile_module_exists) {
    module_enable(array(
      $this->profile,
    ), FALSE);
  }

  // Reset/rebuild all data structures after enabling the modules.
  $this
    ->resetAll();

  // Run cron once in that environment, as install.php does at the end of
  // the installation process.
  drupal_cron_run();

  // Log in with a clean $user.
  $this->originalUser = $user;
  drupal_save_session(FALSE);
  $user = user_load(1);
}