]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Set the vintage theme by default for the time being 754/head
authorArthurHoaro <arthur@hoa.ro>
Mon, 27 Feb 2017 19:20:53 +0000 (20:20 +0100)
committerArthurHoaro <arthur@hoa.ro>
Mon, 27 Feb 2017 19:20:53 +0000 (20:20 +0100)
application/Updater.php
tests/Updater/UpdaterTest.php

index 90aba74508faa33472d3bc6a754f127cf1a8e066..3f5d325b8ec5d29be258144f744b03598f3e19cf 100644 (file)
@@ -324,6 +324,20 @@ class Updater
 
         return rename('inc/user.css', 'data/user.css');
     }
+
+    /**
+     * While the new default theme is in an unstable state
+     * continue to use the vintage theme
+     */
+    public function updateMethodDefaultThemeVintage()
+    {
+        if ($this->conf->get('resource.theme') !== 'default') {
+            return true;
+        }
+        $this->conf->set('resource.theme', 'vintage');
+        $this->conf->write($this->isLoggedIn);
+        return true;
+    }
 }
 
 /**
index 1d15cfaaace698d825a9b711258ee504f0927dc0..de330ae220d1371b4c8f14d573485d76d3ba7740 100644 (file)
@@ -466,4 +466,44 @@ $GLOBALS[\'privateLinkByDefault\'] = true;';
         unlink('sandbox/'. $theme .'/linklist.html');
         rmdir('sandbox/'. $theme);
     }
+
+    /**
+     * Test updateMethodDefaultThemeVintage with the default theme enabled.
+     */
+    public function testSetDefaultThemeToVintage()
+    {
+        $sandboxConf = 'sandbox/config';
+        copy(self::$configFile . '.json.php', $sandboxConf . '.json.php');
+        $this->conf = new ConfigManager($sandboxConf);
+
+        $this->conf->set('resource.theme', 'default');
+        $updater = new Updater([], [], $this->conf, true);
+        $this->assertTrue($updater->updateMethodDefaultThemeVintage());
+        $this->assertEquals('vintage', $this->conf->get('resource.theme'));
+
+        // reload from file
+        $this->conf = new ConfigManager($sandboxConf);
+        $this->assertEquals('vintage', $this->conf->get('resource.theme'));
+    }
+
+    /**
+     * Test updateMethodDefaultThemeVintage with custom theme enabled => nothing to do.
+     */
+    public function testSetDefaultThemeNothingToDo()
+    {
+        $sandboxConf = 'sandbox/config';
+        copy(self::$configFile . '.json.php', $sandboxConf . '.json.php');
+        $this->conf = new ConfigManager($sandboxConf);
+
+        $theme = 'myawesometheme';
+        $this->conf->set('resource.theme', $theme);
+        $this->conf->write(true);
+        $updater = new Updater([], [], $this->conf, true);
+        $this->assertTrue($updater->updateMethodDefaultThemeVintage());
+        $this->assertEquals($theme, $this->conf->get('resource.theme'));
+
+        // reload from file
+        $this->conf = new ConfigManager($sandboxConf);
+        $this->assertEquals($theme, $this->conf->get('resource.theme'));
+    }
 }