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);
*/
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);
*/
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 {
// 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());
// 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');
$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 = '<script>alert("title");</script>';
+ $headerLink = '<script>alert("header_link");</script>';
+ $redirectorUrl = '<script>alert("redirector");</script>';
+ $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');
+ }
}