X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FUpdater%2FUpdaterTest.php;h=0d0ad92220cac1fef8fc954e645066854c7f555a;hb=17c9ac7c35754b607dba2db74b4aa69d1cec335c;hp=5ed2df6caff8527877a594b0213eb49ec050b597;hpb=278d9ee2836df7d805845077f26f8cecd16f0f4f;p=github%2Fshaarli%2FShaarli.git
diff --git a/tests/Updater/UpdaterTest.php b/tests/Updater/UpdaterTest.php
index 5ed2df6c..0d0ad922 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');
@@ -263,4 +263,28 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
$expected = filemtime($this->conf->getConfigFileExt());
$this->assertEquals($expected, $filetime);
}
+
+ /**
+ * Test escapeUnescapedConfig with valid data.
+ */
+ public function testEscapeConfig()
+ {
+ $sandbox = 'sandbox/config';
+ copy(self::$configFile .'.json.php', $sandbox .'.json.php');
+ $this->conf = new ConfigManager($sandbox);
+ $title = '';
+ $headerLink = '';
+ $redirectorUrl = '';
+ $this->conf->set('general.title', $title);
+ $this->conf->set('general.header_link', $headerLink);
+ $this->conf->set('redirector.url', $redirectorUrl);
+ $updater = new Updater(array(), array(), $this->conf, true);
+ $done = $updater->updateMethodEscapeUnescapedConfig();
+ $this->assertTrue($done);
+ $this->conf->reload();
+ $this->assertEquals(escape($title), $this->conf->get('general.title'));
+ $this->assertEquals(escape($headerLink), $this->conf->get('general.header_link'));
+ $this->assertEquals(escape($redirectorUrl), $this->conf->get('redirector.url'));
+ unlink($sandbox .'.json.php');
+ }
}