diff options
author | Joas Schilling <coding@schilljs.com> | 2023-04-04 17:15:00 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-04-04 17:15:00 +0200 |
commit | 3c00ae5b2138223d693a3f09831f013d5c200901 (patch) | |
tree | ffba6fd7dd7c76d3c3516d1c613e888928d0d864 /tests/php | |
parent | a529fea80c2c440c2b874bb6c6f798a84f6f1866 (diff) |
fix(tests): Make sure avatar service is actually called
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/php')
-rw-r--r-- | tests/php/Chat/Parser/UserMentionTest.php | 6 | ||||
-rw-r--r-- | tests/php/Controller/ChatControllerTest.php | 6 | ||||
-rw-r--r-- | tests/php/Notification/NotifierTest.php | 76 |
3 files changed, 52 insertions, 36 deletions
diff --git a/tests/php/Chat/Parser/UserMentionTest.php b/tests/php/Chat/Parser/UserMentionTest.php index a06b78ee0..de44a3991 100644 --- a/tests/php/Chat/Parser/UserMentionTest.php +++ b/tests/php/Chat/Parser/UserMentionTest.php @@ -436,6 +436,10 @@ class UserMentionTest extends TestCase { $chatMessage = new Message($room, $participant, $comment, $l); $chatMessage->setMessage('Mention to @all', []); + $this->avatarService->method('getAvatarUrl') + ->with($room) + ->willReturn('getAvatarUrl'); + $this->parser->parseMessage($chatMessage); $expectedMessageParameters = [ @@ -444,7 +448,7 @@ class UserMentionTest extends TestCase { 'id' => 'token', 'name' => 'name', 'call-type' => 'group', - 'icon-url' => '', + 'icon-url' => 'getAvatarUrl', ] ]; diff --git a/tests/php/Controller/ChatControllerTest.php b/tests/php/Controller/ChatControllerTest.php index 59378e7d6..e759b0fd6 100644 --- a/tests/php/Controller/ChatControllerTest.php +++ b/tests/php/Controller/ChatControllerTest.php @@ -638,6 +638,10 @@ class ChatControllerTest extends TestCase { public function testShareObjectToChatByUser() { $participant = $this->createMock(Participant::class); + $this->avatarService->method('getAvatarUrl') + ->with($this->room) + ->willReturn('getAvatarUrl'); + $richData = [ 'call-type' => 'one2one', 'type' => 'call', @@ -665,7 +669,7 @@ class ChatControllerTest extends TestCase { 'call-type' => 'one2one', 'type' => 'call', 'id' => 'R4nd0mToken', - 'icon-url' => '', + 'icon-url' => 'getAvatarUrl', ], ], ]), diff --git a/tests/php/Notification/NotifierTest.php b/tests/php/Notification/NotifierTest.php index 1473bba99..efb048537 100644 --- a/tests/php/Notification/NotifierTest.php +++ b/tests/php/Notification/NotifierTest.php @@ -424,6 +424,10 @@ class NotifierTest extends TestCase { ->method('getId') ->willReturn($roomId); + $this->avatarService->method('getAvatarUrl') + ->with($room) + ->willReturn('getAvatarUrl'); + if ($type === Room::TYPE_GROUP) { $n->expects($this->once()) ->method('setRichSubject') @@ -438,7 +442,7 @@ class NotifierTest extends TestCase { 'id' => $roomId, 'name' => $name, 'call-type' => 'group', - 'icon-url' => '', + 'icon-url' => 'getAvatarUrl', ], ]) ->willReturnSelf(); @@ -456,7 +460,7 @@ class NotifierTest extends TestCase { 'id' => $roomId, 'name' => $name, 'call-type' => 'public', - 'icon-url' => '', + 'icon-url' => 'getAvatarUrl', ], ]) ->willReturnSelf(); @@ -491,7 +495,7 @@ class NotifierTest extends TestCase { '{user} mentioned you in a private conversation', [ 'user' => ['type' => 'user', 'id' => 'testUser', 'name' => 'Test user'], - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Test user', 'call-type' => 'one2one', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Test user', 'call-type' => 'one2one', 'icon-url' => 'getAvatarUrl'], ], ], ], @@ -502,7 +506,7 @@ class NotifierTest extends TestCase { '{user} mentioned you in conversation {call}', [ 'user' => ['type' => 'user', 'id' => 'testUser', 'name' => 'Test user'], - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => 'getAvatarUrl'], ], ], ], @@ -512,7 +516,7 @@ class NotifierTest extends TestCase { [ 'A deleted user mentioned you in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => 'getAvatarUrl'], ], ], $deletedUser = true, @@ -524,7 +528,7 @@ class NotifierTest extends TestCase { '{user} mentioned you in conversation {call}', [ 'user' => ['type' => 'user', 'id' => 'testUser', 'name' => 'Test user'], - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], ], ], ], @@ -534,7 +538,7 @@ class NotifierTest extends TestCase { [ 'A deleted user mentioned you in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], ], ], $deletedUser = true, @@ -545,7 +549,7 @@ class NotifierTest extends TestCase { [ 'A guest mentioned you in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], ], ], $deletedUser = false, $guestName = null, @@ -556,7 +560,7 @@ class NotifierTest extends TestCase { [ '{guest} (guest) mentioned you in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], 'guest' => ['type' => 'guest', 'id' => 'random-hash', 'name' => 'MyNameIs'], ] ], @@ -568,7 +572,7 @@ class NotifierTest extends TestCase { [ 'A guest mentioned you in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], ], ], $deletedUser = false, $guestName = '', @@ -582,7 +586,7 @@ class NotifierTest extends TestCase { '{user} sent you a private message', [ 'user' => ['type' => 'user', 'id' => 'testUser', 'name' => 'Test user'], - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Test user', 'call-type' => 'one2one', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Test user', 'call-type' => 'one2one', 'icon-url' => 'getAvatarUrl'], ], ], ], @@ -593,7 +597,7 @@ class NotifierTest extends TestCase { '{user} sent a message in conversation {call}', [ 'user' => ['type' => 'user', 'id' => 'testUser', 'name' => 'Test user'], - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => 'getAvatarUrl'], ], ], ], @@ -603,7 +607,7 @@ class NotifierTest extends TestCase { [ 'A deleted user sent a message in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => 'getAvatarUrl'], ], ], $deletedUser = true, @@ -615,7 +619,7 @@ class NotifierTest extends TestCase { '{user} sent a message in conversation {call}', [ 'user' => ['type' => 'user', 'id' => 'testUser', 'name' => 'Test user'], - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], ] ], ], @@ -625,7 +629,7 @@ class NotifierTest extends TestCase { [ 'A deleted user sent a message in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], ], ], $deletedUser = true @@ -635,7 +639,7 @@ class NotifierTest extends TestCase { 'A guest sent a message in conversation Room name', ['A guest sent a message in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], ], ], $deletedUser = false, $guestName = null, @@ -646,7 +650,7 @@ class NotifierTest extends TestCase { [ '{guest} (guest) sent a message in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], 'guest' => ['type' => 'guest', 'id' => 'random-hash', 'name' => 'MyNameIs'], ], ], @@ -658,7 +662,7 @@ class NotifierTest extends TestCase { [ 'A guest sent a message in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], ], ], $deletedUser = false, $guestName = '', @@ -672,7 +676,7 @@ class NotifierTest extends TestCase { '{user} replied to your private message', [ 'user' => ['type' => 'user', 'id' => 'testUser', 'name' => 'Test user'], - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Test user', 'call-type' => 'one2one', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Test user', 'call-type' => 'one2one', 'icon-url' => 'getAvatarUrl'], ], ], ], @@ -683,7 +687,7 @@ class NotifierTest extends TestCase { '{user} replied to your message in conversation {call}', [ 'user' => ['type' => 'user', 'id' => 'testUser', 'name' => 'Test user'], - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => 'getAvatarUrl'], ], ], ], @@ -693,7 +697,7 @@ class NotifierTest extends TestCase { [ 'A deleted user replied to your message in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => 'getAvatarUrl'], ], ], $deletedUser = true, @@ -705,7 +709,7 @@ class NotifierTest extends TestCase { '{user} replied to your message in conversation {call}', [ 'user' => ['type' => 'user', 'id' => 'testUser', 'name' => 'Test user'], - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], ] ], ], @@ -715,7 +719,7 @@ class NotifierTest extends TestCase { [ 'A deleted user replied to your message in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], ], ], $deletedUser = true @@ -725,7 +729,7 @@ class NotifierTest extends TestCase { 'A guest replied to your message in conversation Room name', ['A guest replied to your message in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], ], ], $deletedUser = false, $guestName = null, @@ -736,7 +740,7 @@ class NotifierTest extends TestCase { [ '{guest} (guest) replied to your message in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], 'guest' => ['type' => 'guest', 'id' => 'random-hash', 'name' => 'MyNameIs'], ], ], @@ -748,7 +752,7 @@ class NotifierTest extends TestCase { [ 'A guest replied to your message in conversation {call}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], ], ], $deletedUser = false, $guestName = '', @@ -762,7 +766,7 @@ class NotifierTest extends TestCase { '{user}' . "\n" . '{message}', [ 'user' => ['type' => 'user', 'id' => 'testUser', 'name' => 'Test user'], - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Test user', 'call-type' => 'one2one', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Test user', 'call-type' => 'one2one', 'icon-url' => 'getAvatarUrl'], 'message' => ['type' => 'highlight', 'id' => '123456789', 'name' => 'Hi @Administrator'], ], ], @@ -775,7 +779,7 @@ class NotifierTest extends TestCase { '{user} in {call}' . "\n" . '{message}', [ 'user' => ['type' => 'user', 'id' => 'testUser', 'name' => 'Test user'], - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => 'getAvatarUrl'], 'message' => ['type' => 'highlight', 'id' => '123456789', 'name' => 'Hi @Administrator'], ], ], @@ -787,7 +791,7 @@ class NotifierTest extends TestCase { [ 'Deleted user in {call}' . "\n" . '{message}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'group', 'icon-url' => 'getAvatarUrl'], 'message' => ['type' => 'highlight', 'id' => '123456789', 'name' => 'Hi @Administrator'], ], ], @@ -800,7 +804,7 @@ class NotifierTest extends TestCase { '{user} in {call}' . "\n" . '{message}', [ 'user' => ['type' => 'user', 'id' => 'testUser', 'name' => 'Test user'], - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], 'message' => ['type' => 'highlight', 'id' => '123456789', 'name' => 'Hi @Administrator'], ], ], @@ -812,7 +816,7 @@ class NotifierTest extends TestCase { [ 'Deleted user in {call}' . "\n" . '{message}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], 'message' => ['type' => 'highlight', 'id' => '123456789', 'name' => 'Hi @Administrator'], ], ], @@ -824,7 +828,7 @@ class NotifierTest extends TestCase { [ 'Guest in {call}' . "\n" . '{message}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], 'message' => ['type' => 'highlight', 'id' => '123456789', 'name' => 'Hi @Administrator'], ], ], @@ -836,7 +840,7 @@ class NotifierTest extends TestCase { [ '{guest} (guest) in {call}' . "\n" . '{message}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], 'guest' => ['type' => 'guest', 'id' => 'random-hash', 'name' => 'MyNameIs'], 'message' => ['type' => 'highlight', 'id' => '123456789', 'name' => 'Hi @Administrator'], ], @@ -849,7 +853,7 @@ class NotifierTest extends TestCase { [ 'Guest in {call}' . "\n" . '{message}', [ - 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => ''], + 'call' => ['type' => 'call', 'id' => 1234, 'name' => 'Room name', 'call-type' => 'public', 'icon-url' => 'getAvatarUrl'], 'message' => ['type' => 'highlight', 'id' => '123456789', 'name' => 'Hi @Administrator'], ], ], @@ -895,6 +899,10 @@ class NotifierTest extends TestCase { ->with('recipient') ->willReturn($roomName); + $this->avatarService->method('getAvatarUrl') + ->with($room) + ->willReturn('getAvatarUrl'); + $participant = $this->createMock(Participant::class); $this->participantService->expects($this->once()) ->method('getParticipant') |