Skip to content

Commit

Permalink
unit tests updated
Browse files Browse the repository at this point in the history
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
  • Loading branch information
schiessle authored and skjnldsv committed Jul 14, 2018
1 parent 7c3393f commit a0ac9b3
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public function testGetGetShareNotExists() {
*/

public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner, $path, $permissions,
$shareTime, $expiration, $parent, $target, $mail_send, $token=null,
$shareTime, $expiration, $parent, $target, $mail_send, $note = '', $token=null,
$password=null) {
$share = $this->getMockBuilder(IShare::class)->getMock();
$share->method('getId')->willReturn($id);
Expand All @@ -248,6 +248,7 @@ public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner
$share->method('getShareOwner')->willReturn($shareOwner);
$share->method('getNode')->willReturn($path);
$share->method('getPermissions')->willReturn($permissions);
$share->method('getNote')->willReturn($note);
$time = new \DateTime();
$time->setTimestamp($shareTime);
$share->method('getShareTime')->willReturn($time);
Expand Down Expand Up @@ -310,7 +311,8 @@ public function dataGetShare() {
null,
6,
'target',
0
0,
'personal note'
);
$expected = [
'id' => 100,
Expand All @@ -334,6 +336,7 @@ public function dataGetShare() {
'storage' => 101,
'mail_send' => 0,
'uid_file_owner' => 'ownerId',
'note' => 'personal note',
'displayname_file_owner' => 'ownerDisplay',
'mimetype' => 'myMimeType',
];
Expand All @@ -352,7 +355,8 @@ public function dataGetShare() {
null,
6,
'target',
0
0,
'personal note'
);
$expected = [
'id' => 101,
Expand All @@ -376,6 +380,7 @@ public function dataGetShare() {
'storage' => 101,
'mail_send' => 0,
'uid_file_owner' => 'ownerId',
'note' => 'personal note',
'displayname_file_owner' => 'ownerDisplay',
'mimetype' => 'myFolderMimeType',
];
Expand All @@ -396,6 +401,7 @@ public function dataGetShare() {
6,
'target',
0,
'personal note',
'token',
'password'
);
Expand All @@ -422,6 +428,7 @@ public function dataGetShare() {
'mail_send' => 0,
'url' => 'url',
'uid_file_owner' => 'ownerId',
'note' => 'personal note',
'displayname_file_owner' => 'ownerDisplay',
'mimetype' => 'myFolderMimeType',
];
Expand Down Expand Up @@ -455,7 +462,7 @@ public function testGetShare(\OCP\Share\IShare $share, array $result) {
->willReturn(true);

$this->shareManager
->expects($this->once())
->expects($this->any())
->method('getShareById')
->with($share->getFullId(), 'currentUser')
->willReturn($share);
Expand Down Expand Up @@ -501,6 +508,8 @@ public function testGetShare(\OCP\Share\IShare $share, array $result) {
['group', $group],
]));

$d = $ocs->getShare($share->getId())->getData()[0];

$this->assertEquals($result, $ocs->getShare($share->getId())->getData()[0]);
}

Expand Down Expand Up @@ -1810,6 +1819,7 @@ public function dataFormatShare() {
->setNode($file)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
->setNote('personal note')
->setId(42);

/* User backend down */
Expand All @@ -1836,6 +1846,7 @@ public function dataFormatShare() {
'file_target' => 'myTarget',
'share_with' => 'recipient',
'share_with_displayname' => 'recipient',
'note' => 'personal note',
'mail_send' => 0,
'mimetype' => 'myMimeType',
], $share, [], false
Expand All @@ -1855,6 +1866,7 @@ public function dataFormatShare() {
'token' => null,
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'ownerDN',
'note' => 'personal note',
'path' => 'file',
'item_type' => 'file',
'storage_id' => 'storageId',
Expand Down Expand Up @@ -1883,6 +1895,7 @@ public function dataFormatShare() {
->setNode($file)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
->setNote('personal note')
->setId(42);

/* User backend down */
Expand All @@ -1899,6 +1912,7 @@ public function dataFormatShare() {
'token' => null,
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => 'personal note',
'path' => 'file',
'item_type' => 'file',
'storage_id' => 'storageId',
Expand All @@ -1924,6 +1938,7 @@ public function dataFormatShare() {
->setNode($file)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
->setNote('personal note')
->setId(42);

$result[] = [
Expand All @@ -1939,6 +1954,7 @@ public function dataFormatShare() {
'token' => null,
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => 'personal note',
'path' => 'file',
'item_type' => 'file',
'storage_id' => 'storageId',
Expand All @@ -1964,6 +1980,7 @@ public function dataFormatShare() {
->setNode($file)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
->setNote('personal note')
->setId(42);
$result[] = [
[
Expand All @@ -1978,6 +1995,7 @@ public function dataFormatShare() {
'token' => null,
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => 'personal note',
'path' => 'file',
'item_type' => 'file',
'storage_id' => 'storageId',
Expand All @@ -2004,6 +2022,7 @@ public function dataFormatShare() {
->setPassword('mypassword')
->setExpirationDate(new \DateTime('2001-01-02T00:00:00'))
->setToken('myToken')
->setNote('personal note')
->setId(42);

$result[] = [
Expand All @@ -2019,6 +2038,7 @@ public function dataFormatShare() {
'token' => 'myToken',
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => 'personal note',
'path' => 'file',
'item_type' => 'file',
'storage_id' => 'storageId',
Expand All @@ -2044,6 +2064,7 @@ public function dataFormatShare() {
->setNode($folder)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
->setNote('personal note')
->setId(42);

$result[] = [
Expand All @@ -2059,6 +2080,7 @@ public function dataFormatShare() {
'token' => null,
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => 'personal note',
'path' => 'folder',
'item_type' => 'folder',
'storage_id' => 'storageId',
Expand All @@ -2082,6 +2104,7 @@ public function dataFormatShare() {
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
->setNote('personal note')
->setId(42);

$result[] = [
Expand Down

0 comments on commit a0ac9b3

Please sign in to comment.