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:
authorJulius Härtl <jus@bitgrid.net>2018-06-05 17:59:05 +0300
committerJulius Härtl <jus@bitgrid.net>2018-06-06 14:15:52 +0300
commit5b0ce806a3679b34ae3a6f8e6ae32a0b513a4ca9 (patch)
treebdda614353703033cfa26bfd9b8687b2579be3e0 /apps/theming/tests
parentd132527aa9c4baad344b11adef3a6f4a46cde3ab (diff)
Minor fixes and cleanup
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/theming/tests')
-rw-r--r--apps/theming/tests/Controller/IconControllerTest.php13
-rw-r--r--apps/theming/tests/Controller/ThemingControllerTest.php4
-rw-r--r--apps/theming/tests/IconBuilderTest.php23
-rw-r--r--apps/theming/tests/ImageManagerTest.php4
4 files changed, 25 insertions, 19 deletions
diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php
index f509005d32c..cc83bae32a7 100644
--- a/apps/theming/tests/Controller/IconControllerTest.php
+++ b/apps/theming/tests/Controller/IconControllerTest.php
@@ -118,7 +118,7 @@ class IconControllerTest extends TestCase {
->method('getImage')
->with('favicon')
->will($this->throwException(new NotFoundException()));
- $this->themingDefaults->expects($this->any())
+ $this->imageManager->expects($this->any())
->method('shouldReplaceIcons')
->willReturn(true);
$this->imageManager->expects($this->once())
@@ -142,7 +142,7 @@ class IconControllerTest extends TestCase {
->method('getImage')
->with('favicon')
->will($this->throwException(new NotFoundException()));
- $this->themingDefaults->expects($this->any())
+ $this->imageManager->expects($this->any())
->method('shouldReplaceIcons')
->willReturn(false);
$fallbackLogo = \OC::$SERVERROOT . '/core/img/favicon.png';
@@ -163,10 +163,13 @@ class IconControllerTest extends TestCase {
if (count($checkImagick->queryFormats('SVG')) < 1) {
$this->markTestSkipped('No SVG provider present.');
}
- $this->themingDefaults->expects($this->any())
+
+ $this->imageManager->expects($this->once())
+ ->method('getImage')
+ ->will($this->throwException(new NotFoundException()));
+ $this->imageManager->expects($this->any())
->method('shouldReplaceIcons')
->willReturn(true);
-
$this->iconBuilder->expects($this->once())
->method('getTouchIcon')
->with('core')
@@ -189,7 +192,7 @@ class IconControllerTest extends TestCase {
->method('getImage')
->with('favicon')
->will($this->throwException(new NotFoundException()));
- $this->themingDefaults->expects($this->any())
+ $this->imageManager->expects($this->any())
->method('shouldReplaceIcons')
->willReturn(false);
$fallbackLogo = \OC::$SERVERROOT . '/core/img/favicon-touch.png';
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php
index 4a2b780076c..aaed61016e4 100644
--- a/apps/theming/tests/Controller/ThemingControllerTest.php
+++ b/apps/theming/tests/Controller/ThemingControllerTest.php
@@ -688,7 +688,7 @@ class ThemingControllerTest extends TestCase {
->method('getImage')
->willReturn($file);
$this->config
- ->expects($this->once())
+ ->expects($this->any())
->method('getAppValue')
->with('theming', 'logoMime', '')
->willReturn('text/svg');
@@ -716,7 +716,7 @@ class ThemingControllerTest extends TestCase {
->willReturn($file);
$this->config
- ->expects($this->once())
+ ->expects($this->any())
->method('getAppValue')
->with('theming', 'backgroundMime', '')
->willReturn('image/png');
diff --git a/apps/theming/tests/IconBuilderTest.php b/apps/theming/tests/IconBuilderTest.php
index 1b9f204cd9e..994e0e4a045 100644
--- a/apps/theming/tests/IconBuilderTest.php
+++ b/apps/theming/tests/IconBuilderTest.php
@@ -27,6 +27,7 @@ namespace OCA\Theming\Tests;
use OC\Files\AppData\AppData;
use OCA\Theming\IconBuilder;
+use OCA\Theming\ImageManager;
use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util;
use OCP\App\IAppManager;
@@ -45,6 +46,8 @@ class IconBuilderTest extends TestCase {
protected $themingDefaults;
/** @var Util */
protected $util;
+ /** @var ImageManager */
+ protected $imageManager;
/** @var IconBuilder */
protected $iconBuilder;
/** @var IAppManager */
@@ -53,13 +56,13 @@ class IconBuilderTest extends TestCase {
protected function setUp() {
parent::setUp();
- $this->config = $this->getMockBuilder(IConfig::class)->getMock();
+ $this->config = $this->createMock(IConfig::class);
$this->appData = $this->createMock(AppData::class);
- $this->themingDefaults = $this->getMockBuilder('OCA\Theming\ThemingDefaults')
- ->disableOriginalConstructor()->getMock();
- $this->appManager = $this->getMockBuilder('OCP\App\IAppManager')->getMock();
+ $this->themingDefaults = $this->createMock(ThemingDefaults::class);
+ $this->appManager = $this->createMock(IAppManager::class);
+ $this->imageManager = $this->createMock(ImageManager::class);
$this->util = new Util($this->config, $this->appManager, $this->appData);
- $this->iconBuilder = new IconBuilder($this->themingDefaults, $this->util);
+ $this->iconBuilder = new IconBuilder($this->themingDefaults, $this->util, $this->imageManager);
}
private function checkImagick() {
@@ -152,7 +155,7 @@ class IconBuilderTest extends TestCase {
*/
public function testGetFavicon($app, $color, $file) {
$this->checkImagick();
- $this->themingDefaults->expects($this->once())
+ $this->imageManager->expects($this->once())
->method('shouldReplaceIcons')
->willReturn(true);
$this->themingDefaults->expects($this->once())
@@ -183,8 +186,8 @@ class IconBuilderTest extends TestCase {
$this->checkImagick();
$this->expectException(Warning::class);
$util = $this->getMockBuilder(Util::class)->disableOriginalConstructor()->getMock();
- $iconBuilder = new IconBuilder($this->themingDefaults, $util);
- $this->themingDefaults->expects($this->once())
+ $iconBuilder = new IconBuilder($this->themingDefaults, $util, $this->imageManager);
+ $this->imageManager->expects($this->once())
->method('shouldReplaceIcons')
->willReturn(true);
$util->expects($this->once())
@@ -197,7 +200,7 @@ class IconBuilderTest extends TestCase {
$this->checkImagick();
$this->expectException(Warning::class);
$util = $this->getMockBuilder(Util::class)->disableOriginalConstructor()->getMock();
- $iconBuilder = new IconBuilder($this->themingDefaults, $util);
+ $iconBuilder = new IconBuilder($this->themingDefaults, $util, $this->imageManager);
$util->expects($this->once())
->method('getAppIcon')
->willReturn('notexistingfile');
@@ -208,7 +211,7 @@ class IconBuilderTest extends TestCase {
$this->checkImagick();
$this->expectException(Warning::class);
$util = $this->getMockBuilder(Util::class)->disableOriginalConstructor()->getMock();
- $iconBuilder = new IconBuilder($this->themingDefaults, $util);
+ $iconBuilder = new IconBuilder($this->themingDefaults, $util, $this->imageManager);
$util->expects($this->once())
->method('getAppImage')
->willReturn('notexistingfile');
diff --git a/apps/theming/tests/ImageManagerTest.php b/apps/theming/tests/ImageManagerTest.php
index 6912395268e..6bfa5b330a6 100644
--- a/apps/theming/tests/ImageManagerTest.php
+++ b/apps/theming/tests/ImageManagerTest.php
@@ -66,10 +66,10 @@ class ImageManagerTest extends TestCase {
$this->markTestSkipped('Imagemagick is required for dynamic icon generation.');
}
$checkImagick = new \Imagick();
- if (count($checkImagick->queryFormats('SVG')) < 1) {
+ if (empty($checkImagick->queryFormats('SVG'))) {
$this->markTestSkipped('No SVG provider present.');
}
- if (count($checkImagick->queryFormats('PNG')) < 1) {
+ if (empty($checkImagick->queryFormats('PNG'))) {
$this->markTestSkipped('No PNG provider present.');
}
}