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:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2022-04-20 15:21:42 +0300
committerJohn Molakvoæ <skjnldsv@protonmail.com>2022-04-21 20:00:28 +0300
commit3c75a9926716484020544046f03bfad1c6712cfe (patch)
tree7d92aff6a6b03aabb078ec30b4f9e37970c22c06 /apps/theming/tests
parent48381b8913f90989582a60d90a1dbd0ce96608ae (diff)
Phpunit
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/theming/tests')
-rw-r--r--apps/theming/tests/Controller/ThemingControllerTest.php104
-rw-r--r--apps/theming/tests/Controller/UserThemeControllerTest.php153
-rw-r--r--apps/theming/tests/Service/ThemesServiceTest.php255
-rw-r--r--apps/theming/tests/ServicesTest.php6
-rw-r--r--apps/theming/tests/Settings/AdminTest.php2
-rw-r--r--apps/theming/tests/Settings/SectionTest.php8
-rw-r--r--apps/theming/tests/UtilTest.php9
7 files changed, 431 insertions, 106 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php
index cff2028809d..511f7a6d528 100644
--- a/apps/theming/tests/Controller/ThemingControllerTest.php
+++ b/apps/theming/tests/Controller/ThemingControllerTest.php
@@ -34,8 +34,8 @@
namespace OCA\Theming\Tests\Controller;
use OC\L10N\L10N;
-use OC\Template\SCSSCacher;
use OCA\Theming\Controller\ThemingController;
+use OCA\Theming\Service\ThemesService;
use OCA\Theming\ImageManager;
use OCA\Theming\ThemingDefaults;
use OCP\App\IAppManager;
@@ -72,10 +72,10 @@ class ThemingControllerTest extends TestCase {
private $appData;
/** @var ImageManager|MockObject */
private $imageManager;
- /** @var SCSSCacher */
- private $scssCacher;
- /** @var IURLGenerator */
+ /** @var IURLGenerator|MockObject */
private $urlGenerator;
+ /** @var ThemeService|MockObject */
+ private $themesService;
protected function setUp(): void {
$this->request = $this->createMock(IRequest::class);
@@ -85,9 +85,9 @@ class ThemingControllerTest extends TestCase {
$this->appData = $this->createMock(IAppData::class);
$this->appManager = $this->createMock(IAppManager::class);
$this->tempManager = \OC::$server->getTempManager();
- $this->scssCacher = $this->createMock(SCSSCacher::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->imageManager = $this->createMock(ImageManager::class);
+ $this->themesService = $this->createMock(ThemesService::class);
$timeFactory = $this->createMock(ITimeFactory::class);
$timeFactory->expects($this->any())
@@ -104,10 +104,10 @@ class ThemingControllerTest extends TestCase {
$this->l10n,
$this->tempManager,
$this->appData,
- $this->scssCacher,
$this->urlGenerator,
$this->appManager,
- $this->imageManager
+ $this->imageManager,
+ $this->themesService,
);
parent::setUp();
@@ -144,23 +144,12 @@ class ThemingControllerTest extends TestCase {
->willReturnCallback(function ($str) {
return $str;
});
- $this->scssCacher
- ->expects($this->once())
- ->method('getCachedSCSS')
- ->with('core', '/core/css/css-variables.scss')
- ->willReturn('/core/css/someHash-css-variables.scss');
- $this->urlGenerator
- ->expects($this->once())
- ->method('linkTo')
- ->with('', '/core/css/someHash-css-variables.scss')
- ->willReturn('/nextcloudWebroot/core/css/someHash-css-variables.scss');
$expected = new DataResponse(
[
'data' =>
[
'message' => $message,
- 'serverCssUrl' => '/nextcloudWebroot/core/css/someHash-css-variables.scss',
],
'status' => 'success',
]
@@ -382,9 +371,6 @@ class ThemingControllerTest extends TestCase {
return $str;
});
- $this->urlGenerator->expects($this->once())
- ->method('linkTo')
- ->willReturn('serverCss');
$this->imageManager->expects($this->once())
->method('getImageUrl')
->with('logo')
@@ -400,7 +386,6 @@ class ThemingControllerTest extends TestCase {
'name' => 'logo.svg',
'message' => 'Saved',
'url' => 'imageUrl',
- 'serverCssUrl' => 'serverCss'
],
'status' => 'success'
]
@@ -440,9 +425,6 @@ class ThemingControllerTest extends TestCase {
$this->imageManager->expects($this->once())
->method('updateImage');
- $this->urlGenerator->expects($this->once())
- ->method('linkTo')
- ->willReturn('serverCss');
$this->imageManager->expects($this->once())
->method('getImageUrl')
->with('background')
@@ -454,7 +436,6 @@ class ThemingControllerTest extends TestCase {
'name' => 'logo.svg',
'message' => 'Saved',
'url' => 'imageUrl',
- 'serverCssUrl' => 'serverCss'
],
'status' => 'success'
]
@@ -607,24 +588,13 @@ class ThemingControllerTest extends TestCase {
->method('undo')
->with('MySetting')
->willReturn('MyValue');
- $this->scssCacher
- ->expects($this->once())
- ->method('getCachedSCSS')
- ->with('core', '/core/css/css-variables.scss')
- ->willReturn('/core/css/someHash-css-variables.scss');
- $this->urlGenerator
- ->expects($this->once())
- ->method('linkTo')
- ->with('', '/core/css/someHash-css-variables.scss')
- ->willReturn('/nextcloudWebroot/core/css/someHash-css-variables.scss');
$expected = new DataResponse(
[
'data' =>
[
'value' => 'MyValue',
- 'message' => 'Saved',
- 'serverCssUrl' => '/nextcloudWebroot/core/css/someHash-css-variables.scss',
+ 'message' => 'Saved'
],
'status' => 'success'
]
@@ -651,16 +621,6 @@ class ThemingControllerTest extends TestCase {
->method('undo')
->with($value)
->willReturn($value);
- $this->scssCacher
- ->expects($this->once())
- ->method('getCachedSCSS')
- ->with('core', '/core/css/css-variables.scss')
- ->willReturn('/core/css/someHash-css-variables.scss');
- $this->urlGenerator
- ->expects($this->once())
- ->method('linkTo')
- ->with('', '/core/css/someHash-css-variables.scss')
- ->willReturn('/nextcloudWebroot/core/css/someHash-css-variables.scss');
$expected = new DataResponse(
[
@@ -668,7 +628,6 @@ class ThemingControllerTest extends TestCase {
[
'value' => $value,
'message' => 'Saved',
- 'serverCssUrl' => '/nextcloudWebroot/core/css/someHash-css-variables.scss',
],
'status' => 'success'
]
@@ -743,53 +702,6 @@ class ThemingControllerTest extends TestCase {
@$this->assertEquals($expected, $this->themingController->getImage('background'));
}
-
- public function testGetStylesheet() {
- $this->appManager->expects($this->once())->method('getAppPath')->with('theming')->willReturn(\OC::$SERVERROOT . '/theming');
- $file = $this->createMock(ISimpleFile::class);
- $file->expects($this->any())->method('getName')->willReturn('theming.css');
- $file->expects($this->any())->method('getMTime')->willReturn(42);
- $file->expects($this->any())->method('getContent')->willReturn('compiled');
- $this->scssCacher->expects($this->once())->method('process')->willReturn(true);
- $this->scssCacher->expects($this->once())->method('getCachedCSS')->willReturn($file);
-
- $response = new Http\FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'text/css']);
- $response->cacheFor(86400);
-
- $actual = $this->themingController->getStylesheet();
- $this->assertEquals($response, $actual);
- }
-
- public function testGetStylesheetFails() {
- $this->appManager->expects($this->once())->method('getAppPath')->with('theming')->willReturn(\OC::$SERVERROOT . '/theming');
- $file = $this->createMock(ISimpleFile::class);
- $file->expects($this->any())->method('getName')->willReturn('theming.css');
- $file->expects($this->any())->method('getMTime')->willReturn(42);
- $file->expects($this->any())->method('getContent')->willReturn('compiled');
- $this->scssCacher->expects($this->once())->method('process')->willReturn(true);
- $this->scssCacher->expects($this->once())->method('getCachedCSS')->willThrowException(new NotFoundException());
- $response = new Http\NotFoundResponse();
-
- $actual = $this->themingController->getStylesheet();
- $this->assertEquals($response, $actual);
- }
-
- public function testGetStylesheetOutsideServerroot() {
- $this->appManager->expects($this->once())->method('getAppPath')->with('theming')->willReturn('/outside/serverroot/theming');
- $file = $this->createMock(ISimpleFile::class);
- $file->expects($this->any())->method('getName')->willReturn('theming.css');
- $file->expects($this->any())->method('getMTime')->willReturn(42);
- $file->expects($this->any())->method('getContent')->willReturn('compiled');
- $this->scssCacher->expects($this->once())->method('process')->with('/outside/serverroot/theming', 'css/theming.scss', 'theming')->willReturn(true);
- $this->scssCacher->expects($this->once())->method('getCachedCSS')->willReturn($file);
-
- $response = new Http\FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'text/css']);
- $response->cacheFor(86400);
-
- $actual = $this->themingController->getStylesheet();
- $this->assertEquals($response, $actual);
- }
-
public function testGetManifest() {
$this->config
->expects($this->once())
diff --git a/apps/theming/tests/Controller/UserThemeControllerTest.php b/apps/theming/tests/Controller/UserThemeControllerTest.php
new file mode 100644
index 00000000000..99e36938e74
--- /dev/null
+++ b/apps/theming/tests/Controller/UserThemeControllerTest.php
@@ -0,0 +1,153 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @author Bjoern Schiessle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
+ * @author Daniel Calviño Sánchez <danxuliu@gmail.com>
+ * @author Joas Schilling <coding@schilljs.com>
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ * @author Julius Haertl <jus@bitgrid.net>
+ * @author Julius Härtl <jus@bitgrid.net>
+ * @author Kyle Fazzari <kyrofa@ubuntu.com>
+ * @author Lukas Reschke <lukas@statuscode.ch>
+ * @author Michael Weimann <mail@michael-weimann.eu>
+ * @author rakekniven <mark.ziegler@rakekniven.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/>.
+ *
+ */
+namespace OCA\Theming\Tests\Controller;
+
+use OCA\Theming\Controller\UserThemeController;
+use OCA\Theming\ITheme;
+use OCA\Theming\Themes\DarkHighContrastTheme;
+use OCA\Theming\Themes\DarkTheme;
+use OCA\Theming\Themes\DefaultTheme;
+use OCA\Theming\Themes\DyslexiaFont;
+use OCA\Theming\Themes\HighContrastTheme;
+use OCA\Theming\Service\ThemesService;
+use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\OCS\OCSBadRequestException;
+use OCP\IConfig;
+use OCP\IRequest;
+use OCP\IUser;
+use OCP\IUserSession;
+use PHPUnit\Framework\MockObject\MockObject;
+use Test\TestCase;
+
+class UserThemeControllerTest extends TestCase {
+ /** @var UserThemeController */
+ private $userThemeController;
+
+ /** @var IRequest|MockObject */
+ private $request;
+ /** @var IConfig|MockObject */
+ private $config;
+ /** @var IUserSession|MockObject */
+ private $userSession;
+ /** @var ThemeService|MockObject */
+ private $themesService;
+
+ /** @var ITheme[] */
+ private $themes;
+
+ protected function setUp(): void {
+ $this->request = $this->createMock(IRequest::class);
+ $this->config = $this->createMock(IConfig::class);
+ $this->userSession = $this->createMock(IUserSession::class);
+ $this->themesService = $this->createMock(ThemesService::class);
+
+ $this->themes = [
+ 'default' => $this->createMock(DefaultTheme::class),
+ 'dark' => $this->createMock(DarkTheme::class),
+ 'highcontrast' => $this->createMock(HighContrastTheme::class),
+ 'dark-highcontrast' => $this->createMock(DarkHighContrastTheme::class),
+ 'opendyslexic' => $this->createMock(DyslexiaFont::class),
+ ];
+
+ $user = $this->createMock(IUser::class);
+ $this->userSession->expects($this->any())
+ ->method('getUser')
+ ->willReturn($user);
+ $user->expects($this->any())
+ ->method('getUID')
+ ->willReturn('user');
+
+ $this->userThemeController = new UserThemeController(
+ 'theming',
+ $this->request,
+ $this->config,
+ $this->userSession,
+ $this->themesService,
+ );
+
+ parent::setUp();
+ }
+
+ public function dataTestThemes() {
+ return [
+ ['default'],
+ ['dark'],
+ ['highcontrast'],
+ ['dark-highcontrast'],
+ ['opendyslexic'],
+ ['', OCSBadRequestException::class],
+ ['badTheme', OCSBadRequestException::class],
+ ];
+ }
+
+ /**
+ * @dataProvider dataTestThemes
+ *
+ * @param string $themeId
+ * @param string $exception
+ */
+ public function testEnableTheme($themeId, string $exception = null) {
+ $this->themesService
+ ->expects($this->any())
+ ->method('getThemes')
+ ->willReturn($this->themes);
+
+ if ($exception) {
+ $this->expectException($exception);
+ }
+
+ $expected = new DataResponse();
+ $this->assertEquals($expected, $this->userThemeController->enableTheme($themeId));
+ }
+
+ /**
+ * @dataProvider dataTestThemes
+ *
+ * @param string $themeId
+ * @param string $exception
+ */
+ public function testDisableTheme($themeId, string $exception = null) {
+ $this->themesService
+ ->expects($this->any())
+ ->method('getThemes')
+ ->willReturn($this->themes);
+
+ if ($exception) {
+ $this->expectException($exception);
+ }
+
+ $expected = new DataResponse();
+ $this->assertEquals($expected, $this->userThemeController->disableTheme($themeId));
+ }
+}
diff --git a/apps/theming/tests/Service/ThemesServiceTest.php b/apps/theming/tests/Service/ThemesServiceTest.php
new file mode 100644
index 00000000000..64f461c88a7
--- /dev/null
+++ b/apps/theming/tests/Service/ThemesServiceTest.php
@@ -0,0 +1,255 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @author Bjoern Schiessle <bjoern@schiessle.org>
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
+ * @author Daniel Calviño Sánchez <danxuliu@gmail.com>
+ * @author Joas Schilling <coding@schilljs.com>
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ * @author Julius Haertl <jus@bitgrid.net>
+ * @author Julius Härtl <jus@bitgrid.net>
+ * @author Kyle Fazzari <kyrofa@ubuntu.com>
+ * @author Lukas Reschke <lukas@statuscode.ch>
+ * @author Michael Weimann <mail@michael-weimann.eu>
+ * @author rakekniven <mark.ziegler@rakekniven.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/>.
+ *
+ */
+namespace OCA\Theming\Tests\Service;
+
+use OCA\Theming\AppInfo\Application;
+use OCA\Theming\ImageManager;
+use OCA\Theming\ITheme;
+use OCA\Theming\Themes\DarkHighContrastTheme;
+use OCA\Theming\Themes\DarkTheme;
+use OCA\Theming\Themes\DefaultTheme;
+use OCA\Theming\Themes\DyslexiaFont;
+use OCA\Theming\Themes\HighContrastTheme;
+use OCA\Theming\Service\ThemesService;
+use OCA\Theming\ThemingDefaults;
+use OCA\Theming\Util;
+use OCP\AppFramework\Http\DataResponse;
+use OCP\AppFramework\OCS\OCSBadRequestException;
+use OCP\IConfig;
+use OCP\IL10N;
+use OCP\IRequest;
+use OCP\IURLGenerator;
+use OCP\IUser;
+use OCP\IUserSession;
+use PHPUnit\Framework\MockObject\MockObject;
+use Test\TestCase;
+
+class UserThemeControllerTest extends TestCase {
+ /** @var ThemesService */
+ private $themesService;
+
+ /** @var IUserSession|MockObject */
+ private $userSession;
+ /** @var IConfig|MockObject */
+ private $config;
+ /** @var ThemingDefaults|MockObject */
+ private $themingDefaults;
+
+ /** @var ITheme[] */
+ private $themes;
+
+ protected function setUp(): void {
+ $this->userSession = $this->createMock(IUserSession::class);
+ $this->config = $this->createMock(IConfig::class);
+ $this->themingDefaults = $this->createMock(ThemingDefaults::class);
+
+ $this->themingDefaults->expects($this->any())
+ ->method('getColorPrimary')
+ ->willReturn('#0082c9');
+
+ $this->initThemes();
+
+ $this->themesService = new ThemesService(
+ $this->userSession,
+ $this->config,
+ ...array_values($this->themes)
+ );
+
+ parent::setUp();
+ }
+
+ public function testGetThemes() {
+ $expected = [
+ 'default',
+ 'dark',
+ 'highcontrast',
+ 'dark-highcontrast',
+ 'opendyslexic',
+ ];
+ $this->assertEquals($expected, array_keys($this->themesService->getThemes()));
+ }
+
+
+ public function dataTestEnableTheme() {
+ return [
+ ['dark', [], ['dark']],
+ ['dark', ['dark'], ['dark']],
+ ['opendyslexic', ['dark'], ['dark', 'opendyslexic']],
+ ['dark', ['highcontrast', 'opendyslexic'], ['opendyslexic', 'dark']],
+ ];
+ }
+
+ /**
+ * @dataProvider dataTestEnableTheme
+ *
+ * @param string $toEnable
+ * @param string[] $enabledThemes
+ * @param string[] $expectedEnabled
+ */
+ public function testEnableTheme(string $toEnable, array $enabledThemes, array $expectedEnabled) {
+ $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', Application::APP_ID, 'enabled-themes', '[]')
+ ->willReturn(json_encode($enabledThemes));
+
+ $this->assertEquals($expectedEnabled, $this->themesService->enableTheme($this->themes[$toEnable]));
+ }
+
+
+ public function dataTestDisableTheme() {
+ return [
+ ['dark', [], []],
+ ['dark', ['dark'], []],
+ ['opendyslexic', ['dark', 'opendyslexic'], ['dark'], ],
+ ['highcontrast', ['opendyslexic'], ['opendyslexic']],
+ ];
+ }
+
+ /**
+ * @dataProvider dataTestDisableTheme
+ *
+ * @param string $toEnable
+ * @param string[] $enabledThemes
+ * @param string[] $expectedEnabled
+ */
+ public function testDisableTheme(string $toDisable, array $enabledThemes, array $expectedEnabled) {
+ $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', Application::APP_ID, 'enabled-themes', '[]')
+ ->willReturn(json_encode($enabledThemes));
+
+
+ $this->assertEquals($expectedEnabled, $this->themesService->disableTheme($this->themes[$toDisable]));
+ }
+
+
+ public function dataTestIsEnabled() {
+ return [
+ ['dark', [], false],
+ ['dark', ['dark'], true],
+ ['opendyslexic', ['dark', 'opendyslexic'], true],
+ ['highcontrast', ['opendyslexic'], false],
+ ];
+ }
+
+ /**
+ * @dataProvider dataTestIsEnabled
+ *
+ * @param string $toEnable
+ * @param string[] $enabledThemes
+ */
+ public function testisEnabled(string $themeId, array $enabledThemes, $expected) {
+ $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', Application::APP_ID, 'enabled-themes', '[]')
+ ->willReturn(json_encode($enabledThemes));
+
+
+ $this->assertEquals($expected, $this->themesService->isEnabled($this->themes[$themeId]));
+ }
+
+ private function initThemes() {
+ $util = $this->createMock(Util::class);
+ $urlGenerator = $this->createMock(IURLGenerator::class);
+ $imageManager = $this->createMock(ImageManager::class);
+ $l10n = $this->createMock(IL10N::class);
+
+ $this->themes = [
+ 'default' => new DefaultTheme(
+ $util,
+ $this->themingDefaults,
+ $urlGenerator,
+ $imageManager,
+ $this->config,
+ $l10n,
+ ),
+ 'dark' => new DarkTheme(
+ $util,
+ $this->themingDefaults,
+ $urlGenerator,
+ $imageManager,
+ $this->config,
+ $l10n,
+ ),
+ 'highcontrast' => new HighContrastTheme(
+ $util,
+ $this->themingDefaults,
+ $urlGenerator,
+ $imageManager,
+ $this->config,
+ $l10n,
+ ),
+ 'dark-highcontrast' => new DarkHighContrastTheme(
+ $util,
+ $this->themingDefaults,
+ $urlGenerator,
+ $imageManager,
+ $this->config,
+ $l10n,
+ ),
+ 'opendyslexic' => new DyslexiaFont(
+ $util,
+ $this->themingDefaults,
+ $urlGenerator,
+ $imageManager,
+ $this->config,
+ $l10n,
+ ),
+ ];
+ }
+}
diff --git a/apps/theming/tests/ServicesTest.php b/apps/theming/tests/ServicesTest.php
index fdd49deddd8..441e5d55044 100644
--- a/apps/theming/tests/ServicesTest.php
+++ b/apps/theming/tests/ServicesTest.php
@@ -28,7 +28,7 @@ namespace OCA\Theming\Tests;
use OCA\Theming\Capabilities;
use OCA\Theming\Controller\ThemingController;
use OCA\Theming\Settings\Admin;
-use OCA\Theming\Settings\Section;
+use OCA\Theming\Settings\PersonalSection;
use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util;
use OCP\AppFramework\App;
@@ -74,8 +74,8 @@ class ServicesTest extends TestCase {
// Settings
[Admin::class],
[Admin::class, ISettings::class],
- [Section::class],
- [Section::class, IIconSection::class],
+ [PersonalSection::class],
+ [PersonalSection::class, IIconSection::class],
];
}
diff --git a/apps/theming/tests/Settings/AdminTest.php b/apps/theming/tests/Settings/AdminTest.php
index 50b95fe7e99..b10196a1ac5 100644
--- a/apps/theming/tests/Settings/AdminTest.php
+++ b/apps/theming/tests/Settings/AdminTest.php
@@ -27,6 +27,7 @@
*/
namespace OCA\Theming\Tests\Settings;
+use OCA\Theming\AppInfo\Application;
use OCA\Theming\ImageManager;
use OCA\Theming\Settings\Admin;
use OCA\Theming\ThemingDefaults;
@@ -59,6 +60,7 @@ class AdminTest extends TestCase {
$this->imageManager = $this->createMock(ImageManager::class);
$this->admin = new Admin(
+ Application::APP_ID,
$this->config,
$this->l10n,
$this->themingDefaults,
diff --git a/apps/theming/tests/Settings/SectionTest.php b/apps/theming/tests/Settings/SectionTest.php
index 496c24b3e52..c168f13728d 100644
--- a/apps/theming/tests/Settings/SectionTest.php
+++ b/apps/theming/tests/Settings/SectionTest.php
@@ -23,7 +23,8 @@
*/
namespace OCA\Theming\Tests\Settings;
-use OCA\Theming\Settings\Section;
+use OCA\Theming\AppInfo\Application;
+use OCA\Theming\Settings\AdminSection;
use OCP\IL10N;
use OCP\IURLGenerator;
use Test\TestCase;
@@ -33,7 +34,7 @@ class SectionTest extends TestCase {
private $url;
/** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
private $l;
- /** @var Section */
+ /** @var AdminSection */
private $section;
protected function setUp(): void {
@@ -41,7 +42,8 @@ class SectionTest extends TestCase {
$this->url = $this->createMock(IURLGenerator::class);
$this->l = $this->createMock(IL10N::class);
- $this->section = new Section(
+ $this->section = new AdminSection(
+ Application::APP_ID,
$this->url,
$this->l
);
diff --git a/apps/theming/tests/UtilTest.php b/apps/theming/tests/UtilTest.php
index f805d083e27..914ad8b073f 100644
--- a/apps/theming/tests/UtilTest.php
+++ b/apps/theming/tests/UtilTest.php
@@ -90,14 +90,15 @@ class UtilTest extends TestCase {
$luminance = $this->util->calculateLuminance('#000');
$this->assertEquals(0, $luminance);
}
+
public function testInvertTextColorInvalid() {
- $invert = $this->util->invertTextColor('aaabbbcccddd123');
- $this->assertEquals(false, $invert);
+ $this->expectException(\Exception::class);
+ $this->util->invertTextColor('aaabbbcccddd123');
}
public function testInvertTextColorEmpty() {
- $invert = $this->util->invertTextColor('');
- $this->assertEquals(false, $invert);
+ $this->expectException(\Exception::class);
+ $this->util->invertTextColor('');
}
public function testElementColorDefault() {