diff options
Diffstat (limited to 'apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php')
-rw-r--r-- | apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php b/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php index 41789cdd138..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 @@ -20,7 +21,6 @@ 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; @@ -114,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); @@ -136,12 +132,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); $this->request->method('getHeader') ->with('x-nc-preview') @@ -176,12 +168,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(true); - $share->method('getAttributes') - ->willReturn($attributes); $this->request->method('getHeader') ->with('x-nc-preview') @@ -220,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); @@ -249,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()); @@ -272,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')) |