summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorMichael Kuhn <suraia@ikkoku.de>2014-08-23 12:05:19 +0200
committerMichael Kuhn <suraia@ikkoku.de>2014-08-23 12:05:19 +0200
commit0a77a5ec1938529f4a190df33a35b3a0c9633e4f (patch)
treea6e08c0ac232d97d3bc8aec80ccb6bfa02881be8 /tests/lib
parentecdd04374a4cabdf682e427b59619ef2e42d2997 (diff)
downloadnextcloud-server-0a77a5ec1938529f4a190df33a35b3a0c9633e4f.tar.gz
nextcloud-server-0a77a5ec1938529f4a190df33a35b3a0c9633e4f.zip
Add unit tests for new unshareFromSelf() functionality.
Diffstat (limited to 'tests/lib')
-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 5920b44a8e0..072cf32cd66 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);
@@ -513,6 +532,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);