diff options
author | Joas Schilling <coding@schilljs.com> | 2019-07-12 17:26:49 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-07-30 10:33:41 +0300 |
commit | a1b17d282f5c9d886ad9320aa4178d16a153e9ea (patch) | |
tree | 1dd12245c483ca12a0925663360f94031f16cf6f /tests | |
parent | ece3c74e7cf9bbcc48ac55e8592a9e0090620b10 (diff) |
Allow to reply to messages and return the parent on the message endpoints
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/php/Chat/ChatManagerTest.php | 49 | ||||
-rw-r--r-- | tests/php/Controller/ChatControllerTest.php | 19 |
2 files changed, 67 insertions, 1 deletions
diff --git a/tests/php/Chat/ChatManagerTest.php b/tests/php/Chat/ChatManagerTest.php index ab8774fe8..8398b7596 100644 --- a/tests/php/Chat/ChatManagerTest.php +++ b/tests/php/Chat/ChatManagerTest.php @@ -118,7 +118,54 @@ class ChatManagerTest extends TestCase { $participant = $this->createMock(Participant::class); - $this->chatManager->sendMessage($chat, $participant, 'users', 'testUser', 'testMessage', $creationDateTime); + $this->chatManager->sendMessage($chat, $participant, 'users', 'testUser', 'testMessage', $creationDateTime, null); + } + + public function testReplyToMessage() { + $replyTo = $this->createMock(IComment::class); + $comment = $this->createMock(IComment::class); + + $this->commentsManager->expects($this->once()) + ->method('create') + ->with('users', 'testUser', 'chat', 1234) + ->willReturn($comment); + + $comment->expects($this->once()) + ->method('setMessage') + ->with('testMessage'); + + $creationDateTime = new \DateTime(); + $comment->expects($this->once()) + ->method('setCreationDateTime') + ->with($creationDateTime); + + $comment->expects($this->once()) + ->method('setVerb') + ->with('comment'); + + $this->commentsManager->expects($this->once()) + ->method('save') + ->with($comment); + + $chat = $this->createMock(Room::class); + $chat->expects($this->any()) + ->method('getId') + ->willReturn(1234); + + $this->notifier->expects($this->once()) + ->method('notifyMentionedUsers') + ->with($chat, $comment); + + $replyTo->expects($this->once()) + ->method('getId') + ->willReturn('12345'); + + $comment->expects($this->once()) + ->method('setParentId') + ->with('12345'); + + $participant = $this->createMock(Participant::class); + $this->chatManager->sendMessage($chat, $participant, 'users', 'testUser', 'testMessage', $creationDateTime, $replyTo); } public function testGetHistory() { diff --git a/tests/php/Controller/ChatControllerTest.php b/tests/php/Controller/ChatControllerTest.php index 6e9b82b1f..916329ff9 100644 --- a/tests/php/Controller/ChatControllerTest.php +++ b/tests/php/Controller/ChatControllerTest.php @@ -136,6 +136,7 @@ class ChatControllerTest extends TestCase { $comment->method('getActorId')->willReturn($actorId); $comment->method('getCreationDateTime')->willReturn($creationDateTime); $comment->method('getMessage')->willReturn($message); + $comment->method('getParentId')->willReturn('0'); return $comment; } @@ -185,6 +186,12 @@ class ChatControllerTest extends TestCase { $chatMessage->expects($this->once()) ->method('getVisibility') ->willReturn(true); + $chatMessage->expects($this->exactly(2)) + ->method('getComment') + ->willReturn($comment); + $chatMessage->expects($this->once()) + ->method('getRoom') + ->willReturn($this->room); $this->messageParser->expects($this->once()) ->method('createMessage') @@ -258,6 +265,12 @@ class ChatControllerTest extends TestCase { $chatMessage->expects($this->once()) ->method('getVisibility') ->willReturn(true); + $chatMessage->expects($this->exactly(2)) + ->method('getComment') + ->willReturn($comment); + $chatMessage->expects($this->once()) + ->method('getRoom') + ->willReturn($this->room); $this->messageParser->expects($this->once()) ->method('createMessage') @@ -339,6 +352,12 @@ class ChatControllerTest extends TestCase { $chatMessage->expects($this->once()) ->method('getVisibility') ->willReturn(true); + $chatMessage->expects($this->exactly(2)) + ->method('getComment') + ->willReturn($comment); + $chatMessage->expects($this->once()) + ->method('getRoom') + ->willReturn($this->room); $this->messageParser->expects($this->once()) ->method('createMessage') |