Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'apps/theming/tests/ThemingDefaultsTest.php')
-rw-r--r--apps/theming/tests/ThemingDefaultsTest.php72
1 files changed, 71 insertions, 1 deletions
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php
index 5aa36211053..5106b2551b8 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', '')
+ ->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', '')
+ ->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', '')
+ ->willReturn('nextcloud');
+
+ $this->assertEquals($this->template->getDefaultColorPrimary(), $this->template->getColorPrimary());
+ }
+
public function testSet() {
$this->config
->expects($this->exactly(2))