public function testUpdateNoParametersOther() { $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL)->setSharedBy($this->currentUser->getUID())->setShareType(\OCP\Share::SHARE_TYPE_GROUP); $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $expected = new \OC_OCS_Result(null, 400, 'Wrong or no update parameter given'); $result = $this->ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); $this->assertEquals($expected->getData(), $result->getData()); }
public function testUpdateNoParametersOther() { $node = $this->getMock('\\OCP\\Files\\Folder'); $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL)->setSharedBy($this->currentUser->getUID())->setShareType(\OCP\Share::SHARE_TYPE_GROUP)->setNode($node); $node->expects($this->once())->method('lock')->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); $this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share); $expected = new \OC_OCS_Result(null, 400, 'Wrong or no update parameter given'); $result = $this->ocs->updateShare(42); $this->assertEquals($expected->getMeta(), $result->getMeta()); $this->assertEquals($expected->getData(), $result->getData()); }
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()); }
public function testGetGetShareNotExists() { $this->shareManager->expects($this->once())->method('getShareById')->with(42)->will($this->throwException(new \OC\Share20\Exception\ShareNotFound())); $expected = new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.'); $this->assertEquals($expected, $this->ocs->getShare(42)); }