summaryrefslogtreecommitdiffstats
path: root/apps/comments/tests
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2016-10-14 15:36:05 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2016-10-14 15:36:05 +0200
commit70c7781aa8a1737b4c7ca8e935796b1ebc3d9f34 (patch)
tree5515907e5c06674e076429e597b77eb832bd53a2 /apps/comments/tests
parent1bcd2ca8e35dca6e68e5f06506ade0a78a2beae8 (diff)
downloadnextcloud-server-70c7781aa8a1737b4c7ca8e935796b1ebc3d9f34.tar.gz
nextcloud-server-70c7781aa8a1737b4c7ca8e935796b1ebc3d9f34.zip
apply some polish
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/comments/tests')
-rw-r--r--apps/comments/tests/Unit/EventHandlerTest.php38
-rw-r--r--apps/comments/tests/Unit/Notification/ListenerTest.php23
2 files changed, 13 insertions, 48 deletions
diff --git a/apps/comments/tests/Unit/EventHandlerTest.php b/apps/comments/tests/Unit/EventHandlerTest.php
index f377c01b3c9..bb714993f7a 100644
--- a/apps/comments/tests/Unit/EventHandlerTest.php
+++ b/apps/comments/tests/Unit/EventHandlerTest.php
@@ -23,30 +23,35 @@
namespace OCA\Comments\Tests\Unit\Notification;
-use OCA\Comments\AppInfo\Application;
use OCA\Comments\EventHandler;
use OCP\Comments\CommentsEvent;
use OCP\Comments\IComment;
use OCA\Comments\Activity\Listener as ActivityListener;
use OCA\Comments\Notification\Listener as NotificationListener;
-use OCP\IContainer;
use Test\TestCase;
class EventHandlerTest extends TestCase {
/** @var EventHandler */
protected $eventHandler;
- /** @var Application|\PHPUnit_Framework_MockObject_MockObject */
- protected $app;
+ /** @var ActivityListener|\PHPUnit_Framework_MockObject_MockObject */
+ protected $activityListener;
+
+ /** @var NotificationListener|\PHPUnit_Framework_MockObject_MockObject */
+ protected $notificationListener;
protected function setUp() {
parent::setUp();
- $this->app = $this->getMockBuilder(Application::class)
+ $this->activityListener = $this->getMockBuilder(ActivityListener::class)
->disableOriginalConstructor()
->getMock();
- $this->eventHandler = new EventHandler($this->app);
+ $this->notificationListener = $this->getMockBuilder(NotificationListener::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->eventHandler = new EventHandler($this->activityListener, $this->notificationListener);
}
public function testNotFiles() {
@@ -100,31 +105,14 @@ class EventHandlerTest extends TestCase {
->method('getEvent')
->willReturn($eventType);
- $notificationListener = $this->getMockBuilder(NotificationListener::class)
- ->disableOriginalConstructor()
- ->getMock();
- $notificationListener->expects($this->once())
+ $this->notificationListener->expects($this->once())
->method('evaluate')
->with($event);
- $activityListener = $this->getMockBuilder(ActivityListener::class)
- ->disableOriginalConstructor()
- ->getMock();
- $activityListener->expects($this->any())
+ $this->activityListener->expects($this->any())
->method('commentEvent')
->with($event);
- /** @var IContainer|\PHPUnit_Framework_MockObject_MockObject $c */
- $c = $this->getMockBuilder(IContainer::class)->getMock();
- $c->expects($this->atLeastOnce())
- ->method('query')
- ->withConsecutive([NotificationListener::class], [ActivityListener::class])
- ->willReturnOnConsecutiveCalls($notificationListener, $activityListener);
-
- $this->app->expects($this->atLeastOnce())
- ->method('getContainer')
- ->willReturn($c);
-
$this->eventHandler->handle($event);
}
diff --git a/apps/comments/tests/Unit/Notification/ListenerTest.php b/apps/comments/tests/Unit/Notification/ListenerTest.php
index 5926264fa08..12f388fcff9 100644
--- a/apps/comments/tests/Unit/Notification/ListenerTest.php
+++ b/apps/comments/tests/Unit/Notification/ListenerTest.php
@@ -172,29 +172,6 @@ class ListenerTest extends TestCase {
$this->listener->evaluate($event);
}
- public function testUnsupportedCommentObjectType() {
- /** @var IComment|\PHPUnit_Framework_MockObject_MockObject $comment */
- $comment = $this->getMockBuilder('\OCP\Comments\IComment')->getMock();
- $comment->expects($this->once())
- ->method('getObjectType')
- ->will($this->returnValue('vcards'));
- $comment->expects($this->never())
- ->method('getMessage');
-
- /** @var CommentsEvent|\PHPUnit_Framework_MockObject_MockObject $event */
- $event = $this->getMockBuilder('\OCP\Comments\CommentsEvent')
- ->disableOriginalConstructor()
- ->getMock();
- $event->expects($this->once())
- ->method('getComment')
- ->will($this->returnValue($comment));
- $event->expects(($this->any()))
- ->method(('getEvent'))
- ->will($this->returnValue(CommentsEvent::EVENT_ADD));
-
- $this->listener->evaluate($event);
- }
-
public function testEvaluateUserDoesNotExist() {
$message = '@foobar bla bla bla';