Fix PHPUnit 5.4 warnings in files_sharing tests
This commit is contained in:
parent
ab6db739fa
commit
db559e33be
4 changed files with 116 additions and 116 deletions
|
@ -75,17 +75,17 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
->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);
|
||||
|
@ -141,7 +141,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testDeleteShare() {
|
||||
$node = $this->getMock('\OCP\Files\File');
|
||||
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||
|
||||
$share = $this->newShare();
|
||||
$share->setSharedBy($this->currentUser->getUID())
|
||||
|
@ -168,7 +168,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testDeleteShareLocked() {
|
||||
$node = $this->getMock('\OCP\Files\File');
|
||||
$node = $this->getMockBuilder('\OCP\Files\File')->getMock();
|
||||
|
||||
$share = $this->newShare();
|
||||
$share->setSharedBy($this->currentUser->getUID())
|
||||
|
@ -213,7 +213,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
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);
|
||||
|
@ -253,17 +253,17 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
$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);
|
||||
|
@ -428,7 +428,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
->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));
|
||||
|
@ -445,19 +445,19 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
->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([
|
||||
|
@ -490,31 +490,31 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
@ -524,14 +524,14 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
]));
|
||||
$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]));
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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')
|
||||
|
@ -582,13 +582,13 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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')
|
||||
|
@ -618,14 +618,14 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -660,14 +660,14 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -715,14 +715,14 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -776,14 +776,14 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -831,14 +831,14 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -891,14 +891,14 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -930,8 +930,8 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -957,8 +957,8 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -985,8 +985,8 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -1018,8 +1018,8 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -1062,8 +1062,8 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -1106,8 +1106,8 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -1153,8 +1153,8 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -1203,14 +1203,14 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
['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);
|
||||
|
@ -1235,7 +1235,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testUpdateShareCantAccess() {
|
||||
$node = $this->getMock('\OCP\Files\Folder');
|
||||
$node = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
|
||||
$share = $this->newShare();
|
||||
$share->setNode($node);
|
||||
|
||||
|
@ -1253,7 +1253,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
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())
|
||||
|
@ -1274,7 +1274,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
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())
|
||||
|
@ -1297,7 +1297,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
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())
|
||||
|
@ -1342,7 +1342,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
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)
|
||||
|
@ -1385,7 +1385,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
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)
|
||||
|
@ -1420,7 +1420,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
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)
|
||||
|
@ -1472,7 +1472,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
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)
|
||||
|
@ -1497,7 +1497,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
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)
|
||||
|
@ -1529,7 +1529,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
$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())
|
||||
|
@ -1572,7 +1572,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
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())
|
||||
|
@ -1620,7 +1620,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$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)
|
||||
|
@ -1660,7 +1660,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$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)
|
||||
|
@ -1702,7 +1702,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
|
||||
$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)
|
||||
|
@ -1732,7 +1732,7 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
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)
|
||||
|
@ -1765,9 +1765,9 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
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');
|
||||
|
@ -1782,20 +1782,20 @@ class Share20OCSTest extends \Test\TestCase {
|
|||
$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 = [];
|
||||
|
|
|
@ -81,7 +81,7 @@ class ApiTest extends TestCase {
|
|||
* @return \OCP\IRequest
|
||||
*/
|
||||
private function createRequest(array $data) {
|
||||
$request = $this->getMock('\OCP\IRequest');
|
||||
$request = $this->getMockBuilder('\OCP\IRequest')->getMock();
|
||||
$request->method('getParam')
|
||||
->will($this->returnCallback(function($param, $default = null) use ($data) {
|
||||
if (isset($data[$param])) {
|
||||
|
@ -100,7 +100,7 @@ class ApiTest extends TestCase {
|
|||
private function createOCS($request, $userId) {
|
||||
$currentUser = \OC::$server->getUserManager()->get($userId);
|
||||
|
||||
$l = $this->getMock('\OCP\IL10N');
|
||||
$l = $this->getMockBuilder('\OCP\IL10N')->getMock();
|
||||
$l->method('t')
|
||||
->will($this->returnCallback(function($text, $parameters = []) {
|
||||
return vsprintf($text, $parameters);
|
||||
|
|
|
@ -78,11 +78,11 @@ class ShareControllerTest extends \Test\TestCase {
|
|||
$this->appName = 'files_sharing';
|
||||
|
||||
$this->shareManager = $this->getMockBuilder('\OC\Share20\Manager')->disableOriginalConstructor()->getMock();
|
||||
$this->urlGenerator = $this->getMock('\OCP\IURLGenerator');
|
||||
$this->session = $this->getMock('\OCP\ISession');
|
||||
$this->previewManager = $this->getMock('\OCP\IPreview');
|
||||
$this->config = $this->getMock('\OCP\IConfig');
|
||||
$this->userManager = $this->getMock('\OCP\IUserManager');
|
||||
$this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->getMock();
|
||||
$this->session = $this->getMockBuilder('\OCP\ISession')->getMock();
|
||||
$this->previewManager = $this->getMockBuilder('\OCP\IPreview')->getMock();
|
||||
$this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
|
||||
$this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock();
|
||||
$this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$this->federatedShareProvider->expects($this->any())
|
||||
|
@ -92,16 +92,16 @@ class ShareControllerTest extends \Test\TestCase {
|
|||
|
||||
$this->shareController = new \OCA\Files_Sharing\Controllers\ShareController(
|
||||
$this->appName,
|
||||
$this->getMock('\OCP\IRequest'),
|
||||
$this->getMockBuilder('\OCP\IRequest')->getMock(),
|
||||
$this->config,
|
||||
$this->urlGenerator,
|
||||
$this->userManager,
|
||||
$this->getMock('\OCP\ILogger'),
|
||||
$this->getMock('\OCP\Activity\IManager'),
|
||||
$this->getMockBuilder('\OCP\ILogger')->getMock(),
|
||||
$this->getMockBuilder('\OCP\Activity\IManager')->getMock(),
|
||||
$this->shareManager,
|
||||
$this->session,
|
||||
$this->previewManager,
|
||||
$this->getMock('\OCP\Files\IRootFolder'),
|
||||
$this->getMockBuilder('\OCP\Files\IRootFolder')->getMock(),
|
||||
$this->federatedShareProvider
|
||||
);
|
||||
|
||||
|
@ -310,11 +310,11 @@ class ShareControllerTest extends \Test\TestCase {
|
|||
|
||||
|
||||
public function testShowShare() {
|
||||
$owner = $this->getMock('OCP\IUser');
|
||||
$owner = $this->getMockBuilder('OCP\IUser')->getMock();
|
||||
$owner->method('getDisplayName')->willReturn('ownerDisplay');
|
||||
$owner->method('getUID')->willReturn('ownerUID');
|
||||
|
||||
$file = $this->getMock('OCP\Files\File');
|
||||
$file = $this->getMockBuilder('OCP\Files\File')->getMock();
|
||||
$file->method('getName')->willReturn('file1.txt');
|
||||
$file->method('getMimetype')->willReturn('text/plain');
|
||||
$file->method('getSize')->willReturn(33);
|
||||
|
@ -389,11 +389,11 @@ class ShareControllerTest extends \Test\TestCase {
|
|||
* @expectedException \OCP\Files\NotFoundException
|
||||
*/
|
||||
public function testShowShareInvalid() {
|
||||
$owner = $this->getMock('OCP\IUser');
|
||||
$owner = $this->getMockBuilder('OCP\IUser')->getMock();
|
||||
$owner->method('getDisplayName')->willReturn('ownerDisplay');
|
||||
$owner->method('getUID')->willReturn('ownerUID');
|
||||
|
||||
$file = $this->getMock('OCP\Files\File');
|
||||
$file = $this->getMockBuilder('OCP\Files\File')->getMock();
|
||||
$file->method('getName')->willReturn('file1.txt');
|
||||
$file->method('getMimetype')->willReturn('text/plain');
|
||||
$file->method('getSize')->willReturn(33);
|
||||
|
@ -434,7 +434,7 @@ class ShareControllerTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testDownloadShare() {
|
||||
$share = $this->getMock('\OCP\Share\IShare');
|
||||
$share = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
|
||||
$share->method('getPassword')->willReturn('password');
|
||||
$share
|
||||
->expects($this->once())
|
||||
|
@ -459,7 +459,7 @@ class ShareControllerTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testDownloadShareWithCreateOnlyShare() {
|
||||
$share = $this->getMock('\OCP\Share\IShare');
|
||||
$share = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
|
||||
$share->method('getPassword')->willReturn('password');
|
||||
$share
|
||||
->expects($this->once())
|
||||
|
|
|
@ -56,23 +56,23 @@ class MountProviderTest extends \Test\TestCase {
|
|||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->config = $this->getMock('OCP\IConfig');
|
||||
$this->user = $this->getMock('OCP\IUser');
|
||||
$this->loader = $this->getMock('OCP\Files\Storage\IStorageFactory');
|
||||
$this->shareManager = $this->getMock('\OCP\Share\IManager');
|
||||
$this->logger = $this->getMock('\OCP\ILogger');
|
||||
$this->config = $this->getMockBuilder('OCP\IConfig')->getMock();
|
||||
$this->user = $this->getMockBuilder('OCP\IUser')->getMock();
|
||||
$this->loader = $this->getMockBuilder('OCP\Files\Storage\IStorageFactory')->getMock();
|
||||
$this->shareManager = $this->getMockBuilder('\OCP\Share\IManager')->getMock();
|
||||
$this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
|
||||
|
||||
$this->provider = new MountProvider($this->config, $this->shareManager, $this->logger);
|
||||
}
|
||||
|
||||
public function testExcludeShares() {
|
||||
/** @var IShare | \PHPUnit_Framework_MockObject_MockObject $share1 */
|
||||
$share1 = $this->getMock('\OCP\Share\IShare');
|
||||
$share1 = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
|
||||
$share1->expects($this->once())
|
||||
->method('getPermissions')
|
||||
->will($this->returnValue(0));
|
||||
|
||||
$share2 = $this->getMock('\OCP\Share\IShare');
|
||||
$share2 = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
|
||||
$share2->expects($this->once())
|
||||
->method('getPermissions')
|
||||
->will($this->returnValue(31));
|
||||
|
@ -83,13 +83,13 @@ class MountProviderTest extends \Test\TestCase {
|
|||
->method('getTarget')
|
||||
->will($this->returnValue('/share2'));
|
||||
|
||||
$share3 = $this->getMock('\OCP\Share\IShare');
|
||||
$share3 = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
|
||||
$share3->expects($this->once())
|
||||
->method('getPermissions')
|
||||
->will($this->returnValue(0));
|
||||
|
||||
/** @var IShare | \PHPUnit_Framework_MockObject_MockObject $share4 */
|
||||
$share4 = $this->getMock('\OCP\Share\IShare');
|
||||
$share4 = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
|
||||
$share4->expects($this->once())
|
||||
->method('getPermissions')
|
||||
->will($this->returnValue(31));
|
||||
|
@ -100,7 +100,7 @@ class MountProviderTest extends \Test\TestCase {
|
|||
->method('getTarget')
|
||||
->will($this->returnValue('/share4'));
|
||||
|
||||
$share5 = $this->getMock('\OCP\Share\IShare');
|
||||
$share5 = $this->getMockBuilder('\OCP\Share\IShare')->getMock();
|
||||
$share5->expects($this->once())
|
||||
->method('getPermissions')
|
||||
->will($this->returnValue(31));
|
||||
|
|
Loading…
Reference in a new issue