]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(theming): Return default theme if the user never selected a theme fix/theming/default-theme-selection 49112/head
authorprovokateurin <kate@provokateurin.de>
Wed, 6 Nov 2024 15:20:38 +0000 (16:20 +0100)
committerprovokateurin <kate@provokateurin.de>
Wed, 6 Nov 2024 15:20:38 +0000 (16:20 +0100)
Signed-off-by: provokateurin <kate@provokateurin.de>
apps/theming/lib/Service/ThemesService.php
apps/theming/tests/Service/ThemesServiceTest.php

index ef8d1ff44ffcff72e9d415f017c42b5fcef3e2d7..433555c980c74691ff21eb620d37e91616d780f1 100644 (file)
@@ -127,7 +127,7 @@ class ThemesService {
                        $this->setEnabledThemes($enabledThemes);
                        return $enabledThemes;
                }
-               
+
                return $themesIds;
        }
 
@@ -160,7 +160,7 @@ class ThemesService {
                }
 
                $enforcedTheme = $this->config->getSystemValueString('enforce_theme', '');
-               $enabledThemes = json_decode($this->config->getUserValue($user->getUID(), Application::APP_ID, 'enabled-themes', '[]'));
+               $enabledThemes = json_decode($this->config->getUserValue($user->getUID(), Application::APP_ID, 'enabled-themes', '["default"]'));
                if ($enforcedTheme !== '') {
                        return array_merge([$enforcedTheme], $enabledThemes);
                }
index 77371cfe34c6f3c62055b62561b4f3847d267544..1b242c956e44c7987b4e3f4a80a57bfe70aa5be4 100644 (file)
@@ -121,8 +121,8 @@ class ThemesServiceTest extends TestCase {
 
        public function dataTestEnableTheme() {
                return [
-                       ['default', [], ['default']],
-                       ['dark', [], ['dark']],
+                       ['default', ['default'], ['default']],
+                       ['dark', ['default'], ['dark']],
                        ['dark', ['dark'], ['dark']],
                        ['opendyslexic', ['dark'], ['dark', 'opendyslexic']],
                        ['dark', ['light-highcontrast', 'opendyslexic'], ['opendyslexic', 'dark']],
@@ -147,7 +147,7 @@ class ThemesServiceTest extends TestCase {
 
                $this->config->expects($this->once())
                        ->method('getUserValue')
-                       ->with('user', Application::APP_ID, 'enabled-themes', '[]')
+                       ->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
                        ->willReturn(json_encode($enabledThemes));
 
                $this->assertEquals($expectedEnabled, $this->themesService->enableTheme($this->themes[$toEnable]));
@@ -156,7 +156,7 @@ class ThemesServiceTest extends TestCase {
 
        public function dataTestDisableTheme() {
                return [
-                       ['dark', [], []],
+                       ['dark', ['default'], ['default']],
                        ['dark', ['dark'], []],
                        ['opendyslexic', ['dark', 'opendyslexic'], ['dark'], ],
                        ['light-highcontrast', ['opendyslexic'], ['opendyslexic']],
@@ -181,7 +181,7 @@ class ThemesServiceTest extends TestCase {
 
                $this->config->expects($this->once())
                        ->method('getUserValue')
-                       ->with('user', Application::APP_ID, 'enabled-themes', '[]')
+                       ->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
                        ->willReturn(json_encode($enabledThemes));
 
 
@@ -215,7 +215,7 @@ class ThemesServiceTest extends TestCase {
 
                $this->config->expects($this->once())
                        ->method('getUserValue')
-                       ->with('user', Application::APP_ID, 'enabled-themes', '[]')
+                       ->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
                        ->willReturn(json_encode($enabledThemes));
 
 
@@ -234,14 +234,14 @@ class ThemesServiceTest extends TestCase {
 
                $this->config->expects($this->once())
                        ->method('getUserValue')
-                       ->with('user', Application::APP_ID, 'enabled-themes', '[]')
-                       ->willReturn(json_encode([]));
+                       ->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
+                       ->willReturn(json_encode(['default']));
                $this->config->expects($this->once())
                        ->method('getSystemValueString')
                        ->with('enforce_theme', '')
                        ->willReturn('');
 
-               $this->assertEquals([], $this->themesService->getEnabledThemes());
+               $this->assertEquals(['default'], $this->themesService->getEnabledThemes());
        }
 
        public function testGetEnabledThemesEnforced(): void {
@@ -256,7 +256,7 @@ class ThemesServiceTest extends TestCase {
 
                $this->config->expects($this->once())
                        ->method('getUserValue')
-                       ->with('user', Application::APP_ID, 'enabled-themes', '[]')
+                       ->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
                        ->willReturn(json_encode([]));
                $this->config->expects($this->once())
                        ->method('getSystemValueString')