Add unit tests for sharebymail provider

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-04-11 12:16:10 +02:00 committed by Roeland Jago Douma
parent 4eeb194ae5
commit 6c23a5fa35
No known key found for this signature in database
GPG key ID: F941078878347C0C

View 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();
}
}