aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Updater
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-08-02 12:54:55 +0200
committerArthurHoaro <arthur@hoa.ro>2016-08-02 12:54:55 +0200
commitb9f8b83790a57b55f7d12471460537a268a24642 (patch)
tree1e42039b149a92dd2fcfe7ffbca42d236246a60b /tests/Updater
parentefc0c865ba914e75a6c3c9220450d13f752c7afa (diff)
downloadShaarli-b9f8b83790a57b55f7d12471460537a268a24642.tar.gz
Shaarli-b9f8b83790a57b55f7d12471460537a268a24642.tar.zst
Shaarli-b9f8b83790a57b55f7d12471460537a268a24642.zip
Fix update method escapeUnescapedConfig
* Actually run it * unit tests Fixes #611
Diffstat (limited to 'tests/Updater')
-rw-r--r--tests/Updater/UpdaterTest.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/Updater/UpdaterTest.php b/tests/Updater/UpdaterTest.php
index 6bdce08b..0d0ad922 100644
--- a/tests/Updater/UpdaterTest.php
+++ b/tests/Updater/UpdaterTest.php
@@ -263,4 +263,28 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
263 $expected = filemtime($this->conf->getConfigFileExt()); 263 $expected = filemtime($this->conf->getConfigFileExt());
264 $this->assertEquals($expected, $filetime); 264 $this->assertEquals($expected, $filetime);
265 } 265 }
266
267 /**
268 * Test escapeUnescapedConfig with valid data.
269 */
270 public function testEscapeConfig()
271 {
272 $sandbox = 'sandbox/config';
273 copy(self::$configFile .'.json.php', $sandbox .'.json.php');
274 $this->conf = new ConfigManager($sandbox);
275 $title = '<script>alert("title");</script>';
276 $headerLink = '<script>alert("header_link");</script>';
277 $redirectorUrl = '<script>alert("redirector");</script>';
278 $this->conf->set('general.title', $title);
279 $this->conf->set('general.header_link', $headerLink);
280 $this->conf->set('redirector.url', $redirectorUrl);
281 $updater = new Updater(array(), array(), $this->conf, true);
282 $done = $updater->updateMethodEscapeUnescapedConfig();
283 $this->assertTrue($done);
284 $this->conf->reload();
285 $this->assertEquals(escape($title), $this->conf->get('general.title'));
286 $this->assertEquals(escape($headerLink), $this->conf->get('general.header_link'));
287 $this->assertEquals(escape($redirectorUrl), $this->conf->get('redirector.url'));
288 unlink($sandbox .'.json.php');
289 }
266} 290}