->expects($this->any())
->method('shareApiEnabled')
->willReturn(true);
- $this->groupManager = $this->getMock('OCP\IGroupManager');
- $this->userManager = $this->getMock('OCP\IUserManager');
- $this->request = $this->getMock('OCP\IRequest');
- $this->rootFolder = $this->getMock('OCP\Files\IRootFolder');
- $this->urlGenerator = $this->getMock('OCP\IURLGenerator');
- $this->currentUser = $this->getMock('OCP\IUser');
+ $this->groupManager = $this->getMockBuilder('OCP\IGroupManager')->getMock();
+ $this->userManager = $this->getMockBuilder('OCP\IUserManager')->getMock();
+ $this->request = $this->getMockBuilder('OCP\IRequest')->getMock();
+ $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock();
+ $this->urlGenerator = $this->getMockBuilder('OCP\IURLGenerator')->getMock();
+ $this->currentUser = $this->getMockBuilder('OCP\IUser')->getMock();
$this->currentUser->method('getUID')->willReturn('currentUser');
$this->userManager->expects($this->any())->method('userExists')->willReturn(true);
- $this->l = $this->getMock('\OCP\IL10N');
+ $this->l = $this->getMockBuilder('\OCP\IL10N')->getMock();
$this->l->method('t')
->will($this->returnCallback(function($text, $parameters = []) {
return vsprintf($text, $parameters);
}
public function testDeleteShare() {
- $node = $this->getMock('\OCP\Files\File');
+ $node = $this->getMockBuilder('\OCP\Files\File')->getMock();
$share = $this->newShare();
$share->setSharedBy($this->currentUser->getUID())
}
public function testDeleteShareLocked() {
- $node = $this->getMock('\OCP\Files\File');
+ $node = $this->getMockBuilder('\OCP\Files\File')->getMock();
$share = $this->newShare();
$share->setSharedBy($this->currentUser->getUID())
public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner, $path, $permissions,
$shareTime, $expiration, $parent, $target, $mail_send, $token=null,
$password=null) {
- $share = $this->getMock('\OCP\Share\IShare');
+ $share = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
$share->method('getId')->willReturn($id);
$share->method('getShareType')->willReturn($shareType);
$share->method('getSharedWith')->willReturn($sharedWith);
$storage->method('getId')->willReturn('STORAGE');
$storage->method('getCache')->willReturn($cache);
- $parentFolder = $this->getMock('OCP\Files\Folder');
+ $parentFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
$parentFolder->method('getId')->willReturn(3);
- $file = $this->getMock('OCP\Files\File');
+ $file = $this->getMockBuilder('OCP\Files\File')->getMock();
$file->method('getId')->willReturn(1);
$file->method('getPath')->willReturn('file');
$file->method('getStorage')->willReturn($storage);
$file->method('getParent')->willReturn($parentFolder);
$file->method('getMimeType')->willReturn('myMimeType');
- $folder = $this->getMock('OCP\Files\Folder');
+ $folder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
$folder->method('getId')->willReturn(2);
$folder->method('getPath')->willReturn('folder');
$folder->method('getStorage')->willReturn($storage);
->with($share->getFullId())
->willReturn($share);
- $userFolder = $this->getMock('OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
$userFolder
->method('getRelativePath')
->will($this->returnArgument(0));
->method('linkToRouteAbsolute')
->willReturn('url');
- $initiator = $this->getMock('OCP\IUser');
+ $initiator = $this->getMockBuilder('OCP\IUser')->getMock();
$initiator->method('getUID')->willReturn('initiatorId');
$initiator->method('getDisplayName')->willReturn('initiatorDisplay');
- $owner = $this->getMock('OCP\IUser');
+ $owner = $this->getMockBuilder('OCP\IUser')->getMock();
$owner->method('getUID')->willReturn('ownerId');
$owner->method('getDisplayName')->willReturn('ownerDisplay');
- $user = $this->getMock('OCP\IUser');
+ $user = $this->getMockBuilder('OCP\IUser')->getMock();
$user->method('getUID')->willReturn('userId');
$user->method('getDisplayName')->willReturn('userDisplay');
- $group = $this->getMock('OCP\IGroup');
+ $group = $this->getMockBuilder('OCP\IGroup')->getMock();
$group->method('getGID')->willReturn('groupId');
$this->userManager->method('get')->will($this->returnValueMap([
}
public function testCanAccessShare() {
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getShareOwner')->willReturn($this->currentUser->getUID());
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getSharedBy')->willReturn($this->currentUser->getUID());
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
$share->method('getSharedWith')->willReturn($this->currentUser->getUID());
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
- $share->method('getSharedWith')->willReturn($this->getMock('OCP\IUser'));
+ $share->method('getSharedWith')->willReturn($this->getMockBuilder('OCP\IUser')->getMock());
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
$share->method('getSharedWith')->willReturn('group');
- $group = $this->getMock('OCP\IGroup');
+ $group = $this->getMockBuilder('OCP\IGroup')->getMock();
$group->method('inGroup')->with($this->currentUser)->willReturn(true);
- $group2 = $this->getMock('OCP\IGroup');
+ $group2 = $this->getMockBuilder('OCP\IGroup')->getMock();
$group2->method('inGroup')->with($this->currentUser)->willReturn(false);
]));
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
$share->method('getSharedWith')->willReturn('group2');
$this->groupManager->method('get')->with('group2')->willReturn($group);
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
- $share = $this->getMock('OCP\Share\IShare');
+ $share = $this->getMockBuilder('OCP\Share\IShare')->getMock();
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
}
['path', null, 'invalid-path'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
['permissions', null, 32],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\File');
+ $path = $this->getMockBuilder('\OCP\Files\File')->getMock();
$userFolder->expects($this->once())
->method('get')
->with('valid-path')
['shareType', $this->any(), \OCP\Share::SHARE_TYPE_USER],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\File');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\File')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
['shareWith', $this->any(), 'invalidUser'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\File');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\File')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
['shareWith', null, 'validUser'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\File');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\File')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
['shareWith', $this->any(), 'invalidGroup'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\File');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\File')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
['shareWith', null, 'validGroup'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
['shareWith', null, 'validGroup'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK],
]));
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
['publicUpload', null, 'true'],
]));
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
['publicUpload', null, 'true'],
]));
- $path = $this->getMock('\OCP\Files\File');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\File')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
['password', '', ''],
]));
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
['password', '', 'password'],
]));
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
['password', '', ''],
]));
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
['password', '', ''],
]));
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(false);
['shareWith', null, 'validUser'],
]));
- $userFolder = $this->getMock('\OCP\Files\Folder');
+ $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
->with('currentUser')
->willReturn($userFolder);
- $path = $this->getMock('\OCP\Files\Folder');
- $storage = $this->getMock('OCP\Files\Storage');
+ $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
->with('OCA\Files_Sharing\External\Storage')
->willReturn(true);
}
public function testUpdateShareCantAccess() {
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = $this->newShare();
$share->setNode($node);
}
public function testUpdateNoParametersLink() {
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser->getUID())
}
public function testUpdateNoParametersOther() {
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser->getUID())
public function testUpdateLinkShareClear() {
$ocs = $this->mockFormatShare();
- $node = $this->getMock('\OCP\Files\Folder');
+ $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser->getUID())
public function testUpdateLinkShareSet() {
$ocs = $this->mockFormatShare();
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
public function testUpdateLinkShareEnablePublicUpload($params) {
$ocs = $this->mockFormatShare();
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
public function testUpdateLinkShareInvalidDate() {
$ocs = $this->mockFormatShare();
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
public function testUpdateLinkSharePublicUploadNotAllowed($params) {
$ocs = $this->mockFormatShare();
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
public function testUpdateLinkSharePublicUploadOnFile() {
$ocs = $this->mockFormatShare();
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->getMockBuilder('\OCP\Files\File')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
$date = new \DateTime('2000-01-01');
$date->setTime(0,0,0);
- $node = $this->getMock('\OCP\Files\File');
+ $node = $this->getMockBuilder('\OCP\Files\File')->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser->getUID())
public function testUpdateLinkShareExpireDateDoesNotChangeOther() {
$ocs = $this->mockFormatShare();
- $node = $this->getMock('\OCP\Files\File');
+ $node = $this->getMockBuilder('\OCP\Files\File')->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser->getUID())
$date = new \DateTime('2000-01-01');
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
$date = new \DateTime('2000-01-01');
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
$date = new \DateTime('2000-01-01');
- $folder = $this->getMock('\OCP\Files\Folder');
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
public function testUpdateOtherPermissions() {
$ocs = $this->mockFormatShare();
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->getMockBuilder('\OCP\Files\File')->getMock();
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
}
public function dataFormatShare() {
- $file = $this->getMock('\OCP\Files\File');
- $folder = $this->getMock('\OCP\Files\Folder');
- $parent = $this->getMock('\OCP\Files\Folder');
+ $file = $this->getMockBuilder('\OCP\Files\File')->getMock();
+ $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
+ $parent = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$file->method('getMimeType')->willReturn('myMimeType');
$folder->method('getMimeType')->willReturn('myFolderMimeType');
$file->method('getParent')->willReturn($parent);
$folder->method('getParent')->willReturn($parent);
- $cache = $this->getMock('OCP\Files\Cache\ICache');
+ $cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock();
$cache->method('getNumericStorageId')->willReturn(100);
- $storage = $this->getMock('\OCP\Files\Storage');
+ $storage = $this->getMockBuilder('\OCP\Files\Storage')->getMock();
$storage->method('getId')->willReturn('storageId');
$storage->method('getCache')->willReturn($cache);
$file->method('getStorage')->willReturn($storage);
$folder->method('getStorage')->willReturn($storage);
- $owner = $this->getMock('\OCP\IUser');
+ $owner = $this->getMockBuilder('\OCP\IUser')->getMock();
$owner->method('getDisplayName')->willReturn('ownerDN');
- $initiator = $this->getMock('\OCP\IUser');
+ $initiator = $this->getMockBuilder('\OCP\IUser')->getMock();
$initiator->method('getDisplayName')->willReturn('initiatorDN');
- $recipient = $this->getMock('\OCP\IUser');
+ $recipient = $this->getMockBuilder('\OCP\IUser')->getMock();
$recipient->method('getDisplayName')->willReturn('recipientDN');
$result = [];