Skip to content

Commit

Permalink
Adjust tests due to IUserManager::get change
Browse files Browse the repository at this point in the history
  • Loading branch information
jvillafanez committed Apr 24, 2020
1 parent 4755eea commit d0e50f8
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 61 deletions.
18 changes: 9 additions & 9 deletions apps/files_sharing/tests/Controller/Share20OcsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,9 @@ public function testGetShare(\OCP\Share\IShare $share, array $result) {
$group->method('getGID')->willReturn('groupId');

$this->userManager->method('get')->will($this->returnValueMap([
['userId', $user],
['initiatorId', $initiator],
['ownerId', $owner],
['userId', false, $user],
['initiatorId', false, $initiator],
['ownerId', false, $owner],
]));
$this->groupManager->method('get')->will($this->returnValueMap([
['group', $group],
Expand Down Expand Up @@ -2345,9 +2345,9 @@ public function dataFormatShare() {
'mail_send' => 0,
'mimetype' => 'myMimeType',
], $share, [
['owner', $owner],
['initiator', $initiator],
['recipient', $recipient],
['owner', false, $owner],
['initiator', false, $initiator],
['recipient', false, $recipient],
], false
];

Expand Down Expand Up @@ -2726,9 +2726,9 @@ public function testGetShareAdditionalInfo($configValue, $expectedInfo, $expecte
$recipient->method('getEMailAddress')->willReturn('email@example.com');

$this->userManager->method('get')->will($this->returnValueMap([
['initiator', $initiator],
['recipient', $recipient],
['owner', $owner],
['initiator', false, $initiator],
['recipient', false, $recipient],
['owner', false, $owner],
]));

$ocs = new Share20OcsController(
Expand Down
4 changes: 2 additions & 2 deletions apps/files_sharing/tests/NotifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ public function testPrepareWithCustomConfig($subject, $subjectParams, $displayna

$this->userManager->method('get')
->will($this->returnValueMap([
[$subjectParams[0], $user1],
[$subjectParams[1], $user2],
[$subjectParams[0], false, $user1],
[$subjectParams[1], false, $user2],
]));

$this->config->method('getAppValue')
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Controller/AvatarControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function setUp(): void {
$this->userMock->expects($this->any())->method('getDisplayName')->willReturn('displayName');
$this->userMock->expects($this->any())->method('getUID')->willReturn('userId');
$this->userManager->expects($this->any())->method('get')
->willReturnMap([['userId', $this->userMock]]);
->willReturnMap([['userId', false, $this->userMock]]);
$this->userSession->expects($this->any())->method('getUser')->willReturn($this->userMock);

$this->avatarFile = $this->createMock('OCP\Files\File');
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/Controller/LostControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ public function testEmailUsedForLoginSuccessful() {
->method('get')
->willReturnMap(
[
['test@example.com', null],
['ExistingUser', $this->existingUser]
['test@example.com', false, null],
['ExistingUser', false, $this->existingUser]
]
);
$this->userManager
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/Command/User/SyncBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public function testSingleUserSyncDisableRemovedUser($action, $method, $isEnable
//$reappearedUser = $this->createMock(IUser::class);

$this->userManager->method('get')->willReturnMap([
['removed-uid', $removedUser],
['removed-uid', false, $removedUser],
//['reappeared-uid', $reappearedUser]
]);

Expand Down Expand Up @@ -448,7 +448,7 @@ public function testSyncMultipleUsersRemovedUsers($action, $method, $isEnabled,
$removedUser->method('delete')->willReturn(true);

$this->userManager->method('get')->willReturnMap([
['removed-uid', $removedUser],
['removed-uid', false, $removedUser],
]);
$removedUser->expects($this->once())->method($method)->willReturn($isEnabled);
if ($setEnabled !== null) {
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/Group/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ protected function getUserManager() {
$userManager->expects($this->any())
->method('get')
->will($this->returnValueMap([
['user1', $user1],
['user2', $user2],
['user3', $user3]
['user1', false, $user1],
['user2', false, $user2],
['user3', false, $user3]
]));
return $userManager;
}
Expand Down
60 changes: 30 additions & 30 deletions tests/lib/Share20/DefaultShareProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1027,9 +1027,9 @@ public function testGetSharedWithGroup($storageStringId, $fileName1, $fileName2)
$initiator->method('getUID')->willReturn('sharedBy');

$this->userManager->method('get')->willReturnMap([
['sharedWith', $user],
['shareOwner', $owner],
['sharedBy', $initiator],
['sharedWith', false, $user],
['shareOwner', false, $owner],
['sharedBy', false, $initiator],
]);
$this->groupManager->method('getUserGroups')->with($user)->willReturn($groups);
$this->groupManager->method('get')->with('sharedWith')->willReturn($group);
Expand Down Expand Up @@ -1121,9 +1121,9 @@ public function testGetSharedWithGroupUserModified($storageStringId, $fileName1,
$initiator->method('getUID')->willReturn('sharedBy');

$this->userManager->method('get')->willReturnMap([
['user', $user],
['shareOwner', $owner],
['sharedBy', $initiator],
['user', false, $user],
['shareOwner', false, $owner],
['sharedBy', false, $initiator],
]);
$this->groupManager->method('getUserGroups')->with($user)->willReturn($groups);
$this->groupManager->method('get')->with('sharedWith')->willReturn($group);
Expand Down Expand Up @@ -1203,8 +1203,8 @@ public function testGetSharedWithGroupWithNode($storageStringId, $fileName1, $fi
$user1->method('getUID')->willReturn('user1');

$this->userManager->method('get')->willReturnMap([
['user0', $user0],
['user1', $user1],
['user0', false, $user0],
['user1', false, $user1],
]);

$group0 = $this->createMock(IGroup::class);
Expand Down Expand Up @@ -1243,8 +1243,8 @@ public function testChunkedGetSharedWithGroupWithNode() {
$user1->method('getUID')->willReturn('user1');

$this->userManager->method('get')->willReturnMap([
['user0', $user0],
['user1', $user1],
['user0', false, $user0],
['user1', false, $user1],
]);

for ($i = 0; $i < 105; $i++) {
Expand Down Expand Up @@ -1295,8 +1295,8 @@ public function testGetAllShared($storageStringId, $fileName1, $fileName2) {
$user1->method('getUID')->willReturn('user1');

$this->userManager->method('get')->willReturnMap([
['user0', $user0],
['user1', $user1],
['user0', false, $user0],
['user1', false, $user1],
]);

$group0 = $this->createMock(IGroup::class);
Expand Down Expand Up @@ -1408,9 +1408,9 @@ public function testGetAllSharedSameUserGroup($storageStringId, $fileName1, $fil

// Setup mocking
$this->userManager->method('get')->willReturnMap([
['user1', $user1],
['user2', $user2],
['meow', $userMeow],
['user1', false, $user1],
['user2', false, $user2],
['meow', false, $userMeow],
]);

$this->rootFolder->method('getUserFolder')->with('user2')->will($this->returnSelf());
Expand Down Expand Up @@ -1491,8 +1491,8 @@ public function testGetAllSharedGroupChunking($storageStringId, $fileName1, $fil

// Setup mocking
$this->userManager->method('get')->willReturnMap([
['user1', $user1],
['user2', $user2],
['user1', false, $user1],
['user2', false, $user2],
]);

$this->rootFolder->method('getUserFolder')->with('user1')->will($this->returnSelf());
Expand Down Expand Up @@ -1589,9 +1589,9 @@ public function testGetSharedWithWithDeletedFile($shareType, $trashed) {
$initiator->method('getUID')->willReturn('sharedBy');

$this->userManager->method('get')->willReturnMap([
['sharedWith', $user],
['shareOwner', $owner],
['sharedBy', $initiator],
['sharedWith', false, $user],
['shareOwner', false, $owner],
['sharedBy', false, $initiator],
]);
$this->groupManager->method('getUserGroups')->with($user)->willReturn($groups);
$this->groupManager->method('get')->with('sharedWith')->willReturn($group);
Expand Down Expand Up @@ -1905,8 +1905,8 @@ public function testDeleteFromSelfGroupNoCustomShare() {
$user2 = $this->createMock(IUser::class);
$user2->method('getUID')->willReturn('user2');
$this->userManager->method('get')->will($this->returnValueMap([
['user1', $user1],
['user2', $user2],
['user1', false, $user1],
['user2', false, $user2],
]));

$group = $this->createMock(IGroup::class);
Expand Down Expand Up @@ -1979,8 +1979,8 @@ public function testDeleteFromSelfGroupAlreadyCustomShare() {
$user2 = $this->createMock(IUser::class);
$user2->method('getUID')->willReturn('user2');
$this->userManager->method('get')->will($this->returnValueMap([
['user1', $user1],
['user2', $user2],
['user1', false, $user1],
['user2', false, $user2],
]));

$group = $this->createMock(IGroup::class);
Expand Down Expand Up @@ -2041,8 +2041,8 @@ public function testDeleteFromSelfGroupUserNotInGroup() {
$user2 = $this->createMock(IUser::class);
$user2->method('getUID')->willReturn('user2');
$this->userManager->method('get')->will($this->returnValueMap([
['user1', $user1],
['user2', $user2],
['user1', false, $user1],
['user2', false, $user2],
]));

$group = $this->createMock(IGroup::class);
Expand Down Expand Up @@ -2619,8 +2619,8 @@ public function testMoveGroupShare() {
$this->groupManager->method('get')->with('group0')->willReturn($group0);

$this->userManager->method('get')->will($this->returnValueMap([
['user0', $user0],
['user1', $user1],
['user0', false, $user0],
['user1', false, $user1],
]));

$folder = $this->createMock(Folder::class);
Expand Down Expand Up @@ -2678,8 +2678,8 @@ public function testUpdateShareState($sourceState, $targetState) {
$this->groupManager->method('get')->with('group0')->willReturn($group0);

$this->userManager->method('get')->will($this->returnValueMap([
['user0', $user0],
['user1', $user1],
['user0', false, $user0],
['user1', false, $user1],
]));

$folder = $this->createMock(Folder::class);
Expand Down
22 changes: 11 additions & 11 deletions tests/lib/Share20/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1273,8 +1273,8 @@ public function testUserCreateChecksShareWithGroupMembersOnlyDifferentGroups() {
);

$this->userManager->method('get')->will($this->returnValueMap([
['sharedBy', $sharedBy],
['sharedWith', $sharedWith],
['sharedBy', false, $sharedBy],
['sharedWith', false, $sharedWith],
]));

$this->config
Expand Down Expand Up @@ -1306,8 +1306,8 @@ public function testUserCreateChecksShareWithGroupMembersOnlySharedGroup() {
);

$this->userManager->method('get')->will($this->returnValueMap([
['sharedBy', $sharedBy],
['sharedWith', $sharedWith],
['sharedBy', false, $sharedBy],
['sharedWith', false, $sharedWith],
]));

$this->config
Expand Down Expand Up @@ -2069,8 +2069,8 @@ public function testTransferShare($sharetype) {
$this->userManager->expects($this->any())
->method('get')
->will($this->returnValueMap([
['user1', $user1],
['user2', $user2]
['user1', false, $user1],
['user2', false, $user2]
]));

if ($sharetype === 'user') {
Expand Down Expand Up @@ -2186,8 +2186,8 @@ public function testTransferShareNoNewOwner() {
->getMock();
$this->userManager->method('get')
->will($this->returnValueMap([
['user1', $this->createMock(IUser::class)],
['user2', null]
['user1', false, $this->createMock(IUser::class)],
['user2', false, null]
]));
$share = $this->createShare('23', \OCP\Share::SHARE_TYPE_USER,
'/foo', 'user2', 'user1', 'user1',
Expand All @@ -2207,7 +2207,7 @@ public function testTransferShareNoSameOwner() {
->getMock();
$this->userManager->method('get')
->will($this->returnValueMap([
['user1', $this->createMock(IUser::class)],
['user1', false, $this->createMock(IUser::class)],
]));
$share = $this->createShare('23', \OCP\Share::SHARE_TYPE_USER,
'/foo', 'user2', 'user1', 'user1',
Expand All @@ -2227,8 +2227,8 @@ public function testTransferShareNonExistingFinalTarget() {
->getMock();
$this->userManager->method('get')
->will($this->returnValueMap([
['user1', $this->createMock(IUser::class)],
['user2', $this->createMock(IUser::class)],
['user1', false, $this->createMock(IUser::class)],
['user2', false, $this->createMock(IUser::class)],
]));
$this->view->expects($this->once())
->method('file_exists')
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/User/TokenAuthModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function setUp(): void {

$this->manager->expects($this->any())->method('get')
->willReturnMap([
['user1', $this->user],
['user1', false, $this->user],
]);
}

Expand Down

0 comments on commit d0e50f8

Please sign in to comment.