]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add tests for OCP\Share::unshareAll().
authorAndreas Fischer <bantu@owncloud.com>
Mon, 23 Sep 2013 14:16:48 +0000 (16:16 +0200)
committerMorris Jobke <morris.jobke@gmail.com>
Sun, 3 Nov 2013 11:31:53 +0000 (12:31 +0100)
tests/lib/share/share.php

index 8e9eef65d320fad8bb5d8f4af1211f78c9ae0fb0..84e2e5c63eba105b9c4a59931a1774981fa0e554 100644 (file)
@@ -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.'
+               );
+       }
 }