From 88cfcb536d9b30e751ee8cdd4c71b5265ef8a7ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 8 Jun 2019 12:20:20 +0200 Subject: [PATCH] [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 --- .../PhpUnit/DeprecationErrorHandler.php | 8 ++++++- .../DeprecationErrorHandler/disabled.phpt | 4 ++-- .../disabled_from_env_superglobal.phpt | 24 +++++++++++++++++++ .../disabled_from_putenv.phpt | 24 +++++++++++++++++++ 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/disabled_from_env_superglobal.phpt create mode 100644 src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/disabled_from_putenv.phpt diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 55089e0be1..b259337ee1 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -216,7 +216,13 @@ class DeprecationErrorHandler return $this->configuration; } 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) { return $this->configuration = Configuration::inStrictMode(); diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/disabled.phpt b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/disabled.phpt index 0115bbd242..a55e88d1a8 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/disabled.phpt +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/disabled.phpt @@ -1,9 +1,9 @@ --TEST-- -Test DeprecationErrorHandler in weak mode +Test DeprecationErrorHandler in disabled mode --FILE-- +--EXPECTF-- +00 diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/disabled_from_putenv.phpt b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/disabled_from_putenv.phpt new file mode 100644 index 0000000000..73a67241a4 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/disabled_from_putenv.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test DeprecationErrorHandler in disabled mode (via putenv) +--FILE-- + +--EXPECTF-- +00