Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea16ba2

Browse files
committed
[PHPUnit-Bridge] override some environment variables
1 parent e9c8e19 commit ea16ba2

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ if (PHP_VERSION_ID >= 70200) {
2626
$PHPUNIT_VERSION = '4.8';
2727
}
2828

29-
if ('composer.json' !== $COMPOSER_JSON = getenv('COMPOSER') ?: 'composer.json') {
30-
putenv('COMPOSER=composer.json');
31-
$_SERVER['COMPOSER'] = $_ENV['COMPOSER'] = 'composer.json';
32-
}
29+
$COMPOSER_JSON = getenv('COMPOSER') ?: 'composer.json';
3330

3431
$root = __DIR__;
3532
while (!file_exists($root.'/'.$COMPOSER_JSON) || file_exists($root.'/DeprecationErrorHandler.php')) {
@@ -47,6 +44,19 @@ if ('phpdbg' === PHP_SAPI) {
4744
$PHP .= ' -qrr';
4845
}
4946

47+
$defaultEnvs = [
48+
'COMPOSER' => 'composer.json',
49+
'COMPOSER_VENDOR_DIR' => 'vendor',
50+
'COMPOSER_BIN_DIR' => 'bin',
51+
];
52+
53+
foreach ($defaultEnvs as $envName => $envValue) {
54+
if (getenv($envName)) {
55+
putenv("$envName=$envValue");
56+
$_SERVER[$envName] = $_ENV[$envName] = $envValue;
57+
}
58+
}
59+
5060
$COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar') || ($COMPOSER = rtrim('\\' === DIRECTORY_SEPARATOR ? preg_replace('/[\r\n].*/', '', `where.exe composer.phar`) : `which composer.phar 2> /dev/null`))
5161
? $PHP.' '.escapeshellarg($COMPOSER)
5262
: 'composer';

0 commit comments

Comments
 (0)