summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/comments/commentnode.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests/unit/comments/commentnode.php')
-rw-r--r--apps/dav/tests/unit/comments/commentnode.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/apps/dav/tests/unit/comments/commentnode.php b/apps/dav/tests/unit/comments/commentnode.php
index 8d1bf06ab60..8ebc5c2ff2c 100644
--- a/apps/dav/tests/unit/comments/commentnode.php
+++ b/apps/dav/tests/unit/comments/commentnode.php
@@ -22,6 +22,8 @@
namespace OCA\DAV\Tests\Unit\Comments;
use OCA\DAV\Comments\CommentNode;
+use OCP\Comments\IComment;
+use OCP\Comments\MessageTooLongException;
class CommentsNode extends \Test\TestCase {
@@ -199,6 +201,43 @@ class CommentsNode extends \Test\TestCase {
}
/**
+ * @expectedException \Sabre\DAV\Exception\BadRequest
+ * @expectedExceptionMessage Message exceeds allowed character limit of
+ */
+ public function testUpdateCommentMessageTooLongException() {
+ $user = $this->getMock('\OCP\IUser');
+
+ $user->expects($this->once())
+ ->method('getUID')
+ ->will($this->returnValue('alice'));
+
+ $this->userSession->expects($this->once())
+ ->method('getUser')
+ ->will($this->returnValue($user));
+
+ $this->comment->expects($this->once())
+ ->method('setMessage')
+ ->will($this->throwException(new MessageTooLongException()));
+
+ $this->comment->expects($this->any())
+ ->method('getActorType')
+ ->will($this->returnValue('users'));
+
+ $this->comment->expects($this->any())
+ ->method('getActorId')
+ ->will($this->returnValue('alice'));
+
+ $this->commentsManager->expects($this->never())
+ ->method('save');
+
+ $this->logger->expects($this->once())
+ ->method('logException');
+
+ // imagine 'foo' has >1k characters. comment is mocked anyway.
+ $this->node->updateComment('foo');
+ }
+
+ /**
* @expectedException \Sabre\DAV\Exception\Forbidden
*/
public function testUpdateForbiddenByUser() {