Skip to content

Commit

Permalink
Local & Global environment fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Aug 21, 2023
1 parent 6e442a0 commit 799b8aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/Ease/Functions.php
Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions tests/src/Ease/FunctionsTest.php
Expand Up @@ -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'));
}

/**
Expand Down

0 comments on commit 799b8aa

Please sign in to comment.