summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-01-26 13:36:22 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-01-26 13:36:22 +0100
commit5da4071c4553b5ee64799856e4db58e9484d9839 (patch)
treea266d0814d94d572e2a0a0d913ca592ca29e9719 /tests/lib
parent810d5a6a675bed9a6a04bf7995a88021642c36e5 (diff)
parent9ad9d7bfbb85b03bacf0ed1c12d16bae5c8bc6ac (diff)
downloadnextcloud-server-5da4071c4553b5ee64799856e4db58e9484d9839.tar.gz
nextcloud-server-5da4071c4553b5ee64799856e4db58e9484d9839.zip
Merge pull request #13621 from owncloud/system-config-multiset
Add a method to set/unset multiple config values with one write
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/config.php30
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;