public function testDeleteShare() { $share = $this->getMock('OC\\Share20\\IShare'); $this->shareManager->expects($this->once())->method('getShareById')->with(42)->willReturn($share); $this->shareManager->expects($this->once())->method('deleteShare')->with($share); $expected = new \OC_OCS_Result(); $this->assertEquals($expected, $this->ocs->deleteShare(42)); }
/** * @dataProvider dataGetShare */ public function testGetShare(\OC\Share20\IShare $share, array $result) { $this->shareManager->expects($this->once())->method('getShareById')->with($share->getId())->willReturn($share); $this->userFolder->method('getRelativePath')->will($this->returnArgument(0)); $this->urlGenerator->method('linkToRouteAbsolute')->willReturn('url'); $expected = new \OC_OCS_Result($result); $this->assertEquals($expected->getData(), $this->ocs->getShare($share->getId())->getData()); }
/** * Delete a share * * @param int $id * @return \OC_OCS_Result */ public function deleteShare($id) { try { $share = $this->shareManager->getShareById($id); } catch (\OC\Share20\Exception\ShareNotFound $e) { return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.'); } /* * FIXME * User the old code path for remote shares until we have our remoteshareprovider */ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) { \OCA\Files_Sharing\API\Local::deleteShare(['id' => $id]); } try { $this->shareManager->deleteShare($share); } catch (\OC\Share20\Exception\BackendError $e) { return new \OC_OCS_Result(null, 404, 'could not delete share'); } return new \OC_OCS_Result(); }