From 14acded1713c3e0546f1aad7b0d58b0f3a5bd1d7 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 29 May 2018 21:09:08 +0200 Subject: Make sure the file is readable before attempting to create a preview Signed-off-by: Roeland Jago Douma --- tests/lib/Preview/GeneratorTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/lib/Preview/GeneratorTest.php') diff --git a/tests/lib/Preview/GeneratorTest.php b/tests/lib/Preview/GeneratorTest.php index 130cccdf09e..b6200b1829b 100644 --- a/tests/lib/Preview/GeneratorTest.php +++ b/tests/lib/Preview/GeneratorTest.php @@ -76,6 +76,8 @@ class GeneratorTest extends \Test\TestCase { public function testGetCachedPreview() { $file = $this->createMock(File::class); + $file->method('isReadable') + ->willReturn(true); $file->method('getMimeType') ->willReturn('myMimeType'); $file->method('getId') @@ -122,6 +124,8 @@ class GeneratorTest extends \Test\TestCase { public function testGetNewPreview() { $file = $this->createMock(File::class); + $file->method('isReadable') + ->willReturn(true); $file->method('getMimeType') ->willReturn('myMimeType'); $file->method('getId') @@ -248,6 +252,8 @@ class GeneratorTest extends \Test\TestCase { $this->expectException(NotFoundException::class); $file = $this->createMock(File::class); + $file->method('isReadable') + ->willReturn(true); $this->previewManager->method('isMimeSupported') ->with('invalidType') @@ -271,6 +277,8 @@ class GeneratorTest extends \Test\TestCase { public function testNoProvider() { $file = $this->createMock(File::class); + $file->method('isReadable') + ->willReturn(true); $file->method('getMimeType') ->willReturn('myMimeType'); $file->method('getId') @@ -350,6 +358,8 @@ class GeneratorTest extends \Test\TestCase { */ public function testCorrectSize($maxX, $maxY, $reqX, $reqY, $crop, $mode, $expectedX, $expectedY) { $file = $this->createMock(File::class); + $file->method('isReadable') + ->willReturn(true); $file->method('getMimeType') ->willReturn('myMimeType'); $file->method('getId') @@ -416,4 +426,14 @@ class GeneratorTest extends \Test\TestCase { $this->assertSame($preview, $result); } } + + public function testUnreadbleFile() { + $file = $this->createMock(File::class); + $file->method('isReadable') + ->willReturn(false); + + $this->expectException(NotFoundException::class); + + $this->generator->getPreview($file, 100, 100, false); + } } -- cgit v1.2.3