From eb904c7aa9c9fc7235c82d7a7b522b46291ea5f2 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 2 Feb 2016 16:57:50 +0100 Subject: [PATCH] [Share 2.0] Fix defaultshare provider --- lib/private/share20/defaultshareprovider.php | 133 +++---- lib/public/share/ishareprovider.php | 2 +- .../lib/share20/defaultshareprovidertest.php | 341 ++++++------------ 3 files changed, 169 insertions(+), 307 deletions(-) diff --git a/lib/private/share20/defaultshareprovider.php b/lib/private/share20/defaultshareprovider.php index 7b78be2b61d..38d1dae316d 100644 --- a/lib/private/share20/defaultshareprovider.php +++ b/lib/private/share20/defaultshareprovider.php @@ -29,7 +29,6 @@ use OC\Share20\Exception\BackendError; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\NotFoundException; use OCP\IGroup; -use OCP\IUser; use OCP\IGroupManager; use OCP\IUserManager; use OCP\Files\IRootFolder; @@ -102,14 +101,10 @@ class DefaultShareProvider implements IShareProvider { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { //Set the UID of the user we share with - /** @var IUser $sharedWith */ - $sharedWith = $share->getSharedWith(); - $qb->setValue('share_with', $qb->createNamedParameter($sharedWith->getUID())); + $qb->setValue('share_with', $qb->createNamedParameter($share->getSharedWith())); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { //Set the GID of the group we share with - /** @var IGroup $sharedWith */ - $sharedWith = $share->getSharedWith(); - $qb->setValue('share_with', $qb->createNamedParameter($sharedWith->getGID())); + $qb->setValue('share_with', $qb->createNamedParameter($share->getSharedWith())); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { //Set the token of the share $qb->setValue('token', $qb->createNamedParameter($share->getToken())); @@ -143,10 +138,10 @@ class DefaultShareProvider implements IShareProvider { $qb->setValue('permissions', $qb->createNamedParameter($share->getPermissions())); // Set who created this share - $qb->setValue('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID())); + $qb->setValue('uid_initiator', $qb->createNamedParameter($share->getSharedBy())); // Set who is the owner of this file/folder (and this the owner of the share) - $qb->setValue('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID())); + $qb->setValue('uid_owner', $qb->createNamedParameter($share->getShareOwner())); // Set the file target $qb->setValue('file_target', $qb->createNamedParameter($share->getTarget())); @@ -192,9 +187,9 @@ class DefaultShareProvider implements IShareProvider { $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) - ->set('share_with', $qb->createNamedParameter($share->getSharedWith()->getUID())) - ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID())) - ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID())) + ->set('share_with', $qb->createNamedParameter($share->getSharedWith())) + ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) + ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) ->set('permissions', $qb->createNamedParameter($share->getPermissions())) ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) @@ -203,8 +198,8 @@ class DefaultShareProvider implements IShareProvider { $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) - ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID())) - ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID())) + ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) + ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) ->set('permissions', $qb->createNamedParameter($share->getPermissions())) ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) @@ -216,8 +211,8 @@ class DefaultShareProvider implements IShareProvider { $qb = $this->dbConn->getQueryBuilder(); $qb->update('share') ->where($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) - ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID())) - ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID())) + ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) + ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) ->execute(); @@ -237,8 +232,8 @@ class DefaultShareProvider implements IShareProvider { $qb->update('share') ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) ->set('share_with', $qb->createNamedParameter($share->getPassword())) - ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()->getUID())) - ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()->getUID())) + ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) + ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) ->set('permissions', $qb->createNamedParameter($share->getPermissions())) ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) @@ -255,7 +250,7 @@ class DefaultShareProvider implements IShareProvider { * FIXME: remove once https://github.com/owncloud/core/pull/21660 is in * * @param \OCP\Share\IShare $parent - * @return IShare[] + * @return \OCP\Share\IShare[] */ public function getChildren(\OCP\Share\IShare $parent) { $children = []; @@ -311,17 +306,17 @@ class DefaultShareProvider implements IShareProvider { * this means we need a special entry in the share db. * * @param \OCP\Share\IShare $share - * @param IUser $recipient + * @param string $recipient UserId of recipient * @throws BackendError * @throws ProviderException */ - public function deleteFromSelf(\OCP\Share\IShare $share, IUser $recipient) { + public function deleteFromSelf(\OCP\Share\IShare $share, $recipient) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { - /** @var IGroup $group */ - $group = $share->getSharedWith(); + $group = $this->groupManager->get($share->getSharedWith()); + $user = $this->userManager->get($recipient); - if (!$group->inGroup($recipient)) { + if (!$group->inGroup($user)) { throw new ProviderException('Recipient not in receiving group'); } @@ -330,7 +325,7 @@ class DefaultShareProvider implements IShareProvider { $stmt = $qb->select('*') ->from('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) - ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient->getUID()))) + ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))) ->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) ->execute(); @@ -349,9 +344,9 @@ class DefaultShareProvider implements IShareProvider { $qb->insert('share') ->values([ 'share_type' => $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP), - 'share_with' => $qb->createNamedParameter($recipient->getUID()), - 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()->getUID()), - 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()->getUID()), + 'share_with' => $qb->createNamedParameter($recipient), + 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()), + 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()), 'parent' => $qb->createNamedParameter($share->getId()), 'item_type' => $qb->createNamedParameter($type), 'item_source' => $qb->createNamedParameter($share->getNode()->getId()), @@ -387,7 +382,7 @@ class DefaultShareProvider implements IShareProvider { /** * @inheritdoc */ - public function move(\OCP\Share\IShare $share, IUser $recipient) { + public function move(\OCP\Share\IShare $share, $recipient) { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { // Just update the target $qb = $this->dbConn->getQueryBuilder(); @@ -403,7 +398,7 @@ class DefaultShareProvider implements IShareProvider { $stmt = $qb->select('id') ->from('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) - ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient->getUID()))) + ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))) ->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) ->setMaxResults(1) ->execute(); @@ -417,9 +412,9 @@ class DefaultShareProvider implements IShareProvider { $qb->insert('share') ->values([ 'share_type' => $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP), - 'share_with' => $qb->createNamedParameter($recipient->getUID()), - 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()->getUID()), - 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()->getUID()), + 'share_with' => $qb->createNamedParameter($recipient), + 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()), + 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()), 'parent' => $qb->createNamedParameter($share->getId()), 'item_type' => $qb->createNamedParameter($share->getNode() instanceof File ? 'file' : 'folder'), 'item_source' => $qb->createNamedParameter($share->getNode()->getId()), @@ -444,7 +439,7 @@ class DefaultShareProvider implements IShareProvider { /** * Get all shares by the given user. Sharetype and path can be used to filter. * - * @param IUser $user + * @param string $userId * @param int $shareType * @param \OCP\Files\File|\OCP\Files\Folder $node * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator @@ -452,7 +447,7 @@ class DefaultShareProvider implements IShareProvider { * @param int $offset * @return Share[] */ - public function getSharesBy(IUser $user, $shareType, $node, $reshares, $limit, $offset) { + public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) { $qb = $this->dbConn->getQueryBuilder(); $qb->select('*') ->from('share'); @@ -465,21 +460,21 @@ class DefaultShareProvider implements IShareProvider { if ($reshares === false) { //Special case for old shares created via the web UI $or1 = $qb->expr()->andX( - $qb->expr()->eq('uid_owner', $qb->createNamedParameter($user->getUID())), + $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), $qb->expr()->isNull('uid_initiator') ); $qb->andWhere( $qb->expr()->orX( - $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($user->getUID())), + $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)), $or1 ) ); } else { $qb->andWhere( $qb->expr()->orX( - $qb->expr()->eq('uid_owner', $qb->createNamedParameter($user->getUID())), - $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($user->getUID())) + $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), + $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) ) ); } @@ -508,7 +503,7 @@ class DefaultShareProvider implements IShareProvider { /** * @inheritdoc */ - public function getShareById($id, $recipient = null) { + public function getShareById($id, $recipientId = null) { $qb = $this->dbConn->getQueryBuilder(); $qb->select('*') @@ -540,8 +535,8 @@ class DefaultShareProvider implements IShareProvider { } // If the recipient is set for a group share resolve to that user - if ($recipient !== null && $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { - $share = $this->resolveGroupShare($share, $recipient); + if ($recipientId !== null && $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { + $share = $this->resolveGroupShare($share, $recipientId); } return $share; @@ -551,7 +546,7 @@ class DefaultShareProvider implements IShareProvider { * Get shares for a given path * * @param \OCP\Files\Node $path - * @return IShare[] + * @return \OCP\Share\IShare[] */ public function getSharesByPath(Node $path) { $qb = $this->dbConn->getQueryBuilder(); @@ -578,7 +573,7 @@ class DefaultShareProvider implements IShareProvider { /** * @inheritdoc */ - public function getSharedWith(IUser $user, $shareType, $node, $limit, $offset) { + public function getSharedWith($userId, $shareType, $node, $limit, $offset) { /** @var Share[] $shares */ $shares = []; @@ -598,7 +593,7 @@ class DefaultShareProvider implements IShareProvider { $qb->setFirstResult($offset); $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER))); - $qb->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($user->getUID()))); + $qb->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId))); // Filter by node if provided if ($node !== null) { @@ -613,6 +608,7 @@ class DefaultShareProvider implements IShareProvider { $cursor->closeCursor(); } else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { + $user = $this->userManager->get($userId); $allGroups = $this->groupManager->getUserGroups($user); /** @var Share[] $shares2 */ @@ -666,7 +662,7 @@ class DefaultShareProvider implements IShareProvider { * TODO: Optmize this! */ foreach($shares2 as $share) { - $shares[] = $this->resolveGroupShare($share, $user); + $shares[] = $this->resolveGroupShare($share, $userId); } } else { throw new BackendError('Invalid backend'); @@ -680,7 +676,7 @@ class DefaultShareProvider implements IShareProvider { * Get a share by token * * @param string $token - * @return IShare + * @return \OCP\Share\IShare * @throws ShareNotFound */ public function getShareByToken($token) { @@ -727,17 +723,9 @@ class DefaultShareProvider implements IShareProvider { $share->setShareTime($shareTime); if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { - $sharedWith = $this->userManager->get($data['share_with']); - if ($sharedWith === null) { - throw new InvalidShare(); - } - $share->setSharedWith($sharedWith); + $share->setSharedWith($data['share_with']); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { - $sharedWith = $this->groupManager->get($data['share_with']); - if ($sharedWith === null) { - throw new InvalidShare(); - } - $share->setSharedWith($sharedWith); + $share->setSharedWith($data['share_with']); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) { $share->setPassword($data['share_with']); $share->setToken($data['token']); @@ -745,24 +733,15 @@ class DefaultShareProvider implements IShareProvider { if ($data['uid_initiator'] === null) { //OLD SHARE - $sharedBy = $this->userManager->get($data['uid_owner']); - if ($sharedBy === null) { - throw new InvalidShare(); - } - $share->setSharedBy($sharedBy); + $share->setSharedBy($data['uid_owner']); $path = $this->getNode($share->getSharedBy(), (int)$data['file_source']); $owner = $path->getOwner(); - $share->setShareOwner($owner); + $share->setShareOwner($owner->getUID()); } else { //New share! - $sharedBy = $this->userManager->get($data['uid_initiator']); - $shareOwner = $this->userManager->get($data['uid_owner']); - if ($sharedBy === null || $shareOwner === null) { - throw new InvalidShare(); - } - $share->setSharedBy($sharedBy); - $share->setShareOwner($shareOwner); + $share->setSharedBy($data['uid_initiator']); + $share->setShareOwner($data['uid_owner']); } $path = $this->getNode($share->getShareOwner(), (int)$data['file_source']); @@ -781,14 +760,14 @@ class DefaultShareProvider implements IShareProvider { /** * Get the node with file $id for $user * - * @param IUser $user + * @param string $user The userId * @param int $id * @return \OCP\Files\File|\OCP\Files\Folder * @throws InvalidShare */ - private function getNode(IUser $user, $id) { + private function getNode($user, $id) { try { - $userFolder = $this->rootFolder->getUserFolder($user->getUID()); + $userFolder = $this->rootFolder->getUserFolder($user); } catch (NotFoundException $e) { throw new InvalidShare(); } @@ -806,18 +785,18 @@ class DefaultShareProvider implements IShareProvider { * Resolve a group share to a user specific share * Thus if the user moved their group share make sure this is properly reflected here. * - * @param Share $share - * @param IUser $user + * @param \OCP\Share\IShare $share + * @param string $userId * @return Share Returns the updated share if one was found else return the original share. */ - private function resolveGroupShare(Share $share, IUser $user) { + private function resolveGroupShare(\OCP\Share\IShare $share, $userId) { $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->select('*') ->from('share') ->where($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))) - ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($user->getUID()))) + ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId))) ->setMaxResults(1) ->execute(); diff --git a/lib/public/share/ishareprovider.php b/lib/public/share/ishareprovider.php index a14d58734bc..25fa76369ab 100644 --- a/lib/public/share/ishareprovider.php +++ b/lib/public/share/ishareprovider.php @@ -129,7 +129,7 @@ interface IShareProvider { /** * Get shared with the given user * - * @param stromg $userId get shares where this user is the recipient + * @param string $userId get shares where this user is the recipient * @param int $shareType * @param Node|null $node * @param int $limit The max number of entries returned, -1 for all diff --git a/tests/lib/share20/defaultshareprovidertest.php b/tests/lib/share20/defaultshareprovidertest.php index 32c0b342c41..19f21fba7b1 100644 --- a/tests/lib/share20/defaultshareprovidertest.php +++ b/tests/lib/share20/defaultshareprovidertest.php @@ -157,21 +157,13 @@ class DefaultShareProviderTest extends \Test\TestCase { ['shareOwner', $shareOwnerFolder], ])); - $this->userManager - ->method('get') - ->will($this->returnValueMap([ - ['sharedWith', $sharedWith], - ['sharedBy', $sharedBy], - ['shareOwner', $shareOwner], - ])); - $share = $this->provider->getShareById($id); $this->assertEquals($id, $share->getId()); $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); - $this->assertEquals($sharedWith, $share->getSharedWith()); - $this->assertEquals($sharedBy, $share->getSharedBy()); - $this->assertEquals($shareOwner, $share->getShareOwner()); + $this->assertEquals('sharedWith', $share->getSharedWith()); + $this->assertEquals('sharedBy', $share->getSharedBy()); + $this->assertEquals('shareOwner', $share->getShareOwner()); $this->assertEquals($ownerPath, $share->getNode()); $this->assertEquals(13, $share->getPermissions()); $this->assertEquals(null, $share->getToken()); @@ -221,25 +213,13 @@ class DefaultShareProviderTest extends \Test\TestCase { ['shareOwner', $shareOwnerFolder], ])); - $this->userManager - ->method('get') - ->will($this->returnValueMap([ - ['sharedBy', $sharedBy], - ['shareOwner', $shareOwner], - ])); - $this->groupManager - ->expects($this->once()) - ->method('get') - ->with('sharedWith') - ->willReturn($sharedWith); - $share = $this->provider->getShareById($id); $this->assertEquals($id, $share->getId()); $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); - $this->assertEquals($sharedWith, $share->getSharedWith()); - $this->assertEquals($sharedBy, $share->getSharedBy()); - $this->assertEquals($shareOwner, $share->getShareOwner()); + $this->assertEquals('sharedWith', $share->getSharedWith()); + $this->assertEquals('sharedBy', $share->getSharedBy()); + $this->assertEquals('shareOwner', $share->getShareOwner()); $this->assertEquals($ownerPath, $share->getNode()); $this->assertEquals(13, $share->getPermissions()); $this->assertEquals(null, $share->getToken()); @@ -271,13 +251,13 @@ class DefaultShareProviderTest extends \Test\TestCase { ])); $this->groupManager->method('get')->with('group0')->willReturn($group0); - $share = $this->provider->getShareById($id, $user1); + $share = $this->provider->getShareById($id, 'user1'); $this->assertEquals($id, $share->getId()); $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); - $this->assertSame($group0, $share->getSharedWith()); - $this->assertSame($user0, $share->getSharedBy()); - $this->assertSame($user0, $share->getShareOwner()); + $this->assertSame('group0', $share->getSharedWith()); + $this->assertSame('user0', $share->getSharedBy()); + $this->assertSame('user0', $share->getShareOwner()); $this->assertSame($node, $share->getNode()); $this->assertEquals(0, $share->getPermissions()); $this->assertEquals(null, $share->getToken()); @@ -339,8 +319,8 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals($id, $share->getId()); $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType()); $this->assertEquals('sharedWith', $share->getPassword()); - $this->assertEquals($sharedBy, $share->getSharedBy()); - $this->assertEquals($shareOwner, $share->getShareOwner()); + $this->assertEquals('sharedBy', $share->getSharedBy()); + $this->assertEquals('shareOwner', $share->getShareOwner()); $this->assertEquals($ownerPath, $share->getNode()); $this->assertEquals(13, $share->getPermissions()); $this->assertEquals('token', $share->getToken()); @@ -559,9 +539,9 @@ class DefaultShareProviderTest extends \Test\TestCase { //Child1 $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $children[0]->getShareType()); - $this->assertEquals($user1, $children[0]->getSharedWith()); - $this->assertEquals($user2, $children[0]->getSharedBy()); - $this->assertEquals($shareOwner, $children[0]->getShareOwner()); + $this->assertEquals('user1', $children[0]->getSharedWith()); + $this->assertEquals('user2', $children[0]->getSharedBy()); + $this->assertEquals('shareOwner', $children[0]->getShareOwner()); $this->assertEquals($ownerPath, $children[0]->getNode()); $this->assertEquals(2, $children[0]->getPermissions()); $this->assertEquals(null, $children[0]->getToken()); @@ -570,9 +550,9 @@ class DefaultShareProviderTest extends \Test\TestCase { //Child2 $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $children[1]->getShareType()); - $this->assertEquals($group1, $children[1]->getSharedWith()); - $this->assertEquals($user3, $children[1]->getSharedBy()); - $this->assertEquals($shareOwner, $children[1]->getShareOwner()); + $this->assertEquals('group1', $children[1]->getSharedWith()); + $this->assertEquals('user3', $children[1]->getSharedBy()); + $this->assertEquals('shareOwner', $children[1]->getShareOwner()); $this->assertEquals($ownerPath, $children[1]->getNode()); $this->assertEquals(4, $children[1]->getPermissions()); $this->assertEquals(null, $children[1]->getToken()); @@ -583,21 +563,9 @@ class DefaultShareProviderTest extends \Test\TestCase { public function testCreateUserShare() { $share = new \OC\Share20\Share(); - $sharedWith = $this->getMock('OCP\IUser'); - $sharedWith->method('getUID')->willReturn('sharedWith'); - $sharedBy = $this->getMock('OCP\IUser'); - $sharedBy->method('getUID')->willReturn('sharedBy'); $shareOwner = $this->getMock('OCP\IUser'); $shareOwner->method('getUID')->WillReturn('shareOwner'); - $this->userManager - ->method('get') - ->will($this->returnValueMap([ - ['sharedWith', $sharedWith], - ['sharedBy', $sharedBy], - ['shareOwner', $shareOwner], - ])); - $path = $this->getMock('\OCP\Files\File'); $path->method('getId')->willReturn(100); $path->method('getOwner')->willReturn($shareOwner); @@ -619,9 +587,9 @@ class DefaultShareProviderTest extends \Test\TestCase { ->willReturn([$path]); $share->setShareType(\OCP\Share::SHARE_TYPE_USER); - $share->setSharedWith($sharedWith); - $share->setSharedBy($sharedBy); - $share->setShareOwner($shareOwner); + $share->setSharedWith('sharedWith'); + $share->setSharedBy('sharedBy'); + $share->setShareOwner('shareOwner'); $share->setNode($path); $share->setPermissions(1); $share->setTarget('/target'); @@ -631,9 +599,9 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertNotNull($share2->getId()); $this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId()); $this->assertSame(\OCP\Share::SHARE_TYPE_USER, $share2->getShareType()); - $this->assertSame($sharedWith, $share2->getSharedWith()); - $this->assertSame($sharedBy, $share2->getSharedBy()); - $this->assertSame($shareOwner, $share2->getShareOwner()); + $this->assertSame('sharedWith', $share2->getSharedWith()); + $this->assertSame('sharedBy', $share2->getSharedBy()); + $this->assertSame('shareOwner', $share2->getShareOwner()); $this->assertSame(1, $share2->getPermissions()); $this->assertSame('/target', $share2->getTarget()); $this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime()); @@ -643,23 +611,8 @@ class DefaultShareProviderTest extends \Test\TestCase { public function testCreateGroupShare() { $share = new \OC\Share20\Share(); - $sharedWith = $this->getMock('OCP\IGroup'); - $sharedWith->method('getGID')->willReturn('sharedWith'); - $sharedBy = $this->getMock('OCP\IUser'); - $sharedBy->method('getUID')->willReturn('sharedBy'); - $shareOwner = $this->getMock('OCP\IUser'); - $shareOwner->method('getUID')->WillReturn('shareOwner'); - - $this->userManager - ->method('get') - ->will($this->returnValueMap([ - ['sharedBy', $sharedBy], - ['shareOwner', $shareOwner], - ])); - $this->groupManager - ->method('get') - ->with('sharedWith') - ->willReturn($sharedWith); + $shareOwner = $this->getMock('\OCP\IUser'); + $shareOwner->method('getUID')->willReturn('shareOwner'); $path = $this->getMock('\OCP\Files\Folder'); $path->method('getId')->willReturn(100); @@ -682,9 +635,9 @@ class DefaultShareProviderTest extends \Test\TestCase { ->willReturn([$path]); $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP); - $share->setSharedWith($sharedWith); - $share->setSharedBy($sharedBy); - $share->setShareOwner($shareOwner); + $share->setSharedWith('sharedWith'); + $share->setSharedBy('sharedBy'); + $share->setShareOwner('shareOwner'); $share->setNode($path); $share->setPermissions(1); $share->setTarget('/target'); @@ -694,9 +647,9 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertNotNull($share2->getId()); $this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId()); $this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share2->getShareType()); - $this->assertSame($sharedWith, $share2->getSharedWith()); - $this->assertSame($sharedBy, $share2->getSharedBy()); - $this->assertSame($shareOwner, $share2->getShareOwner()); + $this->assertSame('sharedWith', $share2->getSharedWith()); + $this->assertSame('sharedBy', $share2->getSharedBy()); + $this->assertSame('shareOwner', $share2->getShareOwner()); $this->assertSame(1, $share2->getPermissions()); $this->assertSame('/target', $share2->getTarget()); $this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime()); @@ -706,17 +659,8 @@ class DefaultShareProviderTest extends \Test\TestCase { public function testCreateLinkShare() { $share = new \OC\Share20\Share(); - $sharedBy = $this->getMock('OCP\IUser'); - $sharedBy->method('getUID')->willReturn('sharedBy'); - $shareOwner = $this->getMock('OCP\IUser'); - $shareOwner->method('getUID')->WillReturn('shareOwner'); - - $this->userManager - ->method('get') - ->will($this->returnValueMap([ - ['sharedBy', $sharedBy], - ['shareOwner', $shareOwner], - ])); + $shareOwner = $this->getMock('\OCP\IUser'); + $shareOwner->method('getUID')->willReturn('shareOwner'); $path = $this->getMock('\OCP\Files\Folder'); $path->method('getId')->willReturn(100); @@ -739,8 +683,8 @@ class DefaultShareProviderTest extends \Test\TestCase { ->willReturn([$path]); $share->setShareType(\OCP\Share::SHARE_TYPE_LINK); - $share->setSharedBy($sharedBy); - $share->setShareOwner($shareOwner); + $share->setSharedBy('sharedBy'); + $share->setShareOwner('shareOwner'); $share->setNode($path); $share->setPermissions(1); $share->setPassword('password'); @@ -754,8 +698,8 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertNotNull($share2->getId()); $this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId()); $this->assertSame(\OCP\Share::SHARE_TYPE_LINK, $share2->getShareType()); - $this->assertSame($sharedBy, $share2->getSharedBy()); - $this->assertSame($shareOwner, $share2->getShareOwner()); + $this->assertSame('sharedBy', $share2->getSharedBy()); + $this->assertSame('shareOwner', $share2->getShareOwner()); $this->assertSame(1, $share2->getPermissions()); $this->assertSame('/target', $share2->getTarget()); $this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime()); @@ -783,17 +727,6 @@ class DefaultShareProviderTest extends \Test\TestCase { $qb->execute(); $id = $qb->getLastInsertId(); - $owner = $this->getMock('\OCP\IUser'); - $owner->method('getUID')->willReturn('shareOwner'); - $initiator = $this->getMock('\OCP\IUser'); - $initiator->method('getUID')->willReturn('sharedBy'); - - $this->userManager->method('get') - ->will($this->returnValueMap([ - ['sharedBy', $initiator], - ['shareOwner', $owner], - ])); - $file = $this->getMock('\OCP\Files\File'); $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); @@ -801,8 +734,8 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareByToken('secrettoken'); $this->assertEquals($id, $share->getId()); - $this->assertSame($owner, $share->getShareOwner()); - $this->assertSame($initiator, $share->getSharedBy()); + $this->assertSame('shareOwner', $share->getShareOwner()); + $this->assertSame('sharedBy', $share->getSharedBy()); $this->assertSame('secrettoken', $share->getToken()); $this->assertSame('password', $share->getPassword()); $this->assertSame(null, $share->getSharedWith()); @@ -845,31 +778,18 @@ class DefaultShareProviderTest extends \Test\TestCase { ]); $this->assertEquals(1, $qb->execute()); - $user = $this->getMock('\OCP\IUser'); - $user->method('getUID')->willReturn('sharedWith'); - $owner = $this->getMock('\OCP\IUser'); - $owner->method('getUID')->willReturn('shareOwner'); - $initiator = $this->getMock('\OCP\IUser'); - $initiator->method('getUID')->willReturn('sharedBy'); - - $this->userManager->method('get')->willReturnMap([ - ['sharedWith', $user], - ['shareOwner', $owner], - ['sharedBy', $initiator], - ]); - $file = $this->getMock('\OCP\Files\File'); $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); $this->rootFolder->method('getById')->with(42)->willReturn([$file]); - $share = $this->provider->getSharedWith($user, \OCP\Share::SHARE_TYPE_USER, null, 1 , 0); + $share = $this->provider->getSharedWith('sharedWith', \OCP\Share::SHARE_TYPE_USER, null, 1 , 0); $this->assertCount(1, $share); $share = $share[0]; $this->assertEquals($id, $share->getId()); - $this->assertEquals($user, $share->getSharedWith()); - $this->assertEquals($owner, $share->getShareOwner()); - $this->assertEquals($initiator, $share->getSharedBy()); + $this->assertEquals('sharedWith', $share->getSharedWith()); + $this->assertEquals('shareOwner', $share->getShareOwner()); + $this->assertEquals('sharedBy', $share->getSharedBy()); $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); } @@ -922,6 +842,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $initiator->method('getUID')->willReturn('sharedBy'); $this->userManager->method('get')->willReturnMap([ + ['sharedWith', $user], ['shareOwner', $owner], ['sharedBy', $initiator], ]); @@ -932,14 +853,14 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); $this->rootFolder->method('getById')->with(42)->willReturn([$file]); - $share = $this->provider->getSharedWith($user, \OCP\Share::SHARE_TYPE_GROUP, null, 20 , 1); + $share = $this->provider->getSharedWith('sharedWith', \OCP\Share::SHARE_TYPE_GROUP, null, 20 , 1); $this->assertCount(1, $share); $share = $share[0]; $this->assertEquals($id, $share->getId()); - $this->assertEquals($group, $share->getSharedWith()); - $this->assertEquals($owner, $share->getShareOwner()); - $this->assertEquals($initiator, $share->getSharedBy()); + $this->assertEquals('sharedWith', $share->getSharedWith()); + $this->assertEquals('shareOwner', $share->getShareOwner()); + $this->assertEquals('sharedBy', $share->getSharedBy()); $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); } @@ -1007,6 +928,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $initiator->method('getUID')->willReturn('sharedBy'); $this->userManager->method('get')->willReturnMap([ + ['user', $user], ['shareOwner', $owner], ['sharedBy', $initiator], ]); @@ -1017,14 +939,14 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); $this->rootFolder->method('getById')->with(42)->willReturn([$file]); - $share = $this->provider->getSharedWith($user, \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0); + $share = $this->provider->getSharedWith('user', \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0); $this->assertCount(1, $share); $share = $share[0]; $this->assertSame($id, $share->getId()); - $this->assertSame($group, $share->getSharedWith()); - $this->assertSame($owner, $share->getShareOwner()); - $this->assertSame($initiator, $share->getSharedBy()); + $this->assertSame('sharedWith', $share->getSharedWith()); + $this->assertSame('shareOwner', $share->getShareOwner()); + $this->assertSame('sharedBy', $share->getSharedBy()); $this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); $this->assertSame(0, $share->getPermissions()); $this->assertSame('userTarget', $share->getTarget()); @@ -1051,14 +973,14 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); $this->rootFolder->method('getById')->with(43)->willReturn([$file]); - $share = $this->provider->getSharedWith($user0, \OCP\Share::SHARE_TYPE_USER, $file, -1, 0); + $share = $this->provider->getSharedWith('user0', \OCP\Share::SHARE_TYPE_USER, $file, -1, 0); $this->assertCount(1, $share); $share = $share[0]; $this->assertEquals($id, $share->getId()); - $this->assertSame($user0, $share->getSharedWith()); - $this->assertSame($user1, $share->getShareOwner()); - $this->assertSame($user1, $share->getSharedBy()); + $this->assertSame('user0', $share->getSharedWith()); + $this->assertSame('user1', $share->getShareOwner()); + $this->assertSame('user1', $share->getSharedBy()); $this->assertSame($file, $share->getNode()); $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); } @@ -1090,14 +1012,14 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); $this->rootFolder->method('getById')->with(43)->willReturn([$node]); - $share = $this->provider->getSharedWith($user0, \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0); + $share = $this->provider->getSharedWith('user0', \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0); $this->assertCount(1, $share); $share = $share[0]; $this->assertEquals($id, $share->getId()); - $this->assertSame($group0, $share->getSharedWith()); - $this->assertSame($user1, $share->getShareOwner()); - $this->assertSame($user1, $share->getSharedBy()); + $this->assertSame('group0', $share->getSharedWith()); + $this->assertSame('user1', $share->getShareOwner()); + $this->assertSame('user1', $share->getSharedBy()); $this->assertSame($node, $share->getNode()); $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); } @@ -1133,31 +1055,18 @@ class DefaultShareProviderTest extends \Test\TestCase { ]); $this->assertEquals(1, $qb->execute()); - $user = $this->getMock('\OCP\IUser'); - $user->method('getUID')->willReturn('sharedWith'); - $owner = $this->getMock('\OCP\IUser'); - $owner->method('getUID')->willReturn('shareOwner'); - $initiator = $this->getMock('\OCP\IUser'); - $initiator->method('getUID')->willReturn('sharedBy'); - - $this->userManager->method('get')->willReturnMap([ - ['sharedWith', $user], - ['shareOwner', $owner], - ['sharedBy', $initiator], - ]); - $file = $this->getMock('\OCP\Files\File'); $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); $this->rootFolder->method('getById')->with(42)->willReturn([$file]); - $share = $this->provider->getSharesBy($initiator, \OCP\Share::SHARE_TYPE_USER, null, false, 1, 0); + $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, null, false, 1, 0); $this->assertCount(1, $share); $share = $share[0]; $this->assertEquals($id, $share->getId()); - $this->assertEquals($user, $share->getSharedWith()); - $this->assertEquals($owner, $share->getShareOwner()); - $this->assertEquals($initiator, $share->getSharedBy()); + $this->assertEquals('sharedWith', $share->getSharedWith()); + $this->assertEquals('shareOwner', $share->getShareOwner()); + $this->assertEquals('sharedBy', $share->getSharedBy()); $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); $this->assertEquals(13, $share->getPermissions()); $this->assertEquals('myTarget', $share->getTarget()); @@ -1194,32 +1103,19 @@ class DefaultShareProviderTest extends \Test\TestCase { ]); $this->assertEquals(1, $qb->execute()); - $user = $this->getMock('\OCP\IUser'); - $user->method('getUID')->willReturn('sharedWith'); - $owner = $this->getMock('\OCP\IUser'); - $owner->method('getUID')->willReturn('shareOwner'); - $initiator = $this->getMock('\OCP\IUser'); - $initiator->method('getUID')->willReturn('sharedBy'); - - $this->userManager->method('get')->willReturnMap([ - ['sharedWith', $user], - ['shareOwner', $owner], - ['sharedBy', $initiator], - ]); - $file = $this->getMock('\OCP\Files\File'); $file->method('getId')->willReturn(42); $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); $this->rootFolder->method('getById')->with(42)->willReturn([$file]); - $share = $this->provider->getSharesBy($initiator, \OCP\Share::SHARE_TYPE_USER, $file, false, 1, 0); + $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, $file, false, 1, 0); $this->assertCount(1, $share); $share = $share[0]; $this->assertEquals($id, $share->getId()); - $this->assertEquals($user, $share->getSharedWith()); - $this->assertEquals($owner, $share->getShareOwner()); - $this->assertEquals($initiator, $share->getSharedBy()); + $this->assertEquals('sharedWith', $share->getSharedWith()); + $this->assertEquals('shareOwner', $share->getShareOwner()); + $this->assertEquals('sharedBy', $share->getSharedBy()); $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); $this->assertEquals(13, $share->getPermissions()); $this->assertEquals('myTarget', $share->getTarget()); @@ -1256,41 +1152,28 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals(1, $qb->execute()); $id2 = $qb->getLastInsertId(); - $user = $this->getMock('\OCP\IUser'); - $user->method('getUID')->willReturn('sharedWith'); - $owner = $this->getMock('\OCP\IUser'); - $owner->method('getUID')->willReturn('shareOwner'); - $initiator = $this->getMock('\OCP\IUser'); - $initiator->method('getUID')->willReturn('sharedBy'); - - $this->userManager->method('get')->willReturnMap([ - ['sharedWith', $user], - ['shareOwner', $owner], - ['sharedBy', $initiator], - ]); - $file = $this->getMock('\OCP\Files\File'); $file->method('getId')->willReturn(42); $this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf()); $this->rootFolder->method('getById')->with(42)->willReturn([$file]); - $shares = $this->provider->getSharesBy($owner, \OCP\Share::SHARE_TYPE_USER, null, true, -1, 0); + $shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_USER, null, true, -1, 0); $this->assertCount(2, $shares); $share = $shares[0]; $this->assertEquals($id1, $share->getId()); - $this->assertSame($user, $share->getSharedWith()); - $this->assertSame($owner, $share->getShareOwner()); - $this->assertSame($owner, $share->getSharedBy()); + $this->assertSame('sharedWith', $share->getSharedWith()); + $this->assertSame('shareOwner', $share->getShareOwner()); + $this->assertSame('shareOwner', $share->getSharedBy()); $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); $this->assertEquals(13, $share->getPermissions()); $this->assertEquals('myTarget', $share->getTarget()); $share = $shares[1]; $this->assertEquals($id2, $share->getId()); - $this->assertSame($user, $share->getSharedWith()); - $this->assertSame($owner, $share->getShareOwner()); - $this->assertSame($initiator, $share->getSharedBy()); + $this->assertSame('sharedWith', $share->getSharedWith()); + $this->assertSame('shareOwner', $share->getShareOwner()); + $this->assertSame('sharedBy', $share->getSharedBy()); $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); $this->assertEquals(0, $share->getPermissions()); $this->assertEquals('userTarget', $share->getTarget()); @@ -1334,7 +1217,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id); - $this->provider->deleteFromSelf($share, $user2); + $this->provider->deleteFromSelf($share, 'user2'); $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->select('*') @@ -1405,7 +1288,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id); - $this->provider->deleteFromSelf($share, $user2); + $this->provider->deleteFromSelf($share, 'user2'); $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->select('*') @@ -1465,7 +1348,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id); - $this->provider->deleteFromSelf($share, $user2); + $this->provider->deleteFromSelf($share, 'user2'); } public function testDeleteFromSelfUser() { @@ -1501,7 +1384,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id); - $this->provider->deleteFromSelf($share, $user2); + $this->provider->deleteFromSelf($share, 'user2'); $qb = $this->dbConn->getQueryBuilder(); $stmt = $qb->select('*') @@ -1627,18 +1510,18 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id); - $share->setSharedWith($users['user3']); - $share->setSharedBy($users['user4']); - $share->setShareOwner($users['user5']); + $share->setSharedWith('user3'); + $share->setSharedBy('user4'); + $share->setShareOwner('user5'); $share->setNode($file2); $share->setPermissions(1); $share2 = $this->provider->update($share); $this->assertEquals($id, $share2->getId()); - $this->assertSame($users['user3'], $share2->getSharedWith()); - $this->assertSame($users['user4'], $share2->getSharedBy()); - $this->assertSame($users['user5'], $share2->getShareOwner()); + $this->assertSame('user3', $share2->getSharedWith()); + $this->assertSame('user4', $share2->getSharedBy()); + $this->assertSame('user5', $share2->getShareOwner()); $this->assertSame(1, $share2->getPermissions()); } @@ -1677,8 +1560,8 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id); $share->setPassword('password'); - $share->setSharedBy($users['user4']); - $share->setShareOwner($users['user5']); + $share->setSharedBy('user4'); + $share->setShareOwner('user5'); $share->setNode($file2); $share->setPermissions(1); @@ -1686,8 +1569,8 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals($id, $share2->getId()); $this->assertEquals('password', $share->getPassword()); - $this->assertSame($users['user4'], $share2->getSharedBy()); - $this->assertSame($users['user5'], $share2->getShareOwner()); + $this->assertSame('user4', $share2->getSharedBy()); + $this->assertSame('user5', $share2->getShareOwner()); $this->assertSame(1, $share2->getPermissions()); } @@ -1726,8 +1609,8 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id); $share->setPassword(null); - $share->setSharedBy($users['user4']); - $share->setShareOwner($users['user5']); + $share->setSharedBy('user4'); + $share->setShareOwner('user5'); $share->setNode($file2); $share->setPermissions(1); @@ -1735,8 +1618,8 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals($id, $share2->getId()); $this->assertEquals(null, $share->getPassword()); - $this->assertSame($users['user4'], $share2->getSharedBy()); - $this->assertSame($users['user5'], $share2->getShareOwner()); + $this->assertSame('user4', $share2->getSharedBy()); + $this->assertSame('user5', $share2->getShareOwner()); $this->assertSame(1, $share2->getPermissions()); } @@ -1787,9 +1670,9 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id); - $share->setSharedWith($groups['group0']); - $share->setSharedBy($users['user4']); - $share->setShareOwner($users['user5']); + $share->setSharedWith('group0'); + $share->setSharedBy('user4'); + $share->setShareOwner('user5'); $share->setNode($file2); $share->setPermissions(1); @@ -1797,9 +1680,9 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals($id, $share2->getId()); // Group shares do not allow updating the recipient - $this->assertSame($groups['group0'], $share2->getSharedWith()); - $this->assertSame($users['user4'], $share2->getSharedBy()); - $this->assertSame($users['user5'], $share2->getShareOwner()); + $this->assertSame('group0', $share2->getSharedWith()); + $this->assertSame('user4', $share2->getSharedBy()); + $this->assertSame('user5', $share2->getShareOwner()); $this->assertSame(1, $share2->getPermissions()); } @@ -1856,9 +1739,9 @@ class DefaultShareProviderTest extends \Test\TestCase { $share = $this->provider->getShareById($id); - $share->setSharedWith($groups['group0']); - $share->setSharedBy($users['user4']); - $share->setShareOwner($users['user5']); + $share->setSharedWith('group0'); + $share->setSharedBy('user4'); + $share->setShareOwner('user5'); $share->setNode($file2); $share->setPermissions(1); @@ -1866,9 +1749,9 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals($id, $share2->getId()); // Group shares do not allow updating the recipient - $this->assertSame($groups['group0'], $share2->getSharedWith()); - $this->assertSame($users['user4'], $share2->getSharedBy()); - $this->assertSame($users['user5'], $share2->getShareOwner()); + $this->assertSame('group0', $share2->getSharedWith()); + $this->assertSame('user4', $share2->getSharedBy()); + $this->assertSame('user5', $share2->getShareOwner()); $this->assertSame(1, $share2->getPermissions()); $qb = $this->dbConn->getQueryBuilder(); @@ -1949,18 +1832,18 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf()); $this->rootFolder->method('getById')->willReturn([$folder]); - $share = $this->provider->getShareById($id, $user0); + $share = $this->provider->getShareById($id, 'user0'); $share->setTarget('/newTarget'); - $this->provider->move($share, $user0); + $this->provider->move($share, 'user0'); - $share = $this->provider->getShareById($id, $user0); + $share = $this->provider->getShareById($id, 'user0'); $this->assertSame('/newTarget', $share->getTarget()); $share->setTarget('/ultraNewTarget'); - $this->provider->move($share, $user0); + $this->provider->move($share, 'user0'); - $share = $this->provider->getShareById($id, $user0); + $share = $this->provider->getShareById($id, 'user0'); $this->assertSame('/ultraNewTarget', $share->getTarget()); } } -- 2.39.5