Skip to content
Prev Previous commit
Next Next commit
Fix PHPUnit warnings
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Aug 16, 2022
commit 477a12142fd50c5de36152b34dafd2e94355f69d
74 changes: 38 additions & 36 deletions tests/FilesHooksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,23 +453,25 @@ public function testAddNotificationsForFileAction(array $filterUsers, bool $moun
return $filterUsers[$method];
});

$i = 2;
$addCalls = [];
foreach ($addNotifications as $user => $arguments) {
$filesHooks->expects($this->at($i))
->method('addNotificationsForUser')
->with(
$user,
$arguments['subject'],
$arguments['subject_params'],
1337,
$arguments['path'],
true,
$arguments['email'],
$arguments['notification'],
Files::TYPE_SHARE_RESTORED
);
$i++;
$addCalls[] = [
$user,
$arguments['subject'],
$arguments['subject_params'],
1337,
$arguments['path'],
true,
$arguments['email'],
$arguments['notification'],
Files::TYPE_SHARE_RESTORED,
];
}
$filesHooks->expects($this->any())
->method('addNotificationsForUser')
->withConsecutive(
...$addCalls
);

self::invokePrivate($filesHooks, 'addNotificationsForFileAction', ['path', Files::TYPE_SHARE_RESTORED, 'restored_self', 'restored_by']);
}
Expand Down Expand Up @@ -676,12 +678,10 @@ public function testShareWithGroup(array $usersInGroup, int $settingCalls, int $
]);

$group = $this->createMock(IGroup::class);
for ($i = 0, $iMax = count($usersInGroup); $i < $iMax; $i++) {
$group->expects($this->at($i))
->method('searchUsers')
->with('')
->willReturn($usersInGroup[$i]);
}
$group->expects($this->any())
->method('searchUsers')
->with('')
->willReturnOnConsecutiveCalls(...$usersInGroup);

$this->groupManager->expects($this->once())
->method('get')
Expand All @@ -705,23 +705,25 @@ public function testShareWithGroup(array $usersInGroup, int $settingCalls, int $
->with('user', 'reshared_group_by', 'group1', 42, 'file')
->willReturnArgument(0);

$i = 3;
$addCalls = [];
foreach ($addNotifications as $user => $arguments) {
$filesHooks->expects($this->at($i))
->method('addNotificationsForUser')
->with(
$user,
$arguments['subject'],
$arguments['subject_params'],
42,
$arguments['path'],
true,
$arguments['email'],
$arguments['notification'],
Files_Sharing::TYPE_SHARED
);
$i++;
$addCalls[] = [
$user,
$arguments['subject'],
$arguments['subject_params'],
42,
$arguments['path'],
true,
$arguments['email'],
$arguments['notification'],
Files_Sharing::TYPE_SHARED,
];
}
$filesHooks->expects($this->any())
->method('addNotificationsForUser')
->withConsecutive(
...$addCalls
);

self::invokePrivate($filesHooks, 'shareWithGroup', [
'group1', 42, 'file', '/file', 1337, true
Expand Down