diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-03-21 12:46:17 -0600 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-04-04 15:56:50 -0500 |
commit | 95a21e2f2a7515be1d91d3f70db9cf821f872294 (patch) | |
tree | 449418a967ca1f397dad6008ba6164afb7e4e9ac | |
parent | 0fcb37adcb08e8a74d712ff8a6146f91fa14d7a9 (diff) | |
download | nextcloud-server-95a21e2f2a7515be1d91d3f70db9cf821f872294.tar.gz nextcloud-server-95a21e2f2a7515be1d91d3f70db9cf821f872294.zip |
Check for boolean false and add tests
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
-rw-r--r-- | lib/private/Config.php | 2 | ||||
-rw-r--r-- | tests/lib/ConfigTest.php | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/private/Config.php b/lib/private/Config.php index 79742026660..f15854b6113 100644 --- a/lib/private/Config.php +++ b/lib/private/Config.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; } diff --git a/tests/lib/ConfigTest.php b/tests/lib/ConfigTest.php index 418f7de0ae1..2a4c9620340 100644 --- a/tests/lib/ConfigTest.php +++ b/tests/lib/ConfigTest.php @@ -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() { |