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:
Diffstat (limited to 'apps/theming/tests/Controller/IconControllerTest.php')
-rw-r--r--apps/theming/tests/Controller/IconControllerTest.php44
1 files changed, 22 insertions, 22 deletions
diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php
index d92677e1f84..6539c6e0209 100644
--- a/apps/theming/tests/Controller/IconControllerTest.php
+++ b/apps/theming/tests/Controller/IconControllerTest.php
@@ -33,7 +33,6 @@ use OCA\Theming\ImageManager;
use OCA\Theming\ThemingDefaults;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataDisplayResponse;
-use OCP\AppFramework\Http\NotFoundResponse;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IRequest;
@@ -41,6 +40,7 @@ use Test\TestCase;
use OCA\Theming\Util;
use OCA\Theming\Controller\IconController;
use OCP\AppFramework\Http\FileDisplayResponse;
+use OCP\AppFramework\Utility\ITimeFactory;
class IconControllerTest extends TestCase {
@@ -48,8 +48,6 @@ class IconControllerTest extends TestCase {
private $request;
/** @var ThemingDefaults|\PHPUnit_Framework_MockObject_MockObject */
private $themingDefaults;
- /** @var Util */
- private $util;
/** @var \OCP\AppFramework\Utility\ITimeFactory */
private $timeFactory;
/** @var IconController|\PHPUnit_Framework_MockObject_MockObject */
@@ -64,18 +62,11 @@ class IconControllerTest extends TestCase {
private $imageManager;
public function setUp() {
- $this->request = $this->getMockBuilder(IRequest::class)->getMock();
- $this->themingDefaults = $this->getMockBuilder('OCA\Theming\ThemingDefaults')
- ->disableOriginalConstructor()->getMock();
- $this->util = $this->getMockBuilder('\OCA\Theming\Util')->disableOriginalConstructor()
- ->setMethods(['getAppImage', 'getAppIcon', 'elementColor'])->getMock();
- $this->timeFactory = $this->getMockBuilder('OCP\AppFramework\Utility\ITimeFactory')
- ->disableOriginalConstructor()
- ->getMock();
- $this->config = $this->getMockBuilder(IConfig::class)->getMock();
- $this->iconBuilder = $this->getMockBuilder('OCA\Theming\IconBuilder')
- ->disableOriginalConstructor()->getMock();
- $this->imageManager = $this->getMockBuilder('OCA\Theming\ImageManager')->disableOriginalConstructor()->getMock();
+ $this->request = $this->createMock(IRequest::class);
+ $this->themingDefaults = $this->createMock(ThemingDefaults::class);
+ $this->timeFactory = $this->createMock(ITimeFactory::class);
+ $this->iconBuilder = $this->createMock(IconBuilder::class);
+ $this->imageManager = $this->createMock(ImageManager::class);
$this->fileAccessHelper = $this->createMock(FileAccessHelper::class);
$this->timeFactory->expects($this->any())
->method('getTime')
@@ -85,9 +76,7 @@ class IconControllerTest extends TestCase {
'theming',
$this->request,
$this->themingDefaults,
- $this->util,
$this->timeFactory,
- $this->config,
$this->iconBuilder,
$this->imageManager,
$this->fileAccessHelper
@@ -129,18 +118,21 @@ class IconControllerTest extends TestCase {
if (count($checkImagick->queryFormats('SVG')) < 1) {
$this->markTestSkipped('No SVG provider present.');
}
+ $file = $this->iconFileMock('filename', 'filecontent');
+ $this->imageManager->expects($this->once())
+ ->method('getImage')
+ ->with('favicon')
+ ->will($this->throwException(new NotFoundException()));
$this->themingDefaults->expects($this->any())
->method('shouldReplaceIcons')
->willReturn(true);
-
+ $this->imageManager->expects($this->once())
+ ->method('getCachedImage')
+ ->will($this->throwException(new NotFoundException()));
$this->iconBuilder->expects($this->once())
->method('getFavicon')
->with('core')
->willReturn('filecontent');
- $file = $this->iconFileMock('filename', 'filecontent');
- $this->imageManager->expects($this->once())
- ->method('getCachedImage')
- ->will($this->throwException(new NotFoundException()));
$this->imageManager->expects($this->once())
->method('setCachedImage')
->willReturn($file);
@@ -156,6 +148,10 @@ class IconControllerTest extends TestCase {
}
public function testGetFaviconFail() {
+ $this->imageManager->expects($this->once())
+ ->method('getImage')
+ ->with('favicon')
+ ->will($this->throwException(new NotFoundException()));
$this->themingDefaults->expects($this->any())
->method('shouldReplaceIcons')
->willReturn(false);
@@ -209,6 +205,10 @@ class IconControllerTest extends TestCase {
}
public function testGetTouchIconFail() {
+ $this->imageManager->expects($this->once())
+ ->method('getImage')
+ ->with('favicon')
+ ->will($this->throwException(new NotFoundException()));
$this->themingDefaults->expects($this->any())
->method('shouldReplaceIcons')
->willReturn(false);