]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/updater/UpdaterTest.php
Run Unit Tests against PHP 7.4
[github/shaarli/Shaarli.git] / tests / updater / UpdaterTest.php
index d7df59637395ddf9a7d4760eecefa5db4a32a97e..ac87e33c2acac7d7d3f2e1490f2ef483a42b11bc 100644 (file)
@@ -287,17 +287,14 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
         $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');
     }
 
@@ -707,7 +704,6 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
     }
 
     /**
-<<<<<<< HEAD
      * Test updateMethodWebThumbnailer with thumbnails enabled.
      */
     public function testUpdateMethodWebThumbnailerEnabled()
@@ -728,6 +724,9 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
      */
     public function testUpdateMethodWebThumbnailerDisabled()
     {
+        if (isset($_SESSION['warnings'])) {
+            unset($_SESSION['warnings']);
+        }
         $this->conf->remove('thumbnails');
         $this->conf->set('thumbnail.enable_thumbnails', false);
         $updater = new Updater([], [], $this->conf, true, $_SESSION);
@@ -744,6 +743,9 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
      */
     public function testUpdateMethodWebThumbnailerNothingToDo()
     {
+        if (isset($_SESSION['warnings'])) {
+            unset($_SESSION['warnings']);
+        }
         $updater = new Updater([], [], $this->conf, true, $_SESSION);
         $this->assertTrue($updater->updateMethodWebThumbnailer());
         $this->assertFalse($this->conf->exists('thumbnail'));
@@ -812,4 +814,19 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
         $linkDB = new LinkDB(self::$testDatastore, true, false);
         $this->assertTrue($linkDB[1]['sticky']);
     }
+
+    /**
+     * Test updateMethodRemoveRedirector().
+     */
+    public function testUpdateRemoveRedirector()
+    {
+        $sandboxConf = 'sandbox/config';
+        copy(self::$configFile . '.json.php', $sandboxConf . '.json.php');
+        $this->conf = new ConfigManager($sandboxConf);
+        $updater = new Updater([], null, $this->conf, true);
+        $this->assertTrue($updater->updateMethodRemoveRedirector());
+        $this->assertFalse($this->conf->exists('redirector'));
+        $this->conf = new ConfigManager($sandboxConf);
+        $this->assertFalse($this->conf->exists('redirector'));
+    }
 }