summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
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..9c0f791c0ca 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(3))
+ ->method('handle');
+
+ $handler2 = $this->getMockBuilder(ICommentsEventHandler::class)->getMock();
+ $handler1->expects($this->exactly(3))
+ ->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());
+ }
+
}