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/ThemingControllerTest.php')
-rw-r--r--apps/theming/tests/Controller/ThemingControllerTest.php109
1 files changed, 26 insertions, 83 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php
index 6fc5cf28fbf..5c6763cdd17 100644
--- a/apps/theming/tests/Controller/ThemingControllerTest.php
+++ b/apps/theming/tests/Controller/ThemingControllerTest.php
@@ -47,34 +47,32 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
-use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\ITempManager;
use OCP\IURLGenerator;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class ThemingControllerTest extends TestCase {
- /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IRequest|MockObject */
private $request;
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IConfig|MockObject */
private $config;
- /** @var ThemingDefaults|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var ThemingDefaults|MockObject */
private $themingDefaults;
- /** @var \OCP\AppFramework\Utility\ITimeFactory */
- private $timeFactory;
- /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IL10N|MockObject */
private $l10n;
/** @var ThemingController */
private $themingController;
/** @var ITempManager */
private $tempManager;
- /** @var IAppManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IAppManager|MockObject */
private $appManager;
- /** @var IAppData|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var IAppData|MockObject */
private $appData;
- /** @var ImageManager|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var ImageManager|MockObject */
private $imageManager;
/** @var SCSSCacher */
private $scssCacher;
@@ -93,12 +91,12 @@ class ThemingControllerTest extends TestCase {
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->imageManager = $this->createMock(ImageManager::class);
- $this->timeFactory = $this->createMock(ITimeFactory::class);
- $this->timeFactory->expects($this->any())
+ $timeFactory = $this->createMock(ITimeFactory::class);
+ $timeFactory->expects($this->any())
->method('getTime')
->willReturn(123);
- $this->overwriteService(ITimeFactory::class, $this->timeFactory);
+ $this->overwriteService(ITimeFactory::class, $timeFactory);
$this->themingController = new ThemingController(
'theming',
@@ -287,12 +285,9 @@ class ThemingControllerTest extends TestCase {
return $str;
});
- $folder = $this->createMock(ISimpleFolder::class);
- $this->appData
- ->expects($this->once())
- ->method('getFolder')
- ->with('images')
- ->willReturn($folder);
+ $this->imageManager->expects($this->once())
+ ->method('updateImage')
+ ->willThrowException(new \Exception('Unsupported image type'));
$expected = new DataResponse(
[
@@ -331,12 +326,9 @@ class ThemingControllerTest extends TestCase {
return $str;
});
- $folder = $this->createMock(ISimpleFolder::class);
- $this->appData
- ->expects($this->once())
- ->method('getFolder')
- ->with('images')
- ->willReturn($folder);
+ $this->imageManager->expects($this->once())
+ ->method('updateImage')
+ ->willThrowException(new \Exception('Unsupported image type'));
$expected = new DataResponse(
[
@@ -392,31 +384,6 @@ class ThemingControllerTest extends TestCase {
return $str;
});
-
- $file = $this->createMock(ISimpleFile::class);
- $folder = $this->createMock(ISimpleFolder::class);
- if ($folderExists) {
- $this->appData
- ->expects($this->once())
- ->method('getFolder')
- ->with('images')
- ->willReturn($folder);
- } else {
- $this->appData
- ->expects($this->at(0))
- ->method('getFolder')
- ->with('images')
- ->willThrowException(new NotFoundException());
- $this->appData
- ->expects($this->at(1))
- ->method('newFolder')
- ->with('images')
- ->willReturn($folder);
- }
- $folder->expects($this->once())
- ->method('newFile')
- ->with('logo')
- ->willReturn($file);
$this->urlGenerator->expects($this->once())
->method('linkTo')
->willReturn('serverCss');
@@ -424,6 +391,10 @@ class ThemingControllerTest extends TestCase {
->method('getImageUrl')
->with('logo')
->willReturn('imageUrl');
+
+ $this->imageManager->expects($this->once())
+ ->method('updateImage');
+
$expected = new DataResponse(
[
'data' =>
@@ -468,30 +439,8 @@ class ThemingControllerTest extends TestCase {
return $str;
});
- $file = $this->createMock(ISimpleFile::class);
- $folder = $this->createMock(ISimpleFolder::class);
- if ($folderExists) {
- $this->appData
- ->expects($this->once())
- ->method('getFolder')
- ->with('images')
- ->willReturn($folder);
- } else {
- $this->appData
- ->expects($this->at(0))
- ->method('getFolder')
- ->with('images')
- ->willThrowException(new NotFoundException());
- $this->appData
- ->expects($this->at(1))
- ->method('newFolder')
- ->with('images')
- ->willReturn($folder);
- }
- $folder->expects($this->once())
- ->method('newFile')
- ->with('background')
- ->willReturn($file);
+ $this->imageManager->expects($this->once())
+ ->method('updateImage');
$this->urlGenerator->expects($this->once())
->method('linkTo')
@@ -542,12 +491,9 @@ class ThemingControllerTest extends TestCase {
return $str;
});
- $folder = $this->createMock(ISimpleFolder::class);
- $this->appData
- ->expects($this->once())
- ->method('getFolder')
- ->with('images')
- ->willReturn($folder);
+ $this->imageManager->expects($this->once())
+ ->method('updateImage')
+ ->willThrowException(new \Exception('Unsupported image type'));
$expected = new DataResponse(
[
@@ -717,9 +663,6 @@ class ThemingControllerTest extends TestCase {
->method('linkTo')
->with('', '/core/css/someHash-css-variables.scss')
->willReturn('/nextcloudWebroot/core/css/someHash-css-variables.scss');
- $this->imageManager->expects($this->once())
- ->method('delete')
- ->with($filename);
$expected = new DataResponse(
[