diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-01-29 10:27:39 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-02 11:34:52 +0100 |
commit | 2316cb1f8b9704621b47e6eb1c2cbf30c06c552d (patch) | |
tree | ca606e3695c30823e8967c5f875e359e5e98b4d2 /tests/lib/share20/managertest.php | |
parent | 8ebdfd0e05331ed557920dac915653c309424797 (diff) | |
download | nextcloud-server-2316cb1f8b9704621b47e6eb1c2cbf30c06c552d.tar.gz nextcloud-server-2316cb1f8b9704621b47e6eb1c2cbf30c06c552d.zip |
[Share 2.0] Allow moving of shares
* Only recipient can move a share
* Unit tests
Diffstat (limited to 'tests/lib/share20/managertest.php')
-rw-r--r-- | tests/lib/share20/managertest.php | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php index b5559bb5172..1a6e8200ade 100644 --- a/tests/lib/share20/managertest.php +++ b/tests/lib/share20/managertest.php @@ -1887,6 +1887,79 @@ class ManagerTest extends \Test\TestCase { $manager->updateShare($share); } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Can't change target of link share + */ + public function testMoveShareLink() { + $share = $this->manager->newShare(); + $share->setShareType(\OCP\Share::SHARE_TYPE_LINK); + + $recipient = $this->getMock('\OCP\IUser'); + + $this->manager->moveShare($share, $recipient); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Invalid recipient + */ + public function testMoveShareUserNotRecipient() { + $share = $this->manager->newShare(); + $share->setShareType(\OCP\Share::SHARE_TYPE_USER); + + $sharedWith = $this->getMock('\OCP\IUser'); + $share->setSharedWith($sharedWith); + + $recipient = $this->getMock('\OCP\IUser'); + + $this->manager->moveShare($share, $recipient); + } + + public function testMoveShareUser() { + $share = $this->manager->newShare(); + $share->setShareType(\OCP\Share::SHARE_TYPE_USER); + + $recipient = $this->getMock('\OCP\IUser'); + $share->setSharedWith($recipient); + + $this->defaultProvider->method('move')->with($share, $recipient)->will($this->returnArgument(0)); + + $this->manager->moveShare($share, $recipient); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Invalid recipient + */ + public function testMoveShareGroupNotRecipient() { + $share = $this->manager->newShare(); + $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP); + + $sharedWith = $this->getMock('\OCP\IGroup'); + $share->setSharedWith($sharedWith); + + $recipient = $this->getMock('\OCP\IUser'); + $sharedWith->method('inGroup')->with($recipient)->willReturn(false); + + $this->manager->moveShare($share, $recipient); + } + + public function testMoveShareGroup() { + $share = $this->manager->newShare(); + $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP); + + $sharedWith = $this->getMock('\OCP\IGroup'); + $share->setSharedWith($sharedWith); + + $recipient = $this->getMock('\OCP\IUser'); + $sharedWith->method('inGroup')->with($recipient)->willReturn(true); + + $this->defaultProvider->method('move')->with($share, $recipient)->will($this->returnArgument(0)); + + $this->manager->moveShare($share, $recipient); + } } class DummyPassword { |