diff options
author | Robin Appelman <robin@icewind.nl> | 2024-09-18 15:02:52 +0200 |
---|---|---|
committer | Louis <louis@chmn.me> | 2024-10-08 18:14:26 +0200 |
commit | 1df9f6e6914854e240394534f7ef9d4092aba91f (patch) | |
tree | 4d24e1c5b65845fe8f90a4fd49fa5f3b85d9fbd1 /apps | |
parent | 717b3033d7a6c56ed725c6bf6e6f5e0e06b88f1d (diff) | |
download | nextcloud-server-1df9f6e6914854e240394534f7ef9d4092aba91f.tar.gz nextcloud-server-1df9f6e6914854e240394534f7ef9d4092aba91f.zip |
test: fix ShareAPIControllerTest.php
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/tests/Controller/ShareAPIControllerTest.php | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 139c8996ae0..1c7937ea01f 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -550,6 +550,8 @@ class ShareAPIControllerTest extends TestCase { $parentFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock(); $parentFolder->method('getId')->willReturn(3); + $mountPoint = $this->createMock(IMountPoint::class); + $mountPoint->method('getMountType')->willReturn(''); $file = $this->getMockBuilder('OCP\Files\File')->getMock(); $file->method('getId')->willReturn(1); @@ -559,6 +561,7 @@ class ShareAPIControllerTest extends TestCase { $file->method('getSize')->willReturn(123465); $file->method('getMTime')->willReturn(1234567890); $file->method('getMimeType')->willReturn('myMimeType'); + $file->method('getMountPoint')->willReturn($mountPoint); $folder = $this->getMockBuilder('OCP\Files\Folder')->getMock(); $folder->method('getId')->willReturn(2); @@ -568,6 +571,7 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getSize')->willReturn(123465); $folder->method('getMTime')->willReturn(1234567890); $folder->method('getMimeType')->willReturn('myFolderMimeType'); + $folder->method('getMountPoint')->willReturn($mountPoint); [$shareAttributes, $shareAttributesReturnJson] = $this->mockShareAttributes(); @@ -623,6 +627,9 @@ class ShareAPIControllerTest extends TestCase { 'item_size' => 123465, 'item_mtime' => 1234567890, 'attributes' => null, + 'item_permissions' => 4, + 'is-mount-root' => false, + 'mount-type' => '', ]; $data[] = [$share, $expected]; @@ -677,6 +684,9 @@ class ShareAPIControllerTest extends TestCase { 'item_size' => 123465, 'item_mtime' => 1234567890, 'attributes' => null, + 'item_permissions' => 4, + 'is-mount-root' => false, + 'mount-type' => '', ]; $data[] = [$share, $expected]; @@ -737,6 +747,9 @@ class ShareAPIControllerTest extends TestCase { 'item_size' => 123465, 'item_mtime' => 1234567890, 'attributes' => null, + 'item_permissions' => 4, + 'is-mount-root' => false, + 'mount-type' => '', ]; $data[] = [$share, $expected]; @@ -3727,6 +3740,12 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getMimeType')->willReturn('myFolderMimeType'); $fileWithPreview->method('getMimeType')->willReturn('mimeWithPreview'); + $mountPoint = $this->createMock(IMountPoint::class); + $mountPoint->method('getMountType')->willReturn(''); + $file->method('getMountPoint')->willReturn($mountPoint); + $folder->method('getMountPoint')->willReturn($mountPoint); + $fileWithPreview->method('getMountPoint')->willReturn($mountPoint); + $file->method('getPath')->willReturn('file'); $folder->method('getPath')->willReturn('folder'); $fileWithPreview->method('getPath')->willReturn('fileWithPreview'); @@ -3824,6 +3843,9 @@ class ShareAPIControllerTest extends TestCase { 'item_size' => 123456, 'item_mtime' => 1234567890, 'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]', + 'item_permissions' => 1, + 'is-mount-root' => false, + 'mount-type' => '', ], $share, [], false ]; // User backend up @@ -3863,6 +3885,9 @@ class ShareAPIControllerTest extends TestCase { 'item_size' => 123456, 'item_mtime' => 1234567890, 'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]', + 'item_permissions' => 1, + 'is-mount-root' => false, + 'mount-type' => '', ], $share, [ ['owner', $owner], ['initiator', $initiator], @@ -3920,6 +3945,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 1, ], $share, [], false ]; @@ -3973,6 +3999,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 11, ], $share, [], false ]; @@ -4027,6 +4054,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 1, ], $share, [], false ]; @@ -4078,6 +4106,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 1, ], $share, [], false ]; @@ -4136,6 +4165,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 1, ], $share, [], false ]; @@ -4194,6 +4224,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 1, ], $share, [], false ]; @@ -4246,6 +4277,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 1, ], $share, [], false ]; @@ -4298,6 +4330,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 1, ], $share, [], false ]; @@ -4353,6 +4386,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 1, ], $share, [], false ]; @@ -4405,6 +4439,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 1, ], $share, [], false ]; @@ -4457,6 +4492,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 1, ], $share, [], false ]; @@ -4526,6 +4562,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 1, ], $share, [], false ]; @@ -4581,6 +4618,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 1, ], $share, [], false ]; @@ -4634,6 +4672,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 11, ], $share, [], false ]; @@ -4798,6 +4837,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 1, ], $share, false, [] ]; @@ -4849,6 +4889,7 @@ class ShareAPIControllerTest extends TestCase { 'is-mount-root' => false, 'mount-type' => '', 'attributes' => null, + 'item_permissions' => 9, ], $share, true, [ 'share_with_displayname' => 'recipientRoomName' ] @@ -4888,11 +4929,14 @@ class ShareAPIControllerTest extends TestCase { ->willReturn(true); $helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController') - ->setMethods(['formatShare']) + ->setMethods(['formatShare', 'canAccessShare']) ->getMock(); $helper->method('formatShare') ->with($share) ->willReturn($formatShareByHelper); + $helper->method('canAccessShare') + ->with($share) + ->willReturn(true); $this->serverContainer->method('get') ->with('\OCA\Talk\Share\Helper\ShareAPIController') |