From 43e498844e8c1aa519a19238d2cf3d6b95e1aab0 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 24 Oct 2017 15:26:53 +0200 Subject: Use ::class in test mocks Signed-off-by: Morris Jobke --- .../tests/unit/CalDAV/AbstractCalDavBackend.php | 2 +- apps/dav/tests/unit/CalDAV/CalendarTest.php | 2 +- .../tests/unit/CalDAV/PublicCalendarRootTest.php | 2 +- .../unit/CalDAV/Publishing/PublishingTest.php | 6 +- .../tests/unit/CalDAV/Schedule/IMipPluginTest.php | 12 ++-- apps/dav/tests/unit/CardDAV/AddressBookTest.php | 8 +-- apps/dav/tests/unit/CardDAV/CardDavBackendTest.php | 2 +- .../dav/tests/unit/CardDAV/ContactsManagerTest.php | 7 +- apps/dav/tests/unit/CardDAV/ConverterTest.php | 4 +- apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php | 2 +- apps/dav/tests/unit/CardDAV/SyncServiceTest.php | 21 +++--- apps/dav/tests/unit/Comments/CommentsNodeTest.php | 35 ++++++---- .../dav/tests/unit/Comments/CommentsPluginTest.php | 80 ++++++++++++---------- .../tests/unit/Comments/EntityCollectionTest.php | 29 +++++--- .../unit/Comments/EntityTypeCollectionTest.php | 16 +++-- .../dav/tests/unit/Comments/RootCollectionTest.php | 15 ++-- apps/dav/tests/unit/Connector/PublicAuthTest.php | 6 +- apps/dav/tests/unit/Connector/Sabre/AuthTest.php | 41 +++++------ .../Sabre/BlockLegacyClientPluginTest.php | 2 +- .../Sabre/CommentsPropertiesPluginTest.php | 14 ++-- .../Sabre/CustomPropertiesBackendTest.php | 10 ++- .../Connector/Sabre/DummyGetResponsePluginTest.php | 5 +- .../unit/Connector/Sabre/FakeLockerPluginTest.php | 10 +-- apps/dav/tests/unit/Connector/Sabre/FileTest.php | 34 ++++----- .../tests/unit/Connector/Sabre/FilesPluginTest.php | 24 ++++--- .../unit/Connector/Sabre/FilesReportPluginTest.php | 54 ++++++++------- .../unit/Connector/Sabre/MaintenancePluginTest.php | 2 +- apps/dav/tests/unit/Connector/Sabre/NodeTest.php | 8 ++- .../tests/unit/Connector/Sabre/ObjectTreeTest.php | 12 ++-- .../Sabre/RequestTest/PartFileInRootUploadTest.php | 4 +- .../Sabre/RequestTest/RequestTestCase.php | 3 +- .../unit/Connector/Sabre/SharesPluginTest.php | 32 +++++---- .../tests/unit/Connector/Sabre/TagsPluginTest.php | 14 ++-- apps/dav/tests/unit/DAV/Sharing/PluginTest.php | 2 +- .../unit/SystemTag/SystemTagMappingNodeTest.php | 3 +- .../dav/tests/unit/SystemTag/SystemTagNodeTest.php | 3 +- .../tests/unit/SystemTag/SystemTagPluginTest.php | 35 +++++----- .../SystemTag/SystemTagsByIdCollectionTest.php | 9 ++- .../SystemTagsObjectMappingCollectionTest.php | 3 +- .../SystemTagsObjectTypeCollectionTest.php | 13 ++-- 40 files changed, 338 insertions(+), 248 deletions(-) (limited to 'apps/dav') diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php index 3f3b744e5ab..eef69aadf40 100644 --- a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php +++ b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php @@ -66,7 +66,7 @@ abstract class AbstractCalDavBackend extends TestCase { $this->userManager = $this->createMock(IUserManager::class); $this->groupManager = $this->createMock(IGroupManager::class); $this->dispatcher = $this->createMock(EventDispatcherInterface::class); - $this->principal = $this->getMockBuilder('OCA\DAV\Connector\Sabre\Principal') + $this->principal = $this->getMockBuilder(Principal::class) ->disableOriginalConstructor() ->setMethods(['getPrincipalByPath', 'getGroupMembership']) ->getMock(); diff --git a/apps/dav/tests/unit/CalDAV/CalendarTest.php b/apps/dav/tests/unit/CalDAV/CalendarTest.php index d9ea25b268c..9ad773dd747 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarTest.php @@ -38,7 +38,7 @@ class CalendarTest extends TestCase { public function setUp() { parent::setUp(); - $this->l10n = $this->getMockBuilder('\OCP\IL10N') + $this->l10n = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor()->getMock(); $this->l10n ->expects($this->any()) diff --git a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php index ec767f3dbd8..29ab503e082 100644 --- a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php +++ b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php @@ -65,7 +65,7 @@ class PublicCalendarRootTest extends TestCase { $this->publicCalendarRoot = new PublicCalendarRoot($this->backend); - $this->l10n = $this->getMockBuilder('\OCP\IL10N') + $this->l10n = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor()->getMock(); } diff --git a/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php b/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php index 69de507dac5..b60c567e9f1 100644 --- a/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php +++ b/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php @@ -29,14 +29,14 @@ class PluginTest extends TestCase { public function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig')-> + $this->config = $this->getMockBuilder(IConfig::class)-> disableOriginalConstructor()-> getMock(); $this->config->expects($this->any())->method('getSystemValue') ->with($this->equalTo('secret')) ->willReturn('mysecret'); - $this->urlGenerator = $this->getMockBuilder('OCP\IURLGenerator')-> + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)-> disableOriginalConstructor()-> getMock(); @@ -46,7 +46,7 @@ class PluginTest extends TestCase { $root = new SimpleCollection('calendars'); $this->server = new Server($root); /** @var SimpleCollection $node */ - $this->book = $this->getMockBuilder('OCA\DAV\CalDAV\Calendar')-> + $this->book = $this->getMockBuilder(Calendar::class)-> disableOriginalConstructor()-> getMock(); $this->book->method('getName')->willReturn('cal1'); diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php index 56eb00406da..894617781b5 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php @@ -38,11 +38,11 @@ class IMipPluginTest extends TestCase { public function testDelivery() { $mailMessage = new \OC\Mail\Message(new \Swift_Message()); /** @var Mailer | \PHPUnit_Framework_MockObject_MockObject $mailer */ - $mailer = $this->getMockBuilder('OC\Mail\Mailer')->disableOriginalConstructor()->getMock(); + $mailer = $this->getMockBuilder(Mailer::class)->disableOriginalConstructor()->getMock(); $mailer->method('createMessage')->willReturn($mailMessage); $mailer->expects($this->once())->method('send'); /** @var ILogger | \PHPUnit_Framework_MockObject_MockObject $logger */ - $logger = $this->getMockBuilder('OC\Log')->disableOriginalConstructor()->getMock(); + $logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock(); $timeFactory = $this->getMockBuilder(ITimeFactory::class)->disableOriginalConstructor()->getMock(); $timeFactory->method('getTime')->willReturn(1); @@ -70,11 +70,11 @@ class IMipPluginTest extends TestCase { public function testFailedDelivery() { $mailMessage = new \OC\Mail\Message(new \Swift_Message()); /** @var Mailer | \PHPUnit_Framework_MockObject_MockObject $mailer */ - $mailer = $this->getMockBuilder('OC\Mail\Mailer')->disableOriginalConstructor()->getMock(); + $mailer = $this->getMockBuilder(Mailer::class)->disableOriginalConstructor()->getMock(); $mailer->method('createMessage')->willReturn($mailMessage); $mailer->method('send')->willThrowException(new \Exception()); /** @var ILogger | \PHPUnit_Framework_MockObject_MockObject $logger */ - $logger = $this->getMockBuilder('OC\Log')->disableOriginalConstructor()->getMock(); + $logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock(); $timeFactory = $this->getMockBuilder(ITimeFactory::class)->disableOriginalConstructor()->getMock(); $timeFactory->method('getTime')->willReturn(1); @@ -105,7 +105,7 @@ class IMipPluginTest extends TestCase { public function testNoMessageSendForPastEvents($veventParams, $expectsMail) { $mailMessage = new \OC\Mail\Message(new \Swift_Message()); /** @var Mailer | \PHPUnit_Framework_MockObject_MockObject $mailer */ - $mailer = $this->getMockBuilder('OC\Mail\Mailer')->disableOriginalConstructor()->getMock(); + $mailer = $this->getMockBuilder(Mailer::class)->disableOriginalConstructor()->getMock(); $mailer->method('createMessage')->willReturn($mailMessage); if ($expectsMail) { $mailer->expects($this->once())->method('send'); @@ -113,7 +113,7 @@ class IMipPluginTest extends TestCase { $mailer->expects($this->never())->method('send'); } /** @var ILogger | \PHPUnit_Framework_MockObject_MockObject $logger */ - $logger = $this->getMockBuilder('OC\Log')->disableOriginalConstructor()->getMock(); + $logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock(); $timeFactory = $this->getMockBuilder(ITimeFactory::class)->disableOriginalConstructor()->getMock(); $timeFactory->method('getTime')->willReturn(1496912528); diff --git a/apps/dav/tests/unit/CardDAV/AddressBookTest.php b/apps/dav/tests/unit/CardDAV/AddressBookTest.php index 132fa4796db..0e3d7c6f9b1 100644 --- a/apps/dav/tests/unit/CardDAV/AddressBookTest.php +++ b/apps/dav/tests/unit/CardDAV/AddressBookTest.php @@ -33,7 +33,7 @@ class AddressBookTest extends TestCase { public function testDelete() { /** @var \PHPUnit_Framework_MockObject_MockObject | CardDavBackend $backend */ - $backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')->disableOriginalConstructor()->getMock(); + $backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock(); $backend->expects($this->once())->method('updateShares'); $backend->expects($this->any())->method('getShares')->willReturn([ ['href' => 'principal:user2'] @@ -55,7 +55,7 @@ class AddressBookTest extends TestCase { */ public function testDeleteFromGroup() { /** @var \PHPUnit_Framework_MockObject_MockObject | CardDavBackend $backend */ - $backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')->disableOriginalConstructor()->getMock(); + $backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock(); $backend->expects($this->never())->method('updateShares'); $backend->expects($this->any())->method('getShares')->willReturn([ ['href' => 'principal:group2'] @@ -77,7 +77,7 @@ class AddressBookTest extends TestCase { */ public function testPropPatch() { /** @var \PHPUnit_Framework_MockObject_MockObject | CardDavBackend $backend */ - $backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')->disableOriginalConstructor()->getMock(); + $backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock(); $calendarInfo = [ '{http://owncloud.org/ns}owner-principal' => 'user1', '{DAV:}displayname' => 'Test address book', @@ -95,7 +95,7 @@ class AddressBookTest extends TestCase { */ public function testAcl($expectsWrite, $readOnlyValue, $hasOwnerSet) { /** @var \PHPUnit_Framework_MockObject_MockObject | CardDavBackend $backend */ - $backend = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')->disableOriginalConstructor()->getMock(); + $backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock(); $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1); $calendarInfo = [ '{DAV:}displayname' => 'Test address book', diff --git a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php index 992445392d5..a8c0ce9d9c7 100644 --- a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php +++ b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php @@ -85,7 +85,7 @@ class CardDavBackendTest extends TestCase { $this->userManager = $this->createMock(IUserManager::class); $this->groupManager = $this->createMock(IGroupManager::class); - $this->principal = $this->getMockBuilder('OCA\DAV\Connector\Sabre\Principal') + $this->principal = $this->getMockBuilder(Principal::class) ->disableOriginalConstructor() ->setMethods(['getPrincipalByPath', 'getGroupMembership']) ->getMock(); diff --git a/apps/dav/tests/unit/CardDAV/ContactsManagerTest.php b/apps/dav/tests/unit/CardDAV/ContactsManagerTest.php index a6f0384cc38..7a773ac999c 100644 --- a/apps/dav/tests/unit/CardDAV/ContactsManagerTest.php +++ b/apps/dav/tests/unit/CardDAV/ContactsManagerTest.php @@ -28,16 +28,17 @@ use OCA\DAV\CardDAV\CardDavBackend; use OCA\DAV\CardDAV\ContactsManager; use OCP\Contacts\IManager; use OCP\IL10N; +use OCP\IURLGenerator; use Test\TestCase; class ContactsManagerTest extends TestCase { public function test() { /** @var IManager | \PHPUnit_Framework_MockObject_MockObject $cm */ - $cm = $this->getMockBuilder('OCP\Contacts\IManager')->disableOriginalConstructor()->getMock(); + $cm = $this->getMockBuilder(IManager::class)->disableOriginalConstructor()->getMock(); $cm->expects($this->exactly(2))->method('registerAddressBook'); - $urlGenerator = $this->getMockBuilder('OCP\IUrlGenerator')->disableOriginalConstructor()->getMock(); + $urlGenerator = $this->getMockBuilder(IURLGenerator::class)->disableOriginalConstructor()->getMock(); /** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $backEnd */ - $backEnd = $this->getMockBuilder('OCA\DAV\CardDAV\CardDavBackend')->disableOriginalConstructor()->getMock(); + $backEnd = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock(); $backEnd->method('getAddressBooksForUser')->willReturn([ ['{DAV:}displayname' => 'Test address book', 'uri' => 'default'], ]); diff --git a/apps/dav/tests/unit/CardDAV/ConverterTest.php b/apps/dav/tests/unit/CardDAV/ConverterTest.php index 39853cfd5c8..e4b78485114 100644 --- a/apps/dav/tests/unit/CardDAV/ConverterTest.php +++ b/apps/dav/tests/unit/CardDAV/ConverterTest.php @@ -49,12 +49,12 @@ class ConverterTest extends TestCase { $this->databaseConnection = $this->getMockBuilder('OCP\IDBConnection')->getMock(); $this->eventDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') ->disableOriginalConstructor()->getMock(); - $this->accountManager = $this->getMockBuilder('OC\Accounts\AccountManager') + $this->accountManager = $this->getMockBuilder(AccountManager::class) ->disableOriginalConstructor()->getMock(); } public function getAccountManager(IUser $user) { - $accountManager = $this->getMockBuilder('OC\Accounts\AccountManager') + $accountManager = $this->getMockBuilder(AccountManager::class) ->disableOriginalConstructor()->getMock(); $accountManager->expects($this->any())->method('getUser')->willReturn( [ diff --git a/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php b/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php index 00049075865..8536deb8e6e 100644 --- a/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php +++ b/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php @@ -51,7 +51,7 @@ class PluginTest extends TestCase { $authBackend->method('isDavAuthenticated')->willReturn(true); /** @var IRequest $request */ - $request = $this->getMockBuilder('OCP\IRequest')->disableOriginalConstructor()->getMock(); + $request = $this->getMockBuilder(IRequest::class)->disableOriginalConstructor()->getMock(); $this->plugin = new Plugin($authBackend, $request); $root = new SimpleCollection('root'); diff --git a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php index 32f8a2424b1..debc9238067 100644 --- a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php +++ b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php @@ -28,6 +28,7 @@ namespace OCA\DAV\Tests\unit\CardDAV; use OC\Accounts\AccountManager; use OCA\DAV\CardDAV\CardDavBackend; use OCA\DAV\CardDAV\SyncService; +use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; use Test\TestCase; @@ -75,9 +76,9 @@ class SyncServiceTest extends TestCase { $backend->expects($this->at(1))->method('getAddressBooksByUri')->willReturn([]); /** @var IUserManager $userManager */ - $userManager = $this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock(); - $logger = $this->getMockBuilder('OCP\ILogger')->disableOriginalConstructor()->getMock(); - $accountManager = $this->getMockBuilder('OC\Accounts\AccountManager')->disableOriginalConstructor()->getMock(); + $userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock(); + $logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock(); + $accountManager = $this->getMockBuilder(AccountManager::class)->disableOriginalConstructor()->getMock(); $ss = new SyncService($backend, $userManager, $logger, $accountManager); $book = $ss->ensureSystemAddressBookExists('principals/users/adam', 'contacts', []); } @@ -85,7 +86,7 @@ class SyncServiceTest extends TestCase { public function testUpdateAndDeleteUser() { /** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $backend */ $backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock(); - $logger = $this->getMockBuilder('OCP\ILogger')->disableOriginalConstructor()->getMock(); + $logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock(); $backend->expects($this->once())->method('createCard'); $backend->expects($this->once())->method('updateCard'); @@ -96,15 +97,15 @@ class SyncServiceTest extends TestCase { ]); /** @var IUserManager | \PHPUnit_Framework_MockObject_MockObject $userManager */ - $userManager = $this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock(); + $userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock(); /** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */ - $user = $this->getMockBuilder('OCP\IUser')->disableOriginalConstructor()->getMock(); + $user = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $user->method('getBackendClassName')->willReturn('unittest'); $user->method('getUID')->willReturn('test-user'); $user->method('getCloudId')->willReturn('cloudId'); $user->method('getDisplayName')->willReturn('test-user'); - $accountManager = $this->getMockBuilder('OC\Accounts\AccountManager')->disableOriginalConstructor()->getMock(); + $accountManager = $this->getMockBuilder(AccountManager::class)->disableOriginalConstructor()->getMock(); $accountManager->expects($this->any())->method('getUser') ->willReturn([ AccountManager::PROPERTY_DISPLAYNAME => @@ -174,9 +175,9 @@ class SyncServiceTest extends TestCase { * @return SyncService|\PHPUnit_Framework_MockObject_MockObject */ private function getSyncServiceMock($backend, $response) { - $userManager = $this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock(); - $logger = $this->getMockBuilder('OCP\ILogger')->disableOriginalConstructor()->getMock(); - $accountManager = $this->getMockBuilder('OC\Accounts\AccountManager')->disableOriginalConstructor()->getMock(); + $userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock(); + $logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock(); + $accountManager = $this->getMockBuilder(AccountManager::class)->disableOriginalConstructor()->getMock(); /** @var SyncService | \PHPUnit_Framework_MockObject_MockObject $ss */ $ss = $this->getMockBuilder(SyncService::class) ->setMethods(['ensureSystemAddressBookExists', 'requestSyncReport', 'download', 'getCertPath']) diff --git a/apps/dav/tests/unit/Comments/CommentsNodeTest.php b/apps/dav/tests/unit/Comments/CommentsNodeTest.php index 226aa57598c..57a15a6dc76 100644 --- a/apps/dav/tests/unit/Comments/CommentsNodeTest.php +++ b/apps/dav/tests/unit/Comments/CommentsNodeTest.php @@ -26,8 +26,13 @@ namespace OCA\DAV\Tests\unit\Comments; use OCA\DAV\Comments\CommentNode; +use OCP\Comments\IComment; use OCP\Comments\ICommentsManager; use OCP\Comments\MessageTooLongException; +use OCP\ILogger; +use OCP\IUser; +use OCP\IUserManager; +use OCP\IUserSession; class CommentsNodeTest extends \Test\TestCase { @@ -43,19 +48,19 @@ class CommentsNodeTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager') + $this->commentsManager = $this->getMockBuilder(ICommentsManager::class) ->disableOriginalConstructor() ->getMock(); - $this->comment = $this->getMockBuilder('\OCP\Comments\IComment') + $this->comment = $this->getMockBuilder(IComment::class) ->disableOriginalConstructor() ->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager') + $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->getMockBuilder('\OCP\ILogger') + $this->logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); @@ -69,7 +74,7 @@ class CommentsNodeTest extends \Test\TestCase { } public function testDelete() { - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -104,7 +109,7 @@ class CommentsNodeTest extends \Test\TestCase { * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testDeleteForbidden() { - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -156,7 +161,7 @@ class CommentsNodeTest extends \Test\TestCase { public function testUpdateComment() { $msg = 'Hello Earth'; - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -188,13 +193,13 @@ class CommentsNodeTest extends \Test\TestCase { } /** - * @expectedException Exception + * @expectedException \Exception * @expectedExceptionMessage buh! */ public function testUpdateCommentLogException() { $msg = null; - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -233,7 +238,7 @@ class CommentsNodeTest extends \Test\TestCase { * @expectedExceptionMessage Message exceeds allowed character limit of */ public function testUpdateCommentMessageTooLongException() { - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -273,7 +278,7 @@ class CommentsNodeTest extends \Test\TestCase { public function testUpdateForbiddenByUser() { $msg = 'HaXX0r'; - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -308,7 +313,7 @@ class CommentsNodeTest extends \Test\TestCase { public function testUpdateForbiddenByType() { $msg = 'HaXX0r'; - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); @@ -461,7 +466,7 @@ class CommentsNodeTest extends \Test\TestCase { ->method('getObjectId') ->will($this->returnValue($expected[$ns . 'objectId'])); - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->once()) @@ -515,7 +520,7 @@ class CommentsNodeTest extends \Test\TestCase { $this->userSession->expects($this->once()) ->method('getUser') ->will($this->returnValue( - $this->getMockBuilder('\OCP\IUser') + $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock() )); diff --git a/apps/dav/tests/unit/Comments/CommentsPluginTest.php b/apps/dav/tests/unit/Comments/CommentsPluginTest.php index 265afad96c3..e0f7a09a502 100644 --- a/apps/dav/tests/unit/Comments/CommentsPluginTest.php +++ b/apps/dav/tests/unit/Comments/CommentsPluginTest.php @@ -27,19 +27,27 @@ namespace OCA\DAV\Tests\unit\Comments; use OC\Comments\Comment; use OCA\DAV\Comments\CommentsPlugin as CommentsPluginImplementation; +use OCA\DAV\Comments\EntityCollection; use OCP\Comments\IComment; +use OCP\Comments\ICommentsManager; +use OCP\IUser; +use OCP\IUserSession; +use Sabre\DAV\INode; +use Sabre\DAV\Tree; +use Sabre\HTTP\RequestInterface; +use Sabre\HTTP\ResponseInterface; class CommentsPluginTest extends \Test\TestCase { /** @var \Sabre\DAV\Server */ private $server; - /** @var \Sabre\DAV\Tree */ + /** @var Tree */ private $tree; - /** @var \OCP\Comments\ICommentsManager */ + /** @var ICommentsManager */ private $commentsManager; - /** @var \OCP\IUserSession */ + /** @var IUserSession */ private $userSession; /** @var CommentsPluginImplementation */ @@ -47,7 +55,7 @@ class CommentsPluginTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->tree = $this->getMockBuilder('\Sabre\DAV\Tree') + $this->tree = $this->getMockBuilder(Tree::class) ->disableOriginalConstructor() ->getMock(); @@ -56,10 +64,10 @@ class CommentsPluginTest extends \Test\TestCase { ->setMethods(['getRequestUri']) ->getMock(); - $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager') + $this->commentsManager = $this->getMockBuilder(ICommentsManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); @@ -85,14 +93,14 @@ class CommentsPluginTest extends \Test\TestCase { $requestData = json_encode($commentData); - $user = $this->getMockBuilder('OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->once()) ->method('getUID') ->will($this->returnValue('alice')); - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -124,11 +132,11 @@ class CommentsPluginTest extends \Test\TestCase { ->with('/' . $path) ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -181,13 +189,13 @@ class CommentsPluginTest extends \Test\TestCase { $path = 'comments/files/666'; - $user = $this->getMockBuilder('OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->never()) ->method('getUID'); - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->never()) @@ -210,11 +218,11 @@ class CommentsPluginTest extends \Test\TestCase { ->with('/' . $path) ->will($this->throwException(new \Sabre\DAV\Exception\NotFound())); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -265,13 +273,13 @@ class CommentsPluginTest extends \Test\TestCase { $requestData = json_encode($commentData); - $user = $this->getMockBuilder('OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->never()) ->method('getUID'); - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -296,11 +304,11 @@ class CommentsPluginTest extends \Test\TestCase { ->with('/' . $path) ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -353,13 +361,13 @@ class CommentsPluginTest extends \Test\TestCase { $requestData = json_encode($commentData); - $user = $this->getMockBuilder('OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->never()) ->method('getUID'); - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -384,11 +392,11 @@ class CommentsPluginTest extends \Test\TestCase { ->with('/' . $path) ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -443,14 +451,14 @@ class CommentsPluginTest extends \Test\TestCase { $requestData = json_encode($commentData); - $user = $this->getMockBuilder('OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->once()) ->method('getUID') ->will($this->returnValue('alice')); - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -478,11 +486,11 @@ class CommentsPluginTest extends \Test\TestCase { ->with('/' . $path) ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -537,14 +545,14 @@ class CommentsPluginTest extends \Test\TestCase { $requestData = json_encode($commentData); - $user = $this->getMockBuilder('OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->once()) ->method('getUID') ->will($this->returnValue('alice')); - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -575,11 +583,11 @@ class CommentsPluginTest extends \Test\TestCase { ->with('/' . $path) ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -617,7 +625,7 @@ class CommentsPluginTest extends \Test\TestCase { ->method('getNodeForPath') ->with('/' . $path) ->will($this->returnValue( - $this->getMockBuilder('\Sabre\DAV\INode') + $this->getMockBuilder(INode::class) ->disableOriginalConstructor() ->getMock() )); @@ -640,7 +648,7 @@ class CommentsPluginTest extends \Test\TestCase { ->method('getNodeForPath') ->with('/' . $path) ->will($this->returnValue( - $this->getMockBuilder('\Sabre\DAV\INode') + $this->getMockBuilder(INode::class) ->disableOriginalConstructor() ->getMock() )); @@ -671,7 +679,7 @@ class CommentsPluginTest extends \Test\TestCase { ] ]; - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -679,7 +687,7 @@ class CommentsPluginTest extends \Test\TestCase { ->with(5, 10, null) ->will($this->returnValue([])); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -726,7 +734,7 @@ class CommentsPluginTest extends \Test\TestCase { ] ]; - $node = $this->getMockBuilder('\OCA\DAV\Comments\EntityCollection') + $node = $this->getMockBuilder(EntityCollection::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -734,7 +742,7 @@ class CommentsPluginTest extends \Test\TestCase { ->with(5, 10, new \DateTime($parameters[2]['value'])) ->will($this->returnValue([])); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/Comments/EntityCollectionTest.php b/apps/dav/tests/unit/Comments/EntityCollectionTest.php index c4e343d49d4..0cac135843b 100644 --- a/apps/dav/tests/unit/Comments/EntityCollectionTest.php +++ b/apps/dav/tests/unit/Comments/EntityCollectionTest.php @@ -24,32 +24,39 @@ namespace OCA\DAV\Tests\unit\Comments; +use OCA\DAV\Comments\EntityCollection; +use OCP\Comments\IComment; +use OCP\Comments\ICommentsManager; +use OCP\ILogger; +use OCP\IUserManager; +use OCP\IUserSession; + class EntityCollectionTest extends \Test\TestCase { /** @var \OCP\Comments\ICommentsManager|\PHPUnit_Framework_MockObject_MockObject */ protected $commentsManager; - /** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject */ + /** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */ protected $userManager; - /** @var \OCP\ILogger|\PHPUnit_Framework_MockObject_MockObject */ + /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */ protected $logger; - /** @var \OCA\DAV\Comments\EntityCollection */ + /** @var EntityCollection */ protected $collection; - /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */ + /** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */ protected $userSession; public function setUp() { parent::setUp(); - $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager') + $this->commentsManager = $this->getMockBuilder(ICommentsManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager') + $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->getMockBuilder('\OCP\ILogger') + $this->logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); @@ -72,7 +79,7 @@ class EntityCollectionTest extends \Test\TestCase { ->method('get') ->with('55') ->will($this->returnValue( - $this->getMockBuilder('\OCP\Comments\IComment') + $this->getMockBuilder(IComment::class) ->disableOriginalConstructor() ->getMock() )); @@ -98,7 +105,7 @@ class EntityCollectionTest extends \Test\TestCase { ->method('getForObject') ->with('files', '19') ->will($this->returnValue([ - $this->getMockBuilder('\OCP\Comments\IComment') + $this->getMockBuilder(IComment::class) ->disableOriginalConstructor() ->getMock() ])); @@ -115,7 +122,7 @@ class EntityCollectionTest extends \Test\TestCase { ->method('getForObject') ->with('files', '19', 5, 15, $dt) ->will($this->returnValue([ - $this->getMockBuilder('\OCP\Comments\IComment') + $this->getMockBuilder(IComment::class) ->disableOriginalConstructor() ->getMock() ])); diff --git a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php index 17c4f70fa7f..c63d95ad533 100644 --- a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php +++ b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php @@ -25,10 +25,14 @@ namespace OCA\DAV\Tests\unit\Comments; use OCA\DAV\Comments\EntityCollection as EntityCollectionImplemantation; +use OCP\Comments\ICommentsManager; +use OCP\ILogger; +use OCP\IUserManager; +use OCP\IUserSession; class EntityTypeCollectionTest extends \Test\TestCase { - /** @var \OCP\Comments\ICommentsManager|\PHPUnit_Framework_MockObject_MockObject */ + /** @var ICommentsManager|\PHPUnit_Framework_MockObject_MockObject */ protected $commentsManager; /** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject */ protected $userManager; @@ -36,7 +40,7 @@ class EntityTypeCollectionTest extends \Test\TestCase { protected $logger; /** @var \OCA\DAV\Comments\EntityTypeCollection */ protected $collection; - /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */ + /** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */ protected $userSession; protected $childMap = []; @@ -44,16 +48,16 @@ class EntityTypeCollectionTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager') + $this->commentsManager = $this->getMockBuilder(ICommentsManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager') + $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->getMockBuilder('\OCP\ILogger') + $this->logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/Comments/RootCollectionTest.php b/apps/dav/tests/unit/Comments/RootCollectionTest.php index 95afc42a912..05fb94239b4 100644 --- a/apps/dav/tests/unit/Comments/RootCollectionTest.php +++ b/apps/dav/tests/unit/Comments/RootCollectionTest.php @@ -26,6 +26,11 @@ namespace OCA\DAV\Tests\unit\Comments; use OCA\DAV\Comments\EntityTypeCollection as EntityTypeCollectionImplementation; use OCP\Comments\CommentsEntityEvent; +use OCP\Comments\ICommentsManager; +use OCP\ILogger; +use OCP\IUser; +use OCP\IUserManager; +use OCP\IUserSession; use Symfony\Component\EventDispatcher\EventDispatcher; class RootCollectionTest extends \Test\TestCase { @@ -48,21 +53,21 @@ class RootCollectionTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->user = $this->getMockBuilder('\OCP\IUser') + $this->user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); - $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager') + $this->commentsManager = $this->getMockBuilder(ICommentsManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager') + $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); $this->dispatcher = new EventDispatcher(); - $this->logger = $this->getMockBuilder('\OCP\ILogger') + $this->logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/Connector/PublicAuthTest.php b/apps/dav/tests/unit/Connector/PublicAuthTest.php index 41cfc0f8ceb..90401e03853 100644 --- a/apps/dav/tests/unit/Connector/PublicAuthTest.php +++ b/apps/dav/tests/unit/Connector/PublicAuthTest.php @@ -53,13 +53,13 @@ class PublicAuthTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->session = $this->getMockBuilder('\OCP\ISession') + $this->session = $this->getMockBuilder(ISession::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMockBuilder('\OCP\IRequest') + $this->request = $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor() ->getMock(); - $this->shareManager = $this->getMockBuilder('\OCP\Share\IManager') + $this->shareManager = $this->getMockBuilder(IManager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php index dfcb7939799..34998745f77 100644 --- a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php @@ -34,6 +34,7 @@ use OC\User\Session; use OCP\IRequest; use OCP\ISession; use OCP\IUser; +use Sabre\DAV\Server; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; use Test\TestCase; @@ -60,16 +61,16 @@ class AuthTest extends TestCase { public function setUp() { parent::setUp(); - $this->session = $this->getMockBuilder('\OCP\ISession') + $this->session = $this->getMockBuilder(ISession::class) ->disableOriginalConstructor()->getMock(); - $this->userSession = $this->getMockBuilder('\OC\User\Session') + $this->userSession = $this->getMockBuilder(Session::class) ->disableOriginalConstructor()->getMock(); - $this->request = $this->getMockBuilder('\OCP\IRequest') + $this->request = $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor()->getMock(); - $this->twoFactorManager = $this->getMockBuilder('\OC\Authentication\TwoFactorAuth\Manager') + $this->twoFactorManager = $this->getMockBuilder(Manager::class) ->disableOriginalConstructor() ->getMock(); - $this->throttler = $this->getMockBuilder('\OC\Security\Bruteforce\Throttler') + $this->throttler = $this->getMockBuilder(Throttler::class) ->disableOriginalConstructor() ->getMock(); $this->auth = new \OCA\DAV\Connector\Sabre\Auth( @@ -112,7 +113,7 @@ class AuthTest extends TestCase { } public function testValidateUserPassOfAlreadyDAVAuthenticatedUser() { - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->exactly(2)) @@ -139,7 +140,7 @@ class AuthTest extends TestCase { } public function testValidateUserPassOfInvalidDAVAuthenticatedUser() { - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->once()) @@ -166,7 +167,7 @@ class AuthTest extends TestCase { } public function testValidateUserPassOfInvalidDAVAuthenticatedUserWithValidPassword() { - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->exactly(3)) @@ -258,7 +259,7 @@ class AuthTest extends TestCase { ->method('get') ->with('AUTHENTICATED_TO_DAV_BACKEND') ->will($this->returnValue(null)); - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->any()) @@ -310,7 +311,7 @@ class AuthTest extends TestCase { ->method('get') ->with('AUTHENTICATED_TO_DAV_BACKEND') ->will($this->returnValue('LoggedInUser')); - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->any()) @@ -360,7 +361,7 @@ class AuthTest extends TestCase { ->method('get') ->with('AUTHENTICATED_TO_DAV_BACKEND') ->will($this->returnValue('LoggedInUser')); - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->any()) @@ -414,7 +415,7 @@ class AuthTest extends TestCase { ->method('get') ->with('AUTHENTICATED_TO_DAV_BACKEND') ->will($this->returnValue('AnotherUser')); - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->any()) @@ -460,7 +461,7 @@ class AuthTest extends TestCase { ->method('get') ->with('AUTHENTICATED_TO_DAV_BACKEND') ->will($this->returnValue(null)); - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->any()) @@ -494,7 +495,7 @@ class AuthTest extends TestCase { ->method('get') ->with('AUTHENTICATED_TO_DAV_BACKEND') ->will($this->returnValue(null)); - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->any()) @@ -529,7 +530,7 @@ class AuthTest extends TestCase { ->method('get') ->with('AUTHENTICATED_TO_DAV_BACKEND') ->will($this->returnValue(null)); - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->any()) @@ -549,7 +550,7 @@ class AuthTest extends TestCase { } public function testAuthenticateNoBasicAuthenticateHeadersProvided() { - $server = $this->getMockBuilder('\Sabre\DAV\Server') + $server = $this->getMockBuilder(Server::class) ->disableOriginalConstructor() ->getMock(); $server->httpRequest = $this->getMockBuilder(RequestInterface::class) @@ -597,7 +598,7 @@ class AuthTest extends TestCase { ->disableOriginalConstructor() ->getMock(); /** @var IUser */ - $user = $this->getMockBuilder('OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->method('getUID')->willReturn('MyTestUser'); @@ -630,7 +631,7 @@ class AuthTest extends TestCase { } public function testAuthenticateValidCredentials() { - $server = $this->getMockBuilder('\Sabre\DAV\Server') + $server = $this->getMockBuilder(Server::class) ->disableOriginalConstructor() ->getMock(); $server->httpRequest = $this->getMockBuilder(RequestInterface::class) @@ -654,7 +655,7 @@ class AuthTest extends TestCase { ->method('logClientIn') ->with('username', 'password') ->will($this->returnValue(true)); - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->exactly(3)) @@ -669,7 +670,7 @@ class AuthTest extends TestCase { } public function testAuthenticateInvalidCredentials() { - $server = $this->getMockBuilder('\Sabre\DAV\Server') + $server = $this->getMockBuilder(Server::class) ->disableOriginalConstructor() ->getMock(); $server->httpRequest = $this->getMockBuilder(RequestInterface::class) diff --git a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php index eb1689089a4..e80d12979ed 100644 --- a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php @@ -44,7 +44,7 @@ class BlockLegacyClientPluginTest extends TestCase { public function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig') + $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); $this->blockLegacyClientVersionPlugin = new BlockLegacyClientPlugin($this->config); diff --git a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php index 13e10476a41..c02bd5046d8 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php @@ -25,6 +25,10 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre; use \OCA\DAV\Connector\Sabre\CommentPropertiesPlugin as CommentPropertiesPluginImplementation; +use OCA\DAV\Connector\Sabre\File; +use OCP\Comments\ICommentsManager; +use OCP\IUser; +use OCP\IUserSession; class CommentsPropertiesPluginTest extends \Test\TestCase { @@ -37,10 +41,10 @@ class CommentsPropertiesPluginTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->commentsManager = $this->getMockBuilder('\OCP\Comments\ICommentsManager') + $this->commentsManager = $this->getMockBuilder(ICommentsManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); @@ -103,7 +107,7 @@ class CommentsPropertiesPluginTest extends \Test\TestCase { * @param $expectedHref */ public function testGetCommentsLink($baseUri, $fid, $expectedHref) { - $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\File') + $node = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any()) @@ -121,7 +125,7 @@ class CommentsPropertiesPluginTest extends \Test\TestCase { public function userProvider() { return [ [ - $this->getMockBuilder('\OCP\IUser') + $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock() ], @@ -134,7 +138,7 @@ class CommentsPropertiesPluginTest extends \Test\TestCase { * @param $user */ public function testGetUnreadCount($user) { - $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\File') + $node = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any()) diff --git a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php index f0f4caa07a0..4f51c25741b 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php @@ -31,6 +31,10 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre; * See the COPYING-README file. */ +use OCP\IUser; +use Sabre\DAV\File; +use Sabre\DAV\Tree; + /** * Class CustomPropertiesBackend * @@ -63,13 +67,13 @@ class CustomPropertiesBackendTest extends \Test\TestCase { public function setUp() { parent::setUp(); $this->server = new \Sabre\DAV\Server(); - $this->tree = $this->getMockBuilder('\Sabre\DAV\Tree') + $this->tree = $this->getMockBuilder(Tree::class) ->disableOriginalConstructor() ->getMock(); $userId = $this->getUniqueID('testcustompropertiesuser'); - $this->user = $this->getMockBuilder('\OCP\IUser') + $this->user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $this->user->expects($this->any()) @@ -209,7 +213,7 @@ class CustomPropertiesBackendTest extends \Test\TestCase { public function testGetPropertiesForDirectory() { $rootNode = $this->createTestNode('\OCA\DAV\Connector\Sabre\Directory'); - $nodeSub = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\File') + $nodeSub = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); $nodeSub->expects($this->any()) diff --git a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php index 1c2e249e8c0..f16c374a0e1 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php @@ -26,6 +26,7 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre; use OCA\DAV\Connector\Sabre\DummyGetResponsePlugin; +use Sabre\DAV\Server; use Test\TestCase; /** @@ -44,8 +45,8 @@ class DummyGetResponsePluginTest extends TestCase { } public function testInitialize() { - /** @var \Sabre\DAV\Server $server */ - $server = $this->getMockBuilder('\Sabre\DAV\Server') + /** @var Server $server */ + $server = $this->getMockBuilder(Server::class) ->disableOriginalConstructor() ->getMock(); $server diff --git a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php index abf6e5cf182..1fd2b05c23d 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php @@ -25,6 +25,8 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre; use OCA\DAV\Connector\Sabre\FakeLockerPlugin; +use Sabre\DAV\INode; +use Sabre\DAV\Server; use Sabre\HTTP\Response; use Test\TestCase; @@ -43,8 +45,8 @@ class FakeLockerPluginTest extends TestCase { } public function testInitialize() { - /** @var \Sabre\DAV\Server $server */ - $server = $this->getMockBuilder('\Sabre\DAV\Server') + /** @var Server $server */ + $server = $this->getMockBuilder(Server::class) ->disableOriginalConstructor() ->getMock(); $server @@ -86,7 +88,7 @@ class FakeLockerPluginTest extends TestCase { $propFind = $this->getMockBuilder('\Sabre\DAV\PropFind') ->disableOriginalConstructor() ->getMock(); - $node = $this->getMockBuilder('\Sabre\DAV\INode') + $node = $this->getMockBuilder(INode::class) ->disableOriginalConstructor() ->getMock(); @@ -155,7 +157,7 @@ class FakeLockerPluginTest extends TestCase { ->disableOriginalConstructor() ->getMock(); $response = new Response(); - $server = $this->getMockBuilder('\Sabre\DAV\Server') + $server = $this->getMockBuilder(Server::class) ->getMock(); $this->fakeLockerPlugin->initialize($server); diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php index e2666d0de27..3a2075941ae 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php @@ -27,7 +27,9 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre; use OC\Files\Storage\Local; +use OC\Files\View; use OCP\Files\ForbiddenException; +use OCP\Files\Storage; use Test\HookHelper; use OC\Files\Filesystem; use OCP\Lock\ILockingProvider; @@ -70,7 +72,7 @@ class FileTest extends \Test\TestCase { } private function getMockStorage() { - $storage = $this->getMockBuilder('\OCP\Files\Storage') + $storage = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor() ->getMock(); $storage->expects($this->any()) @@ -151,12 +153,12 @@ class FileTest extends \Test\TestCase { */ public function testSimplePutFails($thrownException, $expectedException, $checkPreviousClass = true) { // setup - $storage = $this->getMockBuilder('\OC\Files\Storage\Local') + $storage = $this->getMockBuilder(Local::class) ->setMethods(['fopen']) ->setConstructorArgs([['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]]) ->getMock(); \OC\Files\Filesystem::mount($storage, [], $this->user . '/'); - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->setMethods(['getRelativePath', 'resolvePath']) ->getMock(); $view->expects($this->atLeastOnce()) @@ -210,12 +212,12 @@ class FileTest extends \Test\TestCase { */ public function testChunkedPutFails($thrownException, $expectedException, $checkPreviousClass = false) { // setup - $storage = $this->getMockBuilder('\OC\Files\Storage\Local') + $storage = $this->getMockBuilder(Local::class) ->setMethods(['fopen']) ->setConstructorArgs([['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]]) ->getMock(); \OC\Files\Filesystem::mount($storage, [], $this->user . '/'); - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->setMethods(['getRelativePath', 'resolvePath']) ->getMock(); $view->expects($this->atLeastOnce()) @@ -535,7 +537,7 @@ class FileTest extends \Test\TestCase { */ public function testSimplePutFailsSizeCheck() { // setup - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->setMethods(['rename', 'getRelativePath', 'filesize']) ->getMock(); $view->expects($this->any()) @@ -653,7 +655,7 @@ class FileTest extends \Test\TestCase { */ public function testSimplePutInvalidChars() { // setup - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->setMethods(['getRelativePath']) ->getMock(); $view->expects($this->any()) @@ -690,7 +692,7 @@ class FileTest extends \Test\TestCase { */ public function testSetNameInvalidChars() { // setup - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->setMethods(['getRelativePath']) ->getMock(); @@ -709,7 +711,7 @@ class FileTest extends \Test\TestCase { */ public function testUploadAbort() { // setup - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->setMethods(['rename', 'getRelativePath', 'filesize']) ->getMock(); $view->expects($this->any()) @@ -755,7 +757,7 @@ class FileTest extends \Test\TestCase { */ public function testDeleteWhenAllowed() { // setup - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->getMock(); $view->expects($this->once()) @@ -777,7 +779,7 @@ class FileTest extends \Test\TestCase { */ public function testDeleteThrowsWhenDeletionNotAllowed() { // setup - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->getMock(); $info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, array( @@ -795,7 +797,7 @@ class FileTest extends \Test\TestCase { */ public function testDeleteThrowsWhenDeletionFailed() { // setup - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->getMock(); // but fails @@ -818,7 +820,7 @@ class FileTest extends \Test\TestCase { */ public function testDeleteThrowsWhenDeletionThrows() { // setup - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->getMock(); // but fails @@ -968,7 +970,7 @@ class FileTest extends \Test\TestCase { * @expectedException \Sabre\DAV\Exception\ServiceUnavailable */ public function testGetFopenFails() { - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->setMethods(['fopen']) ->getMock(); $view->expects($this->atLeastOnce()) @@ -988,7 +990,7 @@ class FileTest extends \Test\TestCase { * @expectedException \OCA\DAV\Connector\Sabre\Exception\Forbidden */ public function testGetFopenThrows() { - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->setMethods(['fopen']) ->getMock(); $view->expects($this->atLeastOnce()) @@ -1008,7 +1010,7 @@ class FileTest extends \Test\TestCase { * @expectedException \Sabre\DAV\Exception\NotFound */ public function testGetThrowsIfNoPermission() { - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->setMethods(['fopen']) ->getMock(); $view->expects($this->never()) diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php index 885f3c23c24..a33ece3c4b3 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php @@ -25,10 +25,16 @@ */ namespace OCA\DAV\Tests\unit\Connector\Sabre; +use OCA\DAV\Connector\Sabre\File; use OCA\DAV\Connector\Sabre\FilesPlugin; use OCP\Files\StorageNotAvailableException; +use OCP\IConfig; +use OCP\IPreview; +use OCP\IRequest; use Sabre\DAV\PropFind; use Sabre\DAV\PropPatch; +use Sabre\DAV\Server; +use Sabre\DAV\Tree; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; use Test\TestCase; @@ -87,20 +93,20 @@ class FilesPluginTest extends TestCase { public function setUp() { parent::setUp(); - $this->server = $this->getMockBuilder('\Sabre\DAV\Server') + $this->server = $this->getMockBuilder(Server::class) ->disableOriginalConstructor() ->getMock(); - $this->tree = $this->getMockBuilder('\Sabre\DAV\Tree') + $this->tree = $this->getMockBuilder(Tree::class) ->disableOriginalConstructor() ->getMock(); - $this->config = $this->createMock('\OCP\IConfig'); + $this->config = $this->createMock(IConfig::class); $this->config->expects($this->any())->method('getSystemValue') ->with($this->equalTo('data-fingerprint'), $this->equalTo('')) ->willReturn('my_fingerprint'); - $this->request = $this->getMockBuilder('\OCP\IRequest') + $this->request = $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor() ->getMock(); - $this->previewManager = $this->getMockBuilder('\OCP\IPreview') + $this->previewManager = $this->getMockBuilder(IPreview::class) ->disableOriginalConstructor() ->getMock(); @@ -245,7 +251,7 @@ class FilesPluginTest extends TestCase { $this->plugin = new FilesPlugin( $this->tree, $this->config, - $this->getMockBuilder('\OCP\IRequest') + $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor() ->getMock(), $this->previewManager, @@ -311,7 +317,7 @@ class FilesPluginTest extends TestCase { public function testGetPropertiesForRootDirectory() { /** @var \OCA\DAV\Connector\Sabre\Directory | \PHPUnit_Framework_MockObject_MockObject $node */ - $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') + $node = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any())->method('getPath')->willReturn('/'); @@ -347,7 +353,7 @@ class FilesPluginTest extends TestCase { // $this->expectException(\Sabre\DAV\Exception\NotFound::class); /** @var \OCA\DAV\Connector\Sabre\Directory|\PHPUnit_Framework_MockObject_MockObject $node */ - $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') + $node = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any())->method('getPath')->willReturn('/'); @@ -539,7 +545,7 @@ class FilesPluginTest extends TestCase { ->method('getPath') ->will($this->returnValue('test/somefile.xml')); - $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\File') + $node = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); $node diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php index 3ca131dbf6f..374557c6b67 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php @@ -24,9 +24,14 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre; +use OCA\DAV\Connector\Sabre\Directory; use OCA\DAV\Connector\Sabre\FilesReportPlugin as FilesReportPluginImplementation; +use OCP\Files\File; +use OCP\IConfig; use OCP\IPreview; +use OCP\IRequest; use OCP\ITagManager; +use OCP\IUser; use OCP\IUserSession; use OCP\SystemTag\ISystemTagObjectMapper; use OC\Files\View; @@ -35,6 +40,9 @@ use OCP\IGroupManager; use OCP\SystemTag\ISystemTagManager; use OCP\ITags; use OCP\Files\FileInfo; +use Sabre\DAV\INode; +use Sabre\DAV\Tree; +use Sabre\HTTP\ResponseInterface; class FilesReportPluginTest extends \Test\TestCase { /** @var \Sabre\DAV\Server|\PHPUnit_Framework_MockObject_MockObject */ @@ -72,11 +80,11 @@ class FilesReportPluginTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->tree = $this->getMockBuilder('\Sabre\DAV\Tree') + $this->tree = $this->getMockBuilder(Tree::class) ->disableOriginalConstructor() ->getMock(); - $this->view = $this->getMockBuilder('\OC\Files\View') + $this->view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); @@ -89,15 +97,15 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('getBaseUri') ->will($this->returnValue('http://example.com/owncloud/remote.php/dav')); - $this->groupManager = $this->getMockBuilder('\OCP\IGroupManager') + $this->groupManager = $this->getMockBuilder(IGroupManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userFolder = $this->getMockBuilder('\OCP\Files\Folder') + $this->userFolder = $this->getMockBuilder(Folder::class) ->disableOriginalConstructor() ->getMock(); - $this->previewManager = $this->getMockBuilder('\OCP\IPreview') + $this->previewManager = $this->getMockBuilder(IPreview::class) ->disableOriginalConstructor() ->getMock(); @@ -111,7 +119,7 @@ class FilesReportPluginTest extends \Test\TestCase { ->with('files') ->will($this->returnValue($this->privateTags)); - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->any()) @@ -140,7 +148,7 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('getNodeForPath') ->with('/' . $path) ->will($this->returnValue( - $this->getMockBuilder('\Sabre\DAV\INode') + $this->getMockBuilder(INode::class) ->disableOriginalConstructor() ->getMock() )); @@ -160,7 +168,7 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('getNodeForPath') ->with('/' . $path) ->will($this->returnValue( - $this->getMockBuilder('\Sabre\DAV\INode') + $this->getMockBuilder(INode::class) ->disableOriginalConstructor() ->getMock() )); @@ -206,11 +214,11 @@ class FilesReportPluginTest extends \Test\TestCase { ->with('456', 'files') ->will($this->returnValue(['111', '222', '333'])); - $reportTargetNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') + $reportTargetNode = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -230,10 +238,10 @@ class FilesReportPluginTest extends \Test\TestCase { ->with('/' . $path) ->will($this->returnValue($reportTargetNode)); - $filesNode1 = $this->getMockBuilder('\OCP\Files\Folder') + $filesNode1 = $this->getMockBuilder(Folder::class) ->disableOriginalConstructor() ->getMock(); - $filesNode2 = $this->getMockBuilder('\OCP\Files\File') + $filesNode2 = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); @@ -256,21 +264,21 @@ class FilesReportPluginTest extends \Test\TestCase { } public function testFindNodesByFileIdsRoot() { - $filesNode1 = $this->getMockBuilder('\OCP\Files\Folder') + $filesNode1 = $this->getMockBuilder(Folder::class) ->disableOriginalConstructor() ->getMock(); $filesNode1->expects($this->once()) ->method('getName') ->will($this->returnValue('first node')); - $filesNode2 = $this->getMockBuilder('\OCP\Files\File') + $filesNode2 = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); $filesNode2->expects($this->once()) ->method('getName') ->will($this->returnValue('second node')); - $reportTargetNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') + $reportTargetNode = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); $reportTargetNode->expects($this->any()) @@ -297,21 +305,21 @@ class FilesReportPluginTest extends \Test\TestCase { } public function testFindNodesByFileIdsSubDir() { - $filesNode1 = $this->getMockBuilder('\OCP\Files\Folder') + $filesNode1 = $this->getMockBuilder(Folder::class) ->disableOriginalConstructor() ->getMock(); $filesNode1->expects($this->once()) ->method('getName') ->will($this->returnValue('first node')); - $filesNode2 = $this->getMockBuilder('\OCP\Files\File') + $filesNode2 = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); $filesNode2->expects($this->once()) ->method('getName') ->will($this->returnValue('second node')); - $reportTargetNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') + $reportTargetNode = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); $reportTargetNode->expects($this->any()) @@ -319,7 +327,7 @@ class FilesReportPluginTest extends \Test\TestCase { ->will($this->returnValue('/sub1/sub2')); - $subNode = $this->getMockBuilder('\OCP\Files\Folder') + $subNode = $this->getMockBuilder(Folder::class) ->disableOriginalConstructor() ->getMock(); @@ -353,10 +361,10 @@ class FilesReportPluginTest extends \Test\TestCase { $fileInfo = $this->createMock(FileInfo::class); $fileInfo->method('isReadable')->willReturn(true); - $node1 = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') + $node1 = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); - $node2 = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\File') + $node2 = $this->getMockBuilder(\OCA\DAV\Connector\Sabre\File::class) ->disableOriginalConstructor() ->getMock(); @@ -378,7 +386,7 @@ class FilesReportPluginTest extends \Test\TestCase { ->will($this->returnValue('/sub/node2')); $node2->method('getFileInfo')->willReturn($fileInfo); - $config = $this->getMockBuilder('\OCP\IConfig') + $config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); @@ -386,7 +394,7 @@ class FilesReportPluginTest extends \Test\TestCase { new \OCA\DAV\Connector\Sabre\FilesPlugin( $this->tree, $config, - $this->getMockBuilder('\OCP\IRequest') + $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor() ->getMock(), $this->previewManager diff --git a/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php b/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php index 43c32299523..b028cb8e6ac 100644 --- a/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php @@ -42,7 +42,7 @@ class MaintenancePluginTest extends TestCase { public function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->maintenancePlugin = new MaintenancePlugin($this->config); } diff --git a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php index 0aa3fe6101d..e7ab94ac926 100644 --- a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php @@ -25,6 +25,8 @@ */ namespace OCA\DAV\Tests\unit\Connector\Sabre; +use OC\Files\View; +use OCP\Files\Storage; /** * Class NodeTest @@ -67,7 +69,7 @@ class NodeTest extends \Test\TestCase { $info->expects($this->any()) ->method('getType') ->will($this->returnValue($type)); - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); @@ -119,7 +121,7 @@ class NodeTest extends \Test\TestCase { * @dataProvider sharePermissionsProvider */ public function testSharePermissions($type, $user, $permissions, $expected) { - $storage = $this->getMockBuilder('\OCP\Files\Storage') + $storage = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor() ->getMock(); $storage->method('getPermissions')->willReturn($permissions); @@ -149,7 +151,7 @@ class NodeTest extends \Test\TestCase { $info->method('getType')->willReturn($type); $info->method('getMountPoint')->willReturn($mountpoint); - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php index 53f60bd0f1c..c9c55adc9e8 100644 --- a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php @@ -156,13 +156,13 @@ class ObjectTreeTest extends \Test\TestCase { $_SERVER['HTTP_OC_CHUNKED'] = true; } - $rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') + $rootNode = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager') ->disableOriginalConstructor() ->getMock(); - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); $fileInfo = $this->getMockBuilder('\OCP\Files\FileInfo') @@ -275,7 +275,7 @@ class ObjectTreeTest extends \Test\TestCase { $storage = new Temporary([]); - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->setMethods(['resolvePath']) ->getMock(); $view->expects($this->once()) @@ -284,7 +284,7 @@ class ObjectTreeTest extends \Test\TestCase { return [$storage, ltrim($path, '/')]; })); - $rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') + $rootNode = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager') @@ -302,7 +302,7 @@ class ObjectTreeTest extends \Test\TestCase { $storage = new Temporary([]); - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->setMethods(['resolvePath']) ->getMock(); $view->expects($this->any()) @@ -311,7 +311,7 @@ class ObjectTreeTest extends \Test\TestCase { return [$storage, ltrim($path, '/')]; })); - $rootNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') + $rootNode = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager') diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php index 3f3bf16a422..ec4652a3af2 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php @@ -24,6 +24,8 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest; +use OCP\IConfig; + /** * Class PartFileInRootUploadTest * @@ -34,7 +36,7 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest; class PartFileInRootUploadTest extends UploadTest { protected function setUp() { $config = \OC::$server->getConfig(); - $mockConfig = $this->getMockBuilder('\OCP\IConfig') + $mockConfig = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); $mockConfig->expects($this->any()) diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php index 58a729e18ec..aec467dd50a 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php @@ -29,6 +29,7 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest; use OCA\DAV\Connector\Sabre\Server; use OCA\DAV\Connector\Sabre\ServerFactory; use OC\Files\View; +use OCP\IRequest; use Sabre\HTTP\Request; use Test\TestCase; use Test\Traits\MountProviderTrait; @@ -62,7 +63,7 @@ abstract class RequestTestCase extends TestCase { \OC::$server->getUserSession(), \OC::$server->getMountManager(), \OC::$server->getTagManager(), - $this->getMockBuilder('\OCP\IRequest') + $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor() ->getMock(), \OC::$server->getPreviewManager() diff --git a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php index 2b4a886050a..7c735ca2334 100644 --- a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php @@ -23,6 +23,14 @@ */ namespace OCA\DAV\Tests\unit\Connector\Sabre; +use OCA\DAV\Connector\Sabre\Directory; +use OCA\DAV\Connector\Sabre\File; +use OCP\Files\Folder; +use OCP\IUser; +use OCP\IUserSession; +use OCP\Share\IManager; +use Sabre\DAV\Tree; + class SharesPluginTest extends \Test\TestCase { const SHARETYPES_PROPERTYNAME = \OCA\DAV\Connector\Sabre\SharesPlugin::SHARETYPES_PROPERTYNAME; @@ -55,26 +63,26 @@ class SharesPluginTest extends \Test\TestCase { public function setUp() { parent::setUp(); $this->server = new \Sabre\DAV\Server(); - $this->tree = $this->getMockBuilder('\Sabre\DAV\Tree') + $this->tree = $this->getMockBuilder(Tree::class) ->disableOriginalConstructor() ->getMock(); - $this->shareManager = $this->getMockBuilder('\OCP\Share\IManager') + $this->shareManager = $this->getMockBuilder(IManager::class) ->disableOriginalConstructor() ->getMock(); - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $user->expects($this->once()) ->method('getUID') ->will($this->returnValue('user1')); - $userSession = $this->getMockBuilder('\OCP\IUserSession') + $userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); $userSession->expects($this->once()) ->method('getUser') ->will($this->returnValue($user)); - $this->userFolder = $this->getMockBuilder('\OCP\Files\Folder') + $this->userFolder = $this->getMockBuilder(Folder::class) ->disableOriginalConstructor() ->getMock(); @@ -102,7 +110,7 @@ class SharesPluginTest extends \Test\TestCase { ->will($this->returnValue('/subdir')); // node API nodes - $node = $this->getMockBuilder('\OCP\Files\Folder') + $node = $this->getMockBuilder(Folder::class) ->disableOriginalConstructor() ->getMock(); @@ -149,7 +157,7 @@ class SharesPluginTest extends \Test\TestCase { * @dataProvider sharesGetPropertiesDataProvider */ public function testPreloadThenGetProperties($shareTypes) { - $sabreNode1 = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\File') + $sabreNode1 = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); $sabreNode1->expects($this->any()) @@ -157,7 +165,7 @@ class SharesPluginTest extends \Test\TestCase { ->will($this->returnValue(111)); $sabreNode1->expects($this->any()) ->method('getPath'); - $sabreNode2 = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\File') + $sabreNode2 = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); $sabreNode2->expects($this->any()) @@ -167,7 +175,7 @@ class SharesPluginTest extends \Test\TestCase { ->method('getPath') ->will($this->returnValue('/subdir/foo')); - $sabreNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') + $sabreNode = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); $sabreNode->expects($this->any()) @@ -181,19 +189,19 @@ class SharesPluginTest extends \Test\TestCase { ->will($this->returnValue('/subdir')); // node API nodes - $node = $this->getMockBuilder('\OCP\Files\Folder') + $node = $this->getMockBuilder(Folder::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any()) ->method('getId') ->will($this->returnValue(123)); - $node1 = $this->getMockBuilder('\OCP\Files\File') + $node1 = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); $node1->expects($this->any()) ->method('getId') ->will($this->returnValue(111)); - $node2 = $this->getMockBuilder('\OCP\Files\File') + $node2 = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); $node2->expects($this->any()) diff --git a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php index 9189a73f77f..48d02cad690 100644 --- a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php @@ -24,6 +24,10 @@ */ namespace OCA\DAV\Tests\unit\Connector\Sabre; +use OCA\DAV\Connector\Sabre\Directory; +use OCA\DAV\Connector\Sabre\File; +use Sabre\DAV\Tree; + /** * Copyright (c) 2014 Vincent Petry * This file is licensed under the Affero General Public License version 3 or @@ -42,7 +46,7 @@ class TagsPluginTest extends \Test\TestCase { private $server; /** - * @var \Sabre\DAV\Tree + * @var Tree */ private $tree; @@ -64,7 +68,7 @@ class TagsPluginTest extends \Test\TestCase { public function setUp() { parent::setUp(); $this->server = new \Sabre\DAV\Server(); - $this->tree = $this->getMockBuilder('\Sabre\DAV\Tree') + $this->tree = $this->getMockBuilder(Tree::class) ->disableOriginalConstructor() ->getMock(); $this->tagger = $this->getMockBuilder('\OCP\ITags') @@ -124,13 +128,13 @@ class TagsPluginTest extends \Test\TestCase { * @dataProvider tagsGetPropertiesDataProvider */ public function testPreloadThenGetProperties($tags, $requestedProperties, $expectedProperties) { - $node1 = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\File') + $node1 = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); $node1->expects($this->any()) ->method('getId') ->will($this->returnValue(111)); - $node2 = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\File') + $node2 = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); $node2->expects($this->any()) @@ -145,7 +149,7 @@ class TagsPluginTest extends \Test\TestCase { $expectedCallCount = 1; } - $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Directory') + $node = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any()) diff --git a/apps/dav/tests/unit/DAV/Sharing/PluginTest.php b/apps/dav/tests/unit/DAV/Sharing/PluginTest.php index c4dae96e52f..1a9015c6cbb 100644 --- a/apps/dav/tests/unit/DAV/Sharing/PluginTest.php +++ b/apps/dav/tests/unit/DAV/Sharing/PluginTest.php @@ -51,7 +51,7 @@ class PluginTest extends TestCase { $authBackend->method('isDavAuthenticated')->willReturn(true); /** @var IRequest $request */ - $request = $this->getMockBuilder('OCP\IRequest')->disableOriginalConstructor()->getMock(); + $request = $this->getMockBuilder(IRequest::class)->disableOriginalConstructor()->getMock(); $this->plugin = new Plugin($authBackend, $request); $root = new SimpleCollection('root'); diff --git a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php index 1831210546d..ac4e9016434 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php @@ -25,6 +25,7 @@ namespace OCA\DAV\Tests\unit\SystemTag; use OC\SystemTag\SystemTag; +use OCP\IUser; use OCP\SystemTag\TagNotFoundException; use OCP\SystemTag\ISystemTag; @@ -52,7 +53,7 @@ class SystemTagMappingNodeTest extends \Test\TestCase { ->getMock(); $this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper') ->getMock(); - $this->user = $this->getMockBuilder('\OCP\IUser') + $this->user = $this->getMockBuilder(IUser::class) ->getMock(); } diff --git a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php index 3722bd9d25a..e50c3d30758 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php @@ -26,6 +26,7 @@ namespace OCA\DAV\Tests\unit\SystemTag; use OC\SystemTag\SystemTag; +use OCP\IUser; use OCP\SystemTag\TagNotFoundException; use OCP\SystemTag\TagAlreadyExistsException; use OCP\SystemTag\ISystemTag; @@ -48,7 +49,7 @@ class SystemTagNodeTest extends \Test\TestCase { $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager') ->getMock(); - $this->user = $this->getMockBuilder('\OCP\IUser') + $this->user = $this->getMockBuilder(IUser::class) ->getMock(); } diff --git a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php index fcfa528ac64..f1c18cf45a3 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php @@ -32,6 +32,9 @@ use OCP\IUserSession; use OCP\SystemTag\TagAlreadyExistsException; use OCP\IUser; use OCP\SystemTag\ISystemTag; +use Sabre\DAV\Tree; +use Sabre\HTTP\RequestInterface; +use Sabre\HTTP\ResponseInterface; class SystemTagPluginTest extends \Test\TestCase { @@ -79,7 +82,7 @@ class SystemTagPluginTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->tree = $this->getMockBuilder('\Sabre\DAV\Tree') + $this->tree = $this->getMockBuilder(Tree::class) ->disableOriginalConstructor() ->getMock(); @@ -87,11 +90,11 @@ class SystemTagPluginTest extends \Test\TestCase { $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager') ->getMock(); - $this->groupManager = $this->getMockBuilder('\OCP\IGroupManager') + $this->groupManager = $this->getMockBuilder(IGroupManager::class) ->getMock(); - $this->user = $this->getMockBuilder('\OCP\IUser') + $this->user = $this->getMockBuilder(IUser::class) ->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->getMock(); $this->userSession ->expects($this->any()) @@ -413,10 +416,10 @@ class SystemTagPluginTest extends \Test\TestCase { ->with('/systemtags') ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -458,10 +461,10 @@ class SystemTagPluginTest extends \Test\TestCase { ->with('/systemtags') ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -545,10 +548,10 @@ class SystemTagPluginTest extends \Test\TestCase { ->with('/systemtags') ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -619,10 +622,10 @@ class SystemTagPluginTest extends \Test\TestCase { ->method('createFile') ->with(1); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -668,10 +671,10 @@ class SystemTagPluginTest extends \Test\TestCase { $node->expects($this->never()) ->method('createFile'); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -715,10 +718,10 @@ class SystemTagPluginTest extends \Test\TestCase { ->with('/systemtags') ->will($this->returnValue($node)); - $request = $this->getMockBuilder('Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); - $response = $this->getMockBuilder('Sabre\HTTP\ResponseInterface') + $response = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php index 73431393071..53f54e19f0a 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php @@ -26,6 +26,9 @@ namespace OCA\DAV\Tests\unit\SystemTag; use OC\SystemTag\SystemTag; +use OCP\IGroupManager; +use OCP\IUser; +use OCP\IUserSession; use OCP\SystemTag\TagNotFoundException; class SystemTagsByIdCollectionTest extends \Test\TestCase { @@ -48,17 +51,17 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase { } public function getNode($isAdmin = true) { - $this->user = $this->getMockBuilder('\OCP\IUser') + $this->user = $this->getMockBuilder(IUser::class) ->getMock(); $this->user->expects($this->any()) ->method('getUID') ->will($this->returnValue('testuser')); - $userSession = $this->getMockBuilder('\OCP\IUserSession') + $userSession = $this->getMockBuilder(IUserSession::class) ->getMock(); $userSession->expects($this->any()) ->method('getUser') ->will($this->returnValue($this->user)); - $groupManager = $this->getMockBuilder('\OCP\IGroupManager') + $groupManager = $this->getMockBuilder(IGroupManager::class) ->getMock(); $groupManager->expects($this->any()) ->method('isAdmin') diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php index 9aa35c2ab24..61f94c9e60b 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php @@ -26,6 +26,7 @@ namespace OCA\DAV\Tests\unit\SystemTag; use OC\SystemTag\SystemTag; +use OCP\IUser; use OCP\SystemTag\TagNotFoundException; class SystemTagsObjectMappingCollectionTest extends \Test\TestCase { @@ -53,7 +54,7 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase { $this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper') ->getMock(); - $this->user = $this->getMockBuilder('\OCP\IUser') + $this->user = $this->getMockBuilder(IUser::class) ->getMock(); } diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php index 0c065d3451a..e3de7db1584 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php @@ -24,6 +24,11 @@ namespace OCA\DAV\Tests\unit\SystemTag; +use OCP\Files\Folder; +use OCP\IGroupManager; +use OCP\IUser; +use OCP\IUserSession; + class SystemTagsObjectTypeCollectionTest extends \Test\TestCase { /** @@ -54,24 +59,24 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase { $this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper') ->getMock(); - $user = $this->getMockBuilder('\OCP\IUser') + $user = $this->getMockBuilder(IUser::class) ->getMock(); $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('testuser')); - $userSession = $this->getMockBuilder('\OCP\IUserSession') + $userSession = $this->getMockBuilder(IUserSession::class) ->getMock(); $userSession->expects($this->any()) ->method('getUser') ->will($this->returnValue($user)); - $groupManager = $this->getMockBuilder('\OCP\IGroupManager') + $groupManager = $this->getMockBuilder(IGroupManager::class) ->getMock(); $groupManager->expects($this->any()) ->method('isAdmin') ->with('testuser') ->will($this->returnValue(true)); - $this->userFolder = $this->getMockBuilder('\OCP\Files\Folder') + $this->userFolder = $this->getMockBuilder(Folder::class) ->getMock(); $userFolder = $this->userFolder; -- cgit v1.2.3