public function testDelete() { $share = $this->getMock('\\OC\\Share20\\IShare'); $share->expects($this->once())->method('getId')->with()->willReturn(42); $this->defaultProvider->expects($this->once())->method('delete')->with($share); $this->manager->deleteShare($share); }
/** * Delete a share * * @param string $id * @return \OC_OCS_Result */ public function deleteShare($id) { // Try both our default and our federated provider $share = null; try { $share = $this->shareManager->getShareById('ocinternal:' . $id); } catch (ShareNotFound $e) { //Ignore for now //return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.'); } // Could not find the share as internal share... maybe it is a federated share if ($share === null) { return \OCA\Files_Sharing\API\Local::deleteShare(['id' => $id]); } if (!$this->canAccessShare($share)) { return new \OC_OCS_Result(null, 404, 'could not delete share'); } $this->shareManager->deleteShare($share); return new \OC_OCS_Result(); }
/** * Delete a share * * @param string $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(); }
/** * @expectedException \OC\Share20\Exception\ShareNotFound */ public function testDeleteNoShareId() { $share = $this->getMock('\\OCP\\Share\\IShare'); $share->expects($this->once())->method('getFullId')->with()->willReturn(null); $this->manager->deleteShare($share); }
/** * @expectedException \InvalidArgumentException */ public function testDeleteNoShareId() { $share = $this->manager->newShare(); $this->manager->deleteShare($share); }