diff options
-rw-r--r-- | application/Updater.php | 14 | ||||
-rw-r--r-- | tests/Updater/UpdaterTest.php | 40 |
2 files changed, 54 insertions, 0 deletions
diff --git a/application/Updater.php b/application/Updater.php index 90aba745..3f5d325b 100644 --- a/application/Updater.php +++ b/application/Updater.php | |||
@@ -324,6 +324,20 @@ class Updater | |||
324 | 324 | ||
325 | return rename('inc/user.css', 'data/user.css'); | 325 | return rename('inc/user.css', 'data/user.css'); |
326 | } | 326 | } |
327 | |||
328 | /** | ||
329 | * While the new default theme is in an unstable state | ||
330 | * continue to use the vintage theme | ||
331 | */ | ||
332 | public function updateMethodDefaultThemeVintage() | ||
333 | { | ||
334 | if ($this->conf->get('resource.theme') !== 'default') { | ||
335 | return true; | ||
336 | } | ||
337 | $this->conf->set('resource.theme', 'vintage'); | ||
338 | $this->conf->write($this->isLoggedIn); | ||
339 | return true; | ||
340 | } | ||
327 | } | 341 | } |
328 | 342 | ||
329 | /** | 343 | /** |
diff --git a/tests/Updater/UpdaterTest.php b/tests/Updater/UpdaterTest.php index 1d15cfaa..de330ae2 100644 --- a/tests/Updater/UpdaterTest.php +++ b/tests/Updater/UpdaterTest.php | |||
@@ -466,4 +466,44 @@ $GLOBALS[\'privateLinkByDefault\'] = true;'; | |||
466 | unlink('sandbox/'. $theme .'/linklist.html'); | 466 | unlink('sandbox/'. $theme .'/linklist.html'); |
467 | rmdir('sandbox/'. $theme); | 467 | rmdir('sandbox/'. $theme); |
468 | } | 468 | } |
469 | |||
470 | /** | ||
471 | * Test updateMethodDefaultThemeVintage with the default theme enabled. | ||
472 | */ | ||
473 | public function testSetDefaultThemeToVintage() | ||
474 | { | ||
475 | $sandboxConf = 'sandbox/config'; | ||
476 | copy(self::$configFile . '.json.php', $sandboxConf . '.json.php'); | ||
477 | $this->conf = new ConfigManager($sandboxConf); | ||
478 | |||
479 | $this->conf->set('resource.theme', 'default'); | ||
480 | $updater = new Updater([], [], $this->conf, true); | ||
481 | $this->assertTrue($updater->updateMethodDefaultThemeVintage()); | ||
482 | $this->assertEquals('vintage', $this->conf->get('resource.theme')); | ||
483 | |||
484 | // reload from file | ||
485 | $this->conf = new ConfigManager($sandboxConf); | ||
486 | $this->assertEquals('vintage', $this->conf->get('resource.theme')); | ||
487 | } | ||
488 | |||
489 | /** | ||
490 | * Test updateMethodDefaultThemeVintage with custom theme enabled => nothing to do. | ||
491 | */ | ||
492 | public function testSetDefaultThemeNothingToDo() | ||
493 | { | ||
494 | $sandboxConf = 'sandbox/config'; | ||
495 | copy(self::$configFile . '.json.php', $sandboxConf . '.json.php'); | ||
496 | $this->conf = new ConfigManager($sandboxConf); | ||
497 | |||
498 | $theme = 'myawesometheme'; | ||
499 | $this->conf->set('resource.theme', $theme); | ||
500 | $this->conf->write(true); | ||
501 | $updater = new Updater([], [], $this->conf, true); | ||
502 | $this->assertTrue($updater->updateMethodDefaultThemeVintage()); | ||
503 | $this->assertEquals($theme, $this->conf->get('resource.theme')); | ||
504 | |||
505 | // reload from file | ||
506 | $this->conf = new ConfigManager($sandboxConf); | ||
507 | $this->assertEquals($theme, $this->conf->get('resource.theme')); | ||
508 | } | ||
469 | } | 509 | } |