diff options
author | Joas Schilling <coding@schilljs.com> | 2017-04-11 12:16:10 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-04-13 12:58:52 +0200 |
commit | 6c23a5fa3511e5212c83e8407fa18b12ec975f97 (patch) | |
tree | 86efb1ef63838c80d52d4f300763a45be08d38f0 /apps/sharebymail | |
parent | 4eeb194ae5f7d52e40a2be318730f0c44eb19ca8 (diff) | |
download | nextcloud-server-6c23a5fa3511e5212c83e8407fa18b12ec975f97.tar.gz nextcloud-server-6c23a5fa3511e5212c83e8407fa18b12ec975f97.zip |
Add unit tests for sharebymail provider
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/sharebymail')
-rw-r--r-- | apps/sharebymail/tests/ShareByMailProviderTest.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index 288ebb4bb45..1b215016ee4 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -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(); + } } |