Skip to content

Commit 232eb9c

Browse files
authored
Merge pull request #49112 from nextcloud/fix/theming/default-theme-selection
2 parents 6fa4266 + 7cb295f commit 232eb9c

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

apps/theming/lib/Service/ThemesService.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function disableTheme(ITheme $theme): array {
127127
$this->setEnabledThemes($enabledThemes);
128128
return $enabledThemes;
129129
}
130-
130+
131131
return $themesIds;
132132
}
133133

@@ -160,7 +160,7 @@ public function getEnabledThemes(): array {
160160
}
161161

162162
$enforcedTheme = $this->config->getSystemValueString('enforce_theme', '');
163-
$enabledThemes = json_decode($this->config->getUserValue($user->getUID(), Application::APP_ID, 'enabled-themes', '[]'));
163+
$enabledThemes = json_decode($this->config->getUserValue($user->getUID(), Application::APP_ID, 'enabled-themes', '["default"]'));
164164
if ($enforcedTheme !== '') {
165165
return array_merge([$enforcedTheme], $enabledThemes);
166166
}

apps/theming/tests/Service/ThemesServiceTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public function testGetThemesEnforcedInvalid(): void {
121121

122122
public function dataTestEnableTheme() {
123123
return [
124-
['default', [], ['default']],
125-
['dark', [], ['dark']],
124+
['default', ['default'], ['default']],
125+
['dark', ['default'], ['dark']],
126126
['dark', ['dark'], ['dark']],
127127
['opendyslexic', ['dark'], ['dark', 'opendyslexic']],
128128
['dark', ['light-highcontrast', 'opendyslexic'], ['opendyslexic', 'dark']],
@@ -147,7 +147,7 @@ public function testEnableTheme(string $toEnable, array $enabledThemes, array $e
147147

148148
$this->config->expects($this->once())
149149
->method('getUserValue')
150-
->with('user', Application::APP_ID, 'enabled-themes', '[]')
150+
->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
151151
->willReturn(json_encode($enabledThemes));
152152

153153
$this->assertEquals($expectedEnabled, $this->themesService->enableTheme($this->themes[$toEnable]));
@@ -156,7 +156,7 @@ public function testEnableTheme(string $toEnable, array $enabledThemes, array $e
156156

157157
public function dataTestDisableTheme() {
158158
return [
159-
['dark', [], []],
159+
['dark', ['default'], ['default']],
160160
['dark', ['dark'], []],
161161
['opendyslexic', ['dark', 'opendyslexic'], ['dark'], ],
162162
['light-highcontrast', ['opendyslexic'], ['opendyslexic']],
@@ -181,7 +181,7 @@ public function testDisableTheme(string $toDisable, array $enabledThemes, array
181181

182182
$this->config->expects($this->once())
183183
->method('getUserValue')
184-
->with('user', Application::APP_ID, 'enabled-themes', '[]')
184+
->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
185185
->willReturn(json_encode($enabledThemes));
186186

187187

@@ -215,7 +215,7 @@ public function testIsEnabled(string $themeId, array $enabledThemes, $expected):
215215

216216
$this->config->expects($this->once())
217217
->method('getUserValue')
218-
->with('user', Application::APP_ID, 'enabled-themes', '[]')
218+
->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
219219
->willReturn(json_encode($enabledThemes));
220220

221221

@@ -234,14 +234,14 @@ public function testGetEnabledThemes(): void {
234234

235235
$this->config->expects($this->once())
236236
->method('getUserValue')
237-
->with('user', Application::APP_ID, 'enabled-themes', '[]')
238-
->willReturn(json_encode([]));
237+
->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
238+
->willReturn(json_encode(['default']));
239239
$this->config->expects($this->once())
240240
->method('getSystemValueString')
241241
->with('enforce_theme', '')
242242
->willReturn('');
243243

244-
$this->assertEquals([], $this->themesService->getEnabledThemes());
244+
$this->assertEquals(['default'], $this->themesService->getEnabledThemes());
245245
}
246246

247247
public function testGetEnabledThemesEnforced(): void {
@@ -256,7 +256,7 @@ public function testGetEnabledThemesEnforced(): void {
256256

257257
$this->config->expects($this->once())
258258
->method('getUserValue')
259-
->with('user', Application::APP_ID, 'enabled-themes', '[]')
259+
->with('user', Application::APP_ID, 'enabled-themes', '["default"]')
260260
->willReturn(json_encode([]));
261261
$this->config->expects($this->once())
262262
->method('getSystemValueString')

0 commit comments

Comments
 (0)