summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorRoeland Douma <rullzer@users.noreply.github.com>2016-02-02 11:34:20 +0100
committerRoeland Douma <rullzer@users.noreply.github.com>2016-02-02 11:34:20 +0100
commit8ebdfd0e05331ed557920dac915653c309424797 (patch)
tree82b716cfbce3e78f6426b4febdca0ea1e8358c4a /tests/lib
parent4777f78187cb758413db1b11f11ccb9304f12482 (diff)
parentdf690cd1f2c3d49d52a0b70fdf04f386718ddb28 (diff)
downloadnextcloud-server-8ebdfd0e05331ed557920dac915653c309424797.tar.gz
nextcloud-server-8ebdfd0e05331ed557920dac915653c309424797.zip
Merge pull request #22005 from owncloud/share2_getshare_byid_as_recipient
[Share 2.0] Allow recipient to be passed in to getShareById
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/share20/defaultshareprovidertest.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/lib/share20/defaultshareprovidertest.php b/tests/lib/share20/defaultshareprovidertest.php
index 28b57435e1d..4145e9e5ec6 100644
--- a/tests/lib/share20/defaultshareprovidertest.php
+++ b/tests/lib/share20/defaultshareprovidertest.php
@@ -247,6 +247,44 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals('myTarget', $share->getTarget());
}
+ public function testGetShareByIdUserGroupShare() {
+ $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user0', 'user0', 'file', 42, 'myTarget', 31, null, null);
+ $this->addShareToDB(2, 'user1', 'user0', 'user0', 'file', 42, 'userTarget', 0, null, null, $id);
+
+ $user0 = $this->getMock('OCP\IUser');
+ $user0->method('getUID')->willReturn('user0');
+ $user1 = $this->getMock('OCP\IUser');
+ $user1->method('getUID')->willReturn('user1');
+
+ $group0 = $this->getMock('OCP\IGroup');
+ $group0->method('inGroup')->with($user1)->willReturn(true);
+
+ $node = $this->getMock('\OCP\Files\Folder');
+ $node->method('getId')->willReturn(42);
+
+ $this->rootFolder->method('getUserFolder')->with('user0')->will($this->returnSelf());
+ $this->rootFolder->method('getById')->willReturn([$node]);
+
+ $this->userManager->method('get')->will($this->returnValueMap([
+ ['user0', $user0],
+ ['user1', $user1],
+ ]));
+ $this->groupManager->method('get')->with('group0')->willReturn($group0);
+
+ $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($node, $share->getNode());
+ $this->assertEquals(0, $share->getPermissions());
+ $this->assertEquals(null, $share->getToken());
+ $this->assertEquals(null, $share->getExpirationDate());
+ $this->assertEquals('userTarget', $share->getTarget());
+ }
+
public function testGetShareByIdLinkShare() {
$qb = $this->dbConn->getQueryBuilder();