Add mimetype to OCS Share API output

Fixes #23044
This commit is contained in:
Roeland Jago Douma 2016-03-09 20:20:37 +01:00
parent b3c1379b8c
commit 517ef52560
2 changed files with 19 additions and 4 deletions

View File

@ -115,6 +115,7 @@ class Share20OCS {
} else { } else {
$result['item_type'] = 'file'; $result['item_type'] = 'file';
} }
$result['mimetype'] = $node->getMimeType();
$result['storage_id'] = $node->getStorage()->getId(); $result['storage_id'] = $node->getStorage()->getId();
$result['storage'] = $node->getStorage()->getCache()->getNumericStorageId(); $result['storage'] = $node->getStorage()->getCache()->getNumericStorageId();
$result['item_source'] = $node->getId(); $result['item_source'] = $node->getId();

View File

@ -203,12 +203,14 @@ class Share20OCSTest extends \Test\TestCase {
$file->method('getPath')->willReturn('file'); $file->method('getPath')->willReturn('file');
$file->method('getStorage')->willReturn($storage); $file->method('getStorage')->willReturn($storage);
$file->method('getParent')->willReturn($parentFolder); $file->method('getParent')->willReturn($parentFolder);
$file->method('getMimeType')->willReturn('myMimeType');
$folder = $this->getMock('OCP\Files\Folder'); $folder = $this->getMock('OCP\Files\Folder');
$folder->method('getId')->willReturn(2); $folder->method('getId')->willReturn(2);
$folder->method('getPath')->willReturn('folder'); $folder->method('getPath')->willReturn('folder');
$folder->method('getStorage')->willReturn($storage); $folder->method('getStorage')->willReturn($storage);
$folder->method('getParent')->willReturn($parentFolder); $folder->method('getParent')->willReturn($parentFolder);
$folder->method('getMimeType')->willReturn('myFolderMimeType');
// File shared with user // File shared with user
$share = $this->createShare( $share = $this->createShare(
@ -247,7 +249,8 @@ class Share20OCSTest extends \Test\TestCase {
'storage' => 101, 'storage' => 101,
'mail_send' => 0, 'mail_send' => 0,
'uid_file_owner' => 'ownerId', 'uid_file_owner' => 'ownerId',
'displayname_file_owner' => 'ownerDisplay' 'displayname_file_owner' => 'ownerDisplay',
'mimetype' => 'myMimeType',
]; ];
$data[] = [$share, $expected]; $data[] = [$share, $expected];
@ -288,7 +291,8 @@ class Share20OCSTest extends \Test\TestCase {
'storage' => 101, 'storage' => 101,
'mail_send' => 0, 'mail_send' => 0,
'uid_file_owner' => 'ownerId', 'uid_file_owner' => 'ownerId',
'displayname_file_owner' => 'ownerDisplay' 'displayname_file_owner' => 'ownerDisplay',
'mimetype' => 'myFolderMimeType',
]; ];
$data[] = [$share, $expected]; $data[] = [$share, $expected];
@ -333,7 +337,8 @@ class Share20OCSTest extends \Test\TestCase {
'mail_send' => 0, 'mail_send' => 0,
'url' => 'url', 'url' => 'url',
'uid_file_owner' => 'ownerId', 'uid_file_owner' => 'ownerId',
'displayname_file_owner' => 'ownerDisplay' 'displayname_file_owner' => 'ownerDisplay',
'mimetype' => 'myFolderMimeType',
]; ];
$data[] = [$share, $expected]; $data[] = [$share, $expected];
@ -1514,6 +1519,9 @@ class Share20OCSTest extends \Test\TestCase {
$folder = $this->getMock('\OCP\Files\Folder'); $folder = $this->getMock('\OCP\Files\Folder');
$parent = $this->getMock('\OCP\Files\Folder'); $parent = $this->getMock('\OCP\Files\Folder');
$file->method('getMimeType')->willReturn('myMimeType');
$folder->method('getMimeType')->willReturn('myFolderMimeType');
$file->method('getPath')->willReturn('file'); $file->method('getPath')->willReturn('file');
$folder->method('getPath')->willReturn('folder'); $folder->method('getPath')->willReturn('folder');
@ -1578,6 +1586,7 @@ class Share20OCSTest extends \Test\TestCase {
'share_with' => 'recipient', 'share_with' => 'recipient',
'share_with_displayname' => 'recipient', 'share_with_displayname' => 'recipient',
'mail_send' => 0, 'mail_send' => 0,
'mimetype' => 'myMimeType',
], $share, [], false ], $share, [], false
]; ];
@ -1606,6 +1615,7 @@ class Share20OCSTest extends \Test\TestCase {
'share_with' => 'recipient', 'share_with' => 'recipient',
'share_with_displayname' => 'recipientDN', 'share_with_displayname' => 'recipientDN',
'mail_send' => 0, 'mail_send' => 0,
'mimetype' => 'myMimeType',
], $share, [ ], $share, [
['owner', $owner], ['owner', $owner],
['initiator', $initiator], ['initiator', $initiator],
@ -1649,6 +1659,7 @@ class Share20OCSTest extends \Test\TestCase {
'share_with' => 'recipient', 'share_with' => 'recipient',
'share_with_displayname' => 'recipient', 'share_with_displayname' => 'recipient',
'mail_send' => 0, 'mail_send' => 0,
'mimetype' => 'myMimeType',
], $share, [], false ], $share, [], false
]; ];
@ -1687,6 +1698,7 @@ class Share20OCSTest extends \Test\TestCase {
'share_with' => 'recipient', 'share_with' => 'recipient',
'share_with_displayname' => 'recipient', 'share_with_displayname' => 'recipient',
'mail_send' => 0, 'mail_send' => 0,
'mimetype' => 'myMimeType',
], $share, [], false ], $share, [], false
]; ];
@ -1727,7 +1739,8 @@ class Share20OCSTest extends \Test\TestCase {
'share_with' => 'mypassword', 'share_with' => 'mypassword',
'share_with_displayname' => 'mypassword', 'share_with_displayname' => 'mypassword',
'mail_send' => 0, 'mail_send' => 0,
'url' => 'myLink' 'url' => 'myLink',
'mimetype' => 'myMimeType',
], $share, [], false ], $share, [], false
]; ];
@ -1766,6 +1779,7 @@ class Share20OCSTest extends \Test\TestCase {
'share_with' => 'user@server.com', 'share_with' => 'user@server.com',
'share_with_displayname' => 'user@server.com', 'share_with_displayname' => 'user@server.com',
'mail_send' => 0, 'mail_send' => 0,
'mimetype' => 'myFolderMimeType',
], $share, [], false ], $share, [], false
]; ];