diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-02 17:24:45 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-02 17:24:45 +0200 |
commit | 9315f0c6de183eeeef620d21cab393f88b8fce5e (patch) | |
tree | 4ff30b4b3c6c42e8a984382f6a2be4166708b0c4 | |
parent | d4a2bb9d15bfeabf3473d5c3325a7aea6fb4be5b (diff) |
typecast config values to default values of config object
-rw-r--r-- | tests/unit/utility/ConfigTest.php | 17 | ||||
-rw-r--r-- | utility/config.php | 2 |
2 files changed, 17 insertions, 2 deletions
diff --git a/tests/unit/utility/ConfigTest.php b/tests/unit/utility/ConfigTest.php index 455abf810..479acabb5 100644 --- a/tests/unit/utility/ConfigTest.php +++ b/tests/unit/utility/ConfigTest.php @@ -66,8 +66,21 @@ class ConfigFetcherTest extends \OCA\AppFramework\Utility\TestUtility { $this->config->read($this->configPath); - $this->assertEquals(3, $this->config->getAutoPurgeCount()); - $this->assertEquals(true, $this->config->getUseCronUpdates()); + $this->assertTrue(3 === $this->config->getAutoPurgeCount()); + $this->assertTrue(true === $this->config->getUseCronUpdates()); + } + + + public function testReadBool () { + $this->fileSystem->expects($this->once()) + ->method('file_get_contents') + ->with($this->equalTo($this->configPath)) + ->will($this->returnValue("autoPurgeCount = 3\nuseCronUpdates = false")); + + $this->config->read($this->configPath); + + $this->assertTrue(3 === $this->config->getAutoPurgeCount()); + $this->assertTrue(false === $this->config->getUseCronUpdates()); } diff --git a/utility/config.php b/utility/config.php index 7841b3f5f..54145c993 100644 --- a/utility/config.php +++ b/utility/config.php @@ -119,6 +119,8 @@ class Config { foreach($configValues as $key => $value) { if(property_exists($this, $key)) { + $type = gettype($this->$key); + settype($value, $type); $this->$key = $value; } else { $this->api->log('Configuration value "' . $key . |