summaryrefslogtreecommitdiffstats
path: root/apps/comments/tests
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2016-10-12 18:06:22 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2016-10-12 18:06:22 +0200
commit1bcd2ca8e35dca6e68e5f06506ade0a78a2beae8 (patch)
treee1af5850f05bfd165c3542f0b50a49fe623452c0 /apps/comments/tests
parenta9671a4dc2cc904ebb852c7804204ac9f245017e (diff)
downloadnextcloud-server-1bcd2ca8e35dca6e68e5f06506ade0a78a2beae8.tar.gz
nextcloud-server-1bcd2ca8e35dca6e68e5f06506ade0a78a2beae8.zip
emit pre-update event for comments
* notifications can be cleaned up, no polluted DB * updating comments will re-notify users or remove notifications, depending on the message Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/comments/tests')
-rw-r--r--apps/comments/tests/Unit/EventHandlerTest.php37
-rw-r--r--apps/comments/tests/Unit/Notification/ListenerTest.php2
2 files changed, 5 insertions, 34 deletions
diff --git a/apps/comments/tests/Unit/EventHandlerTest.php b/apps/comments/tests/Unit/EventHandlerTest.php
index 21b701ea8cc..f377c01b3c9 100644
--- a/apps/comments/tests/Unit/EventHandlerTest.php
+++ b/apps/comments/tests/Unit/EventHandlerTest.php
@@ -69,42 +69,11 @@ class EventHandlerTest extends TestCase {
$this->eventHandler->handle($event);
}
- public function notHandledProvider() {
- return [
- [CommentsEvent::EVENT_UPDATE]
- ];
- }
-
- /**
- * @dataProvider notHandledProvider
- * @param string $eventType
- */
- public function testNotHandled($eventType) {
- /** @var IComment|\PHPUnit_Framework_MockObject_MockObject $comment */
- $comment = $this->getMockBuilder(IComment::class)->getMock();
- $comment->expects($this->once())
- ->method('getObjectType')
- ->willReturn('files');
-
- /** @var CommentsEvent|\PHPUnit_Framework_MockObject_MockObject $event */
- $event = $this->getMockBuilder(CommentsEvent::class)
- ->disableOriginalConstructor()
- ->getMock();
- $event->expects($this->once())
- ->method('getComment')
- ->willReturn($comment);
- $event->expects($this->once())
- ->method('getEvent')
- ->willReturn($eventType);
-
- // further processing does not happen, because $event methods cannot be
- // access more than once.
- $this->eventHandler->handle($event);
- }
-
public function handledProvider() {
return [
[CommentsEvent::EVENT_DELETE],
+ [CommentsEvent::EVENT_UPDATE],
+ [CommentsEvent::EVENT_PRE_UPDATE],
[CommentsEvent::EVENT_ADD]
];
}
@@ -152,7 +121,7 @@ class EventHandlerTest extends TestCase {
->withConsecutive([NotificationListener::class], [ActivityListener::class])
->willReturnOnConsecutiveCalls($notificationListener, $activityListener);
- $this->app->expects($this->once())
+ $this->app->expects($this->atLeastOnce())
->method('getContainer')
->willReturn($c);
diff --git a/apps/comments/tests/Unit/Notification/ListenerTest.php b/apps/comments/tests/Unit/Notification/ListenerTest.php
index 98a0375e49a..5926264fa08 100644
--- a/apps/comments/tests/Unit/Notification/ListenerTest.php
+++ b/apps/comments/tests/Unit/Notification/ListenerTest.php
@@ -60,6 +60,8 @@ class ListenerTest extends TestCase {
public function eventProvider() {
return [
[CommentsEvent::EVENT_ADD, 'notify'],
+ [CommentsEvent::EVENT_UPDATE, 'notify'],
+ [CommentsEvent::EVENT_PRE_UPDATE, 'markProcessed'],
[CommentsEvent::EVENT_DELETE, 'markProcessed']
];
}