From 894a3c4bf38d8dcadb6941049b9167e5101805bd Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 11 Jun 2016 09:08:02 +0200 Subject: Rename configuration key for better sections --- tests/ApplicationUtilsTest.php | 40 +++++++++++++++++----------------- tests/Updater/UpdaterTest.php | 12 +++++----- tests/config/ConfigJsonTest.php | 22 +++++++++---------- tests/utils/config/configJson.json.php | 10 +++++---- 4 files changed, 43 insertions(+), 41 deletions(-) (limited to 'tests') 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 public function testCheckCurrentResourcePermissions() { $conf = new ConfigManager(''); - $conf->set('path.thumbnails_cache', 'cache'); - $conf->set('path.config', 'data/config.php'); - $conf->set('path.data_dir', 'data'); - $conf->set('path.datastore', 'data/datastore.php'); - $conf->set('path.ban_file', 'data/ipbans.php'); - $conf->set('path.log', 'data/log.txt'); - $conf->set('path.page_cache', 'pagecache'); - $conf->set('path.raintpl_tmp', 'tmp'); - $conf->set('path.raintpl_tpl', 'tpl'); - $conf->set('path.update_check', 'data/lastupdatecheck.txt'); + $conf->set('resource.thumbnails_cache', 'cache'); + $conf->set('resource.config', 'data/config.php'); + $conf->set('resource.data_dir', 'data'); + $conf->set('resource.datastore', 'data/datastore.php'); + $conf->set('resource.ban_file', 'data/ipbans.php'); + $conf->set('resource.log', 'data/log.txt'); + $conf->set('resource.page_cache', 'pagecache'); + $conf->set('resource.raintpl_tmp', 'tmp'); + $conf->set('resource.raintpl_tpl', 'tpl'); + $conf->set('resource.update_check', 'data/lastupdatecheck.txt'); $this->assertEquals( array(), @@ -300,16 +300,16 @@ class ApplicationUtilsTest extends PHPUnit_Framework_TestCase public function testCheckCurrentResourcePermissionsErrors() { $conf = new ConfigManager(''); - $conf->set('path.thumbnails_cache', 'null/cache'); - $conf->set('path.config', 'null/data/config.php'); - $conf->set('path.data_dir', 'null/data'); - $conf->set('path.datastore', 'null/data/store.php'); - $conf->set('path.ban_file', 'null/data/ipbans.php'); - $conf->set('path.log', 'null/data/log.txt'); - $conf->set('path.page_cache', 'null/pagecache'); - $conf->set('path.raintpl_tmp', 'null/tmp'); - $conf->set('path.raintpl_tpl', 'null/tpl'); - $conf->set('path.update_check', 'null/data/lastupdatecheck.txt'); + $conf->set('resource.thumbnails_cache', 'null/cache'); + $conf->set('resource.config', 'null/data/config.php'); + $conf->set('resource.data_dir', 'null/data'); + $conf->set('resource.datastore', 'null/data/store.php'); + $conf->set('resource.ban_file', 'null/data/ipbans.php'); + $conf->set('resource.log', 'null/data/log.txt'); + $conf->set('resource.page_cache', 'null/pagecache'); + $conf->set('resource.raintpl_tmp', 'null/tmp'); + $conf->set('resource.raintpl_tpl', 'null/tpl'); + $conf->set('resource.update_check', 'null/data/lastupdatecheck.txt'); $this->assertEquals( array( '"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 public function testReadEmptyUpdatesFile() { $this->assertEquals(array(), read_updates_file('')); - $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt'; + $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; touch($updatesFile); $this->assertEquals(array(), read_updates_file($updatesFile)); unlink($updatesFile); @@ -49,7 +49,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase */ public function testReadWriteUpdatesFile() { - $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt'; + $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; $updatesMethods = array('m1', 'm2', 'm3'); write_updates_file($updatesFile, $updatesMethods); @@ -83,7 +83,7 @@ class UpdaterTest extends PHPUnit_Framework_TestCase */ public function testWriteUpdatesFileNotWritable() { - $updatesFile = $this->conf->get('path.data_dir') . '/updates.txt'; + $updatesFile = $this->conf->get('resource.data_dir') . '/updates.txt'; touch($updatesFile); chmod($updatesFile, 0444); try { @@ -189,7 +189,7 @@ $GLOBALS[\'privateLinkByDefault\'] = true;'; // make sure updated field is changed $this->conf->reload(); - $this->assertTrue($this->conf->get('general.default_private_links')); + $this->assertTrue($this->conf->get('privacy.default_private_links')); $this->assertFalse(is_file($optionsFile)); // Delete the generated file. unlink($this->conf->getConfigFileExt()); @@ -243,8 +243,8 @@ $GLOBALS[\'privateLinkByDefault\'] = true;'; // Check JSON config data. $this->conf->reload(); $this->assertEquals('root', $this->conf->get('credentials.login')); - $this->assertEquals('lala', $this->conf->get('extras.redirector')); - $this->assertEquals('data/datastore.php', $this->conf->get('path.datastore')); + $this->assertEquals('lala', $this->conf->get('redirector.url')); + $this->assertEquals('data/datastore.php', $this->conf->get('resource.datastore')); $this->assertEquals('1', $this->conf->get('plugins.WALLABAG_VERSION')); 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 { $conf = $this->configIO->read('tests/utils/config/configJson.json.php'); $this->assertEquals('root', $conf['credentials']['login']); - $this->assertEquals('lala', $conf['extras']['redirector']); - $this->assertEquals('tests/utils/config/datastore.php', $conf['path']['datastore']); + $this->assertEquals('lala', $conf['redirector']['url']); + $this->assertEquals('tests/utils/config/datastore.php', $conf['resource']['datastore']); $this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']); } @@ -58,11 +58,11 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase 'credentials' => array( 'login' => 'root', ), - 'path' => array( + 'resource' => array( 'datastore' => 'data/datastore.php', ), - 'extras' => array( - 'redirector' => 'lala', + 'redirector' => array( + 'url' => 'lala', ), 'plugins' => array( 'WALLABAG_VERSION' => '1', @@ -75,18 +75,18 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase "credentials": { "login": "root" }, - "path": { + "resource": { "datastore": "data\/datastore.php" }, - "extras": { - "redirector": "lala" + "redirector": { + "url": "lala" }, "plugins": { "WALLABAG_VERSION": "1" } }'; } else { - $expected = '{"credentials":{"login":"root"},"path":{"datastore":"data\/datastore.php"},"extras":{"redirector":"lala"},"plugins":{"WALLABAG_VERSION":"1"}}'; + $expected = '{"credentials":{"login":"root"},"resource":{"datastore":"data\/datastore.php"},"redirector":{"url":"lala"},"plugins":{"WALLABAG_VERSION":"1"}}'; } $expected = ConfigJson::getPhpHeaders() . $expected; $this->assertEquals($expected, file_get_contents($dataFile)); @@ -102,10 +102,10 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase $dest = 'tests/utils/config/configOverwrite.json.php'; copy($source, $dest); $conf = $this->configIO->read($dest); - $conf['extras']['redirector'] = 'blabla'; + $conf['redirector']['url'] = 'blabla'; $this->configIO->write($dest, $conf); $conf = $this->configIO->read($dest); - $this->assertEquals('blabla', $conf['extras']['redirector']); + $this->assertEquals('blabla', $conf['redirector']['url']); unlink($dest); } 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 @@ }, "general": { "timezone":"Europe\/Paris", - "default_private_linksheader_link":true, "title": "Shaarli", "header_link": "?" }, - "extras": { - "redirector":"lala" + "privacy": { + "default_private_links":true + }, + "redirector": { + "url":"lala" }, "config": { "foo": "bar" }, - "path": { + "resource": { "datastore": "tests\/utils\/config\/datastore.php", "data_dir": "tests\/utils\/config" }, -- cgit v1.2.3