aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php')
-rw-r--r--apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php37
1 files changed, 18 insertions, 19 deletions
diff --git a/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php b/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php
index bd64cfc60b4..f49d839e8d4 100644
--- a/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php
+++ b/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -18,8 +19,8 @@ use OCP\Files\SimpleFS\ISimpleFile;
use OCP\IPreview;
use OCP\IRequest;
use OCP\ISession;
+use OCP\Preview\IMimeIconProvider;
use OCP\Share\Exceptions\ShareNotFound;
-use OCP\Share\IAttributes;
use OCP\Share\IManager;
use OCP\Share\IShare;
use PHPUnit\Framework\MockObject\MockObject;
@@ -52,7 +53,8 @@ class PublicPreviewControllerTest extends TestCase {
$this->request,
$this->shareManager,
$this->createMock(ISession::class),
- $this->previewManager
+ $this->previewManager,
+ $this->createMock(IMimeIconProvider::class),
);
}
@@ -112,12 +114,8 @@ class PublicPreviewControllerTest extends TestCase {
$share->method('getPermissions')
->willReturn(Constants::PERMISSION_READ);
- $attributes = $this->createMock(IAttributes::class);
- $attributes->method('getAttribute')
- ->with('permissions', 'download')
+ $share->method('canSeeContent')
->willReturn(false);
- $share->method('getAttributes')
- ->willReturn($attributes);
$res = $this->controller->getPreview('token', 'file', 10, 10);
$expected = new DataResponse([], Http::STATUS_FORBIDDEN);
@@ -134,15 +132,11 @@ class PublicPreviewControllerTest extends TestCase {
$share->method('getPermissions')
->willReturn(Constants::PERMISSION_READ);
- $attributes = $this->createMock(IAttributes::class);
- $attributes->method('getAttribute')
- ->with('permissions', 'download')
+ $share->method('canSeeContent')
->willReturn(false);
- $share->method('getAttributes')
- ->willReturn($attributes);
$this->request->method('getHeader')
- ->with('X-NC-Preview')
+ ->with('x-nc-preview')
->willReturn('true');
$file = $this->createMock(File::class);
@@ -174,15 +168,11 @@ class PublicPreviewControllerTest extends TestCase {
$share->method('getPermissions')
->willReturn(Constants::PERMISSION_READ);
- $attributes = $this->createMock(IAttributes::class);
- $attributes->method('getAttribute')
- ->with('permissions', 'download')
+ $share->method('canSeeContent')
->willReturn(true);
- $share->method('getAttributes')
- ->willReturn($attributes);
$this->request->method('getHeader')
- ->with('X-NC-Preview')
+ ->with('x-nc-preview')
->willReturn('true');
$file = $this->createMock(File::class);
@@ -218,6 +208,9 @@ class PublicPreviewControllerTest extends TestCase {
$share->method('getNode')
->willReturn($file);
+ $share->method('canSeeContent')
+ ->willReturn(true);
+
$preview = $this->createMock(ISimpleFile::class);
$preview->method('getName')->willReturn('name');
$preview->method('getMTime')->willReturn(42);
@@ -247,6 +240,9 @@ class PublicPreviewControllerTest extends TestCase {
$share->method('getNode')
->willReturn($folder);
+ $share->method('canSeeContent')
+ ->willReturn(true);
+
$folder->method('get')
->with($this->equalTo('file'))
->willThrowException(new NotFoundException());
@@ -270,6 +266,9 @@ class PublicPreviewControllerTest extends TestCase {
$share->method('getNode')
->willReturn($folder);
+ $share->method('canSeeContent')
+ ->willReturn(true);
+
$file = $this->createMock(File::class);
$folder->method('get')
->with($this->equalTo('file'))