diff options
author | skjnldsv <skjnldsv@protonmail.com> | 2024-06-14 11:32:16 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2024-06-14 16:28:00 +0200 |
commit | 88e83d9c5a41b2aea3dba49a2466a629c777c75c (patch) | |
tree | 99d209d7fa1c9c13ebe0e8debba7513cab6e5458 /apps/theming/tests/Service/ThemesServiceTest.php | |
parent | 54bf26ae50138606085cdaec50a8443bdf0b7b50 (diff) | |
download | nextcloud-server-88e83d9c5a41b2aea3dba49a2466a629c777c75c.tar.gz nextcloud-server-88e83d9c5a41b2aea3dba49a2466a629c777c75c.zip |
fix(theming): also apply enforced theme for guests
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/theming/tests/Service/ThemesServiceTest.php')
-rw-r--r-- | apps/theming/tests/Service/ThemesServiceTest.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/apps/theming/tests/Service/ThemesServiceTest.php b/apps/theming/tests/Service/ThemesServiceTest.php index 29bc026820a..a670ab3a583 100644 --- a/apps/theming/tests/Service/ThemesServiceTest.php +++ b/apps/theming/tests/Service/ThemesServiceTest.php @@ -24,6 +24,7 @@ use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserSession; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Test\TestCase; class ThemesServiceTest extends TestCase { @@ -34,6 +35,9 @@ class ThemesServiceTest extends TestCase { private $userSession; /** @var IConfig|MockObject */ private $config; + /** @var LoggerInterface|MockObject */ + private $logger; + /** @var ThemingDefaults|MockObject */ private $themingDefaults; @@ -43,6 +47,7 @@ class ThemesServiceTest extends TestCase { protected function setUp(): void { $this->userSession = $this->createMock(IUserSession::class); $this->config = $this->createMock(IConfig::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->themingDefaults = $this->createMock(ThemingDefaults::class); $this->themingDefaults->expects($this->any()) @@ -58,6 +63,7 @@ class ThemesServiceTest extends TestCase { $this->themesService = new ThemesService( $this->userSession, $this->config, + $this->logger, ...array_values($this->themes) ); @@ -76,6 +82,42 @@ class ThemesServiceTest extends TestCase { $this->assertEquals($expected, array_keys($this->themesService->getThemes())); } + public function testGetThemesEnforced() { + $this->config->expects($this->once()) + ->method('getSystemValueString') + ->with('enforce_theme', '') + ->willReturn('dark'); + $this->logger->expects($this->never()) + ->method('error'); + + $expected = [ + 'default', + 'dark', + ]; + + $this->assertEquals($expected, array_keys($this->themesService->getThemes())); + } + + public function testGetThemesEnforcedInvalid() { + $this->config->expects($this->once()) + ->method('getSystemValueString') + ->with('enforce_theme', '') + ->willReturn('invalid'); + $this->logger->expects($this->once()) + ->method('error') + ->with('Enforced theme not found', ['theme' => 'invalid']); + + $expected = [ + 'default', + 'light', + 'dark', + 'light-highcontrast', + 'dark-highcontrast', + 'opendyslexic', + ]; + + $this->assertEquals($expected, array_keys($this->themesService->getThemes())); + } public function dataTestEnableTheme() { return [ |