Rename configuration key for better sections

This commit is contained in:
ArthurHoaro 2016-06-11 09:08:02 +02:00
parent 51def0d849
commit 894a3c4bf3
10 changed files with 173 additions and 167 deletions

View file

@ -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',

View file

@ -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');

View file

@ -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);
}

View file

@ -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"
},