diff options
Diffstat (limited to 'apps/files_sharing/tests/Controller/ShareAPIControllerTest.php')
-rw-r--r-- | apps/files_sharing/tests/Controller/ShareAPIControllerTest.php | 120 |
1 files changed, 88 insertions, 32 deletions
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 2a2a7d940be..df63f61606f 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -576,6 +576,8 @@ class ShareAPIControllerTest extends TestCase { $file->method('getPath')->willReturn('file'); $file->method('getStorage')->willReturn($storage); $file->method('getParent')->willReturn($parentFolder); + $file->method('getSize')->willReturn(123465); + $file->method('getMTime')->willReturn(1234567890); $file->method('getMimeType')->willReturn('myMimeType'); $folder = $this->getMockBuilder('OCP\Files\Folder')->getMock(); @@ -583,6 +585,8 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getPath')->willReturn('folder'); $folder->method('getStorage')->willReturn($storage); $folder->method('getParent')->willReturn($parentFolder); + $folder->method('getSize')->willReturn(123465); + $folder->method('getMTime')->willReturn(1234567890); $folder->method('getMimeType')->willReturn('myFolderMimeType'); [$shareAttributes, $shareAttributesReturnJson] = $this->mockShareAttributes(); @@ -637,6 +641,8 @@ class ShareAPIControllerTest extends TestCase { 'can_edit' => false, 'can_delete' => false, 'status' => [], + 'item_size' => 123465, + 'item_mtime' => 1234567890, 'attributes' => null, ]; $data[] = [$share, $expected]; @@ -689,6 +695,8 @@ class ShareAPIControllerTest extends TestCase { 'hide_download' => 0, 'can_edit' => false, 'can_delete' => false, + 'item_size' => 123465, + 'item_mtime' => 1234567890, 'attributes' => null, ]; $data[] = [$share, $expected]; @@ -747,6 +755,8 @@ class ShareAPIControllerTest extends TestCase { 'hide_download' => 0, 'can_edit' => false, 'can_delete' => false, + 'item_size' => 123465, + 'item_mtime' => 1234567890, 'attributes' => null, ]; $data[] = [$share, $expected]; @@ -3735,6 +3745,13 @@ class ShareAPIControllerTest extends TestCase { $folder->method('getParent')->willReturn($parent); $fileWithPreview->method('getParent')->willReturn($parent); + $file->method('getSize')->willReturn(123456); + $folder->method('getSize')->willReturn(123456); + $fileWithPreview->method('getSize')->willReturn(123456); + $file->method('getMTime')->willReturn(1234567890); + $folder->method('getMTime')->willReturn(1234567890); + $fileWithPreview->method('getMTime')->willReturn(1234567890); + $cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock(); $cache->method('getNumericStorageId')->willReturn(100); $storage = $this->createMock(Storage::class); @@ -3772,7 +3789,7 @@ class ShareAPIControllerTest extends TestCase { // User backend down $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_USER, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -3796,7 +3813,7 @@ class ShareAPIControllerTest extends TestCase { 'share_with_displayname' => 'recipient', 'share_with_displayname_unique' => 'recipient', 'note' => 'personal note', - 'label' => null, + 'label' => '', 'mail_send' => 0, 'mimetype' => 'myMimeType', 'has_preview' => false, @@ -3804,13 +3821,15 @@ class ShareAPIControllerTest extends TestCase { 'can_edit' => false, 'can_delete' => false, 'status' => [], + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]', ], $share, [], false ]; // User backend up $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_USER, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiatorDN', @@ -3823,7 +3842,7 @@ class ShareAPIControllerTest extends TestCase { 'uid_file_owner' => 'owner', 'displayname_file_owner' => 'ownerDN', 'note' => 'personal note', - 'label' => null, + 'label' => '', 'path' => 'file', 'item_type' => 'file', 'storage_id' => 'storageId', @@ -3842,6 +3861,8 @@ class ShareAPIControllerTest extends TestCase { 'can_edit' => false, 'can_delete' => false, 'status' => [], + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]', ], $share, [ ['owner', $owner], @@ -3864,7 +3885,7 @@ class ShareAPIControllerTest extends TestCase { // User backend down $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_USER, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -3877,7 +3898,7 @@ class ShareAPIControllerTest extends TestCase { 'uid_file_owner' => 'owner', 'displayname_file_owner' => 'owner', 'note' => 'personal note', - 'label' => null, + 'label' => '', 'path' => 'file', 'item_type' => 'file', 'storage_id' => 'storageId', @@ -3896,6 +3917,8 @@ class ShareAPIControllerTest extends TestCase { 'can_edit' => false, 'can_delete' => false, 'status' => [], + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -3914,7 +3937,7 @@ class ShareAPIControllerTest extends TestCase { // User backend down $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_USER, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -3927,7 +3950,7 @@ class ShareAPIControllerTest extends TestCase { 'uid_file_owner' => 'currentUser', 'displayname_file_owner' => 'currentUser', 'note' => 'personal note', - 'label' => null, + 'label' => '', 'path' => 'file', 'item_type' => 'file', 'storage_id' => 'storageId', @@ -3946,6 +3969,8 @@ class ShareAPIControllerTest extends TestCase { 'can_edit' => true, 'can_delete' => true, 'status' => [], + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -3966,7 +3991,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_GROUP, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -3979,7 +4004,7 @@ class ShareAPIControllerTest extends TestCase { 'uid_file_owner' => 'owner', 'displayname_file_owner' => 'owner', 'note' => 'personal note', - 'label' => null, + 'label' => '', 'path' => 'file', 'item_type' => 'file', 'storage_id' => 'storageId', @@ -3996,6 +4021,8 @@ class ShareAPIControllerTest extends TestCase { 'hide_download' => 0, 'can_edit' => false, 'can_delete' => false, + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -4014,7 +4041,7 @@ class ShareAPIControllerTest extends TestCase { ->setId(42); $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_GROUP, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -4026,7 +4053,7 @@ class ShareAPIControllerTest extends TestCase { 'uid_file_owner' => 'owner', 'displayname_file_owner' => 'owner', 'note' => 'personal note', - 'label' => null, + 'label' => '', 'path' => 'file', 'item_type' => 'file', 'storage_id' => 'storageId', @@ -4043,6 +4070,8 @@ class ShareAPIControllerTest extends TestCase { 'hide_download' => 0, 'can_edit' => false, 'can_delete' => false, + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -4064,7 +4093,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_LINK, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -4097,6 +4126,8 @@ class ShareAPIControllerTest extends TestCase { 'hide_download' => 0, 'can_edit' => false, 'can_delete' => false, + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -4119,7 +4150,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_LINK, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -4151,6 +4182,8 @@ class ShareAPIControllerTest extends TestCase { 'hide_download' => 0, 'can_edit' => false, 'can_delete' => false, + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -4170,7 +4203,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_REMOTE, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -4182,7 +4215,7 @@ class ShareAPIControllerTest extends TestCase { 'uid_file_owner' => 'owner', 'displayname_file_owner' => 'owner', 'note' => 'personal note', - 'label' => null, + 'label' => '', 'path' => 'folder', 'item_type' => 'folder', 'storage_id' => 'storageId', @@ -4199,6 +4232,8 @@ class ShareAPIControllerTest extends TestCase { 'hide_download' => 0, 'can_edit' => false, 'can_delete' => false, + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -4218,7 +4253,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_REMOTE_GROUP, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -4230,7 +4265,7 @@ class ShareAPIControllerTest extends TestCase { 'uid_file_owner' => 'owner', 'displayname_file_owner' => 'owner', 'note' => 'personal note', - 'label' => null, + 'label' => '', 'path' => 'folder', 'item_type' => 'folder', 'storage_id' => 'storageId', @@ -4247,6 +4282,8 @@ class ShareAPIControllerTest extends TestCase { 'hide_download' => 0, 'can_edit' => false, 'can_delete' => false, + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -4267,7 +4304,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_CIRCLE, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -4280,7 +4317,7 @@ class ShareAPIControllerTest extends TestCase { 'uid_file_owner' => 'owner', 'displayname_file_owner' => 'owner', 'note' => '', - 'label' => null, + 'label' => '', 'path' => 'folder', 'item_type' => 'folder', 'storage_id' => 'storageId', @@ -4298,6 +4335,8 @@ class ShareAPIControllerTest extends TestCase { 'hide_download' => 0, 'can_edit' => false, 'can_delete' => false, + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -4316,7 +4355,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_CIRCLE, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -4328,7 +4367,7 @@ class ShareAPIControllerTest extends TestCase { 'uid_file_owner' => 'owner', 'displayname_file_owner' => 'owner', 'note' => '', - 'label' => null, + 'label' => '', 'path' => 'folder', 'item_type' => 'folder', 'storage_id' => 'storageId', @@ -4346,6 +4385,8 @@ class ShareAPIControllerTest extends TestCase { 'hide_download' => 0, 'can_edit' => false, 'can_delete' => false, + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -4364,7 +4405,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_CIRCLE, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -4376,7 +4417,7 @@ class ShareAPIControllerTest extends TestCase { 'uid_file_owner' => 'owner', 'displayname_file_owner' => 'owner', 'note' => '', - 'label' => null, + 'label' => '', 'path' => 'folder', 'item_type' => 'folder', 'storage_id' => 'storageId', @@ -4394,6 +4435,8 @@ class ShareAPIControllerTest extends TestCase { 'hide_download' => 0, 'can_edit' => false, 'can_delete' => false, + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -4427,7 +4470,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_EMAIL, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -4439,7 +4482,7 @@ class ShareAPIControllerTest extends TestCase { 'uid_file_owner' => 'owner', 'displayname_file_owner' => 'owner', 'note' => '', - 'label' => null, + 'label' => '', 'path' => 'folder', 'item_type' => 'folder', 'storage_id' => 'storageId', @@ -4459,6 +4502,8 @@ class ShareAPIControllerTest extends TestCase { 'can_edit' => false, 'can_delete' => false, 'password_expiration_time' => null, + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -4478,7 +4523,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_EMAIL, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -4490,7 +4535,7 @@ class ShareAPIControllerTest extends TestCase { 'uid_file_owner' => 'owner', 'displayname_file_owner' => 'owner', 'note' => '', - 'label' => null, + 'label' => '', 'path' => 'folder', 'item_type' => 'folder', 'storage_id' => 'storageId', @@ -4510,6 +4555,8 @@ class ShareAPIControllerTest extends TestCase { 'can_edit' => false, 'can_delete' => false, 'password_expiration_time' => null, + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -4529,7 +4576,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_USER, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -4541,7 +4588,7 @@ class ShareAPIControllerTest extends TestCase { 'uid_file_owner' => 'currentUser', 'displayname_file_owner' => 'currentUser', 'note' => 'personal note', - 'label' => null, + 'label' => '', 'path' => 'fileWithPreview', 'item_type' => 'file', 'storage_id' => 'storageId', @@ -4560,6 +4607,8 @@ class ShareAPIControllerTest extends TestCase { 'can_edit' => true, 'can_delete' => true, 'status' => [], + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, [], false ]; @@ -4659,6 +4708,9 @@ class ShareAPIControllerTest extends TestCase { $file->method('getParent')->willReturn($parent); + $file->method('getSize')->willReturn(123456); + $file->method('getMTime')->willReturn(1234567890); + $cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock(); $cache->method('getNumericStorageId')->willReturn(100); $storage = $this->createMock(Storage::class); @@ -4683,7 +4735,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_ROOM, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -4712,6 +4764,8 @@ class ShareAPIControllerTest extends TestCase { 'label' => '', 'can_edit' => false, 'can_delete' => false, + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, false, [] ]; @@ -4730,7 +4784,7 @@ class ShareAPIControllerTest extends TestCase { $result[] = [ [ - 'id' => 42, + 'id' => '42', 'share_type' => IShare::TYPE_ROOM, 'uid_owner' => 'initiator', 'displayname_owner' => 'initiator', @@ -4759,6 +4813,8 @@ class ShareAPIControllerTest extends TestCase { 'label' => '', 'can_edit' => false, 'can_delete' => false, + 'item_size' => 123456, + 'item_mtime' => 1234567890, 'attributes' => null, ], $share, true, [ 'share_with_displayname' => 'recipientRoomName' |