aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/config
diff options
context:
space:
mode:
Diffstat (limited to 'tests/config')
-rw-r--r--tests/config/ConfigJsonTest.php38
-rw-r--r--tests/config/ConfigManagerTest.php6
2 files changed, 26 insertions, 18 deletions
diff --git a/tests/config/ConfigJsonTest.php b/tests/config/ConfigJsonTest.php
index 5b3bce46..0960c729 100644
--- a/tests/config/ConfigJsonTest.php
+++ b/tests/config/ConfigJsonTest.php
@@ -23,9 +23,9 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
23 public function testRead() 23 public function testRead()
24 { 24 {
25 $conf = $this->configIO->read('tests/utils/config/configJson.json.php'); 25 $conf = $this->configIO->read('tests/utils/config/configJson.json.php');
26 $this->assertEquals('root', $conf['login']); 26 $this->assertEquals('root', $conf['credentials']['login']);
27 $this->assertEquals('lala', $conf['redirector']); 27 $this->assertEquals('lala', $conf['extras']['redirector']);
28 $this->assertEquals('data/datastore.php', $conf['config']['DATASTORE']); 28 $this->assertEquals('tests/utils/config/datastore.php', $conf['path']['datastore']);
29 $this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']); 29 $this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']);
30 } 30 }
31 31
@@ -55,10 +55,14 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
55 { 55 {
56 $dataFile = 'tests/utils/config/configWrite.json.php'; 56 $dataFile = 'tests/utils/config/configWrite.json.php';
57 $data = array( 57 $data = array(
58 'login' => 'root', 58 'credentials' => array(
59 'redirector' => 'lala', 59 'login' => 'root',
60 'config' => array( 60 ),
61 'DATASTORE' => 'data/datastore.php', 61 'path' => array(
62 'datastore' => 'data/datastore.php',
63 ),
64 'extras' => array(
65 'redirector' => 'lala',
62 ), 66 ),
63 'plugins' => array( 67 'plugins' => array(
64 'WALLABAG_VERSION' => '1', 68 'WALLABAG_VERSION' => '1',
@@ -68,19 +72,23 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
68 // PHP 5.3 doesn't support json pretty print. 72 // PHP 5.3 doesn't support json pretty print.
69 if (defined('JSON_PRETTY_PRINT')) { 73 if (defined('JSON_PRETTY_PRINT')) {
70 $expected = '{ 74 $expected = '{
71 "login": "root", 75 "credentials": {
72 "redirector": "lala", 76 "login": "root"
73 "config": { 77 },
74 "DATASTORE": "data\/datastore.php" 78 "path": {
79 "datastore": "data\/datastore.php"
80 },
81 "extras": {
82 "redirector": "lala"
75 }, 83 },
76 "plugins": { 84 "plugins": {
77 "WALLABAG_VERSION": "1" 85 "WALLABAG_VERSION": "1"
78 } 86 }
79}'; 87}';
80 } else { 88 } else {
81 $expected = '{"login":"root","redirector":"lala","config":{"DATASTORE":"data\/datastore.php"},"plugins":{"WALLABAG_VERSION":"1"}}'; 89 $expected = '{"credentials":{"login":"root"},"path":{"datastore":"data\/datastore.php"},"extras":{"redirector":"lala"},"plugins":{"WALLABAG_VERSION":"1"}}';
82 } 90 }
83 $expected = ConfigJson::$PHP_HEADER . $expected; 91 $expected = ConfigJson::getPhpHeaders() . $expected;
84 $this->assertEquals($expected, file_get_contents($dataFile)); 92 $this->assertEquals($expected, file_get_contents($dataFile));
85 unlink($dataFile); 93 unlink($dataFile);
86 } 94 }
@@ -94,10 +102,10 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
94 $dest = 'tests/utils/config/configOverwrite.json.php'; 102 $dest = 'tests/utils/config/configOverwrite.json.php';
95 copy($source, $dest); 103 copy($source, $dest);
96 $conf = $this->configIO->read($dest); 104 $conf = $this->configIO->read($dest);
97 $conf['redirector'] = 'blabla'; 105 $conf['extras']['redirector'] = 'blabla';
98 $this->configIO->write($dest, $conf); 106 $this->configIO->write($dest, $conf);
99 $conf = $this->configIO->read($dest); 107 $conf = $this->configIO->read($dest);
100 $this->assertEquals('blabla', $conf['redirector']); 108 $this->assertEquals('blabla', $conf['extras']['redirector']);
101 unlink($dest); 109 unlink($dest);
102 } 110 }
103 111
diff --git a/tests/config/ConfigManagerTest.php b/tests/config/ConfigManagerTest.php
index 7390699c..9ff0f473 100644
--- a/tests/config/ConfigManagerTest.php
+++ b/tests/config/ConfigManagerTest.php
@@ -131,7 +131,7 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase
131 */ 131 */
132 public function testExistsOk() 132 public function testExistsOk()
133 { 133 {
134 $this->assertTrue($this->conf->exists('login')); 134 $this->assertTrue($this->conf->exists('credentials.login'));
135 $this->assertTrue($this->conf->exists('config.foo')); 135 $this->assertTrue($this->conf->exists('config.foo'));
136 } 136 }
137 137
@@ -163,12 +163,12 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase
163 public function testReload() 163 public function testReload()
164 { 164 {
165 ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp'; 165 ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp';
166 $newConf = ConfigJson::$PHP_HEADER . '{ "key": "value" }'; 166 $newConf = ConfigJson::getPhpHeaders() . '{ "key": "value" }';
167 file_put_contents($this->conf->getConfigFile(), $newConf); 167 file_put_contents($this->conf->getConfigFile(), $newConf);
168 $this->conf->reload(); 168 $this->conf->reload();
169 unlink($this->conf->getConfigFile()); 169 unlink($this->conf->getConfigFile());
170 // Previous conf no longer exists, and new values have been loaded. 170 // Previous conf no longer exists, and new values have been loaded.
171 $this->assertFalse($this->conf->exists('login')); 171 $this->assertFalse($this->conf->exists('credentials.login'));
172 $this->assertEquals('value', $this->conf->get('key')); 172 $this->assertEquals('value', $this->conf->get('key'));
173 } 173 }
174} 174}