aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/config/ConfigJsonTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-05-29 16:10:32 +0200
committerArthurHoaro <arthur@hoa.ro>2016-06-11 09:30:56 +0200
commitda10377b3c263d96a46cf9101c202554343d2cd0 (patch)
treed91d1fcdbd79367418007add4d135d3f84e57a04 /tests/config/ConfigJsonTest.php
parenteeea1c3daa87f133c57c96fa17ed26b02c392636 (diff)
downloadShaarli-da10377b3c263d96a46cf9101c202554343d2cd0.tar.gz
Shaarli-da10377b3c263d96a46cf9101c202554343d2cd0.tar.zst
Shaarli-da10377b3c263d96a46cf9101c202554343d2cd0.zip
Rename configuration keys and fix GLOBALS in templates
Diffstat (limited to 'tests/config/ConfigJsonTest.php')
-rw-r--r--tests/config/ConfigJsonTest.php38
1 files changed, 23 insertions, 15 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