function unish_init

8.0.x bootstrap.inc unish_init()
6.x drush_testcase.inc unish_init()
7.x bootstrap.inc unish_init()
4.x drush_testcase.inc unish_init()
5.x drush_testcase.inc unish_init()
master bootstrap.inc unish_init()

File

tests/drush_testcase.inc, line 291

Code

function unish_init() {
  // We read from globals here because env can be empty and ini did not work in quick test.
  define('UNISH_DB_URL', getenv('UNISH_DB_URL') ? getenv('UNISH_DB_URL') : !empty($GLOBALS['UNISH_DB_URL']) ? $GLOBALS['UNISH_DB_URL'] : 'mysql://root:@127.0.0.1');

  // UNISH_DRUSH value can come from phpunit.xml or `which drush`.
  if (!defined('UNISH_DRUSH')) {
    // Let the UNISH_DRUSH environment variable override if set.
    $unish_drush = isset($_SERVER['UNISH_DRUSH']) ? $_SERVER['UNISH_DRUSH'] : NULL;
    $unish_drush = isset($GLOBALS['UNISH_DRUSH']) ? $GLOBALS['UNISH_DRUSH'] : $unish_drush;
    if (empty($unish_drush)) {
      $unish_drush = Drush_TestCase::is_windows() ? exec('for %i in (drush) do @echo.   %~$PATH:i') : trim();
    }
    define('UNISH_DRUSH', $unish_drush);
  }

  define('UNISH_TMP', getenv('UNISH_TMP') ? getenv('UNISH_TMP') : (isset($GLOBALS['UNISH_TMP']) ? $GLOBALS['UNISH_TMP'] : sys_get_temp_dir()));
  define('UNISH_SANDBOX', UNISH_TMP . '/drush-sandbox');

  $home = UNISH_SANDBOX . '/home';
  putenv("HOME=$home");
  putenv("HOMEDRIVE=$home");

  putenv('ETC_PREFIX=' . UNISH_SANDBOX);
  putenv('SHARE_PREFIX=' . UNISH_SANDBOX);

  // Cache dir lives outside the sandbox so that we get persistence across classes.
  $cache = UNISH_TMP . '/drush_cache';
  putenv("CACHE_PREFIX=" . $cache);
  // Wipe at beginning of run.
  if (file_exists($cache)) {
    unish_file_delete_recursive($cache);
  }
}