Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2021-09-17 12:22:14 +0300
committerGitHub <noreply@github.com>2021-09-17 12:22:14 +0300
commit783a46bdebdaf26889c1faac7933aee796280a9e (patch)
tree0dfe933bcadb6bff67fd783acb4bc2c0b58a1b39 /tests
parentecc36cbf3022bdaea94394ca66773deab9d53618 (diff)
parent7a17994b1af7e02e61aaacd751ba7252405bf8ef (diff)
Merge pull request #6234 from nextcloud/fix-remove-warnings-on-phpunit9.5.6
Fix: remove warnings on phpunit9.5.6
Diffstat (limited to 'tests')
-rw-r--r--tests/php/BackgroundJob/CheckHostedSignalingServerTest.php44
-rw-r--r--tests/php/Chat/SystemMessage/ListenerTest.php50
-rw-r--r--tests/php/Notification/NotifierTest.php54
3 files changed, 74 insertions, 74 deletions
diff --git a/tests/php/BackgroundJob/CheckHostedSignalingServerTest.php b/tests/php/BackgroundJob/CheckHostedSignalingServerTest.php
index 0627baef6..b8cd73c21 100644
--- a/tests/php/BackgroundJob/CheckHostedSignalingServerTest.php
+++ b/tests/php/BackgroundJob/CheckHostedSignalingServerTest.php
@@ -81,15 +81,13 @@ class CheckHostedSignalingServerTest extends TestCase {
public function testRunWithNoChange() {
$backgroundJob = $this->getBackgroundJob();
- $this->config->expects($this->at(0))
+ $this->config
->method('getAppValue')
- ->with('spreed', 'hosted-signaling-server-account-id', '')
- ->willReturn('my-account-id');
- $this->config->expects($this->at(1))
- ->method('getAppValue')
- ->with('spreed', 'hosted-signaling-server-account', '{}')
- ->willReturn('{"status": "pending"}');
- $this->config->expects($this->at(2))
+ ->will($this->returnValueMap([
+ ['spreed', 'hosted-signaling-server-account-id', '', 'my-account-id'],
+ ['spreed', 'hosted-signaling-server-account', '{}', '{"status": "pending"}']
+ ]));
+ $this->config->expects($this->once())
->method('setAppValue')
->with('spreed', 'hosted-signaling-server-account-last-checked', null);
@@ -110,26 +108,20 @@ class CheckHostedSignalingServerTest extends TestCase {
],
];
- $this->config->expects($this->at(0))
- ->method('getAppValue')
- ->with('spreed', 'hosted-signaling-server-account-id', '')
- ->willReturn('my-account-id');
- $this->config->expects($this->at(1))
+ $this->config
->method('getAppValue')
- ->with('spreed', 'hosted-signaling-server-account', '{}')
- ->willReturn('{"status": "pending"}');
- $this->config->expects($this->at(2))
- ->method('setAppValue')
- ->with('spreed', 'signaling_mode', 'external');
- $this->config->expects($this->at(3))
+ ->will($this->returnValueMap([
+ ['spreed', 'hosted-signaling-server-account-id', '', 'my-account-id'],
+ ['spreed', 'hosted-signaling-server-account', '{}', '{"status": "pending"}']
+ ]));
+ $this->config->expects($this->exactly(4))
->method('setAppValue')
- ->with('spreed', 'signaling_servers', '{"servers":[{"server":"signaling-url","verify":true}],"secret":"signaling-secret"}');
- $this->config->expects($this->at(4))
- ->method('setAppValue')
- ->with('spreed', 'hosted-signaling-server-account', json_encode($newStatus));
- $this->config->expects($this->at(5))
- ->method('setAppValue')
- ->with('spreed', 'hosted-signaling-server-account-last-checked', null);
+ ->withConsecutive(
+ ['spreed', 'signaling_mode', 'external'],
+ ['spreed', 'signaling_servers', '{"servers":[{"server":"signaling-url","verify":true}],"secret":"signaling-secret"}'],
+ ['spreed', 'hosted-signaling-server-account', json_encode($newStatus)],
+ ['spreed', 'hosted-signaling-server-account-last-checked', null]
+ );
$group = $this->createMock(IGroup::class);
$this->groupManager->expects($this->once())
diff --git a/tests/php/Chat/SystemMessage/ListenerTest.php b/tests/php/Chat/SystemMessage/ListenerTest.php
index 62e93bd19..60b8d946a 100644
--- a/tests/php/Chat/SystemMessage/ListenerTest.php
+++ b/tests/php/Chat/SystemMessage/ListenerTest.php
@@ -217,18 +217,21 @@ class ListenerTest extends TestCase {
// TODO: add all cases
$event = new AddParticipantsEvent($room, $participants);
- foreach ($expectedMessages as $index => $expectedMessage) {
- $this->chatManager->expects($this->at($index))
+ foreach ($expectedMessages as $expectedMessage) {
+ $consecutive[] = [
+ $room,
+ $expectedMessage['actorType'],
+ $expectedMessage['actorId'],
+ json_encode($expectedMessage['message']),
+ $this->dummyTime,
+ false,
+ self::DUMMY_REFERENCE_ID,
+ ];
+ }
+ if (isset($consecutive)) {
+ $this->chatManager
->method('addSystemMessage')
- ->with(
- $room,
- $expectedMessage['actorType'],
- $expectedMessage['actorId'],
- json_encode($expectedMessage['message']),
- $this->dummyTime,
- false,
- self::DUMMY_REFERENCE_ID,
- );
+ ->withConsecutive(...$consecutive);
}
$this->dispatch(Room::EVENT_AFTER_USERS_ADD, $event);
@@ -298,18 +301,21 @@ class ListenerTest extends TestCase {
$event = new ModifyParticipantEvent($room, $participant, '', $newParticipantType, $oldParticipantType);
- foreach ($expectedMessages as $index => $expectedMessage) {
- $this->chatManager->expects($this->at($index))
+ foreach ($expectedMessages as $expectedMessage) {
+ $consecutive[] = [
+ $room,
+ Attendee::ACTOR_USERS,
+ 'alice_actor',
+ json_encode($expectedMessage),
+ $this->dummyTime,
+ false,
+ self::DUMMY_REFERENCE_ID
+ ];
+ }
+ if (isset($consecutive)) {
+ $this->chatManager->expects($this->once())
->method('addSystemMessage')
- ->with(
- $room,
- Attendee::ACTOR_USERS,
- 'alice_actor',
- json_encode($expectedMessage),
- $this->dummyTime,
- false,
- self::DUMMY_REFERENCE_ID,
- );
+ ->withConsecutive(...$consecutive);
}
$this->dispatch(Room::EVENT_AFTER_PARTICIPANT_TYPE_SET, $event);
diff --git a/tests/php/Notification/NotifierTest.php b/tests/php/Notification/NotifierTest.php
index 6aeff338f..678b61518 100644
--- a/tests/php/Notification/NotifierTest.php
+++ b/tests/php/Notification/NotifierTest.php
@@ -158,18 +158,20 @@ class NotifierTest extends \Test\TestCase {
->willReturn($l);
$recipient = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(0))
- ->method('get')
- ->with('recipient')
- ->willReturn($recipient);
$u = $this->createMock(IUser::class);
$u->expects($this->exactly(2))
->method('getDisplayName')
->willReturn($displayName);
- $this->userManager->expects($this->at(1))
+ $this->userManager->expects($this->exactly(2))
->method('get')
- ->with($uid)
- ->willReturn($u);
+ ->withConsecutive(
+ ['recipient'],
+ [$uid]
+ )
+ ->willReturnOnConsecutiveCalls(
+ $recipient,
+ $u
+ );
$n->expects($this->once())
->method('setIcon')
@@ -383,18 +385,20 @@ class NotifierTest extends \Test\TestCase {
->willReturn($l);
$recipient = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(0))
- ->method('get')
- ->with('recipient')
- ->willReturn($recipient);
$u = $this->createMock(IUser::class);
$u->expects($this->exactly(2))
->method('getDisplayName')
->willReturn($displayName);
- $this->userManager->expects($this->at(1))
+ $this->userManager->expects($this->exactly(2))
->method('get')
- ->with($uid)
- ->willReturn($u);
+ ->withConsecutive(
+ ['recipient'],
+ [$uid]
+ )
+ ->willReturnOnConsecutiveCalls(
+ $recipient,
+ $u
+ );
$n->expects($this->once())
->method('setIcon')
@@ -904,31 +908,29 @@ class NotifierTest extends \Test\TestCase {
->willReturn($l);
$recipient = $this->createMock(IUser::class);
- $this->userManager->expects($this->at(0))
- ->method('get')
- ->with('recipient')
- ->willReturn($recipient);
+ $userManagerGet['with'][] = ['recipient'];
+ $userManagerGet['willReturn'][] = $recipient;
$user = $this->createMock(IUser::class);
if ($subjectParameters['userType'] === 'users' && !$deletedUser) {
$user->expects($this->once())
->method('getDisplayName')
->willReturn($displayName);
- $this->userManager->expects($this->at(1))
- ->method('get')
- ->with($subjectParameters['userId'])
- ->willReturn($user);
+ $userManagerGet['with'][] = [$subjectParameters['userId']];
+ $userManagerGet['willReturn'][] = $user;
} elseif ($subjectParameters['userType'] === 'users' && $deletedUser) {
$user->expects($this->never())
->method('getDisplayName');
- $this->userManager->expects($this->at(1))
- ->method('get')
- ->with($subjectParameters['userId'])
- ->willReturn(null);
+ $userManagerGet['with'][] = [$subjectParameters['userId']];
+ $userManagerGet['willReturn'][] = null;
} else {
$user->expects($this->never())
->method('getDisplayName');
}
+ $this->userManager->expects($this->exactly(count($userManagerGet['with'])))
+ ->method('get')
+ ->withConsecutive(...$userManagerGet['with'])
+ ->willReturnOnConsecutiveCalls(...$userManagerGet['willReturn']);
$comment = $this->createMock(IComment::class);
$comment->expects($this->any())