diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2023-01-30 14:49:55 +0100 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2023-01-31 05:00:56 +0100 |
commit | cee13cb8cf10f5a4c9437731732df8a2e10ffcfe (patch) | |
tree | a02eea588da44cead04c25e3a875b5857cbdbb32 /tests | |
parent | 62fd48d1a764c24d731e24b9289917c6e2c9bdc8 (diff) |
Do not send "switchto" messages for breakout rooms without sessions
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/php/Signaling/BackendNotifierTest.php | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/php/Signaling/BackendNotifierTest.php b/tests/php/Signaling/BackendNotifierTest.php index 5c25a8669..5fbe80491 100644 --- a/tests/php/Signaling/BackendNotifierTest.php +++ b/tests/php/Signaling/BackendNotifierTest.php @@ -230,6 +230,24 @@ class BackendNotifierTest extends TestCase { return $body; } + private function assertMessageCount(Room $room, string $messageType, int $expectedCount): void { + $expectedUrl = $this->baseUrl . '/api/v1/room/' . $room->getToken(); + + $requests = $this->controller->getRequests(); + $requests = array_filter($requests, function ($request) use ($expectedUrl) { + return $request['url'] === $expectedUrl; + }); + $bodies = array_map(function ($request) use ($expectedUrl) { + return json_decode($this->validateBackendRequest($expectedUrl, $request), true); + }, $requests); + + $bodies = array_filter($bodies, function (array $body) use ($messageType) { + return $body['type'] === $messageType; + }); + + $this->assertCount($expectedCount, $bodies, json_encode($bodies, JSON_PRETTY_PRINT)); + } + private function assertMessageWasSent(Room $room, array $message): void { $expectedUrl = $this->baseUrl . '/api/v1/room/' . $room->getToken(); @@ -1260,18 +1278,21 @@ class BackendNotifierTest extends TestCase { $this->participantService->updateParticipantType($room, $participantModerator1, Participant::MODERATOR); + // Third room is explicitly empty. $attendeeMap = []; $attendeeMap[$participant1->getSession()->getAttendeeId()] = 0; $attendeeMap[$participant2->getSession()->getAttendeeId()] = 1; $attendeeMap[$participant3->getSession()->getAttendeeId()] = 0; $attendeeMap[$participantModerator1->getSession()->getAttendeeId()] = 0; - $breakoutRooms = $this->breakoutRoomService->setupBreakoutRooms($room, BreakoutRoom::MODE_MANUAL, 2, json_encode($attendeeMap)); + $breakoutRooms = $this->breakoutRoomService->setupBreakoutRooms($room, BreakoutRoom::MODE_MANUAL, 3, json_encode($attendeeMap)); $this->controller->clearRequests(); $this->breakoutRoomService->startBreakoutRooms($room); + $this->assertMessageCount($room, 'switchto', 2); + $this->assertMessageWasSent($room, [ 'type' => 'switchto', 'switchto' => [ @@ -1362,13 +1383,14 @@ class BackendNotifierTest extends TestCase { $this->participantService->updateParticipantType($room, $participantModerator1, Participant::MODERATOR); + // Third room is explicitly empty. $attendeeMap = []; $attendeeMap[$participant1->getSession()->getAttendeeId()] = 0; $attendeeMap[$participant2->getSession()->getAttendeeId()] = 1; $attendeeMap[$participant3->getSession()->getAttendeeId()] = 0; $attendeeMap[$participantModerator1->getSession()->getAttendeeId()] = 0; - $breakoutRooms = $this->breakoutRoomService->setupBreakoutRooms($room, BreakoutRoom::MODE_MANUAL, 2, json_encode($attendeeMap)); + $breakoutRooms = $this->breakoutRoomService->setupBreakoutRooms($room, BreakoutRoom::MODE_MANUAL, 3, json_encode($attendeeMap)); $this->breakoutRoomService->startBreakoutRooms($room); @@ -1391,6 +1413,10 @@ class BackendNotifierTest extends TestCase { $this->breakoutRoomService->stopBreakoutRooms($room); + $this->assertMessageCount($breakoutRooms[0], 'switchto', 1); + $this->assertMessageCount($breakoutRooms[1], 'switchto', 1); + $this->assertMessageCount($breakoutRooms[2], 'switchto', 0); + $this->assertMessageWasSent($breakoutRooms[0], [ 'type' => 'switchto', 'switchto' => [ |