Fix tests env usage

main
Jordi Boggiano 3 years ago
parent f7e8f7625f
commit a54d16f8a6
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -38,35 +38,11 @@ class AllFunctionalTest extends TestCase
{ {
chdir($this->oldcwd); chdir($this->oldcwd);
$fs = new Filesystem;
if ($this->testDir) { if ($this->testDir) {
$fs = new Filesystem;
$fs->removeDirectory($this->testDir); $fs->removeDirectory($this->testDir);
$this->testDir = null; $this->testDir = null;
} }
if (!is_null($this->oldenv)) {
$fs->removeDirectory(getenv('COMPOSER_HOME'));
if ($this->oldenv === '') {
unset($_SERVER['COMPOSER_HOME']);
putenv('COMPOSER_HOME');
} else {
$_SERVER['COMPOSER_HOME'] = $this->oldenv;
putenv('COMPOSER_HOME='.$_SERVER['COMPOSER_HOME']);
}
$this->oldenv = null;
}
if (!is_null($this->oldenvCache)) {
$fs->removeDirectory(getenv('COMPOSER_CACHE_DIR'));
if ($this->oldenv === '') {
unset($_SERVER['COMPOSER_CACHE_DIR']);
putenv('COMPOSER_CACHE_DIR');
} else {
$_SERVER['COMPOSER_CACHE_DIR'] = $this->oldenvCache;
putenv('COMPOSER_CACHE_DIR='.$_SERVER['COMPOSER_CACHE_DIR']);
}
$this->oldenvCache = null;
}
} }
public static function setUpBeforeClass() public static function setUpBeforeClass()
@ -129,15 +105,13 @@ class AllFunctionalTest extends TestCase
$fs->copy($testFileSetupDir, $this->testDir); $fs->copy($testFileSetupDir, $this->testDir);
} }
$this->oldenv = getenv('COMPOSER_HOME'); $env = array(
$this->oldenvCache = getenv('COMPOSER_CACHE_DIR'); 'COMPOSER_HOME' => $this->testDir.'home',
$_SERVER['COMPOSER_HOME'] = $this->testDir.'home'; 'COMPOSER_CACHE_DIR' => $this->testDir.'cache',
putenv('COMPOSER_HOME='.$_SERVER['COMPOSER_HOME']); );
$_SERVER['COMPOSER_CACHE_DIR'] = $this->testDir.'cache';
putenv('COMPOSER_CACHE_DIR='.$_SERVER['COMPOSER_CACHE_DIR']);
$cmd = 'php '.escapeshellarg(self::$pharPath).' --no-ansi '.$testData['RUN']; $cmd = 'php '.escapeshellarg(self::$pharPath).' --no-ansi '.$testData['RUN'];
$proc = new Process($cmd, $this->testDir, null, null, 300); $proc = new Process($cmd, $this->testDir, $env, null, 300);
$output = ''; $output = '';
$exitcode = $proc->run(function ($type, $buffer) use (&$output) { $exitcode = $proc->run(function ($type, $buffer) use (&$output) {

Loading…
Cancel
Save