Skip to content

Commit

Permalink
Merge pull request #49138 from nextcloud/backport/49112/stable30
Browse files Browse the repository at this point in the history
  • Loading branch information
provokateurin authored Nov 8, 2024
2 parents 0304e8d + 6ac71e5 commit 74239ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions apps/theming/lib/Service/ThemesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function disableTheme(ITheme $theme): array {
$this->setEnabledThemes($enabledThemes);
return $enabledThemes;
}

return $themesIds;
}

Expand Down Expand Up @@ -159,7 +159,7 @@ public function getEnabledThemes(): array {
}

$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);
}
Expand Down
20 changes: 10 additions & 10 deletions apps/theming/tests/Service/ThemesServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ public function testGetThemesEnforcedInvalid() {

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']],
Expand All @@ -147,7 +147,7 @@ public function testEnableTheme(string $toEnable, array $enabledThemes, array $e

$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]));
Expand All @@ -156,7 +156,7 @@ public function testEnableTheme(string $toEnable, array $enabledThemes, array $e

public function dataTestDisableTheme() {
return [
['dark', [], []],
['dark', ['default'], ['default']],
['dark', ['dark'], []],
['opendyslexic', ['dark', 'opendyslexic'], ['dark'], ],
['light-highcontrast', ['opendyslexic'], ['opendyslexic']],
Expand All @@ -181,7 +181,7 @@ public function testDisableTheme(string $toDisable, array $enabledThemes, array

$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));


Expand Down Expand Up @@ -215,7 +215,7 @@ public function testIsEnabled(string $themeId, array $enabledThemes, $expected)

$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));


Expand All @@ -234,14 +234,14 @@ public function testGetEnabledThemes() {

$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() {
Expand All @@ -256,7 +256,7 @@ public function testGetEnabledThemesEnforced() {

$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')
Expand Down

0 comments on commit 74239ef

Please sign in to comment.