diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-04 14:28:09 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-04 14:28:09 +0100 |
commit | 0f22a8db1d29b6be8ec13dcb92ba5f344f2a34f0 (patch) | |
tree | 59296b820cbf061e5d13abfa1a733bda95d536cc /tests | |
parent | 2c0cb5a00eb15bfb233bb29de1156e7e35d84743 (diff) | |
download | nextcloud-server-0f22a8db1d29b6be8ec13dcb92ba5f344f2a34f0.tar.gz nextcloud-server-0f22a8db1d29b6be8ec13dcb92ba5f344f2a34f0.zip |
Also add type (file/folder) to IShare object
We need this for the hooks :(
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/share20/managertest.php | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php index 01e5283fcf7..270f5da33cd 100644 --- a/tests/lib/share20/managertest.php +++ b/tests/lib/share20/managertest.php @@ -242,6 +242,86 @@ class ManagerTest extends \Test\TestCase { $manager->deleteShare($share); } + public function testDeleteLazyShare() { + $manager = $this->createManagerMock() + ->setMethods(['getShareById', 'deleteChildren']) + ->getMock(); + + $share = $this->manager->newShare(); + $share->setId(42) + ->setProviderId('prov') + ->setShareType(\OCP\Share::SHARE_TYPE_USER) + ->setSharedWith('sharedWith') + ->setSharedBy('sharedBy') + ->setShareOwner('shareOwner') + ->setTarget('myTarget') + ->setNodeId(1) + ->setNodeType('file'); + + $this->rootFolder->expects($this->never())->method($this->anything()); + + $manager->expects($this->once())->method('getShareById')->with('prov:42')->willReturn($share); + $manager->expects($this->once())->method('deleteChildren')->with($share); + + $this->defaultProvider + ->expects($this->once()) + ->method('delete') + ->with($share); + + $hookListner = $this->getMockBuilder('Dummy')->setMethods(['pre', 'post'])->getMock(); + \OCP\Util::connectHook('OCP\Share', 'pre_unshare', $hookListner, 'pre'); + \OCP\Util::connectHook('OCP\Share', 'post_unshare', $hookListner, 'post'); + + $hookListnerExpectsPre = [ + 'id' => 42, + 'itemType' => 'file', + 'itemSource' => 1, + 'shareType' => \OCP\Share::SHARE_TYPE_USER, + 'shareWith' => 'sharedWith', + 'itemparent' => null, + 'uidOwner' => 'sharedBy', + 'fileSource' => 1, + 'fileTarget' => 'myTarget', + ]; + + $hookListnerExpectsPost = [ + 'id' => 42, + 'itemType' => 'file', + 'itemSource' => 1, + 'shareType' => \OCP\Share::SHARE_TYPE_USER, + 'shareWith' => 'sharedWith', + 'itemparent' => null, + 'uidOwner' => 'sharedBy', + 'fileSource' => 1, + 'fileTarget' => 'myTarget', + 'deletedShares' => [ + [ + 'id' => 42, + 'itemType' => 'file', + 'itemSource' => 1, + 'shareType' => \OCP\Share::SHARE_TYPE_USER, + 'shareWith' => 'sharedWith', + 'itemparent' => null, + 'uidOwner' => 'sharedBy', + 'fileSource' => 1, + 'fileTarget' => 'myTarget', + ], + ], + ]; + + + $hookListner + ->expects($this->exactly(1)) + ->method('pre') + ->with($hookListnerExpectsPre); + $hookListner + ->expects($this->exactly(1)) + ->method('post') + ->with($hookListnerExpectsPost); + + $manager->deleteShare($share); + } + public function testDeleteNested() { $manager = $this->createManagerMock() ->setMethods(['getShareById']) |