Example #1
0
 public function testCreateShareLinkPublicUploadFile()
 {
     $this->request->method('getParam')->will($this->returnValueMap([['path', null, 'valid-path'], ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK], ['publicUpload', null, 'true']]));
     $path = $this->getMock('\\OCP\\Files\\File');
     $this->rootFolder->method('getUserFolder')->with($this->currentUser->getUID())->will($this->returnSelf());
     $this->rootFolder->method('get')->with('valid-path')->willReturn($path);
     $this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
     $this->shareManager->method('shareApiAllowLinks')->willReturn(true);
     $this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
     $expected = new \OC_OCS_Result(null, 404, 'public upload is only possible for public shared folders');
     $result = $this->ocs->createShare();
     $this->assertEquals($expected->getMeta(), $result->getMeta());
     $this->assertEquals($expected->getData(), $result->getData());
 }
Example #2
0
 public function testCreateShareGroupNoValidShareWith()
 {
     $share = $this->getMock('\\OC\\Share20\\IShare');
     $this->shareManager->method('newShare')->willReturn($share);
     $this->request->method('getParam')->will($this->returnValueMap([['path', null, 'valid-path'], ['permissions', null, \OCP\Constants::PERMISSION_ALL], ['shareType', $this->any(), \OCP\Share::SHARE_TYPE_GROUP], ['shareWith', $this->any(), 'invalidGroup']]));
     $userFolder = $this->getMock('\\OCP\\Files\\Folder');
     $this->rootFolder->expects($this->once())->method('getUserFolder')->with('currentUser')->willReturn($userFolder);
     $path = $this->getMock('\\OCP\\Files\\File');
     $userFolder->expects($this->once())->method('get')->with('valid-path')->willReturn($path);
     $expected = new \OC_OCS_Result(null, 404, 'please specify a valid user');
     $result = $this->ocs->createShare();
     $this->assertEquals($expected->getMeta(), $result->getMeta());
     $this->assertEquals($expected->getData(), $result->getData());
 }