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
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-05-29 22:09:08 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2018-05-29 23:04:17 +0300
commit8d596461d5a860b5e778e1c5db1543f94d00ded0 (patch)
tree4b3b9029094a99c2d70ec47998aff91d3cf7e0ec /tests
parent9fe202a811e5ffc916529b7dbc8b97b3e5a4aec2 (diff)
Make sure the file is readable before attempting to create a preview
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Preview/GeneratorTest.php20
1 files changed, 20 insertions, 0 deletions
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);
+ }
}