public static function UnishTestCase::setUpFreshSandBox

8.0.x UnishTestCase.php public static UnishTestCase::setUpFreshSandBox()
7.x UnishTestCase.php public static UnishTestCase::setUpFreshSandBox()
master UnishTestCase.php public static UnishTestCase::setUpFreshSandBox()

Remove any pre-existing sandbox, then create a new one.

1 call to UnishTestCase::setUpFreshSandBox()
UnishTestCase::setUpBeforeClass in tests/Unish/UnishTestCase.php
Assure that each class starts with an empty sandbox directory and a clean environment - http://drupal.org/node/1103568.

File

tests/Unish/UnishTestCase.php, line 30

Namespace

Unish

Class

UnishTestCase

Code

public static function setUpFreshSandBox() {
  $sandbox = UNISH_SANDBOX;
  if (file_exists($sandbox)) {
    unish_file_delete_recursive($sandbox);
  }
  $ret = mkdir($sandbox, 0777, TRUE);
  chdir(UNISH_SANDBOX);

  mkdir(getenv('HOME') . '/.drush', 0777, TRUE);
  mkdir($sandbox . '/etc/drush', 0777, TRUE);
  mkdir($sandbox . '/share/drush/commands', 0777, TRUE);

  if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    // Hack to make git use unix line endings on windows
    // We need it to make hashes of files pulled from git match ones hardcoded in tests
    if (!file_exists($sandbox . '\home')) {
      mkdir($sandbox . '\home');
    }
    exec("git config --file $sandbox\\home\\.gitconfig core.autocrlf false", $output, $return);
  }
}