diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-10-24 15:26:53 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-10-24 17:45:32 +0200 |
commit | 43e498844e8c1aa519a19238d2cf3d6b95e1aab0 (patch) | |
tree | 59510ef2ffc6c1fd1fd92475013b108f1da2bfeb /apps/comments/tests | |
parent | b1f77aca4effec99387481a831910d4870ae2ffc (diff) | |
download | nextcloud-server-43e498844e8c1aa519a19238d2cf3d6b95e1aab0.tar.gz nextcloud-server-43e498844e8c1aa519a19238d2cf3d6b95e1aab0.zip |
Use ::class in test mocks
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/comments/tests')
-rw-r--r-- | apps/comments/tests/Unit/Controller/NotificationsTest.php | 36 | ||||
-rw-r--r-- | apps/comments/tests/Unit/Notification/ListenerTest.php | 16 |
2 files changed, 31 insertions, 21 deletions
diff --git a/apps/comments/tests/Unit/Controller/NotificationsTest.php b/apps/comments/tests/Unit/Controller/NotificationsTest.php index e887900a615..2c34971f4b7 100644 --- a/apps/comments/tests/Unit/Controller/NotificationsTest.php +++ b/apps/comments/tests/Unit/Controller/NotificationsTest.php @@ -22,7 +22,17 @@ namespace OCA\Comments\Tests\Unit\Controller; use OCA\Comments\Controller\Notifications; +use OCP\Comments\IComment; +use OCP\Comments\ICommentsManager; use OCP\Comments\NotFoundException; +use OCP\Files\Folder; +use OCP\Files\Node; +use OCP\IRequest; +use OCP\IURLGenerator; +use OCP\IUser; +use OCP\IUserSession; +use OCP\Notification\IManager; +use OCP\Notification\INotification; use Test\TestCase; class NotificationsTest extends TestCase { @@ -44,24 +54,24 @@ class NotificationsTest extends TestCase { protected function setUp() { parent::setUp(); - $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager')->getMock(); - $this->folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); - $this->session = $this->getMockBuilder('\OCP\IUserSession')->getMock(); - $this->notificationManager = $this->getMockBuilder('\OCP\Notification\IManager')->getMock(); + $this->commentsManager = $this->getMockBuilder(ICommentsManager::class)->getMock(); + $this->folder = $this->getMockBuilder(Folder::class)->getMock(); + $this->session = $this->getMockBuilder(IUserSession::class)->getMock(); + $this->notificationManager = $this->getMockBuilder(IManager::class)->getMock(); $this->notificationsController = new Notifications( 'comments', - $this->getMockBuilder('\OCP\IRequest')->getMock(), + $this->getMockBuilder(IRequest::class)->getMock(), $this->commentsManager, $this->folder, - $this->getMockBuilder('\OCP\IURLGenerator')->getMock(), + $this->getMockBuilder(IURLGenerator::class)->getMock(), $this->notificationManager, $this->session ); } public function testViewSuccess() { - $comment = $this->getMockBuilder('\OCP\Comments\IComment')->getMock(); + $comment = $this->getMockBuilder(IComment::class)->getMock(); $comment->expects($this->any()) ->method('getObjectType') ->will($this->returnValue('files')); @@ -71,7 +81,7 @@ class NotificationsTest extends TestCase { ->with('42') ->will($this->returnValue($comment)); - $file = $this->getMockBuilder('\OCP\Files\Node')->getMock(); + $file = $this->getMockBuilder(Node::class)->getMock(); $this->folder->expects($this->once()) ->method('getById') @@ -79,9 +89,9 @@ class NotificationsTest extends TestCase { $this->session->expects($this->once()) ->method('getUser') - ->will($this->returnValue($this->getMockBuilder('\OCP\IUser')->getMock())); + ->will($this->returnValue($this->getMockBuilder(IUser::class)->getMock())); - $notification = $this->getMockBuilder('\OCP\Notification\INotification')->getMock(); + $notification = $this->getMockBuilder(INotification::class)->getMock(); $notification->expects($this->any()) ->method($this->anything()) ->will($this->returnValue($notification)); @@ -119,7 +129,7 @@ class NotificationsTest extends TestCase { } public function testViewNoFile() { - $comment = $this->getMockBuilder('\OCP\Comments\IComment')->getMock(); + $comment = $this->getMockBuilder(IComment::class)->getMock(); $comment->expects($this->any()) ->method('getObjectType') ->will($this->returnValue('files')); @@ -135,9 +145,9 @@ class NotificationsTest extends TestCase { $this->session->expects($this->once()) ->method('getUser') - ->will($this->returnValue($this->getMockBuilder('\OCP\IUser')->getMock())); + ->will($this->returnValue($this->getMockBuilder(IUser::class)->getMock())); - $notification = $this->getMockBuilder('\OCP\Notification\INotification')->getMock(); + $notification = $this->getMockBuilder(INotification::class)->getMock(); $notification->expects($this->any()) ->method($this->anything()) ->will($this->returnValue($notification)); diff --git a/apps/comments/tests/Unit/Notification/ListenerTest.php b/apps/comments/tests/Unit/Notification/ListenerTest.php index ef84d1c60de..cbe2b633429 100644 --- a/apps/comments/tests/Unit/Notification/ListenerTest.php +++ b/apps/comments/tests/Unit/Notification/ListenerTest.php @@ -71,7 +71,7 @@ class ListenerTest extends TestCase { */ public function testEvaluate($eventType, $notificationMethod) { /** @var IComment|\PHPUnit_Framework_MockObject_MockObject $comment */ - $comment = $this->getMockBuilder('\OCP\Comments\IComment')->getMock(); + $comment = $this->getMockBuilder(IComment::class)->getMock(); $comment->expects($this->any()) ->method('getObjectType') ->will($this->returnValue('files')); @@ -90,7 +90,7 @@ class ListenerTest extends TestCase { ]); /** @var CommentsEvent|\PHPUnit_Framework_MockObject_MockObject $event */ - $event = $this->getMockBuilder('\OCP\Comments\CommentsEvent') + $event = $this->getMockBuilder(CommentsEvent::class) ->disableOriginalConstructor() ->getMock(); $event->expects($this->once()) @@ -101,7 +101,7 @@ class ListenerTest extends TestCase { ->will($this->returnValue($eventType)); /** @var INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder('\OCP\Notification\INotification')->getMock(); + $notification = $this->getMockBuilder(INotification::class)->getMock(); $notification->expects($this->any()) ->method($this->anything()) ->will($this->returnValue($notification)); @@ -136,7 +136,7 @@ class ListenerTest extends TestCase { */ public function testEvaluateNoMentions($eventType) { /** @var IComment|\PHPUnit_Framework_MockObject_MockObject $comment */ - $comment = $this->getMockBuilder('\OCP\Comments\IComment')->getMock(); + $comment = $this->getMockBuilder(IComment::class)->getMock(); $comment->expects($this->any()) ->method('getObjectType') ->will($this->returnValue('files')); @@ -148,7 +148,7 @@ class ListenerTest extends TestCase { ->willReturn([]); /** @var CommentsEvent|\PHPUnit_Framework_MockObject_MockObject $event */ - $event = $this->getMockBuilder('\OCP\Comments\CommentsEvent') + $event = $this->getMockBuilder(CommentsEvent::class) ->disableOriginalConstructor() ->getMock(); $event->expects($this->once()) @@ -173,7 +173,7 @@ class ListenerTest extends TestCase { public function testEvaluateUserDoesNotExist() { /** @var IComment|\PHPUnit_Framework_MockObject_MockObject $comment */ - $comment = $this->getMockBuilder('\OCP\Comments\IComment')->getMock(); + $comment = $this->getMockBuilder(IComment::class)->getMock(); $comment->expects($this->any()) ->method('getObjectType') ->will($this->returnValue('files')); @@ -185,7 +185,7 @@ class ListenerTest extends TestCase { ->willReturn([[ 'type' => 'user', 'id' => 'foobar']]); /** @var CommentsEvent|\PHPUnit_Framework_MockObject_MockObject $event */ - $event = $this->getMockBuilder('\OCP\Comments\CommentsEvent') + $event = $this->getMockBuilder(CommentsEvent::class) ->disableOriginalConstructor() ->getMock(); $event->expects($this->once()) @@ -196,7 +196,7 @@ class ListenerTest extends TestCase { ->will($this->returnValue(CommentsEvent::EVENT_ADD)); /** @var INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder('\OCP\Notification\INotification')->getMock(); + $notification = $this->getMockBuilder(INotification::class)->getMock(); $notification->expects($this->any()) ->method($this->anything()) ->will($this->returnValue($notification)); |