mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
Fix theming setEnabledThemes unique array
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
parent
24c5d994c7
commit
f577b5dc96
2 changed files with 33 additions and 1 deletions
|
|
@ -176,6 +176,6 @@ class ThemesService {
|
|||
*/
|
||||
private function setEnabledThemes(array $themes): void {
|
||||
$user = $this->userSession->getUser();
|
||||
$this->config->setUserValue($user->getUID(), Application::APP_ID, 'enabled-themes', json_encode(array_unique(array_values($themes))));
|
||||
$this->config->setUserValue($user->getUID(), Application::APP_ID, 'enabled-themes', json_encode(array_values(array_unique($themes))));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,6 +239,38 @@ class ThemesServiceTest extends TestCase {
|
|||
$this->assertEquals(['light'], $this->themesService->getEnabledThemes());
|
||||
}
|
||||
|
||||
|
||||
public function dataTestSetEnabledThemes() {
|
||||
return [
|
||||
[[], []],
|
||||
[['light'], ['light']],
|
||||
[['dark'], ['dark']],
|
||||
[['dark', 'dark', 'opendyslexic'], ['dark', 'opendyslexic']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTestSetEnabledThemes
|
||||
*
|
||||
* @param string[] $enabledThemes
|
||||
* @param string[] $expected
|
||||
*/
|
||||
public function testSetEnabledThemes(array $enabledThemes, array $expected) {
|
||||
$user = $this->createMock(IUser::class);
|
||||
$this->userSession->expects($this->any())
|
||||
->method('getUser')
|
||||
->willReturn($user);
|
||||
$user->expects($this->any())
|
||||
->method('getUID')
|
||||
->willReturn('user');
|
||||
|
||||
$this->config->expects($this->once())
|
||||
->method('setUserValue')
|
||||
->with('user', Application::APP_ID, 'enabled-themes', json_encode($expected));
|
||||
|
||||
$this->invokePrivate($this->themesService, 'setEnabledThemes', [$enabledThemes]);
|
||||
}
|
||||
|
||||
private function initThemes() {
|
||||
$util = $this->createMock(Util::class);
|
||||
$urlGenerator = $this->createMock(IURLGenerator::class);
|
||||
|
|
|
|||
Loading…
Reference in a new issue