diff options
author | Lukas Reschke <lukas@owncloud.com> | 2016-04-12 21:32:40 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2016-04-12 21:32:40 +0200 |
commit | ef93ec8bc2a0a18d6fa26a2990913463b0861bc7 (patch) | |
tree | 20b2b7c521c0df02fbc6323c6d7437e638cf3bc0 /tests/lib | |
parent | f17ad1886527b7dc4d493a1012c2bb7945bbe80f (diff) | |
download | nextcloud-server-ef93ec8bc2a0a18d6fa26a2990913463b0861bc7.tar.gz nextcloud-server-ef93ec8bc2a0a18d6fa26a2990913463b0861bc7.zip |
Add test
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/share20/managertest.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php index d173f86f091..197fa874388 100644 --- a/tests/lib/share20/managertest.php +++ b/tests/lib/share20/managertest.php @@ -2042,6 +2042,46 @@ class ManagerTest extends \Test\TestCase { $this->assertSame($share, $ret); } + public function testGetShareByTokenWithException() { + $factory = $this->getMock('\OCP\Share\IProviderFactory'); + + $manager = new Manager( + $this->logger, + $this->config, + $this->secureRandom, + $this->hasher, + $this->mountManager, + $this->groupManager, + $this->l, + $factory, + $this->userManager, + $this->rootFolder + ); + + $share = $this->getMock('\OCP\Share\IShare'); + + $factory->expects($this->at(0)) + ->method('getProviderForType') + ->with(\OCP\Share::SHARE_TYPE_LINK) + ->willReturn($this->defaultProvider); + $factory->expects($this->at(1)) + ->method('getProviderForType') + ->with(\OCP\Share::SHARE_TYPE_REMOTE) + ->willReturn($this->defaultProvider); + + $this->defaultProvider->expects($this->at(0)) + ->method('getShareByToken') + ->with('token') + ->will($this->throwException(new ShareNotFound())); + $this->defaultProvider->expects($this->at(1)) + ->method('getShareByToken') + ->with('token') + ->willReturn($share); + + $ret = $manager->getShareByToken('token'); + $this->assertSame($share, $ret); + } + /** * @expectedException \OCP\Share\Exceptions\ShareNotFound */ |