summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/Comments/CommentsNodeTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests/unit/Comments/CommentsNodeTest.php')
-rw-r--r--apps/dav/tests/unit/Comments/CommentsNodeTest.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/dav/tests/unit/Comments/CommentsNodeTest.php b/apps/dav/tests/unit/Comments/CommentsNodeTest.php
index 1c7bd782496..94eaea01d56 100644
--- a/apps/dav/tests/unit/Comments/CommentsNodeTest.php
+++ b/apps/dav/tests/unit/Comments/CommentsNodeTest.php
@@ -27,11 +27,14 @@ namespace OCA\DAV\Tests\unit\Comments;
use OCA\DAV\Comments\CommentNode;
use OCP\Comments\IComment;
+use OCP\Comments\ICommentsManager;
use OCP\Comments\MessageTooLongException;
class CommentsNodeTest extends \Test\TestCase {
+ /** @var ICommentsManager|\PHPUnit_Framework_MockObject_MockObject */
protected $commentsManager;
+
protected $comment;
protected $node;
protected $userManager;
@@ -373,6 +376,18 @@ class CommentsNodeTest extends \Test\TestCase {
$ns . 'topmostParentId' => '2',
$ns . 'childrenCount' => 3,
$ns . 'message' => 'such a nice file you haveā€¦',
+ $ns . 'mentions' => [
+ [ $ns . 'mention' => [
+ $ns . 'mentionType' => 'user',
+ $ns . 'mentionId' => 'alice',
+ $ns . 'mentionDisplayName' => 'Alice Al-Isson',
+ ] ],
+ [ $ns . 'mention' => [
+ $ns . 'mentionType' => 'user',
+ $ns . 'mentionId' => 'bob',
+ $ns . 'mentionDisplayName' => 'Unknown user',
+ ] ],
+ ],
$ns . 'verb' => 'comment',
$ns . 'actorType' => 'users',
$ns . 'actorId' => 'alice',
@@ -384,6 +399,14 @@ class CommentsNodeTest extends \Test\TestCase {
$ns . 'isUnread' => null,
];
+ $this->commentsManager->expects($this->exactly(2))
+ ->method('resolveDisplayName')
+ ->withConsecutive(
+ [$this->equalTo('user'), $this->equalTo('alice')],
+ [$this->equalTo('user'), $this->equalTo('bob')]
+ )
+ ->willReturnOnConsecutiveCalls('Alice Al-Isson', 'Unknown user');
+
$this->comment->expects($this->once())
->method('getId')
->will($this->returnValue($expected[$ns . 'id']));
@@ -405,6 +428,13 @@ class CommentsNodeTest extends \Test\TestCase {
->will($this->returnValue($expected[$ns . 'message']));
$this->comment->expects($this->once())
+ ->method('getMentions')
+ ->willReturn([
+ ['type' => 'user', 'id' => 'alice'],
+ ['type' => 'user', 'id' => 'bob'],
+ ]);
+
+ $this->comment->expects($this->once())
->method('getVerb')
->will($this->returnValue($expected[$ns . 'verb']));
@@ -475,6 +505,10 @@ class CommentsNodeTest extends \Test\TestCase {
->method('getCreationDateTime')
->will($this->returnValue($creationDT));
+ $this->comment->expects($this->any())
+ ->method('getMentions')
+ ->willReturn([]);
+
$this->commentsManager->expects($this->once())
->method('getReadMark')
->will($this->returnValue($readDT));