aboutsummaryrefslogtreecommitdiffstats
path: root/apps/theming/tests/Settings/PersonalTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/theming/tests/Settings/PersonalTest.php')
-rw-r--r--apps/theming/tests/Settings/PersonalTest.php92
1 files changed, 42 insertions, 50 deletions
diff --git a/apps/theming/tests/Settings/PersonalTest.php b/apps/theming/tests/Settings/PersonalTest.php
index 0a9bf4b59c9..9216450ec9c 100644
--- a/apps/theming/tests/Settings/PersonalTest.php
+++ b/apps/theming/tests/Settings/PersonalTest.php
@@ -1,35 +1,16 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Theming\Tests\Settings;
use OCA\Theming\AppInfo\Application;
use OCA\Theming\ImageManager;
use OCA\Theming\ITheme;
+use OCA\Theming\Service\BackgroundService;
use OCA\Theming\Service\ThemesService;
use OCA\Theming\Settings\Personal;
use OCA\Theming\Themes\DarkHighContrastTheme;
@@ -45,20 +26,22 @@ use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\IConfig;
use OCP\IL10N;
+use OCP\INavigationManager;
use OCP\IURLGenerator;
use OCP\IUserSession;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class PersonalTest extends TestCase {
- private IConfig $config;
- private ThemesService $themesService;
- private IInitialState $initialStateService;
- private ThemingDefaults $themingDefaults;
- private IAppManager $appManager;
+ private IConfig&MockObject $config;
+ private ThemesService&MockObject $themesService;
+ private IInitialState&MockObject $initialStateService;
+ private ThemingDefaults&MockObject $themingDefaults;
+ private INavigationManager&MockObject $navigationManager;
private Personal $admin;
/** @var ITheme[] */
- private $themes;
+ private array $themes;
protected function setUp(): void {
parent::setUp();
@@ -66,7 +49,7 @@ class PersonalTest extends TestCase {
$this->themesService = $this->createMock(ThemesService::class);
$this->initialStateService = $this->createMock(IInitialState::class);
$this->themingDefaults = $this->createMock(ThemingDefaults::class);
- $this->appManager = $this->createMock(IAppManager::class);
+ $this->navigationManager = $this->createMock(INavigationManager::class);
$this->initThemes();
@@ -82,12 +65,11 @@ class PersonalTest extends TestCase {
$this->themesService,
$this->initialStateService,
$this->themingDefaults,
- $this->appManager,
+ $this->navigationManager,
);
}
-
- public function dataTestGetForm() {
+ public function dataTestGetForm(): array {
return [
['', [
$this->formatThemeForm('default'),
@@ -105,44 +87,48 @@ class PersonalTest extends TestCase {
}
/**
- * @dataProvider dataTestGetForm
- *
- * @param string $toEnable
* @param string[] $enabledThemes
*/
- public function testGetForm(string $enforcedTheme, $themesState) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetForm')]
+ public function testGetForm(string $enforcedTheme, array $themesState): void {
$this->config->expects($this->once())
->method('getSystemValueString')
->with('enforce_theme', '')
->willReturn($enforcedTheme);
- $this->config->expects($this->once())
+ $this->config->expects($this->any())
->method('getUserValue')
- ->with('admin', 'core', 'apporder')
- ->willReturn('[]');
+ ->willReturnMap([
+ ['admin', 'core', 'apporder', '[]', '[]'],
+ ['admin', 'theming', 'background_image', BackgroundService::BACKGROUND_DEFAULT],
+ ]);
- $this->appManager->expects($this->once())
- ->method('getDefaultAppForUser')
- ->willReturn('forcedapp');
+ $this->navigationManager->expects($this->once())
+ ->method('getDefaultEntryIdForUser')
+ ->willReturn('forced_id');
- $this->initialStateService->expects($this->exactly(4))
+ $this->initialStateService->expects($this->exactly(8))
->method('provideInitialState')
- ->withConsecutive(
+ ->willReturnMap([
+ ['shippedBackgrounds', BackgroundService::SHIPPED_BACKGROUNDS],
+ ['themingDefaults'],
+ ['enableBlurFilter', ''],
+ ['userBackgroundImage'],
['themes', $themesState],
['enforceTheme', $enforcedTheme],
['isUserThemingDisabled', false],
- ['navigationBar', ['userAppOrder' => [], 'enforcedDefaultApp' => 'forcedapp']],
- );
+ ['navigationBar', ['userAppOrder' => [], 'enforcedDefaultApp' => 'forced_id']],
+ ]);
$expected = new TemplateResponse('theming', 'settings-personal');
$this->assertEquals($expected, $this->admin->getForm());
}
- public function testGetSection() {
+ public function testGetSection(): void {
$this->assertSame('theming', $this->admin->getSection());
}
- public function testGetPriority() {
+ public function testGetPriority(): void {
$this->assertSame(40, $this->admin->getPriority());
}
@@ -174,6 +160,7 @@ class PersonalTest extends TestCase {
$config,
$l10n,
$appManager,
+ null,
),
'light' => new LightTheme(
$util,
@@ -184,6 +171,7 @@ class PersonalTest extends TestCase {
$config,
$l10n,
$appManager,
+ null,
),
'dark' => new DarkTheme(
$util,
@@ -194,6 +182,7 @@ class PersonalTest extends TestCase {
$config,
$l10n,
$appManager,
+ null,
),
'light-highcontrast' => new HighContrastTheme(
$util,
@@ -204,6 +193,7 @@ class PersonalTest extends TestCase {
$config,
$l10n,
$appManager,
+ null,
),
'dark-highcontrast' => new DarkHighContrastTheme(
$util,
@@ -214,6 +204,7 @@ class PersonalTest extends TestCase {
$config,
$l10n,
$appManager,
+ null,
),
'opendyslexic' => new DyslexiaFont(
$util,
@@ -224,6 +215,7 @@ class PersonalTest extends TestCase {
$config,
$l10n,
$appManager,
+ null,
),
];
}