Skip to content

Commit

Permalink
Merge pull request #49135 from nextcloud/backport/49112/stable28
Browse files Browse the repository at this point in the history
  • Loading branch information
provokateurin authored Nov 8, 2024
2 parents 09beee5 + c786e41 commit 9874716
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 @@ -143,7 +143,7 @@ public function disableTheme(ITheme $theme): array {
$this->setEnabledThemes($enabledThemes);
return $enabledThemes;
}

return $themesIds;
}

Expand Down Expand Up @@ -176,7 +176,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 @@ -138,8 +138,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 @@ -164,7 +164,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 @@ -173,7 +173,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 @@ -198,7 +198,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 @@ -232,7 +232,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 @@ -251,14 +251,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 @@ -273,7 +273,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 9874716

Please sign in to comment.