Commit aeb62690 authored by Sergio Bertolín's avatar Sergio Bertolín Committed by GitHub

Merge pull request #27533 from owncloud/modifying-comments-tests-fix

Fix problem with 0 comments
parents 62f6d25a ae4aa413
......@@ -179,6 +179,8 @@ class CommentPropertiesPlugin extends ServerPlugin {
[$node->getId()],
$user);
// Initialize with 0 as in prefetch phase in handleGetProperties
$numberOfCommentsForNode = 0;
if (isset($numberOfCommentsForNodes[$node->getId()])) {
$numberOfCommentsForNode = $numberOfCommentsForNodes[$node->getId()];
}
......
......@@ -304,4 +304,33 @@ class CommentsPropertiesPluginTest extends \Test\TestCase {
}
}
/**
* @dataProvider userProvider
* @param $user
*/
public function testGetUnreadCountWithZeroUnread($user) {
$node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\File')
->disableOriginalConstructor()
->getMock();
$node->expects($this->any())
->method('getId')
->will($this->returnValue('4567'));
$this->userSession->expects($this->once())
->method('getUser')
->will($this->returnValue($user));
$numberOfCommentsForNodes = [];
$this->commentsManager->expects($this->any())
->method('getNumberOfUnreadCommentsForNodes')
->willReturn($numberOfCommentsForNodes);
$unread = $this->plugin->getUnreadCount($node);
if(is_null($user)) {
$this->assertNull($unread);
} else {
$this->assertSame($unread, 0);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment