diff options
author | Michael Weimann <mail@michael-weimann.eu> | 2018-09-02 14:17:17 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-09-05 20:50:21 +0200 |
commit | 38ea5d14b38d86fe09acf0df34857c9eba6e1c6f (patch) | |
tree | a598a2f6c5ecfacefcdf0c4fc9ae640925558cd7 /apps/theming/tests/Controller/ThemingControllerTest.php | |
parent | 0899f2cbc43b05005dc045db001c41e199192f67 (diff) | |
download | nextcloud-server-38ea5d14b38d86fe09acf0df34857c9eba6e1c6f.tar.gz nextcloud-server-38ea5d14b38d86fe09acf0df34857c9eba6e1c6f.zip |
Disables SVG favicon uploads when imagemagick is missing.
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
Diffstat (limited to 'apps/theming/tests/Controller/ThemingControllerTest.php')
-rw-r--r-- | apps/theming/tests/Controller/ThemingControllerTest.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index a2105264f10..457e9900b5e 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -246,6 +246,61 @@ class ThemingControllerTest extends TestCase { $this->assertEquals($expected, $this->themingController->uploadImage()); } + /** + * Checks that trying to upload an SVG favicon without imagemagick + * results in an unsupported media type response. + * + * @test + * @return void + */ + public function testUploadSVGFaviconWithoutImagemagick() { + $this->imageManager + ->method('shouldReplaceIcons') + ->willReturn(false); + + $this->request + ->expects($this->at(0)) + ->method('getParam') + ->with('key') + ->willReturn('favicon'); + $this->request + ->expects($this->at(1)) + ->method('getUploadedFile') + ->with('image') + ->willReturn([ + 'tmp_name' => __DIR__ . '/../../../../tests/data/testimagelarge.svg', + 'type' => 'image/svg', + 'name' => 'testimagelarge.svg', + 'error' => 0, + ]); + $this->l10n + ->expects($this->any()) + ->method('t') + ->will($this->returnCallback(function($str) { + return $str; + })); + + $folder = $this->createMock(ISimpleFolder::class); + $this->appData + ->expects($this->once()) + ->method('getFolder') + ->with('images') + ->willReturn($folder); + + $expected = new DataResponse( + [ + 'data' => + [ + 'message' => 'Unsupported image type', + ], + 'status' => 'failure' + ], + Http::STATUS_UNPROCESSABLE_ENTITY + ); + + $this->assertEquals($expected, $this->themingController->uploadImage()); + } + public function testUpdateLogoInvalidMimeType() { $this->request ->expects($this->at(0)) |