mirror of
https://github.com/nextcloud/server.git
synced 2026-04-05 00:56:16 -04:00
fix(tests): Adjust theming test for new splitted background and primary colors
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
282f1b1fab
commit
0ef3147ea0
11 changed files with 200 additions and 122 deletions
|
|
@ -85,7 +85,7 @@
|
|||
--color-primary-element-light-hover: #dbe4ea;
|
||||
--color-primary-element-light-text: #00293f;
|
||||
--gradient-primary-background: linear-gradient(40deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
|
||||
--image-background-default: url('/apps/theming/img/background/kamil-porembinski-clouds.jpg');
|
||||
--color-background-plain: #0082c9;
|
||||
--color-background-plain: #00679e;
|
||||
--color-background-plain-text: #ffffff;
|
||||
--image-background-default: url('/apps/theming/img/background/kamil-porembinski-clouds.jpg');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ class Capabilities implements IPublicCapability {
|
|||
* color-element-dark: string,
|
||||
* logo: string,
|
||||
* background: string,
|
||||
* background-text: string,
|
||||
* background-plain: bool,
|
||||
* background-default: bool,
|
||||
* logoheader: string,
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ use OCP\Files\IAppData;
|
|||
use OCP\IConfig;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUserSession;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
/**
|
||||
|
|
@ -45,16 +46,16 @@ use Test\TestCase;
|
|||
* @package OCA\Theming\Tests
|
||||
*/
|
||||
class CapabilitiesTest extends TestCase {
|
||||
/** @var ThemingDefaults|\PHPUnit\Framework\MockObject\MockObject */
|
||||
/** @var ThemingDefaults|MockObject */
|
||||
protected $theming;
|
||||
|
||||
/** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
|
||||
/** @var IURLGenerator|MockObject */
|
||||
protected $url;
|
||||
|
||||
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
|
||||
/** @var IConfig|MockObject */
|
||||
protected $config;
|
||||
|
||||
/** @var Util|\PHPUnit\Framework\MockObject\MockObject */
|
||||
/** @var Util|MockObject */
|
||||
protected $util;
|
||||
|
||||
protected IUserSession $userSession;
|
||||
|
|
@ -66,16 +67,22 @@ class CapabilitiesTest extends TestCase {
|
|||
parent::setUp();
|
||||
|
||||
$this->theming = $this->createMock(ThemingDefaults::class);
|
||||
$this->url = $this->getMockBuilder(IURLGenerator::class)->getMock();
|
||||
$this->url = $this->createMock(IURLGenerator::class);
|
||||
$this->config = $this->createMock(IConfig::class);
|
||||
$this->util = $this->createMock(Util::class);
|
||||
$this->userSession = $this->createMock(IUserSession::class);
|
||||
$this->capabilities = new Capabilities($this->theming, $this->util, $this->url, $this->config, $this->userSession);
|
||||
$this->capabilities = new Capabilities(
|
||||
$this->theming,
|
||||
$this->util,
|
||||
$this->url,
|
||||
$this->config,
|
||||
$this->userSession,
|
||||
);
|
||||
}
|
||||
|
||||
public function dataGetCapabilities() {
|
||||
return [
|
||||
['name', 'url', 'slogan', '#FFFFFF', '#000000', 'logo', 'background', 'http://absolute/', true, [
|
||||
['name', 'url', 'slogan', '#FFFFFF', '#000000', 'logo', 'background', '#fff', '#000', 'http://absolute/', true, [
|
||||
'name' => 'name',
|
||||
'url' => 'url',
|
||||
'slogan' => 'slogan',
|
||||
|
|
@ -86,12 +93,13 @@ class CapabilitiesTest extends TestCase {
|
|||
'color-element-dark' => '#FFFFFF',
|
||||
'logo' => 'http://absolute/logo',
|
||||
'background' => 'http://absolute/background',
|
||||
'background-text' => '#000',
|
||||
'background-plain' => false,
|
||||
'background-default' => false,
|
||||
'logoheader' => 'http://absolute/logo',
|
||||
'favicon' => 'http://absolute/logo',
|
||||
]],
|
||||
['name1', 'url2', 'slogan3', '#01e4a0', '#ffffff', 'logo5', 'background6', 'http://localhost/', false, [
|
||||
['name1', 'url2', 'slogan3', '#01e4a0', '#ffffff', 'logo5', 'background6', '#fff', '#000', 'http://localhost/', false, [
|
||||
'name' => 'name1',
|
||||
'url' => 'url2',
|
||||
'slogan' => 'slogan3',
|
||||
|
|
@ -102,12 +110,13 @@ class CapabilitiesTest extends TestCase {
|
|||
'color-element-dark' => '#01e4a0',
|
||||
'logo' => 'http://localhost/logo5',
|
||||
'background' => 'http://localhost/background6',
|
||||
'background-text' => '#000',
|
||||
'background-plain' => false,
|
||||
'background-default' => true,
|
||||
'logoheader' => 'http://localhost/logo5',
|
||||
'favicon' => 'http://localhost/logo5',
|
||||
]],
|
||||
['name1', 'url2', 'slogan3', '#000000', '#ffffff', 'logo5', 'backgroundColor', 'http://localhost/', true, [
|
||||
['name1', 'url2', 'slogan3', '#000000', '#ffffff', 'logo5', 'backgroundColor', '#000000', '#ffffff', 'http://localhost/', true, [
|
||||
'name' => 'name1',
|
||||
'url' => 'url2',
|
||||
'slogan' => 'slogan3',
|
||||
|
|
@ -118,12 +127,13 @@ class CapabilitiesTest extends TestCase {
|
|||
'color-element-dark' => '#4d4d4d',
|
||||
'logo' => 'http://localhost/logo5',
|
||||
'background' => '#000000',
|
||||
'background-text' => '#ffffff',
|
||||
'background-plain' => true,
|
||||
'background-default' => false,
|
||||
'logoheader' => 'http://localhost/logo5',
|
||||
'favicon' => 'http://localhost/logo5',
|
||||
]],
|
||||
['name1', 'url2', 'slogan3', '#000000', '#ffffff', 'logo5', 'backgroundColor', 'http://localhost/', false, [
|
||||
['name1', 'url2', 'slogan3', '#000000', '#ffffff', 'logo5', 'backgroundColor', '#000000', '#ffffff', 'http://localhost/', false, [
|
||||
'name' => 'name1',
|
||||
'url' => 'url2',
|
||||
'slogan' => 'slogan3',
|
||||
|
|
@ -134,6 +144,7 @@ class CapabilitiesTest extends TestCase {
|
|||
'color-element-dark' => '#4d4d4d',
|
||||
'logo' => 'http://localhost/logo5',
|
||||
'background' => '#000000',
|
||||
'background-text' => '#ffffff',
|
||||
'background-plain' => true,
|
||||
'background-default' => true,
|
||||
'logoheader' => 'http://localhost/logo5',
|
||||
|
|
@ -155,7 +166,7 @@ class CapabilitiesTest extends TestCase {
|
|||
* @param bool $backgroundThemed
|
||||
* @param string[] $expected
|
||||
*/
|
||||
public function testGetCapabilities($name, $url, $slogan, $color, $textColor, $logo, $background, $baseUrl, $backgroundThemed, array $expected) {
|
||||
public function testGetCapabilities($name, $url, $slogan, $color, $textColor, $logo, $background, $backgroundColor, $backgroundTextColor, $baseUrl, $backgroundThemed, array $expected) {
|
||||
$this->config->expects($this->once())
|
||||
->method('getAppValue')
|
||||
->willReturn($background);
|
||||
|
|
@ -168,6 +179,12 @@ class CapabilitiesTest extends TestCase {
|
|||
$this->theming->expects($this->once())
|
||||
->method('getSlogan')
|
||||
->willReturn($slogan);
|
||||
$this->theming->expects($this->once())
|
||||
->method('getColorBackground')
|
||||
->willReturn($backgroundColor);
|
||||
$this->theming->expects($this->once())
|
||||
->method('getTextColorBackground')
|
||||
->willReturn($backgroundTextColor);
|
||||
$this->theming->expects($this->atLeast(1))
|
||||
->method('getDefaultColorPrimary')
|
||||
->willReturn($color);
|
||||
|
|
|
|||
|
|
@ -42,13 +42,11 @@ use OCP\App\IAppManager;
|
|||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\Files\IAppData;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\Files\SimpleFS\ISimpleFile;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
use OCP\ITempManager;
|
||||
use OCP\IURLGenerator;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
|
@ -64,17 +62,13 @@ class ThemingControllerTest extends TestCase {
|
|||
private $l10n;
|
||||
/** @var ThemingController */
|
||||
private $themingController;
|
||||
/** @var ITempManager */
|
||||
private $tempManager;
|
||||
/** @var IAppManager|MockObject */
|
||||
private $appManager;
|
||||
/** @var IAppData|MockObject */
|
||||
private $appData;
|
||||
/** @var ImageManager|MockObject */
|
||||
private $imageManager;
|
||||
/** @var IURLGenerator|MockObject */
|
||||
private $urlGenerator;
|
||||
/** @var ThemeService|MockObject */
|
||||
/** @var ThemesService|MockObject */
|
||||
private $themesService;
|
||||
|
||||
protected function setUp(): void {
|
||||
|
|
@ -82,9 +76,7 @@ class ThemingControllerTest extends TestCase {
|
|||
$this->config = $this->createMock(IConfig::class);
|
||||
$this->themingDefaults = $this->createMock(ThemingDefaults::class);
|
||||
$this->l10n = $this->createMock(L10N::class);
|
||||
$this->appData = $this->createMock(IAppData::class);
|
||||
$this->appManager = $this->createMock(IAppManager::class);
|
||||
$this->tempManager = \OC::$server->getTempManager();
|
||||
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
||||
$this->imageManager = $this->createMock(ImageManager::class);
|
||||
$this->themesService = $this->createMock(ThemesService::class);
|
||||
|
|
@ -102,8 +94,6 @@ class ThemingControllerTest extends TestCase {
|
|||
$this->config,
|
||||
$this->themingDefaults,
|
||||
$this->l10n,
|
||||
$this->tempManager,
|
||||
$this->appData,
|
||||
$this->urlGenerator,
|
||||
$this->appManager,
|
||||
$this->imageManager,
|
||||
|
|
@ -164,9 +154,12 @@ class ThemingControllerTest extends TestCase {
|
|||
['url', str_repeat('a', 501), 'The given web address is not a valid URL'],
|
||||
['url', 'javascript:alert(1)', 'The given web address is not a valid URL'],
|
||||
['slogan', str_repeat('a', 501), 'The given slogan is too long'],
|
||||
['color', '0082C9', 'The given color is invalid'],
|
||||
['color', '#0082Z9', 'The given color is invalid'],
|
||||
['color', 'Nextcloud', 'The given color is invalid'],
|
||||
['primary_color', '0082C9', 'The given color is invalid'],
|
||||
['primary_color', '#0082Z9', 'The given color is invalid'],
|
||||
['primary_color', 'Nextcloud', 'The given color is invalid'],
|
||||
['background_color', '0082C9', 'The given color is invalid'],
|
||||
['background_color', '#0082Z9', 'The given color is invalid'],
|
||||
['background_color', 'Nextcloud', 'The given color is invalid'],
|
||||
['imprintUrl', '0082C9', 'The given legal notice address is not a valid URL'],
|
||||
['imprintUrl', '0082C9', 'The given legal notice address is not a valid URL'],
|
||||
['imprintUrl', 'javascript:foo', 'The given legal notice address is not a valid URL'],
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
namespace OCA\Theming\Tests;
|
||||
|
||||
use OCA\Theming\ImageManager;
|
||||
use OCA\Theming\Service\BackgroundService;
|
||||
use OCP\Files\IAppData;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\Files\SimpleFS\ISimpleFile;
|
||||
|
|
@ -57,6 +58,8 @@ class ImageManagerTest extends TestCase {
|
|||
private $tempManager;
|
||||
/** @var ISimpleFolder|MockObject */
|
||||
private $rootFolder;
|
||||
/** @var BackgroundService|MockObject */
|
||||
private $backgroundService;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -67,13 +70,15 @@ class ImageManagerTest extends TestCase {
|
|||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
$this->tempManager = $this->createMock(ITempManager::class);
|
||||
$this->rootFolder = $this->createMock(ISimpleFolder::class);
|
||||
$this->backgroundService = $this->createMock(BackgroundService::class);
|
||||
$this->imageManager = new ImageManager(
|
||||
$this->config,
|
||||
$this->appData,
|
||||
$this->urlGenerator,
|
||||
$this->cacheFactory,
|
||||
$this->logger,
|
||||
$this->tempManager
|
||||
$this->tempManager,
|
||||
$this->backgroundService,
|
||||
);
|
||||
$this->appData
|
||||
->expects($this->any())
|
||||
|
|
|
|||
|
|
@ -81,6 +81,14 @@ class DarkHighContrastThemeTest extends AccessibleThemeTestCase {
|
|||
->expects($this->any())
|
||||
->method('getDefaultColorPrimary')
|
||||
->willReturn('#0082c9');
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
->method('getColorBackground')
|
||||
->willReturn('#0082c9');
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
->method('getDefaultColorBackground')
|
||||
->willReturn('#0082c9');
|
||||
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
|
|
|
|||
|
|
@ -78,6 +78,14 @@ class DarkThemeTest extends AccessibleThemeTestCase {
|
|||
->expects($this->any())
|
||||
->method('getDefaultColorPrimary')
|
||||
->willReturn('#0082c9');
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
->method('getColorBackground')
|
||||
->willReturn('#0082c9');
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
->method('getDefaultColorBackground')
|
||||
->willReturn('#0082c9');
|
||||
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
|
|
|
|||
|
|
@ -69,15 +69,27 @@ class DefaultThemeTest extends AccessibleThemeTestCase {
|
|||
$this->imageManager
|
||||
);
|
||||
|
||||
$defaultBackground = BackgroundService::SHIPPED_BACKGROUNDS[BackgroundService::DEFAULT_BACKGROUND_IMAGE];
|
||||
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
->method('getColorPrimary')
|
||||
->willReturn('#0082c9');
|
||||
->willReturn($defaultBackground['primary_color']);
|
||||
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
->method('getColorBackground')
|
||||
->willReturn($defaultBackground['background_color']);
|
||||
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
->method('getDefaultColorPrimary')
|
||||
->willReturn('#0082c9');
|
||||
->willReturn($defaultBackground['primary_color']);
|
||||
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
->method('getDefaultColorBackground')
|
||||
->willReturn($defaultBackground['background_color']);
|
||||
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
|
|
|
|||
|
|
@ -94,6 +94,16 @@ class DyslexiaFontTest extends TestCase {
|
|||
->method('getDefaultColorPrimary')
|
||||
->willReturn('#0082c9');
|
||||
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
->method('getColorBackground')
|
||||
->willReturn('#0082c9');
|
||||
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
->method('getDefaultColorBackground')
|
||||
->willReturn('#0082c9');
|
||||
|
||||
$this->l10n
|
||||
->expects($this->any())
|
||||
->method('t')
|
||||
|
|
|
|||
|
|
@ -81,6 +81,14 @@ class HighContrastThemeTest extends AccessibleThemeTestCase {
|
|||
->expects($this->any())
|
||||
->method('getDefaultColorPrimary')
|
||||
->willReturn('#0082c9');
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
->method('getColorBackground')
|
||||
->willReturn('#0082c9');
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
->method('getDefaultColorBackground')
|
||||
->willReturn('#0082c9');
|
||||
|
||||
$this->themingDefaults
|
||||
->expects($this->any())
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@ class ThemingDefaultsTest extends TestCase {
|
|||
private $imageManager;
|
||||
/** @var INavigationManager|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $navigationManager;
|
||||
/** @var BackgroundService|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $backgroundService;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -91,6 +93,7 @@ class ThemingDefaultsTest extends TestCase {
|
|||
$this->imageManager = $this->createMock(ImageManager::class);
|
||||
$this->appManager = $this->createMock(IAppManager::class);
|
||||
$this->navigationManager = $this->createMock(INavigationManager::class);
|
||||
$this->backgroundService = $this->createMock(BackgroundService::class);
|
||||
$this->defaults = new \OC_Defaults();
|
||||
$this->urlGenerator
|
||||
->expects($this->any())
|
||||
|
|
@ -105,7 +108,8 @@ class ThemingDefaultsTest extends TestCase {
|
|||
$this->util,
|
||||
$this->imageManager,
|
||||
$this->appManager,
|
||||
$this->navigationManager
|
||||
$this->navigationManager,
|
||||
$this->backgroundService,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -428,7 +432,7 @@ class ThemingDefaultsTest extends TestCase {
|
|||
->method('getAppValue')
|
||||
->willReturnMap([
|
||||
['theming', 'disable-user-theming', 'no', 'no'],
|
||||
['theming', 'color', '', $this->defaults->getColorPrimary()],
|
||||
['theming', 'primary_color', '', $this->defaults->getColorPrimary()],
|
||||
]);
|
||||
|
||||
$this->assertEquals($this->defaults->getColorPrimary(), $this->template->getColorPrimary());
|
||||
|
|
@ -440,40 +444,101 @@ class ThemingDefaultsTest extends TestCase {
|
|||
->method('getAppValue')
|
||||
->willReturnMap([
|
||||
['theming', 'disable-user-theming', 'no', 'no'],
|
||||
['theming', 'color', '', '#fff'],
|
||||
['theming', 'primary_color', '', '#fff'],
|
||||
]);
|
||||
|
||||
$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->config
|
||||
->expects($this->exactly(2))
|
||||
->method('getAppValue')
|
||||
->willReturnMap([
|
||||
['theming', 'disable-user-theming', 'no', 'no'],
|
||||
['theming', 'color', '', ''],
|
||||
]);
|
||||
$this->config
|
||||
->expects($this->once())
|
||||
->method('getUserValue')
|
||||
->with('user', 'theming', 'background_color')
|
||||
->willReturn('');
|
||||
|
||||
$this->assertEquals(BackgroundService::DEFAULT_COLOR, $this->template->getColorPrimary());
|
||||
public function dataGetColorPrimary() {
|
||||
return [
|
||||
'with fallback default' => [
|
||||
'disableTheming' => 'no',
|
||||
'primaryColor' => '',
|
||||
'backgroundColor' => '',
|
||||
'userBackgroundColor' => '',
|
||||
'userPrimaryColor' => '',
|
||||
'expected' => BackgroundService::DEFAULT_COLOR,
|
||||
],
|
||||
'with custom admin background' => [
|
||||
'disableTheming' => 'no',
|
||||
'primaryColor' => '',
|
||||
'backgroundColor' => '#123',
|
||||
'userBackgroundColor' => '',
|
||||
'userPrimaryColor' => '',
|
||||
'expected' => '#123',
|
||||
],
|
||||
'with custom invalid admin background' => [
|
||||
'disableTheming' => 'no',
|
||||
'primaryColor' => '',
|
||||
'backgroundColor' => 'invalid-name',
|
||||
'userBackgroundColor' => '',
|
||||
'userPrimaryColor' => '',
|
||||
'expected' => BackgroundService::DEFAULT_COLOR,
|
||||
],
|
||||
'with custom admin primary' => [
|
||||
'disableTheming' => 'no',
|
||||
'primaryColor' => '#aaa',
|
||||
'backgroundColor' => '',
|
||||
'userBackgroundColor' => '',
|
||||
'userPrimaryColor' => '',
|
||||
'expected' => '#aaa',
|
||||
],
|
||||
'with custom invalid admin primary' => [
|
||||
'disableTheming' => 'no',
|
||||
'primaryColor' => 'invalid',
|
||||
'backgroundColor' => '',
|
||||
'userBackgroundColor' => '',
|
||||
'userPrimaryColor' => '',
|
||||
'expected' => BackgroundService::DEFAULT_COLOR,
|
||||
],
|
||||
'with custom user background' => [
|
||||
'disableTheming' => 'no',
|
||||
'primaryColor' => '',
|
||||
'backgroundColor' => '',
|
||||
'userBackgroundColor' => '#456',
|
||||
'userPrimaryColor' => '#456',
|
||||
'expected' => '#456',
|
||||
],
|
||||
'with custom invalid user primary' => [
|
||||
'disableTheming' => 'no',
|
||||
'primaryColor' => '',
|
||||
'backgroundColor' => '',
|
||||
'userBackgroundColor' => '',
|
||||
'userPrimaryColor' => 'invalid-name',
|
||||
'expected' => BackgroundService::DEFAULT_COLOR,
|
||||
],
|
||||
'with custom user primary' => [
|
||||
'disableTheming' => 'no',
|
||||
'primaryColor' => '',
|
||||
'backgroundColor' => '',
|
||||
'userBackgroundColor' => '',
|
||||
'userPrimaryColor' => '#bbb',
|
||||
'expected' => '#bbb',
|
||||
],
|
||||
'with custom invalid user background' => [
|
||||
'disableTheming' => 'no',
|
||||
'primaryColor' => '',
|
||||
'backgroundColor' => '',
|
||||
'userBackgroundColor' => 'invalid-name',
|
||||
'userPrimaryColor' => '',
|
||||
'expected' => BackgroundService::DEFAULT_COLOR,
|
||||
],
|
||||
'with custom admin and user background' => [
|
||||
'disableTheming' => 'no',
|
||||
'primaryColor' => '',
|
||||
'backgroundColor' => '#123',
|
||||
'userBackgroundColor' => '#456',
|
||||
'userPrimaryColor' => '#456',
|
||||
'expected' => '#456',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function testGetColorPrimaryWithCustomBackground() {
|
||||
$backgroundIndex = 2;
|
||||
$background = array_values(BackgroundService::SHIPPED_BACKGROUNDS)[$backgroundIndex];
|
||||
|
||||
/**
|
||||
* @dataProvider dataGetColorPrimary
|
||||
*/
|
||||
public function testGetColorPrimary(string $disableTheming, string $primaryColor, string $backgroundColor, string $userBackgroundColor, $userPrimaryColor, $expected) {
|
||||
$user = $this->createMock(IUser::class);
|
||||
$this->userSession->expects($this->any())
|
||||
->method('getUser')
|
||||
|
|
@ -481,72 +546,23 @@ class ThemingDefaultsTest extends TestCase {
|
|||
$user->expects($this->any())
|
||||
->method('getUID')
|
||||
->willReturn('user');
|
||||
|
||||
$this->config
|
||||
->expects($this->once())
|
||||
->method('getUserValue')
|
||||
->with('user', 'theming', 'background_color', '')
|
||||
->willReturn($background['primary_color']);
|
||||
|
||||
$this->config
|
||||
->expects($this->exactly(2))
|
||||
->expects($this->any())
|
||||
->method('getAppValue')
|
||||
->willReturnMap([
|
||||
['theming', 'color', '', ''],
|
||||
['theming', 'disable-user-theming', 'no', 'no'],
|
||||
['theming', 'disable-user-theming', 'no', $disableTheming],
|
||||
['theming', 'primary_color', '', $primaryColor],
|
||||
['theming', 'background_color', '', $backgroundColor],
|
||||
]);
|
||||
|
||||
$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())
|
||||
->expects($this->any())
|
||||
->method('getUserValue')
|
||||
->with('user', 'theming', 'background_color', '')
|
||||
->willReturn('#fff');
|
||||
$this->config
|
||||
->expects($this->exactly(2))
|
||||
->method('getAppValue')
|
||||
->willReturnMap([
|
||||
['theming', 'color', '', ''],
|
||||
['theming', 'disable-user-theming', 'no', 'no'],
|
||||
['user', 'theming', 'background_color', '', $userBackgroundColor],
|
||||
['user', 'theming', 'primary_color', $userBackgroundColor, $userPrimaryColor],
|
||||
]);
|
||||
|
||||
$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_color', '')
|
||||
->willReturn('nextcloud');
|
||||
$this->config
|
||||
->expects($this->exactly(3))
|
||||
->method('getAppValue')
|
||||
->willReturnMap([
|
||||
['theming', 'color', '', ''],
|
||||
['theming', 'disable-user-theming', 'no', 'no'],
|
||||
]);
|
||||
|
||||
$this->assertEquals($this->template->getDefaultColorPrimary(), $this->template->getColorPrimary());
|
||||
$this->assertEquals($expected, $this->template->getColorPrimary());
|
||||
}
|
||||
|
||||
public function testSet() {
|
||||
|
|
@ -646,17 +662,17 @@ class ThemingDefaultsTest extends TestCase {
|
|||
$this->assertSame($this->defaults->getSlogan(), $this->template->undo('slogan'));
|
||||
}
|
||||
|
||||
public function testUndoColor() {
|
||||
public function testUndoPrimaryColor() {
|
||||
$this->config
|
||||
->expects($this->once())
|
||||
->method('deleteAppValue')
|
||||
->with('theming', 'color');
|
||||
->with('theming', 'primary_color');
|
||||
$this->config
|
||||
->expects($this->exactly(2))
|
||||
->method('getAppValue')
|
||||
->withConsecutive(
|
||||
['theming', 'cachebuster', '0'],
|
||||
['theming', 'color', null],
|
||||
['theming', 'primary_color', null],
|
||||
)->willReturnOnConsecutiveCalls(
|
||||
'15',
|
||||
$this->defaults->getColorPrimary(),
|
||||
|
|
@ -666,7 +682,7 @@ class ThemingDefaultsTest extends TestCase {
|
|||
->method('setAppValue')
|
||||
->with('theming', 'cachebuster', 16);
|
||||
|
||||
$this->assertSame($this->defaults->getColorPrimary(), $this->template->undo('color'));
|
||||
$this->assertSame($this->defaults->getColorPrimary(), $this->template->undo('primary_color'));
|
||||
}
|
||||
|
||||
public function testUndoDefaultAction() {
|
||||
|
|
@ -764,8 +780,8 @@ class ThemingDefaultsTest extends TestCase {
|
|||
['theming', 'backgroundMime', '', 'jpeg'],
|
||||
['theming', 'logoheaderMime', '', 'jpeg'],
|
||||
['theming', 'faviconMime', '', 'jpeg'],
|
||||
['theming', 'color', '', $this->defaults->getColorPrimary()],
|
||||
['theming', 'color', $this->defaults->getColorPrimary(), $this->defaults->getColorPrimary()],
|
||||
['theming', 'primary_color', '', $this->defaults->getColorPrimary()],
|
||||
['theming', 'primary_color', $this->defaults->getColorPrimary(), $this->defaults->getColorPrimary()],
|
||||
]);
|
||||
|
||||
$this->util->expects($this->any())->method('invertTextColor')->with($this->defaults->getColorPrimary())->willReturn(false);
|
||||
|
|
|
|||
Loading…
Reference in a new issue