diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2015-01-23 10:50:25 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2015-01-23 11:00:53 +0100 |
commit | c61e9f391273e5f7f4b7aa91ee4174d47402cae9 (patch) | |
tree | 1993ccdd315b3ea8d14123ee3514fde2b8707d4f /tests | |
parent | bc93a8f14094dfb59c826ffa76d7b046370b0410 (diff) | |
download | nextcloud-server-c61e9f391273e5f7f4b7aa91ee4174d47402cae9.tar.gz nextcloud-server-c61e9f391273e5f7f4b7aa91ee4174d47402cae9.zip |
Add a method to set/unset multiple config values in one call
This reduces the number of file writes we do for config.php and therefor
hopefully helps lowering the chances for empty config.php files
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/config.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/lib/config.php b/tests/lib/config.php index 6adba356a1c..91154579ab5 100644 --- a/tests/lib/config.php +++ b/tests/lib/config.php @@ -71,6 +71,36 @@ class Test_Config extends \Test\TestCase { $this->assertEquals($expected, $content); } + public function testSetValues() { + $content = file_get_contents($this->configFile); + $this->assertEquals(self::TESTCONTENT, $content); + + // Changing configs to existing values and deleting non-existing once + // should not rewrite the config.php + $this->config->setValues([ + 'foo' => 'bar', + 'not_exists' => null, + ]); + + $this->assertAttributeEquals($this->initialConfig, 'cache', $this->config); + $content = file_get_contents($this->configFile); + $this->assertEquals(self::TESTCONTENT, $content); + + $this->config->setValues([ + 'foo' => 'moo', + 'alcohol_free' => null, + ]); + $expectedConfig = $this->initialConfig; + $expectedConfig['foo'] = 'moo'; + unset($expectedConfig['alcohol_free']); + $this->assertAttributeEquals($expectedConfig, 'cache', $this->config); + + $content = file_get_contents($this->configFile); + $expected = "<?php\n\$CONFIG = array (\n 'foo' => 'moo',\n 'beers' => \n array (\n 0 => 'Appenzeller',\n " . + " 1 => 'Guinness',\n 2 => 'Kölsch',\n ),\n);\n"; + $this->assertEquals($expected, $content); + } + public function testDeleteKey() { $this->config->deleteKey('foo'); $expectedConfig = $this->initialConfig; |