aboutsummaryrefslogtreecommitdiffstats
path: root/apps/theming/tests/Controller/IconControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/theming/tests/Controller/IconControllerTest.php')
-rw-r--r--apps/theming/tests/Controller/IconControllerTest.php52
1 files changed, 22 insertions, 30 deletions
diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php
index e0159c03082..c5034600e03 100644
--- a/apps/theming/tests/Controller/IconControllerTest.php
+++ b/apps/theming/tests/Controller/IconControllerTest.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
@@ -17,29 +19,19 @@ use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\NotFoundException;
-use OCP\IConfig;
use OCP\IRequest;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class IconControllerTest extends TestCase {
- /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
- private $request;
- /** @var ThemingDefaults|\PHPUnit\Framework\MockObject\MockObject */
- private $themingDefaults;
- /** @var \OCP\AppFramework\Utility\ITimeFactory */
- private $timeFactory;
- /** @var IconController|\PHPUnit\Framework\MockObject\MockObject */
- private $iconController;
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
- private $config;
- /** @var IconBuilder|\PHPUnit\Framework\MockObject\MockObject */
- private $iconBuilder;
- /** @var FileAccessHelper|\PHPUnit\Framework\MockObject\MockObject */
- private $fileAccessHelper;
- /** @var IAppManager|\PHPUnit\Framework\MockObject\MockObject */
- private $appManager;
- /** @var ImageManager */
- private $imageManager;
+ private IRequest&MockObject $request;
+ private ThemingDefaults&MockObject $themingDefaults;
+ private ITimeFactory&MockObject $timeFactory;
+ private IconBuilder&MockObject $iconBuilder;
+ private FileAccessHelper&MockObject $fileAccessHelper;
+ private IAppManager&MockObject $appManager;
+ private ImageManager&MockObject $imageManager;
+ private IconController $iconController;
protected function setUp(): void {
$this->request = $this->createMock(IRequest::class);
@@ -80,7 +72,7 @@ class IconControllerTest extends TestCase {
return new SimpleFile($icon);
}
- public function testGetThemedIcon() {
+ public function testGetThemedIcon(): void {
$file = $this->iconFileMock('icon-core-filetypes_folder.svg', 'filecontent');
$this->imageManager->expects($this->once())
->method('getCachedImage')
@@ -91,7 +83,7 @@ class IconControllerTest extends TestCase {
$this->assertEquals($expected, $this->iconController->getThemedIcon('core', 'filetypes/folder.svg'));
}
- public function testGetFaviconDefault() {
+ public function testGetFaviconDefault(): void {
if (!extension_loaded('imagick')) {
$this->markTestSkipped('Imagemagick is required for dynamic icon generation.');
}
@@ -103,13 +95,13 @@ class IconControllerTest extends TestCase {
$this->imageManager->expects($this->once())
->method('getImage', false)
->with('favicon')
- ->will($this->throwException(new NotFoundException()));
+ ->willThrowException(new NotFoundException());
$this->imageManager->expects($this->any())
->method('shouldReplaceIcons')
->willReturn(true);
$this->imageManager->expects($this->once())
->method('getCachedImage')
- ->will($this->throwException(new NotFoundException()));
+ ->willThrowException(new NotFoundException());
$this->iconBuilder->expects($this->once())
->method('getFavicon')
->with('core')
@@ -123,11 +115,11 @@ class IconControllerTest extends TestCase {
$this->assertEquals($expected, $this->iconController->getFavicon());
}
- public function testGetFaviconFail() {
+ public function testGetFaviconFail(): void {
$this->imageManager->expects($this->once())
->method('getImage')
->with('favicon', false)
- ->will($this->throwException(new NotFoundException()));
+ ->willThrowException(new NotFoundException());
$this->imageManager->expects($this->any())
->method('shouldReplaceIcons')
->willReturn(false);
@@ -141,7 +133,7 @@ class IconControllerTest extends TestCase {
$this->assertEquals($expected, $this->iconController->getFavicon());
}
- public function testGetTouchIconDefault() {
+ public function testGetTouchIconDefault(): void {
if (!extension_loaded('imagick')) {
$this->markTestSkipped('Imagemagick is required for dynamic icon generation.');
}
@@ -152,7 +144,7 @@ class IconControllerTest extends TestCase {
$this->imageManager->expects($this->once())
->method('getImage')
- ->will($this->throwException(new NotFoundException()));
+ ->willThrowException(new NotFoundException());
$this->imageManager->expects($this->any())
->method('shouldReplaceIcons')
->willReturn(true);
@@ -163,7 +155,7 @@ class IconControllerTest extends TestCase {
$file = $this->iconFileMock('filename', 'filecontent');
$this->imageManager->expects($this->once())
->method('getCachedImage')
- ->will($this->throwException(new NotFoundException()));
+ ->willThrowException(new NotFoundException());
$this->imageManager->expects($this->once())
->method('setCachedImage')
->willReturn($file);
@@ -173,11 +165,11 @@ class IconControllerTest extends TestCase {
$this->assertEquals($expected, $this->iconController->getTouchIcon());
}
- public function testGetTouchIconFail() {
+ public function testGetTouchIconFail(): void {
$this->imageManager->expects($this->once())
->method('getImage')
->with('favicon')
- ->will($this->throwException(new NotFoundException()));
+ ->willThrowException(new NotFoundException());
$this->imageManager->expects($this->any())
->method('shouldReplaceIcons')
->willReturn(false);