]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add unit tests for sharebymail provider
authorJoas Schilling <coding@schilljs.com>
Tue, 11 Apr 2017 10:16:10 +0000 (12:16 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 13 Apr 2017 10:58:52 +0000 (12:58 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/sharebymail/tests/ShareByMailProviderTest.php

index 288ebb4bb452a250e78e312940fe3a3432f2248b..1b215016ee4bab1ace5b264d1dec76965230b579 100644 (file)
@@ -664,4 +664,59 @@ class ShareByMailProviderTest extends TestCase {
                $u2->delete();
        }
 
+       public function testGetAccessList() {
+               $userManager = \OC::$server->getUserManager();
+               $rootFolder = \OC::$server->getRootFolder();
+
+               $provider = $this->getInstance(['sendMailNotification', 'createActivity']);
+
+               $u1 = $userManager->createUser('testFed', md5(time()));
+               $u2 = $userManager->createUser('testFed2', md5(time()));
+
+               $folder = $rootFolder->getUserFolder($u1->getUID())->newFolder('foo');
+
+               $share1 = $this->shareManager->newShare();
+               $share1->setSharedWith('user@server.com')
+                       ->setSharedBy($u1->getUID())
+                       ->setShareOwner($u1->getUID())
+                       ->setPermissions(\OCP\Constants::PERMISSION_READ)
+                       ->setNode($folder);
+               $share1 = $provider->create($share1);
+
+               $share2 = $this->shareManager->newShare();
+               $share2->setSharedWith('user2@server.com')
+                       ->setSharedBy($u2->getUID())
+                       ->setShareOwner($u1->getUID())
+                       ->setPermissions(\OCP\Constants::PERMISSION_READ)
+                       ->setNode($folder);
+               $share2 = $provider->create($share2);
+
+               $accessList = $provider->getAccessList([$folder], true);
+               $this->assertArrayHasKey('mail', $accessList);
+               $this->assertTrue($accessList['mail']);
+               $accessList = $provider->getAccessList([$folder], false);
+               $this->assertArrayHasKey('mail', $accessList);
+               $this->assertTrue($accessList['mail']);
+
+               $provider->delete($share2);
+
+               $accessList = $provider->getAccessList([$folder], true);
+               $this->assertArrayHasKey('mail', $accessList);
+               $this->assertTrue($accessList['mail']);
+               $accessList = $provider->getAccessList([$folder], false);
+               $this->assertArrayHasKey('mail', $accessList);
+               $this->assertTrue($accessList['mail']);
+
+               $provider->delete($share1);
+
+               $accessList = $provider->getAccessList([$folder], true);
+               $this->assertArrayHasKey('mail', $accessList);
+               $this->assertFalse($accessList['mail']);
+               $accessList = $provider->getAccessList([$folder], false);
+               $this->assertArrayHasKey('mail', $accessList);
+               $this->assertFalse($accessList['mail']);
+
+               $u1->delete();
+               $u2->delete();
+       }
 }