aboutsummaryrefslogtreecommitdiffstats
path: root/apps/theming/tests/Controller/ThemingControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/theming/tests/Controller/ThemingControllerTest.php')
-rw-r--r--apps/theming/tests/Controller/ThemingControllerTest.php114
1 files changed, 48 insertions, 66 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php
index 6dfbb72bb77..fb461f03a28 100644
--- a/apps/theming/tests/Controller/ThemingControllerTest.php
+++ b/apps/theming/tests/Controller/ThemingControllerTest.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -82,7 +84,7 @@ class ThemingControllerTest extends TestCase {
parent::setUp();
}
- public function dataUpdateStylesheetSuccess() {
+ public static function dataUpdateStylesheetSuccess(): array {
return [
['name', str_repeat('a', 250), 'Saved'],
['url', 'https://nextcloud.com/' . str_repeat('a', 478), 'Saved'],
@@ -95,14 +97,8 @@ class ThemingControllerTest extends TestCase {
];
}
- /**
- * @dataProvider dataUpdateStylesheetSuccess
- *
- * @param string $setting
- * @param string $value
- * @param string $message
- */
- public function testUpdateStylesheetSuccess($setting, $value, $message): void {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataUpdateStylesheetSuccess')]
+ public function testUpdateStylesheetSuccess(string $setting, string $value, string $message): void {
$this->themingDefaults
->expects($this->once())
->method('set')
@@ -116,8 +112,8 @@ class ThemingControllerTest extends TestCase {
$expected = new DataResponse(
[
- 'data' =>
- [
+ 'data'
+ => [
'message' => $message,
],
'status' => 'success',
@@ -126,7 +122,7 @@ class ThemingControllerTest extends TestCase {
$this->assertEquals($expected, $this->themingController->updateStylesheet($setting, $value));
}
- public function dataUpdateStylesheetError() {
+ public static function dataUpdateStylesheetError(): array {
$urls = [
'url' => 'web address',
'imprintUrl' => 'legal notice address',
@@ -157,14 +153,8 @@ class ThemingControllerTest extends TestCase {
];
}
- /**
- * @dataProvider dataUpdateStylesheetError
- *
- * @param string $setting
- * @param string $value
- * @param string $message
- */
- public function testUpdateStylesheetError($setting, $value, $message): void {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataUpdateStylesheetError')]
+ public function testUpdateStylesheetError(string $setting, string $value, string $message): void {
$this->themingDefaults
->expects($this->never())
->method('set')
@@ -178,8 +168,8 @@ class ThemingControllerTest extends TestCase {
$expected = new DataResponse(
[
- 'data' =>
- [
+ 'data'
+ => [
'message' => $message,
],
'status' => 'error',
@@ -209,8 +199,8 @@ class ThemingControllerTest extends TestCase {
$expected = new DataResponse(
[
- 'data' =>
- [
+ 'data'
+ => [
'message' => 'No file uploaded',
],
'status' => 'failure',
@@ -239,8 +229,8 @@ class ThemingControllerTest extends TestCase {
$expected = new DataResponse(
[
- 'data' =>
- [
+ 'data'
+ => [
'message' => 'Invalid key',
],
'status' => 'failure',
@@ -254,9 +244,6 @@ class ThemingControllerTest extends TestCase {
/**
* Checks that trying to upload an SVG favicon without imagemagick
* results in an unsupported media type response.
- *
- * @test
- * @return void
*/
public function testUploadSVGFaviconWithoutImagemagick(): void {
$this->imageManager
@@ -291,8 +278,8 @@ class ThemingControllerTest extends TestCase {
$expected = new DataResponse(
[
- 'data' =>
- [
+ 'data'
+ => [
'message' => 'Unsupported image type',
],
'status' => 'failure'
@@ -332,8 +319,8 @@ class ThemingControllerTest extends TestCase {
$expected = new DataResponse(
[
- 'data' =>
- [
+ 'data'
+ => [
'message' => 'Unsupported image type',
],
'status' => 'failure'
@@ -344,7 +331,7 @@ class ThemingControllerTest extends TestCase {
$this->assertEquals($expected, $this->themingController->uploadImage());
}
- public function dataUpdateImages() {
+ public static function dataUpdateImages(): array {
return [
['image/jpeg', false],
['image/jpeg', true],
@@ -355,8 +342,8 @@ class ThemingControllerTest extends TestCase {
];
}
- /** @dataProvider dataUpdateImages */
- public function testUpdateLogoNormalLogoUpload($mimeType, $folderExists = true): void {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataUpdateImages')]
+ public function testUpdateLogoNormalLogoUpload(string $mimeType, bool $folderExists = true): void {
$tmpLogo = Server::get(ITempManager::class)->getTemporaryFolder() . '/logo.svg';
$destination = Server::get(ITempManager::class)->getTemporaryFolder();
@@ -394,8 +381,8 @@ class ThemingControllerTest extends TestCase {
$expected = new DataResponse(
[
- 'data' =>
- [
+ 'data'
+ => [
'name' => 'logo.svg',
'message' => 'Saved',
'url' => 'imageUrl',
@@ -407,8 +394,7 @@ class ThemingControllerTest extends TestCase {
$this->assertEquals($expected, $this->themingController->uploadImage());
}
- /** @dataProvider dataUpdateImages */
- public function testUpdateLogoLoginScreenUpload($folderExists): void {
+ public function testUpdateLogoLoginScreenUpload(): void {
$tmpLogo = Server::get(ITempManager::class)->getTemporaryFolder() . 'logo.png';
touch($tmpLogo);
@@ -444,8 +430,8 @@ class ThemingControllerTest extends TestCase {
->willReturn('imageUrl');
$expected = new DataResponse(
[
- 'data' =>
- [
+ 'data'
+ => [
'name' => 'logo.svg',
'message' => 'Saved',
'url' => 'imageUrl',
@@ -489,8 +475,8 @@ class ThemingControllerTest extends TestCase {
$expected = new DataResponse(
[
- 'data' =>
- [
+ 'data'
+ => [
'message' => 'Unsupported image type',
],
'status' => 'failure'
@@ -500,7 +486,7 @@ class ThemingControllerTest extends TestCase {
$this->assertEquals($expected, $this->themingController->uploadImage());
}
- public function dataPhpUploadErrors() {
+ public static function dataPhpUploadErrors(): array {
return [
[UPLOAD_ERR_INI_SIZE, 'The uploaded file exceeds the upload_max_filesize directive in php.ini'],
[UPLOAD_ERR_FORM_SIZE, 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'],
@@ -512,10 +498,8 @@ class ThemingControllerTest extends TestCase {
];
}
- /**
- * @dataProvider dataPhpUploadErrors
- */
- public function testUpdateLogoLoginScreenUploadWithInvalidImageUpload($error, $expectedErrorMessage): void {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataPhpUploadErrors')]
+ public function testUpdateLogoLoginScreenUploadWithInvalidImageUpload(int $error, string $expectedErrorMessage): void {
$this->request
->expects($this->once())
->method('getParam')
@@ -540,8 +524,8 @@ class ThemingControllerTest extends TestCase {
$expected = new DataResponse(
[
- 'data' =>
- [
+ 'data'
+ => [
'message' => $expectedErrorMessage,
],
'status' => 'failure'
@@ -551,9 +535,7 @@ class ThemingControllerTest extends TestCase {
$this->assertEquals($expected, $this->themingController->uploadImage());
}
- /**
- * @dataProvider dataPhpUploadErrors
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataPhpUploadErrors')]
public function testUpdateLogoUploadWithInvalidImageUpload($error, $expectedErrorMessage): void {
$this->request
->expects($this->once())
@@ -579,8 +561,8 @@ class ThemingControllerTest extends TestCase {
$expected = new DataResponse(
[
- 'data' =>
- [
+ 'data'
+ => [
'message' => $expectedErrorMessage
],
'status' => 'failure'
@@ -604,8 +586,8 @@ class ThemingControllerTest extends TestCase {
$expected = new DataResponse(
[
- 'data' =>
- [
+ 'data'
+ => [
'value' => 'MyValue',
'message' => 'Saved'
],
@@ -615,15 +597,15 @@ class ThemingControllerTest extends TestCase {
$this->assertEquals($expected, $this->themingController->undo('MySetting'));
}
- public function dataUndoDelete() {
+ public static function dataUndoDelete(): array {
return [
[ 'backgroundMime', 'background' ],
[ 'logoMime', 'logo' ]
];
}
- /** @dataProvider dataUndoDelete */
- public function testUndoDelete($value, $filename): void {
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataUndoDelete')]
+ public function testUndoDelete(string $value, string $filename): void {
$this->l10n
->expects($this->once())
->method('t')
@@ -637,8 +619,8 @@ class ThemingControllerTest extends TestCase {
$expected = new DataResponse(
[
- 'data' =>
- [
+ 'data'
+ => [
'value' => $value,
'message' => 'Saved',
],
@@ -722,7 +704,7 @@ class ThemingControllerTest extends TestCase {
];
}
- /** @dataProvider dataGetManifest */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataGetManifest')]
public function testGetManifest(bool $standalone): void {
$this->config
->expects($this->once())
@@ -752,8 +734,8 @@ class ThemingControllerTest extends TestCase {
$response = new JSONResponse([
'name' => 'Nextcloud',
'start_url' => 'localhost',
- 'icons' =>
- [
+ 'icons'
+ => [
[
'src' => 'touchicon?v=0',
'type' => 'image/png',