From d0dd8ce9d5ab922d80d7e3a758601ae587533bdc Mon Sep 17 00:00:00 2001 From: Nicole Cordes Date: Mon, 18 Jun 2018 18:20:58 +0200 Subject: [PATCH] Ensure environment values are stored in $_ENV in \PHPUnit\Util\Configuration --- src/Util/Configuration.php | 2 ++ tests/Util/ConfigurationTest.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Util/Configuration.php b/src/Util/Configuration.php index 2137f269fac..2dd07d346e1 100644 --- a/src/Util/Configuration.php +++ b/src/Util/Configuration.php @@ -568,6 +568,8 @@ public function handlePHPConfiguration() \putenv("{$name}={$value}"); } + $value = \getenv($name); + if (!isset($_ENV[$name])) { $_ENV[$name] = $value; } diff --git a/tests/Util/ConfigurationTest.php b/tests/Util/ConfigurationTest.php index 8500946fcb3..ed6d62c26c4 100644 --- a/tests/Util/ConfigurationTest.php +++ b/tests/Util/ConfigurationTest.php @@ -263,7 +263,7 @@ public function testPHPConfigurationIsHandledCorrectly() $this->assertFalse(\FOO); $this->assertTrue(\BAR); $this->assertFalse($GLOBALS['foo']); - $this->assertTrue($_ENV['foo']); + $this->assertTrue((bool) $_ENV['foo']); $this->assertEquals(1, \getenv('foo')); $this->assertEquals('bar', $_POST['foo']); $this->assertEquals('bar', $_GET['foo']); @@ -311,7 +311,7 @@ public function testHandlePHPConfigurationDoesNotOverriteVariablesFromPutEnv() \putenv('foo=putenv'); $this->configuration->handlePHPConfiguration(); - $this->assertTrue($_ENV['foo']); + $this->assertEquals('putenv', $_ENV['foo']); $this->assertEquals('putenv', \getenv('foo')); }