From 4779d3ae0c8a1aa54002feb60a8a3c03d8088424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 9 Oct 2018 14:52:55 +0200 Subject: [PATCH] Tests: Comment actrivity parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- tests/unit/Activity/DeckProviderTest.php | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/unit/Activity/DeckProviderTest.php b/tests/unit/Activity/DeckProviderTest.php index 08551b5b0..fce8b16bc 100644 --- a/tests/unit/Activity/DeckProviderTest.php +++ b/tests/unit/Activity/DeckProviderTest.php @@ -26,6 +26,7 @@ use OC\Activity\Event; use OCA\Deck\Db\Acl; use OCP\Activity\IEvent; +use OCP\Comments\IComment; use OCP\Comments\ICommentsManager; use OCP\IL10N; use OCP\IURLGenerator; @@ -449,6 +450,30 @@ public function testParseParamForChanges() { $this->assertEquals($expected, $actual); } + public function testParseParamForComment() { + $comment = $this->createMock(IComment::class); + $comment->expects($this->once()) + ->method('getMessage') + ->willReturn('Comment content'); + $this->commentsManager->expects($this->once()) + ->method('get') + ->with(123) + ->willReturn($comment); + $event = $this->createMock(IEvent::class); + $event->expects($this->once()) + ->method('setParsedMessage') + ->with('Comment content'); + $params = []; + $subjectParams = [ + 'comment' => 123 + ]; + $expected = [ + 'comment' => 123, + ]; + $actual = $this->invokePrivate($this->provider, 'parseParamForComment', [$subjectParams, $params, $event]); + $this->assertEquals($expected, $actual); + } + public function invokePrivate(&$object, $methodName, array $parameters = array()) { $reflection = new \ReflectionClass(get_class($object));