aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ApplicationUtilsTest.php40
-rw-r--r--tests/Updater/UpdaterTest.php12
-rw-r--r--tests/config/ConfigJsonTest.php22
-rw-r--r--tests/utils/config/configJson.json.php10
4 files changed, 43 insertions, 41 deletions
diff --git a/tests/ApplicationUtilsTest.php b/tests/ApplicationUtilsTest.php
index 3da72639..c37a94f0 100644
--- a/tests/ApplicationUtilsTest.php
+++ b/tests/ApplicationUtilsTest.php
@@ -277,16 +277,16 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase
277 public function testCheckCurrentResourcePermissions() 277 public function testCheckCurrentResourcePermissions()
278 { 278 {
279 $conf = new ConfigManager(''); 279 $conf = new ConfigManager('');
280 $conf->set('path.thumbnails_cache', 'cache'); 280 $conf->set('resource.thumbnails_cache', 'cache');
281 $conf->set('path.config', 'data/config.php'); 281 $conf->set('resource.config', 'data/config.php');
282 $conf->set('path.data_dir', 'data'); 282 $conf->set('resource.data_dir', 'data');
283 $conf->set('path.datastore', 'data/datastore.php'); 283 $conf->set('resource.datastore', 'data/datastore.php');
284 $conf->set('path.ban_file', 'data/ipbans.php'); 284 $conf->set('resource.ban_file', 'data/ipbans.php');
285 $conf->set('path.log', 'data/log.txt'); 285 $conf->set('resource.log', 'data/log.txt');
286 $conf->set('path.page_cache', 'pagecache'); 286 $conf->set('resource.page_cache', 'pagecache');
287 $conf->set('path.raintpl_tmp', 'tmp'); 287 $conf->set('resource.raintpl_tmp', 'tmp');
288 $conf->set('path.raintpl_tpl', 'tpl'); 288 $conf->set('resource.raintpl_tpl', 'tpl');
289 $conf->set('path.update_check', 'data/lastupdatecheck.txt'); 289 $conf->set('resource.update_check', 'data/lastupdatecheck.txt');
290 290
291 $this->assertEquals( 291 $this->assertEquals(
292 array(), 292 array(),
@@ -300,16 +300,16 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase
300 public function testCheckCurrentResourcePermissionsErrors() 300 public function testCheckCurrentResourcePermissionsErrors()
301 { 301 {
302 $conf = new ConfigManager(''); 302 $conf = new ConfigManager('');
303 $conf->set('path.thumbnails_cache', 'null/cache'); 303 $conf->set('resource.thumbnails_cache', 'null/cache');
304 $conf->set('path.config', 'null/data/config.php'); 304 $conf->set('resource.config', 'null/data/config.php');
305 $conf->set('path.data_dir', 'null/data'); 305 $conf->set('resource.data_dir', 'null/data');
306 $conf->set('path.datastore', 'null/data/store.php'); 306 $conf->set('resource.datastore', 'null/data/store.php');
307 $conf->set('path.ban_file', 'null/data/ipbans.php'); 307 $conf->set('resource.ban_file', 'null/data/ipbans.php');
308 $conf->set('path.log', 'null/data/log.txt'); 308 $conf->set('resource.log', 'null/data/log.txt');
309 $conf->set('path.page_cache', 'null/pagecache'); 309 $conf->set('resource.page_cache', 'null/pagecache');
310 $conf->set('path.raintpl_tmp', 'null/tmp'); 310 $conf->set('resource.raintpl_tmp', 'null/tmp');
311 $conf->set('path.raintpl_tpl', 'null/tpl'); 311 $conf->set('resource.raintpl_tpl', 'null/tpl');
312 $conf->set('path.update_check', 'null/data/lastupdatecheck.txt'); 312 $conf->set('resource.update_check', 'null/data/lastupdatecheck.txt');
313 $this->assertEquals( 313 $this->assertEquals(
314 array( 314 array(
315 '"null/tpl" directory is not readable', 315 '"null/tpl" directory is not readable',
diff --git a/tests/Updater/UpdaterTest.php b/tests/Updater/UpdaterTest.php
index 5ed2df6c..6bdce08b 100644
--- a/tests/Updater/UpdaterTest.php
+++ b/tests/Updater/UpdaterTest.php
@@ -38,7 +38,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
38 public function testReadEmptyUpdatesFile() 38 public function testReadEmptyUpdatesFile()
39 { 39 {
40 $this->assertEquals(array(), read_updates_file('')); 40 $this->assertEquals(array(), read_updates_file(''));
41 $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt'; 41 $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
42 touch($updatesFile); 42 touch($updatesFile);
43 $this->assertEquals(array(), read_updates_file($updatesFile)); 43 $this->assertEquals(array(), read_updates_file($updatesFile));
44 unlink($updatesFile); 44 unlink($updatesFile);
@@ -49,7 +49,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
49 */ 49 */
50 public function testReadWriteUpdatesFile() 50 public function testReadWriteUpdatesFile()
51 { 51 {
52 $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt'; 52 $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
53 $updatesMethods = array('m1', 'm2', 'm3'); 53 $updatesMethods = array('m1', 'm2', 'm3');
54 54
55 write_updates_file($updatesFile, $updatesMethods); 55 write_updates_file($updatesFile, $updatesMethods);
@@ -83,7 +83,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase
83 */ 83 */
84 public function testWriteUpdatesFileNotWritable() 84 public function testWriteUpdatesFileNotWritable()
85 { 85 {
86 $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt'; 86 $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt';
87 touch($updatesFile); 87 touch($updatesFile);
88 chmod($updatesFile, 0444); 88 chmod($updatesFile, 0444);
89 try { 89 try {
@@ -189,7 +189,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
189 189
190 // make sure updated field is changed 190 // make sure updated field is changed
191 $this->conf->reload(); 191 $this->conf->reload();
192 $this->assertTrue($this->conf->get('general.default_private_links')); 192 $this->assertTrue($this->conf->get('privacy.default_private_links'));
193 $this->assertFalse(is_file($optionsFile)); 193 $this->assertFalse(is_file($optionsFile));
194 // Delete the generated file. 194 // Delete the generated file.
195 unlink($this->conf->getConfigFileExt()); 195 unlink($this->conf->getConfigFileExt());
@@ -243,8 +243,8 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
243 // Check JSON config data. 243 // Check JSON config data.
244 $this->conf->reload(); 244 $this->conf->reload();
245 $this->assertEquals('root', $this->conf->get('credentials.login')); 245 $this->assertEquals('root', $this->conf->get('credentials.login'));
246 $this->assertEquals('lala', $this->conf->get('extras.redirector')); 246 $this->assertEquals('lala', $this->conf->get('redirector.url'));
247 $this->assertEquals('data/datastore.php', $this->conf->get('path.datastore')); 247 $this->assertEquals('data/datastore.php', $this->conf->get('resource.datastore'));
248 $this->assertEquals('1', $this->conf->get('plugins.WALLABAG_VERSION')); 248 $this->assertEquals('1', $this->conf->get('plugins.WALLABAG_VERSION'));
249 249
250 rename($configFile . '.save.php', $configFile . '.php'); 250 rename($configFile . '.save.php', $configFile . '.php');
diff --git a/tests/config/ConfigJsonTest.php b/tests/config/ConfigJsonTest.php
index 0960c729..359e9112 100644
--- a/tests/config/ConfigJsonTest.php
+++ b/tests/config/ConfigJsonTest.php
@@ -24,8 +24,8 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
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['credentials']['login']); 26 $this->assertEquals('root', $conf['credentials']['login']);
27 $this->assertEquals('lala', $conf['extras']['redirector']); 27 $this->assertEquals('lala', $conf['redirector']['url']);
28 $this->assertEquals('tests/utils/config/datastore.php', $conf['path']['datastore']); 28 $this->assertEquals('tests/utils/config/datastore.php', $conf['resource']['datastore']);
29 $this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']); 29 $this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']);
30 } 30 }
31 31
@@ -58,11 +58,11 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
58 'credentials' => array( 58 'credentials' => array(
59 'login' => 'root', 59 'login' => 'root',
60 ), 60 ),
61 'path' => array( 61 'resource' => array(
62 'datastore' => 'data/datastore.php', 62 'datastore' => 'data/datastore.php',
63 ), 63 ),
64 'extras' => array( 64 'redirector' => array(
65 'redirector' => 'lala', 65 'url' => 'lala',
66 ), 66 ),
67 'plugins' => array( 67 'plugins' => array(
68 'WALLABAG_VERSION' => '1', 68 'WALLABAG_VERSION' => '1',
@@ -75,18 +75,18 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
75 "credentials": { 75 "credentials": {
76 "login": "root" 76 "login": "root"
77 }, 77 },
78 "path": { 78 "resource": {
79 "datastore": "data\/datastore.php" 79 "datastore": "data\/datastore.php"
80 }, 80 },
81 "extras": { 81 "redirector": {
82 "redirector": "lala" 82 "url": "lala"
83 }, 83 },
84 "plugins": { 84 "plugins": {
85 "WALLABAG_VERSION": "1" 85 "WALLABAG_VERSION": "1"
86 } 86 }
87}'; 87}';
88 } else { 88 } else {
89 $expected = '{"credentials":{"login":"root"},"path":{"datastore":"data\/datastore.php"},"extras":{"redirector":"lala"},"plugins":{"WALLABAG_VERSION":"1"}}'; 89 $expected = '{"credentials":{"login":"root"},"resource":{"datastore":"data\/datastore.php"},"redirector":{"url":"lala"},"plugins":{"WALLABAG_VERSION":"1"}}';
90 } 90 }
91 $expected = ConfigJson::getPhpHeaders() . $expected; 91 $expected = ConfigJson::getPhpHeaders() . $expected;
92 $this->assertEquals($expected, file_get_contents($dataFile)); 92 $this->assertEquals($expected, file_get_contents($dataFile));
@@ -102,10 +102,10 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
102 $dest = 'tests/utils/config/configOverwrite.json.php'; 102 $dest = 'tests/utils/config/configOverwrite.json.php';
103 copy($source, $dest); 103 copy($source, $dest);
104 $conf = $this->configIO->read($dest); 104 $conf = $this->configIO->read($dest);
105 $conf['extras']['redirector'] = 'blabla'; 105 $conf['redirector']['url'] = 'blabla';
106 $this->configIO->write($dest, $conf); 106 $this->configIO->write($dest, $conf);
107 $conf = $this->configIO->read($dest); 107 $conf = $this->configIO->read($dest);
108 $this->assertEquals('blabla', $conf['extras']['redirector']); 108 $this->assertEquals('blabla', $conf['redirector']['url']);
109 unlink($dest); 109 unlink($dest);
110 } 110 }
111 111
diff --git a/tests/utils/config/configJson.json.php b/tests/utils/config/configJson.json.php
index 6a841f8a..c54882c3 100644
--- a/tests/utils/config/configJson.json.php
+++ b/tests/utils/config/configJson.json.php
@@ -10,17 +10,19 @@
10 }, 10 },
11 "general": { 11 "general": {
12 "timezone":"Europe\/Paris", 12 "timezone":"Europe\/Paris",
13 "default_private_linksheader_link":true,
14 "title": "Shaarli", 13 "title": "Shaarli",
15 "header_link": "?" 14 "header_link": "?"
16 }, 15 },
17 "extras": { 16 "privacy": {
18 "redirector":"lala" 17 "default_private_links":true
18 },
19 "redirector": {
20 "url":"lala"
19 }, 21 },
20 "config": { 22 "config": {
21 "foo": "bar" 23 "foo": "bar"
22 }, 24 },
23 "path": { 25 "resource": {
24 "datastore": "tests\/utils\/config\/datastore.php", 26 "datastore": "tests\/utils\/config\/datastore.php",
25 "data_dir": "tests\/utils\/config" 27 "data_dir": "tests\/utils\/config"
26 }, 28 },