function Drush_TestCase::setUpDrupal

6.x drush_testcase.inc Drush_TestCase::setUpDrupal($num_sites = 1, $install = FALSE, $version_string = UNISH_DRUPAL_MAJOR_VERSION, $profile = NULL)
4.x drush_testcase.inc Drush_TestCase::setUpDrupal($env = 'dev', $install = FALSE, $version_string = '7.x', $profile = NULL)
5.x drush_testcase.inc Drush_TestCase::setUpDrupal($num_sites = 1, $install = FALSE, $version_string = UNISH_DRUPAL_MAJOR_VERSION, $profile = NULL)
25 calls to Drush_TestCase::setUpDrupal()
batchCase::testBatch in tests/batchTest.php
cacheCommandCase::testCacheGetSetClear in tests/cacheCommandTest.php
commandCase::testDisabledModule in tests/commandTest.php
Assert that commands in disabled modules are detected.
completeCase::testComplete in tests/completeTest.php
contextCase::setUp in tests/contextTest.php
Try to write a tiny drushrc.php to each place that drush checks. Also write a sites/dev/aliases.drushrc.php file to the sandbox.

... See full list

File

tests/drush_testcase.inc, line 219

Class

Drush_TestCase

Code

function setUpDrupal($num_sites = 1, $install = FALSE, $version_string = UNISH_DRUPAL_MAJOR_VERSION, $profile = NULL) {
  $sites_subdirs_all = array(
    'dev',
    'stage',
    'prod',
    'retired',
    'elderly',
    'dead',
    'dust',
  );
  $sites_subdirs = array_slice($sites_subdirs_all, 0, $num_sites);
  $root = $this->webroot();

  if (is_null($profile)) {
    $profile = substr($version_string, 0, 1) >= 7 ? 'testing' : 'default';
  }
  $db_driver = parse_url(UNISH_DB_URL, PHP_URL_SCHEME);
  $cache_keys = array(
    $num_sites,
    $install ? 'install' : 'noinstall',
    $version_string,
    $profile,
    $db_driver,
  );
  $source = $this->directory_cache('environments') . '/' . implode('-', $cache_keys) . '.tar.gz';
  if (file_exists($source)) {
    $this->log('Cache HIT. Environment: ' . $source, 'verbose');
    $this->drush('archive-restore', array($source), array('destination' => $root, 'overwrite' => NULL));
  }
  else {
    $this->log('Cache MISS. Environment: ' . $source, 'verbose');
    // Build the site(s), install (if needed), then cache.
    foreach ($sites_subdirs as $subdir) {
      $this->fetchInstallDrupal($subdir, $install, $version_string, $profile);
    }
    $options = array(
      'destination' => $source,
      'root' => $root,
      'uri' => reset($sites_subdirs),
      'overwrite' => NULL,
    );
    $this->drush('archive-dump', array('@sites'), $options);
  }

  // Stash details about each site.
  foreach ($sites_subdirs as $subdir) {
    $this->sites[$subdir] = array(
      'db_url' => $this->db_url($subdir),
    );
    // Make an alias for the site
    $alias_definition = array($subdir => array(
      'root' => $root,
      'uri' => $subdir,
    ));
    file_put_contents(UNISH_SANDBOX . '/etc/drush/' . $subdir . '.alias.drushrc.php', $this->file_aliases($alias_definition));
  }
  return $this->sites;
}