]> source.dussan.org Git - nextcloud-server.git/commitdiff
test: fix ShareAPIControllerTest.php
authorRobin Appelman <robin@icewind.nl>
Wed, 18 Sep 2024 13:02:52 +0000 (15:02 +0200)
committerLouis <louis@chmn.me>
Tue, 8 Oct 2024 16:14:26 +0000 (18:14 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_sharing/tests/Controller/ShareAPIControllerTest.php

index 139c8996ae011d5eeab69c6e0e305b977a2b0dad..1c7937ea01fb6c2fc3e111bc9046b46aadcb4954 100644 (file)
@@ -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')