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
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2022-02-11 18:16:40 +0300
committerVitor Mattos <vitor@php.rio>2022-02-15 18:49:54 +0300
commitc028352454c6aee79b7a9c8d066a8cf00615b1be (patch)
tree2a4cfabcbe7f6ca8211d6502c2c9d672634bf0ed
parent0a62079b1754e587138b5732a5e92838859fcde0 (diff)
Change return format
Signed-off-by: Vitor Mattos <vitor@php.rio>
-rw-r--r--lib/Chat/ReactionManager.php4
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php36
2 files changed, 23 insertions, 17 deletions
diff --git a/lib/Chat/ReactionManager.php b/lib/Chat/ReactionManager.php
index 98f705213..4b4576ea4 100644
--- a/lib/Chat/ReactionManager.php
+++ b/lib/Chat/ReactionManager.php
@@ -114,17 +114,15 @@ class ReactionManager {
$comments = $this->commentsManager->retrieveAllReactions($messageId);
}
- $reactions = [];
foreach ($comments as $comment) {
$message = $this->messageParser->createMessage($chat, $participant, $comment, $this->l);
$this->messageParser->parseMessage($message);
- $reactions[] = [
+ $reactions[$comment->getMessage()][] = [
'actorType' => $comment->getActorType(),
'actorId' => $comment->getActorId(),
'actorDisplayName' => $message->getActorDisplayName(),
'timestamp' => $comment->getCreationDateTime()->getTimestamp(),
- 'reaction' => $comment->getMessage(),
];
}
return $reactions;
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index 169adc3ac..3bdca6641 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -447,8 +447,8 @@ class FeatureContext implements Context, SnippetAcceptingContext {
return $attendee;
}, $result);
- usort($expected, [$this, 'sortAttendees']);
- usort($result, [$this, 'sortAttendees']);
+ usort($expected, [self::class, 'sortAttendees']);
+ usort($result, [self::class, 'sortAttendees']);
Assert::assertEquals($expected, $result);
} else {
@@ -477,7 +477,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
}
- protected function sortAttendees(array $a1, array $a2): int {
+ protected static function sortAttendees(array $a1, array $a2): int {
if (array_key_exists('participantType', $a1) && array_key_exists('participantType', $a2) && $a1['participantType'] !== $a2['participantType']) {
return $a1['participantType'] <=> $a2['participantType'];
}
@@ -2111,19 +2111,27 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
private function assertReactionList(TableNode $formData): void {
- $expected = $formData->getHash();
+ $expected = [];
+ foreach ($formData->getHash() as $row) {
+ $reaction = $row['reaction'];
+ unset($row['reaction']);
+ $expected[$reaction][] = $row;
+ }
$result = $this->getDataFromResponse($this->response);
- $result = array_map(function ($reaction) {
- unset($reaction['timestamp']);
- return $reaction;
- }, $result);
-
- Assert::assertCount(count($formData->getHash()), $result, 'Reaction count does not match');
-
- usort($expected, [$this, 'sortAttendees']);
- usort($result, [$this, 'sortAttendees']);
- Assert::assertEquals($expected, $result);
+ $result = array_map(static function ($reaction, $list) use ($expected): array {
+ $list = array_map(function ($reaction) {
+ unset($reaction['timestamp']);
+ return $reaction;
+ }, $list);
+ Assert::assertCount(count($list), $expected[$reaction], 'Reaction count by type does not match');
+
+ usort($expected[$reaction], [self::class, 'sortAttendees']);
+ usort($list, [self::class, 'sortAttendees']);
+ Assert::assertEquals($expected[$reaction], $list, 'Reaction list by type does not match');
+ return $list;
+ }, array_keys($result), array_values($result));
+ Assert::assertCount(count($expected), $result, 'Reaction count does not match');
}
/*