From da10377b3c263d96a46cf9101c202554343d2cd0 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 29 May 2016 16:10:32 +0200 Subject: Rename configuration keys and fix GLOBALS in templates --- tests/config/ConfigJsonTest.php | 38 +++++++++++++++++++++++--------------- tests/config/ConfigManagerTest.php | 6 +++--- 2 files changed, 26 insertions(+), 18 deletions(-) (limited to 'tests/config') 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 public function testRead() { $conf = $this->configIO->read('tests/utils/config/configJson.json.php'); - $this->assertEquals('root', $conf['login']); - $this->assertEquals('lala', $conf['redirector']); - $this->assertEquals('data/datastore.php', $conf['config']['DATASTORE']); + $this->assertEquals('root', $conf['credentials']['login']); + $this->assertEquals('lala', $conf['extras']['redirector']); + $this->assertEquals('tests/utils/config/datastore.php', $conf['path']['datastore']); $this->assertEquals('1', $conf['plugins']['WALLABAG_VERSION']); } @@ -55,10 +55,14 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase { $dataFile = 'tests/utils/config/configWrite.json.php'; $data = array( - 'login' => 'root', - 'redirector' => 'lala', - 'config' => array( - 'DATASTORE' => 'data/datastore.php', + 'credentials' => array( + 'login' => 'root', + ), + 'path' => array( + 'datastore' => 'data/datastore.php', + ), + 'extras' => array( + 'redirector' => 'lala', ), 'plugins' => array( 'WALLABAG_VERSION' => '1', @@ -68,19 +72,23 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase // PHP 5.3 doesn't support json pretty print. if (defined('JSON_PRETTY_PRINT')) { $expected = '{ - "login": "root", - "redirector": "lala", - "config": { - "DATASTORE": "data\/datastore.php" + "credentials": { + "login": "root" + }, + "path": { + "datastore": "data\/datastore.php" + }, + "extras": { + "redirector": "lala" }, "plugins": { "WALLABAG_VERSION": "1" } }'; } else { - $expected = '{"login":"root","redirector":"lala","config":{"DATASTORE":"data\/datastore.php"},"plugins":{"WALLABAG_VERSION":"1"}}'; + $expected = '{"credentials":{"login":"root"},"path":{"datastore":"data\/datastore.php"},"extras":{"redirector":"lala"},"plugins":{"WALLABAG_VERSION":"1"}}'; } - $expected = ConfigJson::$PHP_HEADER . $expected; + $expected = ConfigJson::getPhpHeaders() . $expected; $this->assertEquals($expected, file_get_contents($dataFile)); unlink($dataFile); } @@ -94,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['redirector'] = 'blabla'; + $conf['extras']['redirector'] = 'blabla'; $this->configIO->write($dest, $conf); $conf = $this->configIO->read($dest); - $this->assertEquals('blabla', $conf['redirector']); + $this->assertEquals('blabla', $conf['extras']['redirector']); unlink($dest); } 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 */ public function testExistsOk() { - $this->assertTrue($this->conf->exists('login')); + $this->assertTrue($this->conf->exists('credentials.login')); $this->assertTrue($this->conf->exists('config.foo')); } @@ -163,12 +163,12 @@ class ConfigManagerTest extends PHPUnit_Framework_TestCase public function testReload() { ConfigManager::$CONFIG_FILE = 'tests/utils/config/configTmp'; - $newConf = ConfigJson::$PHP_HEADER . '{ "key": "value" }'; + $newConf = ConfigJson::getPhpHeaders() . '{ "key": "value" }'; file_put_contents($this->conf->getConfigFile(), $newConf); $this->conf->reload(); unlink($this->conf->getConfigFile()); // Previous conf no longer exists, and new values have been loaded. - $this->assertFalse($this->conf->exists('login')); + $this->assertFalse($this->conf->exists('credentials.login')); $this->assertEquals('value', $this->conf->get('key')); } } -- cgit v1.2.3