]> source.dussan.org Git - nextcloud-server.git/commitdiff
Test whether a still-valid user share is still accessible.
authorAndreas Fischer <bantu@owncloud.com>
Wed, 4 Sep 2013 15:26:30 +0000 (17:26 +0200)
committerAndreas Fischer <bantu@owncloud.com>
Thu, 12 Sep 2013 21:43:20 +0000 (23:43 +0200)
tests/lib/share/share.php

index bce041a06f23bbdfe70aba11520a8c2f79846ee6..cf211817e3c6006527f8a1deedc30192ec3f6fda 100644 (file)
@@ -266,34 +266,57 @@ class Test_Share extends PHPUnit_Framework_TestCase {
 
        public function testShareWithUserExpirationExpired()
        {
+               $this->shareUserOneTestFileWithUserTwo();
+
                OC_User::setUserId($this->user1);
                $this->assertTrue(
-                       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.'
+                       OCP\Share::setExpirationDate('test', 'test.txt', '2000-01-01 00:00'),
+                       'Failed asserting that user 1 successfully set an expiration date for the test.txt share.'
                );
-               $this->assertEquals(
-                       array('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->assertFalse(
+                       OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
+                       'Failed asserting that user 2 no longer has access to test.txt after expiration.'
+               );
+       }
+
+       public function testShareWithUserExpirationValid()
+       {
+               $this->shareUserOneTestFileWithUserTwo();
+
+               OC_User::setUserId($this->user1);
+               $this->assertTrue(
+                       OCP\Share::setExpirationDate('test', 'test.txt', '2037-01-01 00:00'),
+                       'Failed asserting that user 1 successfully set an expiration date for the test.txt share.'
                );
 
                OC_User::setUserId($this->user2);
                $this->assertEquals(
                        array('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.'
+                       'Failed asserting that user 2 still has access to test.txt after expiration date has been set.'
                );
+       }
 
+       protected function shareUserOneTestFileWithUserTwo()
+       {
                OC_User::setUserId($this->user1);
                $this->assertTrue(
-                       OCP\Share::setExpirationDate('test', 'test.txt', '2000-01-01 00:00'),
-                       'Failed asserting that user 1 successfully set an expiration date for the test.txt share.'
+                       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'),
+                       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->assertFalse(
+               $this->assertEquals(
+                       array('test.txt'),
                        OCP\Share::getItemSharedWith('test', 'test.txt', Test_Share_Backend::FORMAT_SOURCE),
-                       'Failed asserting that user 2 no longer has access to test.txt after expiration.'
+                       'Failed asserting that user 2 has access to test.txt after initial sharing.'
                );
        }