summaryrefslogtreecommitdiffstats
path: root/tests/lib/share
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2014-08-27 10:31:35 +0200
committerBjörn Schießle <schiessle@owncloud.com>2014-08-27 10:31:35 +0200
commitc35d60f6d80dbb244b6223de3fdb894b0ef34d34 (patch)
tree2719e18a9db147b81a0e812add34d427b64bda86 /tests/lib/share
parent2740908a5b168563b60ab9cf40ae274c2ce1df25 (diff)
parent0a77a5ec1938529f4a190df33a35b3a0c9633e4f (diff)
downloadnextcloud-server-c35d60f6d80dbb244b6223de3fdb894b0ef34d34.tar.gz
nextcloud-server-c35d60f6d80dbb244b6223de3fdb894b0ef34d34.zip
Merge pull request #9915 from suraia/unsharefromself-source
Allow specifying the item source in unshareFromSelf().
Diffstat (limited to 'tests/lib/share')
-rw-r--r--tests/lib/share/share.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index bb827eece73..59056003fca 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -314,6 +314,25 @@ class Test_Share extends PHPUnit_Framework_TestCase {
$this->assertTrue(in_array('test.txt', $to_test));
$this->assertTrue(in_array('test1.txt', $to_test));
+ // Unshare from self
+ $this->assertTrue(OCP\Share::unshareFromSelf('test', 'test.txt'));
+ $this->assertEquals(array('test1.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET));
+
+ // Unshare from self via source
+ $this->assertTrue(OCP\Share::unshareFromSelf('test', 'share.txt', true));
+ $this->assertEquals(array(), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET));
+
+ OC_User::setUserId($this->user1);
+ $this->assertTrue(OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ));
+ OC_User::setUserId($this->user3);
+ $this->assertTrue(OCP\Share::shareItem('test', 'share.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ));
+
+ OC_User::setUserId($this->user2);
+ $to_test = OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET);
+ $this->assertEquals(2, count($to_test));
+ $this->assertTrue(in_array('test.txt', $to_test));
+ $this->assertTrue(in_array('test1.txt', $to_test));
+
// Remove user
OC_User::setUserId($this->user1);
OC_User::deleteUser($this->user1);
@@ -568,6 +587,11 @@ class Test_Share extends PHPUnit_Framework_TestCase {
OC_User::setUserId($this->user2);
$this->assertEquals(array('test.txt'), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET));
+ // Unshare from self via source
+ OC_User::setUserId($this->user1);
+ $this->assertTrue(OCP\Share::unshareFromSelf('test', 'share.txt', true));
+ $this->assertEquals(array(), OCP\Share::getItemsSharedWith('test', Test_Share_Backend::FORMAT_TARGET));
+
// Remove group
OC_Group::deleteGroup($this->group1);
OC_User::setUserId($this->user4);