diff options
author | Andreas Fischer <bantu@owncloud.com> | 2013-09-23 16:16:48 +0200 |
---|---|---|
committer | Morris Jobke <morris.jobke@gmail.com> | 2013-11-03 12:31:53 +0100 |
commit | 8872b881ccc9641607dbb12e308b55b3c1714698 (patch) | |
tree | 7649c25f7b763c5e9e2c1a44177f74a2a358cffd /tests | |
parent | a937272379feea129c27b38055a14eed5e43156e (diff) | |
download | nextcloud-server-8872b881ccc9641607dbb12e308b55b3c1714698.tar.gz nextcloud-server-8872b881ccc9641607dbb12e308b55b3c1714698.zip |
Add tests for OCP\Share::unshareAll().
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/share/share.php | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index 8e9eef65d32..84e2e5c63eb 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -135,15 +135,15 @@ class Test_Share extends PHPUnit_Framework_TestCase { OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user2, OCP\PERMISSION_READ), 'Failed asserting that user 1 successfully shared text.txt with user 2.' ); - $this->assertEquals( - array('test.txt'), + $this->assertContains( + 'test.txt', OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE), 'Failed asserting that test.txt is a shared file of user 1.' ); OC_User::setUserId($this->user2); - $this->assertEquals( - array('test.txt'), + $this->assertContains( + 'test.txt', OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE), 'Failed asserting that user 2 has access to test.txt after initial sharing.' ); @@ -328,22 +328,22 @@ class Test_Share extends PHPUnit_Framework_TestCase { OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_GROUP, $this->group1, OCP\PERMISSION_READ), 'Failed asserting that user 1 successfully shared text.txt with group 1.' ); - $this->assertEquals( - array('test.txt'), + $this->assertContains( + 'test.txt', OCP\Share::getItemShared('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE), 'Failed asserting that test.txt is a shared file of user 1.' ); OC_User::setUserId($this->user2); - $this->assertEquals( - array('test.txt'), + $this->assertContains( + 'test.txt', OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE), 'Failed asserting that user 2 has access to test.txt after initial sharing.' ); OC_User::setUserId($this->user3); - $this->assertEquals( - array('test.txt'), + $this->assertContains( + 'test.txt', OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE), 'Failed asserting that user 3 has access to test.txt after initial sharing.' ); @@ -583,4 +583,27 @@ class Test_Share extends PHPUnit_Framework_TestCase { 'Failed asserting that an expired share could not be found.' ); } + + public function testUnshareAll() { + $this->shareUserOneTestFileWithUserTwo(); + $this->shareUserOneTestFileWithGroupOne(); + + OC_User::setUserId($this->user1); + $this->assertEquals( + array('test.txt', 'test.txt'), + OCP\Share::getItemsShared('test', 'test.txt'), + 'Failed asserting that the test.txt file is shared exactly two times.' + ); + + $this->assertTrue( + OCP\Share::unshareAll('test', 'test.txt'), + 'Failed asserting that user 1 successfully unshared all shares of the test.txt share.' + ); + + $this->assertEquals( + array(), + OCP\Share::getItemsShared('test'), + 'Failed asserting that both shares of the test.txt file have been removed.' + ); + } } |