From 70c7781aa8a1737b4c7ca8e935796b1ebc3d9f34 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 14 Oct 2016 15:36:05 +0200 Subject: apply some polish Signed-off-by: Arthur Schiwon --- apps/comments/tests/Unit/EventHandlerTest.php | 38 ++++++++-------------- .../tests/Unit/Notification/ListenerTest.php | 23 ------------- 2 files changed, 13 insertions(+), 48 deletions(-) (limited to 'apps/comments/tests') 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'; -- cgit v1.2.3