summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-10-17 09:30:47 +0200
committerGitHub <noreply@github.com>2016-10-17 09:30:47 +0200
commit96f8f209b9e899207a338eaa69b439e55f749ed5 (patch)
tree85d18ea0e4bed793c037a498aa684adca0441798 /tests
parent5b74b3ceafd17490ea7bef74051c70090f51b17e (diff)
parent70c7781aa8a1737b4c7ca8e935796b1ebc3d9f34 (diff)
downloadnextcloud-server-96f8f209b9e899207a338eaa69b439e55f749ed5.tar.gz
nextcloud-server-96f8f209b9e899207a338eaa69b439e55f749ed5.zip
Merge pull request #1449 from nextcloud/comments-user-mention
Notifications for simple @-mentioning in comments
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Comments/FakeManager.php2
-rw-r--r--tests/lib/Comments/ManagerTest.php44
2 files changed, 41 insertions, 5 deletions
diff --git a/tests/lib/Comments/FakeManager.php b/tests/lib/Comments/FakeManager.php
index 7186529e718..7cd146e7cb2 100644
--- a/tests/lib/Comments/FakeManager.php
+++ b/tests/lib/Comments/FakeManager.php
@@ -38,4 +38,6 @@ class FakeManager implements \OCP\Comments\ICommentsManager {
public function deleteReadMarksFromUser(\OCP\IUser $user) {}
public function deleteReadMarksOnObject($objectType, $objectId) {}
+
+ public function registerEventHandler(\Closure $closure) {}
}
diff --git a/tests/lib/Comments/ManagerTest.php b/tests/lib/Comments/ManagerTest.php
index 730d82d9d0d..71c918af6c7 100644
--- a/tests/lib/Comments/ManagerTest.php
+++ b/tests/lib/Comments/ManagerTest.php
@@ -2,6 +2,9 @@
namespace Test\Comments;
+use OC\Comments\Comment;
+use OCP\Comments\CommentsEvent;
+use OCP\Comments\ICommentsEventHandler;
use OCP\Comments\ICommentsManager;
use OCP\IUser;
use Test\TestCase;
@@ -355,7 +358,7 @@ class ManagerTest extends TestCase {
public function testSaveNew() {
$manager = $this->getManager();
- $comment = new \OC\Comments\Comment();
+ $comment = new Comment();
$comment
->setActor('users', 'alice')
->setObject('files', 'file64')
@@ -375,7 +378,7 @@ class ManagerTest extends TestCase {
public function testSaveUpdate() {
$manager = $this->getManager();
- $comment = new \OC\Comments\Comment();
+ $comment = new Comment();
$comment
->setActor('users', 'alice')
->setObject('files', 'file64')
@@ -396,7 +399,7 @@ class ManagerTest extends TestCase {
*/
public function testSaveUpdateException() {
$manager = $this->getManager();
- $comment = new \OC\Comments\Comment();
+ $comment = new Comment();
$comment
->setActor('users', 'alice')
->setObject('files', 'file64')
@@ -415,7 +418,7 @@ class ManagerTest extends TestCase {
*/
public function testSaveIncomplete() {
$manager = $this->getManager();
- $comment = new \OC\Comments\Comment();
+ $comment = new Comment();
$comment->setMessage('from no one to nothing');
$manager->save($comment);
}
@@ -426,7 +429,7 @@ class ManagerTest extends TestCase {
$manager = $this->getManager();
for($i = 0; $i < 3; $i++) {
- $comment = new \OC\Comments\Comment();
+ $comment = new Comment();
$comment
->setActor('users', 'alice')
->setObject('files', 'file64')
@@ -630,4 +633,35 @@ class ManagerTest extends TestCase {
$this->assertNull($dateTimeGet);
}
+ public function testSendEvent() {
+ $handler1 = $this->getMockBuilder(ICommentsEventHandler::class)->getMock();
+ $handler1->expects($this->exactly(4))
+ ->method('handle');
+
+ $handler2 = $this->getMockBuilder(ICommentsEventHandler::class)->getMock();
+ $handler1->expects($this->exactly(4))
+ ->method('handle');
+
+ $manager = $this->getManager();
+ $manager->registerEventHandler(function () use ($handler1) {return $handler1; });
+ $manager->registerEventHandler(function () use ($handler2) {return $handler2; });
+
+ $comment = new Comment();
+ $comment
+ ->setActor('users', 'alice')
+ ->setObject('files', 'file64')
+ ->setMessage('very beautiful, I am impressed!')
+ ->setVerb('comment');
+
+ // Add event
+ $manager->save($comment);
+
+ // Update event
+ $comment->setMessage('Different topic');
+ $manager->save($comment);
+
+ // Delete event
+ $manager->delete($comment->getId());
+ }
+
}