diff --git a/src/Ease/Functions.php b/src/Ease/Functions.php index 11ee95f..b4e23e8 100644 --- a/src/Ease/Functions.php +++ b/src/Ease/Functions.php @@ -505,6 +505,8 @@ public static function cfg(/*string*/ $constant, $cfg = null) { if (!empty($constant) && defined($constant)) { $cfg = constant($constant); } elseif (array_key_exists($constant, $_ENV)) { + $cfg = getenv($constant,true); + } elseif (($env = getenv($constant)) && !empty($env)) { $cfg = getenv($constant); } return $cfg; diff --git a/tests/src/Ease/FunctionsTest.php b/tests/src/Ease/FunctionsTest.php index e239b81..22111d8 100644 --- a/tests/src/Ease/FunctionsTest.php +++ b/tests/src/Ease/FunctionsTest.php @@ -267,13 +267,11 @@ public function testFormatBytes() */ public function testCfg() { - $this->assertEquals('x', Functions::cfg('EASE_TEST', 'x')); + $this->assertEquals('x', Functions::cfg('EASE_TEST', 'x'),'default value not used'); putenv('EASE_TEST=a'); - $this->assertEquals('a', Functions::cfg('EASE_TEST')); + $this->assertEquals('a', Functions::cfg('EASE_TEST'),'unexepected environment value'); define('EASE_TEST', 'b'); $this->assertEquals('b', Functions::cfg('EASE_TEST')); - $_ENV['tst'] = 'ok'; - $this->assertEquals('ok', Functions::cfg('tst')); } /**