diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-19 12:34:28 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-01-19 12:34:28 +0100 |
commit | d2d6472e39144f1dfe5915bf8c11119fc8dcdd4b (patch) | |
tree | d3899715948611b823d8249d79820d877ed547d0 /tests | |
parent | d75af7ddd29179a6f22b1ee46efd3c8df9dd09a9 (diff) | |
parent | 40931a8b0d5d10c0f711756a4e8a423ff055621e (diff) | |
download | nextcloud-server-d2d6472e39144f1dfe5915bf8c11119fc8dcdd4b.tar.gz nextcloud-server-d2d6472e39144f1dfe5915bf8c11119fc8dcdd4b.zip |
Merge pull request #13423 from owncloud/share-fixfindshareforuserwithmultiplegroups
Fix getItemSharedWithUser for groups
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/share/share.php | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index b8abfa29a81..b1261b0afbd 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -692,6 +692,41 @@ class Test_Share extends \Test\TestCase { $this->verifyResult($result4, array('target1', 'target2', 'target3', 'target4')); } + public function testGetItemSharedWithUserFromGroupShare() { + OC_User::setUserId($this->user1); + + //add dummy values to the share table + $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (' + .' `item_type`, `item_source`, `item_target`, `share_type`,' + .' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)'); + $args = array('test', 99, 'target1', OCP\Share::SHARE_TYPE_GROUP, $this->group1, $this->user1); + $query->execute($args); + $args = array('test', 99, 'target2', OCP\Share::SHARE_TYPE_GROUP, $this->group2, $this->user1); + $query->execute($args); + $args = array('test', 99, 'target3', OCP\Share::SHARE_TYPE_GROUP, $this->group1, $this->user2); + $query->execute($args); + $args = array('test', 99, 'target4', OCP\Share::SHARE_TYPE_GROUP, $this->group1, $this->user4); + $query->execute($args); + + // user2 is in group1 and group2 + $result1 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user2, $this->user1); + $this->assertSame(2, count($result1)); + $this->verifyResult($result1, array('target1', 'target2')); + + $result2 = \OCP\Share::getItemSharedWithUser('test', 99, null, $this->user1); + $this->assertSame(2, count($result2)); + $this->verifyResult($result2, array('target1', 'target2')); + + // user3 is in group1 and group2 + $result3 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user3); + $this->assertSame(3, count($result3)); + $this->verifyResult($result3, array('target1', 'target3', 'target4')); + + $result4 = \OCP\Share::getItemSharedWithUser('test', 99, null, null); + $this->assertSame(4, count($result4)); + $this->verifyResult($result4, array('target1', 'target2', 'target3', 'target4')); + } + public function verifyResult($result, $expected) { foreach ($result as $r) { if (in_array($r['item_target'], $expected)) { |