summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2023-02-08 13:34:03 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2023-02-22 13:09:26 +0100
commit3a397142c247c2d1acbb56999965c4e8eedbefc1 (patch)
treed43f6194921553850cf996c9eafe67f1f265fb61 /tests
parent24bb1cf20f091c83f4de4cb42984534670c7313d (diff)
Add optional participant parameter to the "callRecording" change event
This makes possible to set a different participant than the current user as the participant who started or stopped the recording, which is needed now that the recording status is changed in a request from the recording server. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/php/Chat/SystemMessage/ListenerTest.php115
1 files changed, 115 insertions, 0 deletions
diff --git a/tests/php/Chat/SystemMessage/ListenerTest.php b/tests/php/Chat/SystemMessage/ListenerTest.php
index 274b47c2f..3e073a244 100644
--- a/tests/php/Chat/SystemMessage/ListenerTest.php
+++ b/tests/php/Chat/SystemMessage/ListenerTest.php
@@ -25,6 +25,7 @@ use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Chat\SystemMessage\Listener;
use OCA\Talk\Events\AddParticipantsEvent;
use OCA\Talk\Events\ModifyParticipantEvent;
+use OCA\Talk\Events\ModifyRoomEvent;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Participant;
use OCA\Talk\Room;
@@ -317,4 +318,118 @@ class ListenerTest extends TestCase {
$this->dispatch(Room::EVENT_AFTER_PARTICIPANT_TYPE_SET, $event);
}
+
+ public function callRecordingChangeProvider() {
+ return [
+ [
+ Room::RECORDING_VIDEO,
+ Room::RECORDING_NONE,
+ null,
+ null,
+ ['message' => 'recording_started', 'parameters' => []],
+ ],
+ [
+ Room::RECORDING_VIDEO,
+ Room::RECORDING_NONE,
+ Attendee::ACTOR_USERS,
+ 'alice',
+ ['message' => 'recording_started', 'parameters' => []],
+ ],
+ [
+ Room::RECORDING_AUDIO,
+ Room::RECORDING_NONE,
+ null,
+ null,
+ ['message' => 'audio_recording_started', 'parameters' => []],
+ ],
+ [
+ Room::RECORDING_AUDIO,
+ Room::RECORDING_NONE,
+ Attendee::ACTOR_USERS,
+ 'alice',
+ ['message' => 'audio_recording_started', 'parameters' => []],
+ ],
+ [
+ Room::RECORDING_NONE,
+ Room::RECORDING_VIDEO,
+ null,
+ null,
+ ['message' => 'recording_stopped', 'parameters' => []],
+ ],
+ [
+ Room::RECORDING_NONE,
+ Room::RECORDING_VIDEO,
+ Attendee::ACTOR_USERS,
+ 'bob',
+ ['message' => 'recording_stopped', 'parameters' => []],
+ ],
+ [
+ Room::RECORDING_NONE,
+ Room::RECORDING_AUDIO,
+ null,
+ null,
+ ['message' => 'audio_recording_stopped', 'parameters' => []],
+ ],
+ [
+ Room::RECORDING_NONE,
+ Room::RECORDING_AUDIO,
+ Attendee::ACTOR_USERS,
+ 'bob',
+ ['message' => 'audio_recording_stopped', 'parameters' => []],
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider callRecordingChangeProvider
+ *
+ * @param int $newStatus
+ * @param int $oldStatus
+ * @param string|null $actorType
+ * @param string|null $actorId
+ * @param array $expectedMessage
+ */
+ public function testAfterCallRecordingSet(int $newStatus, int $oldStatus, ?string $actorType, ?string $actorId, array $expectedMessage): void {
+ $this->mockLoggedInUser('logged_in_user');
+
+ $room = $this->createMock(Room::class);
+ $room->expects($this->any())
+ ->method('getType')
+ ->willReturn(Room::TYPE_PUBLIC);
+
+ if ($actorType !== null && $actorId !== null) {
+ $attendee = new Attendee();
+ $attendee->setActorType($actorType);
+ $attendee->setActorId($actorId);
+
+ $participant = $this->createMock(Participant::class);
+ $participant->method('getAttendee')->willReturn($attendee);
+
+ $expectedActorType = $actorType;
+ $expectedActorId = $actorId;
+ } else {
+ $participant = null;
+
+ $expectedActorType = Attendee::ACTOR_USERS;
+ $expectedActorId = 'logged_in_user';
+ }
+
+ $event = new ModifyRoomEvent($room, 'callRecording', $newStatus, $oldStatus, $participant);
+
+ $this->chatManager->expects($this->once())
+ ->method('addSystemMessage')
+ ->with(
+ $room,
+ $expectedActorType,
+ $expectedActorId,
+ json_encode($expectedMessage),
+ $this->dummyTime,
+ false,
+ SELF::DUMMY_REFERENCE_ID,
+ null,
+ false
+ );
+
+ $this->dispatch(Room::EVENT_AFTER_SET_CALL_RECORDING, $event);
+ }
}