[PhpunitBridge] Read environment variable from superglobals
The Dotenv component has recently been switched to using superglobals instead of putenv(). Let us support both and give priority to superglobals. Closes #31857
This commit is contained in:
parent
2b8e44164e
commit
88cfcb536d
@ -216,7 +216,13 @@ class DeprecationErrorHandler
|
|||||||
return $this->configuration;
|
return $this->configuration;
|
||||||
}
|
}
|
||||||
if (false === $mode = $this->mode) {
|
if (false === $mode = $this->mode) {
|
||||||
$mode = getenv('SYMFONY_DEPRECATIONS_HELPER');
|
if (isset($_SERVER['SYMFONY_DEPRECATIONS_HELPER'])) {
|
||||||
|
$mode = $_SERVER['SYMFONY_DEPRECATIONS_HELPER'];
|
||||||
|
} elseif (isset($_ENV['SYMFONY_DEPRECATIONS_HELPER'])) {
|
||||||
|
$mode = $_ENV['SYMFONY_DEPRECATIONS_HELPER'];
|
||||||
|
} else {
|
||||||
|
$mode = getenv('SYMFONY_DEPRECATIONS_HELPER');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ('strict' === $mode) {
|
if ('strict' === $mode) {
|
||||||
return $this->configuration = Configuration::inStrictMode();
|
return $this->configuration = Configuration::inStrictMode();
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
--TEST--
|
--TEST--
|
||||||
Test DeprecationErrorHandler in weak mode
|
Test DeprecationErrorHandler in disabled mode
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
putenv('SYMFONY_DEPRECATIONS_HELPER=disabled');
|
$_SERVER['SYMFONY_DEPRECATIONS_HELPER'] = 'disabled';
|
||||||
putenv('ANSICON');
|
putenv('ANSICON');
|
||||||
putenv('ConEmuANSI');
|
putenv('ConEmuANSI');
|
||||||
putenv('TERM');
|
putenv('TERM');
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
--TEST--
|
||||||
|
Test DeprecationErrorHandler in disabled mode (via putenv)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$_ENV['SYMFONY_DEPRECATIONS_HELPER'] = 'disabled';
|
||||||
|
putenv('ANSICON');
|
||||||
|
putenv('ConEmuANSI');
|
||||||
|
putenv('TERM');
|
||||||
|
|
||||||
|
$vendor = __DIR__;
|
||||||
|
while (!file_exists($vendor.'/vendor')) {
|
||||||
|
$vendor = dirname($vendor);
|
||||||
|
}
|
||||||
|
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
|
||||||
|
require PHPUNIT_COMPOSER_INSTALL;
|
||||||
|
require_once __DIR__.'/../../bootstrap.php';
|
||||||
|
|
||||||
|
echo (int) set_error_handler('var_dump');
|
||||||
|
echo (int) class_exists('Symfony\Bridge\PhpUnit\DeprecationErrorHandler', false);
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
00
|
@ -0,0 +1,24 @@
|
|||||||
|
--TEST--
|
||||||
|
Test DeprecationErrorHandler in disabled mode (via putenv)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
putenv('SYMFONY_DEPRECATIONS_HELPER=disabled');
|
||||||
|
putenv('ANSICON');
|
||||||
|
putenv('ConEmuANSI');
|
||||||
|
putenv('TERM');
|
||||||
|
|
||||||
|
$vendor = __DIR__;
|
||||||
|
while (!file_exists($vendor.'/vendor')) {
|
||||||
|
$vendor = dirname($vendor);
|
||||||
|
}
|
||||||
|
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
|
||||||
|
require PHPUNIT_COMPOSER_INSTALL;
|
||||||
|
require_once __DIR__.'/../../bootstrap.php';
|
||||||
|
|
||||||
|
echo (int) set_error_handler('var_dump');
|
||||||
|
echo (int) class_exists('Symfony\Bridge\PhpUnit\DeprecationErrorHandler', false);
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
00
|
Reference in New Issue
Block a user