diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2022-10-20 16:03:19 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2022-11-29 11:23:05 +0100 |
commit | 064fa10ecfe4725398895a21ab8bafd171e2eadd (patch) | |
tree | 5f2d8124eb131a65eac207edee560c49ea7835f3 /apps/theming/tests | |
parent | cedae7c6d74e11c8aaa59b09a38db04dbebc818d (diff) | |
download | nextcloud-server-064fa10ecfe4725398895a21ab8bafd171e2eadd.tar.gz nextcloud-server-064fa10ecfe4725398895a21ab8bafd171e2eadd.zip |
Extract colour from custom background
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/theming/tests')
-rw-r--r-- | apps/theming/tests/Controller/ThemingControllerTest.php | 2 | ||||
-rw-r--r-- | apps/theming/tests/Themes/DefaultThemeTest.php | 7 | ||||
-rw-r--r-- | apps/theming/tests/ThemingDefaultsTest.php | 28 |
3 files changed, 22 insertions, 15 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index c67be434631..9042a338fb7 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -680,7 +680,7 @@ class ThemingControllerTest extends TestCase { public function testGetLoginBackground() { $file = $this->createMock(ISimpleFile::class); - $file->method('getName')->willReturn('app-background.jpg'); + $file->method('getName')->willReturn('background.png'); $file->method('getMTime')->willReturn(42); $this->imageManager->expects($this->once()) ->method('getImage') diff --git a/apps/theming/tests/Themes/DefaultThemeTest.php b/apps/theming/tests/Themes/DefaultThemeTest.php index 4471dddb01e..2a62211f268 100644 --- a/apps/theming/tests/Themes/DefaultThemeTest.php +++ b/apps/theming/tests/Themes/DefaultThemeTest.php @@ -22,8 +22,10 @@ */ namespace OCA\Theming\Tests\Service; +use OCA\Theming\AppInfo\Application; use OCA\Theming\ImageManager; use OCA\Theming\ITheme; +use OCA\Theming\Service\BackgroundService; use OCA\Theming\Themes\DefaultTheme; use OCA\Theming\ThemingDefaults; use OCA\Theming\Util; @@ -80,6 +82,11 @@ class DefaultThemeTest extends TestCase { ->method('getDefaultColorPrimary') ->willReturn('#0082c9'); + $this->themingDefaults + ->expects($this->any()) + ->method('getBackground') + ->willReturn('/apps/' . Application::APP_ID . '/img/background/' . BackgroundService::DEFAULT_BACKGROUND); + $this->l10n ->expects($this->any()) ->method('t') diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index caed7002980..04fce553c33 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -473,6 +473,7 @@ class ThemingDefaultsTest extends TestCase { public function testGetColorPrimaryWithCustomBackground() { $backgroundIndex = 2; $background = array_values(BackgroundService::SHIPPED_BACKGROUNDS)[$backgroundIndex]; + $user = $this->createMock(IUser::class); $this->userSession->expects($this->any()) ->method('getUser') @@ -484,14 +485,15 @@ class ThemingDefaultsTest extends TestCase { $this->config ->expects($this->once()) ->method('getUserValue') - ->with('user', 'theming', 'background_image', '') - ->willReturn(array_keys(BackgroundService::SHIPPED_BACKGROUNDS)[$backgroundIndex]); + ->with('user', 'theming', 'background_color', '') + ->willReturn($background['primary_color']); + $this->config ->expects($this->exactly(2)) ->method('getAppValue') ->willReturnMap([ - ['theming', 'disable-user-theming', 'no', 'no'], ['theming', 'color', '', ''], + ['theming', 'disable-user-theming', 'no', 'no'], ]); $this->assertEquals($background['primary_color'], $this->template->getColorPrimary()); @@ -509,14 +511,14 @@ class ThemingDefaultsTest extends TestCase { $this->config ->expects($this->once()) ->method('getUserValue') - ->with('user', 'theming', 'background_image', '') + ->with('user', 'theming', 'background_color', '') ->willReturn('#fff'); $this->config ->expects($this->exactly(2)) ->method('getAppValue') ->willReturnMap([ - ['theming', 'disable-user-theming', 'no', 'no'], ['theming', 'color', '', ''], + ['theming', 'disable-user-theming', 'no', 'no'], ]); $this->assertEquals('#fff', $this->template->getColorPrimary()); @@ -534,14 +536,14 @@ class ThemingDefaultsTest extends TestCase { $this->config ->expects($this->once()) ->method('getUserValue') - ->with('user', 'theming', 'background_image', '') + ->with('user', 'theming', 'background_color', '') ->willReturn('nextcloud'); $this->config ->expects($this->exactly(3)) ->method('getAppValue') ->willReturnMap([ - ['theming', 'disable-user-theming', 'no', 'no'], ['theming', 'color', '', ''], + ['theming', 'disable-user-theming', 'no', 'no'], ]); $this->assertEquals($this->template->getDefaultColorPrimary(), $this->template->getColorPrimary()); @@ -650,16 +652,14 @@ class ThemingDefaultsTest extends TestCase { ->method('deleteAppValue') ->with('theming', 'color'); $this->config - ->expects($this->exactly(3)) + ->expects($this->exactly(2)) ->method('getAppValue') ->withConsecutive( ['theming', 'cachebuster', '0'], ['theming', 'color', null], - ['theming', 'disable-user-theming', 'no'], )->willReturnOnConsecutiveCalls( '15', $this->defaults->getColorPrimary(), - 'no', ); $this->config ->expects($this->once()) @@ -778,10 +778,10 @@ class ThemingDefaultsTest extends TestCase { $this->imageManager->expects($this->exactly(4)) ->method('getImageUrl') ->willReturnMap([ - ['logo', true, 'custom-logo?v=0'], - ['logoheader', true, 'custom-logoheader?v=0'], - ['favicon', true, 'custom-favicon?v=0'], - ['background_image', true, 'custom-background?v=0'], + ['logo', 'custom-logo?v=0'], + ['logoheader', 'custom-logoheader?v=0'], + ['favicon', 'custom-favicon?v=0'], + ['background', 'custom-background?v=0'], ]); $expected = [ |