diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2016-05-09 10:02:07 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2016-10-07 17:11:19 +0200 |
commit | e1073cf442613ac92878c8ded30a33db35b30e14 (patch) | |
tree | 43bf514650829b6a4684cb564c62b3785f60b188 /tests | |
parent | 9e7824f3edcb498447915a396e93678ddb6f5768 (diff) | |
download | nextcloud-server-e1073cf442613ac92878c8ded30a33db35b30e14.tar.gz nextcloud-server-e1073cf442613ac92878c8ded30a33db35b30e14.zip |
Notificacations for simple @-mentioning in comments
(WIP) notify user when mentioned in comments
Fix doc, and create absolute URL for as notification link.
PSR-4 compatibility changes
also move notification creation to comments app
Do not notify yourself
unit test for controller and application
smaller fixes
- translatable app name
- remove doubles in mention array
- micro perf optimization
- display name: special label for deleted users, keep user id for users that could not be fetched from userManager
Comment Notification-Listener Unit Test
fix email adresses
remove notification when triggering comment was deleted
add and adjust tests
add missing @license tags
simplify NotificationsController registration
appinfo simplification, php docs
make string easier to translate
adjust test
replace dispatcher-based listeners with a registration method and interface
safer to not pass optional data parameter to setSubject for marking as processed. ID and mention suffices
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
update comment
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Comments/FakeManager.php | 2 | ||||
-rw-r--r-- | tests/lib/Comments/ManagerTest.php | 44 |
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()); + } + } |