Check for boolean false and add tests

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
pull/3966/head
Morris Jobke 9 years ago
parent 0fcb37adcb
commit 95a21e2f2a
No known key found for this signature in database
GPG Key ID: 9CE5ED29E7FCD38A
  1. 2
      lib/private/Config.php
  2. 15
      tests/lib/ConfigTest.php

@ -86,7 +86,7 @@ class Config {
*/
public function getValue($key, $default = null) {
$envValue = getenv(self::ENV_PREFIX . $key);
if ($envValue) {
if ($envValue !== false) {
return $envValue;
}

@ -52,6 +52,21 @@ class ConfigTest extends TestCase {
$this->assertEquals('bar', $this->config->getValue('foo'));
putenv('NC_foo=baz');
$this->assertEquals('baz', $this->config->getValue('foo'));
putenv('NC_foo'); // unset the env variable
}
public function testGetValueReturnsEnvironmentValueIfSetToZero() {
$this->assertEquals('bar', $this->config->getValue('foo'));
putenv('NC_foo=0');
$this->assertEquals('0', $this->config->getValue('foo'));
putenv('NC_foo'); // unset the env variable
}
public function testGetValueReturnsEnvironmentValueIfSetToFalse() {
$this->assertEquals('bar', $this->config->getValue('foo'));
putenv('NC_foo=false');
$this->assertEquals('false', $this->config->getValue('foo'));
putenv('NC_foo'); // unset the env variable
}
public function testSetValue() {

Loading…
Cancel
Save