diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2022-10-05 12:14:03 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2022-10-13 12:13:39 +0200 |
commit | db831359d3ad10d35536bd5f0e72ba629b828471 (patch) | |
tree | 5b953a93ef251e5ed8ea012e80e9fe1327a7b662 /apps/theming/tests | |
parent | 4b46c5a5a02b6c1c77b99cf21b9ff933fabbcc35 (diff) | |
download | nextcloud-server-db831359d3ad10d35536bd5f0e72ba629b828471.tar.gz nextcloud-server-db831359d3ad10d35536bd5f0e72ba629b828471.zip |
Allow to pick custom colour
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/theming/tests')
-rw-r--r-- | apps/theming/tests/Service/ThemesServiceTest.php | 4 | ||||
-rw-r--r-- | apps/theming/tests/Settings/AdminTest.php | 4 | ||||
-rw-r--r-- | apps/theming/tests/Settings/PersonalTest.php | 4 | ||||
-rw-r--r-- | apps/theming/tests/Themes/DefaultThemeTest.php | 5 | ||||
-rw-r--r-- | apps/theming/tests/Themes/DyslexiaFontTest.php | 5 | ||||
-rw-r--r-- | apps/theming/tests/ThemingDefaultsTest.php | 72 |
6 files changed, 91 insertions, 3 deletions
diff --git a/apps/theming/tests/Service/ThemesServiceTest.php b/apps/theming/tests/Service/ThemesServiceTest.php index 5a2907ec073..62f00ab0e31 100644 --- a/apps/theming/tests/Service/ThemesServiceTest.php +++ b/apps/theming/tests/Service/ThemesServiceTest.php @@ -68,6 +68,10 @@ class ThemesServiceTest extends TestCase { ->method('getColorPrimary') ->willReturn('#0082c9'); + $this->themingDefaults->expects($this->any()) + ->method('getDefaultColorPrimary') + ->willReturn('#0082c9'); + $this->initThemes(); $this->themesService = new ThemesService( diff --git a/apps/theming/tests/Settings/AdminTest.php b/apps/theming/tests/Settings/AdminTest.php index b10196a1ac5..8f259e29ba5 100644 --- a/apps/theming/tests/Settings/AdminTest.php +++ b/apps/theming/tests/Settings/AdminTest.php @@ -97,7 +97,7 @@ class AdminTest extends TestCase { ->willReturn('MySlogan'); $this->themingDefaults ->expects($this->once()) - ->method('getColorPrimary') + ->method('getDefaultColorPrimary') ->willReturn('#fff'); $this->urlGenerator ->expects($this->once()) @@ -156,7 +156,7 @@ class AdminTest extends TestCase { ->willReturn('MySlogan'); $this->themingDefaults ->expects($this->once()) - ->method('getColorPrimary') + ->method('getDefaultColorPrimary') ->willReturn('#fff'); $this->urlGenerator ->expects($this->once()) diff --git a/apps/theming/tests/Settings/PersonalTest.php b/apps/theming/tests/Settings/PersonalTest.php index 0cb289cb86a..8597461a175 100644 --- a/apps/theming/tests/Settings/PersonalTest.php +++ b/apps/theming/tests/Settings/PersonalTest.php @@ -138,6 +138,10 @@ class PersonalTest extends TestCase { $themingDefaults->expects($this->any()) ->method('getColorPrimary') ->willReturn('#0082c9'); + + $themingDefaults->expects($this->any()) + ->method('getDefaultColorPrimary') + ->willReturn('#0082c9'); $this->themes = [ 'default' => new DefaultTheme( diff --git a/apps/theming/tests/Themes/DefaultThemeTest.php b/apps/theming/tests/Themes/DefaultThemeTest.php index c1de2810396..eafd66ef663 100644 --- a/apps/theming/tests/Themes/DefaultThemeTest.php +++ b/apps/theming/tests/Themes/DefaultThemeTest.php @@ -70,6 +70,11 @@ class DefaultThemeTest extends TestCase { ->method('getColorPrimary') ->willReturn('#0082c9'); + $this->themingDefaults + ->expects($this->any()) + ->method('getDefaultColorPrimary') + ->willReturn('#0082c9'); + $this->l10n ->expects($this->any()) ->method('t') diff --git a/apps/theming/tests/Themes/DyslexiaFontTest.php b/apps/theming/tests/Themes/DyslexiaFontTest.php index 77eb77a2818..8a0df960205 100644 --- a/apps/theming/tests/Themes/DyslexiaFontTest.php +++ b/apps/theming/tests/Themes/DyslexiaFontTest.php @@ -84,6 +84,11 @@ class DyslexiaFontTest extends TestCase { ->method('getColorPrimary') ->willReturn('#0082c9'); + $this->themingDefaults + ->expects($this->any()) + ->method('getDefaultColorPrimary') + ->willReturn('#0082c9'); + $this->l10n ->expects($this->any()) ->method('t') diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index 5aa36211053..6879999e341 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -35,6 +35,7 @@ namespace OCA\Theming\Tests; use OCA\Theming\ImageManager; +use OCA\Theming\Service\BackgroundService; use OCA\Theming\ThemingDefaults; use OCA\Theming\Util; use OCP\App\IAppManager; @@ -46,6 +47,7 @@ use OCP\IConfig; use OCP\IL10N; use OCP\INavigationManager; use OCP\IURLGenerator; +use OCP\IUser; use OCP\IUserSession; use Test\TestCase; @@ -420,7 +422,7 @@ class ThemingDefaultsTest extends TestCase { $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan', $this->template->getShortFooter()); } - public function testgetColorPrimaryWithDefault() { + public function testGetColorPrimaryWithDefault() { $this->config ->expects($this->once()) ->method('getAppValue') @@ -440,6 +442,74 @@ class ThemingDefaultsTest extends TestCase { $this->assertEquals('#fff', $this->template->getColorPrimary()); } + public function testGetColorPrimaryWithDefaultBackground() { + $user = $this->createMock(IUser::class); + $this->userSession->expects($this->any()) + ->method('getUser') + ->willReturn($user); + $user->expects($this->any()) + ->method('getUID') + ->willReturn('user'); + + $this->assertEquals(BackgroundService::DEFAULT_COLOR, $this->template->getColorPrimary()); + } + + public function testGetColorPrimaryWithCustomBackground() { + $backgroundIndex = 2; + $background = array_values(BackgroundService::SHIPPED_BACKGROUNDS)[$backgroundIndex]; + $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('getUserValue') + ->with('user', 'theming', 'background', 'default') + ->willReturn(array_keys(BackgroundService::SHIPPED_BACKGROUNDS)[$backgroundIndex]); + + $this->assertEquals($background['primary_color'], $this->template->getColorPrimary()); + } + + public function testGetColorPrimaryWithCustomBackgroundColor() { + $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('getUserValue') + ->with('user', 'theming', 'background', 'default') + ->willReturn('#fff'); + + $this->assertEquals('#fff', $this->template->getColorPrimary()); + } + + public function testGetColorPrimaryWithInvalidCustomBackgroundColor() { + $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('getUserValue') + ->with('user', 'theming', 'background', 'default') + ->willReturn('nextcloud'); + + $this->assertEquals($this->template->getDefaultColorPrimary(), $this->template->getColorPrimary()); + } + public function testSet() { $this->config ->expects($this->exactly(2)) |