diff --git a/src/Phing/Task/System/PropertyTask.php b/src/Phing/Task/System/PropertyTask.php index 97574c1af..51dfb7870 100644 --- a/src/Phing/Task/System/PropertyTask.php +++ b/src/Phing/Task/System/PropertyTask.php @@ -412,7 +412,7 @@ protected function loadEnvironment(string $prefix) $prefix .= '.'; } $this->log("Loading Environment {$prefix}", Project::MSG_VERBOSE); - foreach ($_ENV as $key => $value) { + foreach (getenv() as $key => $value) { $props->setProperty($prefix . '.' . $key, $value); } $this->addProperties($props); diff --git a/tests/Phing/Test/Task/System/PropertyTaskTest.php b/tests/Phing/Test/Task/System/PropertyTaskTest.php index 3b924e54b..e7c1affef 100644 --- a/tests/Phing/Test/Task/System/PropertyTaskTest.php +++ b/tests/Phing/Test/Task/System/PropertyTaskTest.php @@ -38,8 +38,9 @@ public function setUp(): void public function test1(): void { - // should get no output at all - $this->expectOutputAndError('test1', '', ''); + putenv('MESSAGE=foo bar baz'); + $this->executeTarget(__FUNCTION__); + $this->assertPropertyEquals('testenv.MESSAGE', 'foo bar baz'); } public function test2(): void