From ca4278a4d764258ccc18c50038ed997b3fa1596d Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Mon, 23 Oct 2017 14:20:21 +0200 Subject: Provide tests for future timestamp formatting Signed-off-by: Morris Jobke --- tests/lib/DateTimeFormatterTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/lib') diff --git a/tests/lib/DateTimeFormatterTest.php b/tests/lib/DateTimeFormatterTest.php index 85884c9bfb4..deb6a7c783c 100644 --- a/tests/lib/DateTimeFormatterTest.php +++ b/tests/lib/DateTimeFormatterTest.php @@ -46,10 +46,13 @@ class DateTimeFormatterTest extends TestCase { $deL10N = \OC::$server->getL10N('lib', 'de'); return array( array('seconds ago', $time, $time), + array('in a few seconds', $time + 5 , $time), array('1 minute ago', $this->getTimestampAgo($time, 30, 1), $time), array('15 minutes ago', $this->getTimestampAgo($time, 30, 15), $time), + array('in 15 minutes', $time, $this->getTimestampAgo($time, 30, 15)), array('1 hour ago', $this->getTimestampAgo($time, 30, 15, 1), $time), array('3 hours ago', $this->getTimestampAgo($time, 30, 15, 3), $time), + array('in 3 hours', $time, $this->getTimestampAgo($time, 30, 15, 3)), array('4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4), $time), array('seconds ago', new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), @@ -86,9 +89,15 @@ class DateTimeFormatterTest extends TestCase { // Normal testing array('today', $this->getTimestampAgo($time, 30, 15), $time), array('yesterday', $this->getTimestampAgo($time, 0, 0, 0, 1), $time), + array('tomorrow', $time, $this->getTimestampAgo($time, 0, 0, 0, 1)), array('4 days ago', $this->getTimestampAgo($time, 0, 0, 0, 4), $time), + array('in 4 days', $time, $this->getTimestampAgo($time, 0, 0, 0, 4)), array('5 months ago', $this->getTimestampAgo($time, 0, 0, 0, 155), $time), + array('next month', $time, $this->getTimestampAgo($time, 0, 0, 0, 32)), + array('in 5 months', $time, $this->getTimestampAgo($time, 0, 0, 0, 155)), array('2 years ago', $this->getTimestampAgo($time, 0, 0, 0, 0, 2), $time), + array('next year', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), + array('in 2 years', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 2)), // Test with compare timestamp array('today', $this->getTimestampAgo($time, 0, 0, 0, 0, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), -- cgit v1.2.3 From ce0c45a4eabbe622500a4b621ccc4393720fc5ad Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Mon, 23 Oct 2017 23:40:17 +0200 Subject: Use proper DI for security middleware for app enabled check Signed-off-by: Morris Jobke --- lib/private/AppFramework/DependencyInjection/DIContainer.php | 3 ++- .../AppFramework/Middleware/Security/SecurityMiddleware.php | 10 ++++++++-- .../Middleware/Security/SecurityMiddlewareTest.php | 10 +++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'tests/lib') diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 2290f0d0045..0ea7eed4ae2 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -230,7 +230,8 @@ class DIContainer extends SimpleContainer implements IAppContainer { $app->isAdminUser(), $server->getContentSecurityPolicyManager(), $server->getCsrfTokenManager(), - $server->getContentSecurityPolicyNonceManager() + $server->getContentSecurityPolicyNonceManager(), + $server->getAppManager() ); }); diff --git a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php index 4e41c946432..52004987909 100644 --- a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php @@ -39,6 +39,7 @@ use OC\AppFramework\Utility\ControllerMethodReflector; use OC\Security\CSP\ContentSecurityPolicyManager; use OC\Security\CSP\ContentSecurityPolicyNonceManager; use OC\Security\CSRF\CsrfTokenManager; +use OCP\App\IAppManager; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Http\EmptyContentSecurityPolicy; use OCP\AppFramework\Http\RedirectResponse; @@ -87,6 +88,8 @@ class SecurityMiddleware extends Middleware { private $csrfTokenManager; /** @var ContentSecurityPolicyNonceManager */ private $cspNonceManager; + /** @var IAppManager */ + private $appManager; /** * @param IRequest $request @@ -101,6 +104,7 @@ class SecurityMiddleware extends Middleware { * @param ContentSecurityPolicyManager $contentSecurityPolicyManager * @param CSRFTokenManager $csrfTokenManager * @param ContentSecurityPolicyNonceManager $cspNonceManager + * @param IAppManager $appManager */ public function __construct(IRequest $request, ControllerMethodReflector $reflector, @@ -113,7 +117,8 @@ class SecurityMiddleware extends Middleware { $isAdminUser, ContentSecurityPolicyManager $contentSecurityPolicyManager, CsrfTokenManager $csrfTokenManager, - ContentSecurityPolicyNonceManager $cspNonceManager) { + ContentSecurityPolicyNonceManager $cspNonceManager, + IAppManager $appManager) { $this->navigationManager = $navigationManager; $this->request = $request; $this->reflector = $reflector; @@ -126,6 +131,7 @@ class SecurityMiddleware extends Middleware { $this->contentSecurityPolicyManager = $contentSecurityPolicyManager; $this->csrfTokenManager = $csrfTokenManager; $this->cspNonceManager = $cspNonceManager; + $this->appManager = $appManager; } /** @@ -190,7 +196,7 @@ class SecurityMiddleware extends Middleware { * The getAppPath() check is here since components such as settings also use the AppFramework and * therefore won't pass this check. */ - if(\OC_App::getAppPath($this->appName) !== false && !\OC_App::isEnabled($this->appName)) { + if(\OC_App::getAppPath($this->appName) !== false && !$this->appManager->isEnabledForUser($this->appName)) { throw new AppNotEnabledException(); } diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index 773cb2b196f..6b311c7ae15 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -37,6 +37,7 @@ use OC\Security\CSP\ContentSecurityPolicyManager; use OC\Security\CSP\ContentSecurityPolicyNonceManager; use OC\Security\CSRF\CsrfToken; use OC\Security\CSRF\CsrfTokenManager; +use OCP\App\IAppManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\EmptyContentSecurityPolicy; use OCP\AppFramework\Http\RedirectResponse; @@ -79,6 +80,8 @@ class SecurityMiddlewareTest extends \Test\TestCase { private $csrfTokenManager; /** @var ContentSecurityPolicyNonceManager|\PHPUnit_Framework_MockObject_MockObject */ private $cspNonceManager; + /** @var IAppManager|\PHPUnit_Framework_MockObject_MockObject */ + private $appManager; protected function setUp() { parent::setUp(); @@ -93,6 +96,10 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->contentSecurityPolicyManager = $this->createMock(ContentSecurityPolicyManager::class); $this->csrfTokenManager = $this->createMock(CsrfTokenManager::class); $this->cspNonceManager = $this->createMock(ContentSecurityPolicyNonceManager::class); + $this->appManager = $this->createMock(IAppManager::class); + $this->appManager->expects($this->any()) + ->method('isEnabledForUser') + ->willReturn(true); $this->middleware = $this->getMiddleware(true, true); $this->secException = new SecurityException('hey', false); $this->secAjaxException = new SecurityException('hey', true); @@ -116,7 +123,8 @@ class SecurityMiddlewareTest extends \Test\TestCase { $isAdminUser, $this->contentSecurityPolicyManager, $this->csrfTokenManager, - $this->cspNonceManager + $this->cspNonceManager, + $this->appManager ); } -- cgit v1.2.3 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/Controller/NotificationsTest.php | 36 +++-- .../tests/Unit/Notification/ListenerTest.php | 16 +-- .../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 +- .../tests/Command/TestEnableMasterKey.php | 3 +- .../tests/Controller/RecoveryControllerTest.php | 9 +- .../tests/Controller/SettingsControllerTest.php | 6 +- .../tests/Controller/StatusControllerTest.php | 3 +- apps/encryption/tests/Crypto/CryptTest.php | 6 +- apps/encryption/tests/Crypto/EncryptAllTest.php | 15 ++- apps/encryption/tests/Crypto/EncryptionTest.php | 6 +- apps/encryption/tests/Hooks/UserHooksTest.php | 3 +- apps/encryption/tests/MigrationTest.php | 5 +- apps/encryption/tests/Settings/AdminTest.php | 12 +- .../tests/AddressHandlerTest.php | 4 +- .../Controller/MountPublicLinkControllerTest.php | 7 +- .../Controller/RequestHandlerControllerTest.php | 8 +- .../tests/FederatedShareProviderTest.php | 31 ++--- apps/files/tests/Controller/ViewControllerTest.php | 34 ++--- apps/files/tests/Settings/AdminTest.php | 2 +- .../tests/Auth/AuthMechanismTest.php | 12 +- apps/files_external/tests/Backend/BackendTest.php | 7 +- .../tests/Controller/StoragesControllerTest.php | 6 +- .../tests/FrontendDefinitionTraitTest.php | 13 +- .../tests/Service/BackendServiceTest.php | 10 +- .../tests/Service/StoragesServiceTest.php | 8 +- apps/files_external/tests/Settings/SectionTest.php | 4 +- apps/files_external/tests/StorageConfigTest.php | 9 +- apps/files_sharing/tests/ApiTest.php | 6 +- apps/files_sharing/tests/CapabilitiesTest.php | 3 +- .../tests/Controller/ShareAPIControllerTest.php | 104 ++++++++------- .../tests/Controller/ShareControllerTest.php | 26 ++-- apps/files_sharing/tests/External/ManagerTest.php | 3 +- apps/files_sharing/tests/MountProviderTest.php | 8 +- apps/files_trashbin/tests/ExpirationTest.php | 5 +- apps/files_trashbin/tests/StorageTest.php | 3 +- apps/files_versions/tests/ExpirationTest.php | 3 +- .../tests/Controller/AppsControllerTest.php | 5 +- .../tests/Controller/GroupsControllerTest.php | 6 +- .../tests/Controller/UsersControllerTest.php | 146 ++++++++++----------- apps/sharebymail/tests/ShareByMailProviderTest.php | 8 +- .../tests/Controller/IconControllerTest.php | 4 +- apps/theming/tests/IconBuilderTest.php | 2 +- apps/theming/tests/ImageManagerTest.php | 2 +- apps/theming/tests/Settings/AdminTest.php | 6 +- apps/user_ldap/tests/Settings/AdminTest.php | 2 +- apps/user_ldap/tests/User/UserTest.php | 7 +- .../tests/Check/AbstractStringCheckTest.php | 3 +- .../tests/Check/RequestRemoteAddressTest.php | 6 +- .../workflowengine/tests/Check/RequestTimeTest.php | 3 +- tests/Core/Controller/AvatarControllerTest.php | 10 +- .../Controller/ChangePasswordControllerTest.php | 9 +- tests/Core/Controller/LostControllerTest.php | 6 +- tests/Core/Middleware/TwoFactorMiddlewareTest.php | 6 +- .../Controller/AdminSettingsControllerTest.php | 9 +- .../Controller/CertificateControllerTest.php | 4 +- .../Controller/CheckSetupControllerTest.php | 12 +- .../Controller/EncryptionControllerTest.php | 22 ++-- tests/Settings/Controller/GroupsControllerTest.php | 19 +-- tests/Settings/Controller/UsersControllerTest.php | 96 +++++++------- .../Settings/Middleware/SubadminMiddlewareTest.php | 4 +- tests/lib/APITest.php | 4 +- tests/lib/Accounts/AccountsManagerTest.php | 12 +- tests/lib/Activity/ManagerTest.php | 5 +- tests/lib/App/DependencyAnalyzerTest.php | 2 +- .../AppFramework/Controller/ApiControllerTest.php | 3 +- .../lib/AppFramework/Controller/ControllerTest.php | 3 +- tests/lib/AppFramework/Http/DispatcherTest.php | 13 +- tests/lib/AppFramework/Http/RequestTest.php | 2 +- .../Middleware/MiddlewareDispatcherTest.php | 3 +- .../lib/AppFramework/Middleware/MiddlewareTest.php | 3 +- .../Middleware/SessionMiddlewareTest.php | 3 +- tests/lib/AppFramework/Routing/RoutingTest.php | 11 +- tests/lib/BackgroundJob/JobTest.php | 4 +- tests/lib/CapabilitiesManagerTest.php | 2 +- tests/lib/Encryption/DecryptAllTest.php | 5 +- tests/lib/Encryption/Keys/StorageTest.php | 3 +- tests/lib/Encryption/UpdateTest.php | 3 +- tests/lib/Encryption/UtilTest.php | 3 +- tests/lib/Files/Node/NodeTest.php | 12 +- tests/lib/Files/Node/RootTest.php | 14 +- tests/lib/Files/Storage/Wrapper/EncryptionTest.php | 3 +- tests/lib/Files/Storage/Wrapper/QuotaTest.php | 2 +- tests/lib/Files/Stream/EncryptionTest.php | 3 +- tests/lib/Files/Type/DetectionTest.php | 19 +-- tests/lib/Group/GroupTest.php | 6 +- tests/lib/HTTPHelperTest.php | 3 +- tests/lib/Memcache/FactoryTest.php | 6 +- tests/lib/Migration/BackgroundRepairTest.php | 2 +- tests/lib/Notification/ManagerTest.php | 53 ++++---- tests/lib/Repair/CleanTagsTest.php | 3 +- tests/lib/Repair/RepairInvalidSharesTest.php | 3 +- tests/lib/Repair/RepairMimeTypesTest.php | 2 +- .../CSRF/TokenStorage/SessionStorageTest.php | 2 +- tests/lib/Security/HasherTest.php | 5 +- tests/lib/Security/TrustedDomainHelperTest.php | 2 +- tests/lib/Settings/Admin/AdditionalTest.php | 2 +- tests/lib/Settings/Admin/EncryptionTest.php | 2 +- tests/lib/Settings/Admin/ServerTest.php | 4 +- tests/lib/Settings/Admin/SharingTest.php | 2 +- tests/lib/Settings/Admin/TipsTricksTest.php | 2 +- tests/lib/SystemTag/SystemTagManagerTest.php | 7 +- tests/lib/TestCase.php | 2 +- tests/lib/Updater/VersionCheckTest.php | 5 +- tests/lib/User/ManagerTest.php | 2 +- tests/lib/User/SessionTest.php | 8 +- tests/lib/User/UserTest.php | 2 +- tests/lib/UtilTest.php | 6 +- 146 files changed, 947 insertions(+), 740 deletions(-) (limited to 'tests/lib') 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)); 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; diff --git a/apps/encryption/tests/Command/TestEnableMasterKey.php b/apps/encryption/tests/Command/TestEnableMasterKey.php index 75d5fa3d5e7..dac26c5d3c7 100644 --- a/apps/encryption/tests/Command/TestEnableMasterKey.php +++ b/apps/encryption/tests/Command/TestEnableMasterKey.php @@ -27,6 +27,7 @@ namespace OCA\Encryption\Tests\Command; use OCA\Encryption\Command\EnableMasterKey; use OCA\Encryption\Util; +use OCP\IConfig; use Test\TestCase; class TestEnableMasterKey extends TestCase { @@ -54,7 +55,7 @@ class TestEnableMasterKey extends TestCase { $this->util = $this->getMockBuilder('OCA\Encryption\Util') ->disableOriginalConstructor()->getMock(); - $this->config = $this->getMockBuilder('OCP\IConfig') + $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor()->getMock(); $this->questionHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper') ->disableOriginalConstructor()->getMock(); diff --git a/apps/encryption/tests/Controller/RecoveryControllerTest.php b/apps/encryption/tests/Controller/RecoveryControllerTest.php index fd1b0663b49..384cce94c42 100644 --- a/apps/encryption/tests/Controller/RecoveryControllerTest.php +++ b/apps/encryption/tests/Controller/RecoveryControllerTest.php @@ -27,6 +27,9 @@ namespace OCA\Encryption\Tests\Controller; use OCA\Encryption\Controller\RecoveryController; use OCP\AppFramework\Http; +use OCP\IConfig; +use OCP\IL10N; +use OCP\IRequest; use Test\TestCase; class RecoveryControllerTest extends TestCase { @@ -151,15 +154,15 @@ class RecoveryControllerTest extends TestCase { protected function setUp() { parent::setUp(); - $this->requestMock = $this->getMockBuilder('OCP\IRequest') + $this->requestMock = $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor() ->getMock(); - $this->configMock = $this->getMockBuilder('OCP\IConfig') + $this->configMock = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); - $this->l10nMock = $this->getMockBuilder('OCP\IL10N') + $this->l10nMock = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/encryption/tests/Controller/SettingsControllerTest.php b/apps/encryption/tests/Controller/SettingsControllerTest.php index 4f3e09687e3..fcff78d77de 100644 --- a/apps/encryption/tests/Controller/SettingsControllerTest.php +++ b/apps/encryption/tests/Controller/SettingsControllerTest.php @@ -26,7 +26,9 @@ namespace OCA\Encryption\Tests\Controller; use OCA\Encryption\Controller\SettingsController; use OCA\Encryption\Session; use OCP\AppFramework\Http; +use OCP\IL10N; use OCP\IRequest; +use OCP\IUserManager; use Test\TestCase; class SettingsControllerTest extends TestCase { @@ -67,7 +69,7 @@ class SettingsControllerTest extends TestCase { $this->requestMock = $this->createMock(IRequest::class); - $this->l10nMock = $this->getMockBuilder('OCP\IL10N') + $this->l10nMock = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor()->getMock(); $this->l10nMock->expects($this->any()) @@ -76,7 +78,7 @@ class SettingsControllerTest extends TestCase { return $message; })); - $this->userManagerMock = $this->getMockBuilder('OCP\IUserManager') + $this->userManagerMock = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor()->getMock(); $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') diff --git a/apps/encryption/tests/Controller/StatusControllerTest.php b/apps/encryption/tests/Controller/StatusControllerTest.php index ee0f7b2661c..cd3a8fdaa72 100644 --- a/apps/encryption/tests/Controller/StatusControllerTest.php +++ b/apps/encryption/tests/Controller/StatusControllerTest.php @@ -28,6 +28,7 @@ namespace OCA\Encryption\Tests\Controller; use OCA\Encryption\Controller\StatusController; use OCA\Encryption\Session; use OCP\Encryption\IManager; +use OCP\IL10N; use OCP\IRequest; use Test\TestCase; @@ -56,7 +57,7 @@ class StatusControllerTest extends TestCase { ->disableOriginalConstructor()->getMock(); $this->requestMock = $this->createMock(IRequest::class); - $this->l10nMock = $this->getMockBuilder('OCP\IL10N') + $this->l10nMock = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor()->getMock(); $this->l10nMock->expects($this->any()) ->method('t') diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php index 3c226ed94ab..4800be0a5ed 100644 --- a/apps/encryption/tests/Crypto/CryptTest.php +++ b/apps/encryption/tests/Crypto/CryptTest.php @@ -27,7 +27,9 @@ namespace OCA\Encryption\Tests\Crypto; use OCA\Encryption\Crypto\Crypt; +use OCP\IConfig; use OCP\IL10N; +use OCP\ILogger; use Test\TestCase; class CryptTest extends TestCase { @@ -51,7 +53,7 @@ class CryptTest extends TestCase { public function setUp() { parent::setUp(); - $this->logger = $this->getMockBuilder('OCP\ILogger') + $this->logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); $this->logger->expects($this->any()) @@ -60,7 +62,7 @@ class CryptTest extends TestCase { $this->userSession = $this->getMockBuilder('OCP\IUserSession') ->disableOriginalConstructor() ->getMock(); - $this->config = $this->getMockBuilder('OCP\IConfig') + $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); $this->l = $this->createMock(IL10N::class); diff --git a/apps/encryption/tests/Crypto/EncryptAllTest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php index df8401c15b2..7d432a6d524 100644 --- a/apps/encryption/tests/Crypto/EncryptAllTest.php +++ b/apps/encryption/tests/Crypto/EncryptAllTest.php @@ -26,6 +26,11 @@ namespace OCA\Encryption\Tests\Crypto; use OCA\Encryption\Crypto\EncryptAll; +use OCP\IConfig; +use OCP\IL10N; +use OCP\IUserManager; +use OCP\Mail\IMailer; +use OCP\UserInterface; use Symfony\Component\Console\Formatter\OutputFormatterInterface; use Test\TestCase; @@ -81,15 +86,15 @@ class EncryptAllTest extends TestCase { ->disableOriginalConstructor()->getMock(); $this->util = $this->getMockBuilder('OCA\Encryption\Util') ->disableOriginalConstructor()->getMock(); - $this->userManager = $this->getMockBuilder('OCP\IUserManager') + $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor()->getMock(); $this->view = $this->getMockBuilder('OC\Files\View') ->disableOriginalConstructor()->getMock(); - $this->config = $this->getMockBuilder('OCP\IConfig') + $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor()->getMock(); - $this->mailer = $this->getMockBuilder('OCP\Mail\IMailer') + $this->mailer = $this->getMockBuilder(IMailer::class) ->disableOriginalConstructor()->getMock(); - $this->l = $this->getMockBuilder('OCP\IL10N') + $this->l = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor()->getMock(); $this->questionHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper') ->disableOriginalConstructor()->getMock(); @@ -97,7 +102,7 @@ class EncryptAllTest extends TestCase { ->disableOriginalConstructor()->getMock(); $this->outputInterface = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') ->disableOriginalConstructor()->getMock(); - $this->userInterface = $this->getMockBuilder('OCP\UserInterface') + $this->userInterface = $this->getMockBuilder(UserInterface::class) ->disableOriginalConstructor()->getMock(); diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php index 7e074a5b9e8..3bd4593d6bc 100644 --- a/apps/encryption/tests/Crypto/EncryptionTest.php +++ b/apps/encryption/tests/Crypto/EncryptionTest.php @@ -24,6 +24,8 @@ namespace OCA\Encryption\Tests\Crypto; use OCA\Encryption\Exceptions\PublicKeyMissingException; +use OCP\IL10N; +use OCP\ILogger; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Test\TestCase; @@ -84,10 +86,10 @@ class EncryptionTest extends TestCase { $this->decryptAllMock = $this->getMockBuilder('OCA\Encryption\Crypto\DecryptAll') ->disableOriginalConstructor() ->getMock(); - $this->loggerMock = $this->getMockBuilder('OCP\ILogger') + $this->loggerMock = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); - $this->l10nMock = $this->getMockBuilder('OCP\IL10N') + $this->l10nMock = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor() ->getMock(); $this->l10nMock->expects($this->any()) diff --git a/apps/encryption/tests/Hooks/UserHooksTest.php b/apps/encryption/tests/Hooks/UserHooksTest.php index f9477e3e038..506f46eb8e6 100644 --- a/apps/encryption/tests/Hooks/UserHooksTest.php +++ b/apps/encryption/tests/Hooks/UserHooksTest.php @@ -31,6 +31,7 @@ use OCA\Encryption\Crypto\Crypt; use OCA\Encryption\Hooks\UserHooks; use OCP\ILogger; use OCP\IUser; +use OCP\IUserManager; use Test\TestCase; /** @@ -327,7 +328,7 @@ class UserHooksTest extends TestCase { $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') ->disableOriginalConstructor() ->getMock(); - $this->userManagerMock = $this->getMockBuilder('OCP\IUserManager') + $this->userManagerMock = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); $this->userSetupMock = $this->getMockBuilder('OCA\Encryption\Users\Setup') diff --git a/apps/encryption/tests/MigrationTest.php b/apps/encryption/tests/MigrationTest.php index 8f168e31e4d..71d2f52dd5c 100644 --- a/apps/encryption/tests/MigrationTest.php +++ b/apps/encryption/tests/MigrationTest.php @@ -25,6 +25,7 @@ namespace OCA\Encryption\Tests; +use OC\Files\View; use OCA\Encryption\Migration; use OCP\ILogger; @@ -68,7 +69,7 @@ class MigrationTest extends \Test\TestCase { public function setUp() { - $this->logger = $this->getMockBuilder('\OCP\ILogger')->disableOriginalConstructor()->getMock(); + $this->logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock(); $this->view = new \OC\Files\View(); $this->moduleId = \OCA\Encryption\Crypto\Encryption::ID; } @@ -524,7 +525,7 @@ class MigrationTest extends \Test\TestCase { */ public function testGetTargetDir($user, $keyPath, $filename, $trash, $systemMounts, $expected) { - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); $view->expects($this->any())->method('file_exists')->willReturn(true); diff --git a/apps/encryption/tests/Settings/AdminTest.php b/apps/encryption/tests/Settings/AdminTest.php index 93896585dad..5fe3fe956e4 100644 --- a/apps/encryption/tests/Settings/AdminTest.php +++ b/apps/encryption/tests/Settings/AdminTest.php @@ -52,12 +52,12 @@ class AdminTest extends TestCase { public function setUp() { parent::setUp(); - $this->l = $this->getMockBuilder('\OCP\IL10N')->getMock(); - $this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession')->getMock(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock(); - $this->session = $this->getMockBuilder('\OCP\ISession')->getMock(); + $this->l = $this->getMockBuilder(IL10N::class)->getMock(); + $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); + $this->userSession = $this->getMockBuilder(IUserSession::class)->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); + $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); + $this->session = $this->getMockBuilder(ISession::class)->getMock(); $this->admin = new Admin( $this->l, diff --git a/apps/federatedfilesharing/tests/AddressHandlerTest.php b/apps/federatedfilesharing/tests/AddressHandlerTest.php index 6d215d40156..a9c5cedf49b 100644 --- a/apps/federatedfilesharing/tests/AddressHandlerTest.php +++ b/apps/federatedfilesharing/tests/AddressHandlerTest.php @@ -47,9 +47,9 @@ class AddressHandlerTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->urlGenerator = $this->getMockBuilder('OCP\IURLGenerator') + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class) ->getMock(); - $this->il10n = $this->getMockBuilder('OCP\IL10N') + $this->il10n = $this->getMockBuilder(IL10N::class) ->getMock(); $this->cloudIdManager = new CloudIdManager(); diff --git a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php index 7714ff4731c..b5ea08af8d5 100644 --- a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php @@ -35,6 +35,7 @@ use OCP\Federation\ICloudIdManager; use OCP\Files\IRootFolder; use OCP\Http\Client\IClientService; use OCP\IL10N; +use OCP\IRequest; use OCP\ISession; use OCP\IUserManager; use OCP\IUserSession; @@ -85,17 +86,17 @@ class MountPublicLinkControllerTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->request = $this->getMockBuilder('OCP\IRequest')->disableOriginalConstructor()->getMock(); + $this->request = $this->getMockBuilder(IRequest::class)->disableOriginalConstructor()->getMock(); $this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider') ->disableOriginalConstructor()->getMock(); $this->shareManager = $this->getMockBuilder('OCP\Share\IManager')->disableOriginalConstructor()->getMock(); $this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler') ->disableOriginalConstructor()->getMock(); $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->disableOriginalConstructor()->getMock(); - $this->userManager = $this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock(); + $this->userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock(); $this->share = new \OC\Share20\Share($this->rootFolder, $this->userManager); $this->session = $this->getMockBuilder('OCP\ISession')->disableOriginalConstructor()->getMock(); - $this->l10n = $this->getMockBuilder('OCP\IL10N')->disableOriginalConstructor()->getMock(); + $this->l10n = $this->getMockBuilder(IL10N::class)->disableOriginalConstructor()->getMock(); $this->userSession = $this->getMockBuilder('OCP\IUserSession')->disableOriginalConstructor()->getMock(); $this->clientService = $this->getMockBuilder('OCP\Http\Client\IClientService')->disableOriginalConstructor()->getMock(); $this->cloudIdManager = new CloudIdManager(); diff --git a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php index d57b2cb207f..538c6ae5a08 100644 --- a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php @@ -29,13 +29,13 @@ namespace OCA\FederatedFileSharing\Tests; use OC\Federation\CloudIdManager; use OC\Files\Filesystem; -use OCA\FederatedFileSharing\DiscoveryManager; use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\FederatedFileSharing\Controller\RequestHandlerController; use OCP\Federation\ICloudIdManager; use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; +use OCP\IConfig; use OCP\IUserManager; use OCP\Share\IShare; @@ -83,9 +83,9 @@ class RequestHandlerControllerTest extends TestCase { self::loginHelper(self::TEST_FILES_SHARING_API_USER1); \OC\Share\Share::registerBackend('test', 'Test\Share\Backend'); - $config = $this->getMockBuilder('\OCP\IConfig') + $config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor()->getMock(); - $clientService = $this->getMockBuilder('\OCP\Http\Client\IClientService')->getMock(); + $clientService = $this->getMockBuilder(IClientService::class)->getMock(); $httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper') ->setConstructorArgs([$config, $clientService]) ->getMock(); @@ -104,7 +104,7 @@ class RequestHandlerControllerTest extends TestCase { ->disableOriginalConstructor()->getMock(); $this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler') ->disableOriginalConstructor()->getMock(); - $this->userManager = $this->getMockBuilder('OCP\IUserManager')->getMock(); + $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); $this->cloudIdManager = new CloudIdManager(); diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index 3ecd8162cad..aa81eef9e63 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -31,6 +31,7 @@ use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\FederatedFileSharing\Notifications; use OCA\FederatedFileSharing\TokenHandler; use OCP\Federation\ICloudIdManager; +use OCP\Files\File; use OCP\Files\IRootFolder; use OCP\IConfig; use OCP\IDBConnection; @@ -87,15 +88,15 @@ class FederatedShareProviderTest extends \Test\TestCase { $this->tokenHandler = $this->getMockBuilder('OCA\FederatedFileSharing\TokenHandler') ->disableOriginalConstructor() ->getMock(); - $this->l = $this->getMockBuilder('OCP\IL10N')->getMock(); + $this->l = $this->getMockBuilder(IL10N::class)->getMock(); $this->l->method('t') ->will($this->returnCallback(function($text, $parameters = []) { return vsprintf($text, $parameters); })); - $this->logger = $this->getMockBuilder('OCP\ILogger')->getMock(); + $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock(); - $this->config = $this->getMockBuilder('OCP\IConfig')->getMock(); - $this->userManager = $this->getMockBuilder('OCP\IUserManager')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); + $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); //$this->addressHandler = new AddressHandler(\OC::$server->getURLGenerator(), $this->l); $this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler')->disableOriginalConstructor()->getMock(); $this->cloudIdManager = new CloudIdManager(); @@ -129,7 +130,7 @@ class FederatedShareProviderTest extends \Test\TestCase { public function testCreate() { $share = $this->shareManager->newShare(); - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $node->method('getId')->willReturn(42); $node->method('getName')->willReturn('myFile'); @@ -200,7 +201,7 @@ class FederatedShareProviderTest extends \Test\TestCase { public function testCreateCouldNotFindServer() { $share = $this->shareManager->newShare(); - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $node->method('getId')->willReturn(42); $node->method('getName')->willReturn('myFile'); @@ -256,7 +257,7 @@ class FederatedShareProviderTest extends \Test\TestCase { public function testCreateException() { $share = $this->shareManager->newShare(); - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $node->method('getId')->willReturn(42); $node->method('getName')->willReturn('myFile'); @@ -312,7 +313,7 @@ class FederatedShareProviderTest extends \Test\TestCase { public function testCreateShareWithSelf() { $share = $this->shareManager->newShare(); - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $node->method('getId')->willReturn(42); $node->method('getName')->willReturn('myFile'); @@ -351,7 +352,7 @@ class FederatedShareProviderTest extends \Test\TestCase { public function testCreateAlreadyShared() { $share = $this->shareManager->newShare(); - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $node->method('getId')->willReturn(42); $node->method('getName')->willReturn('myFile'); @@ -419,7 +420,7 @@ class FederatedShareProviderTest extends \Test\TestCase { $share = $this->shareManager->newShare(); - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $node->method('getId')->willReturn(42); $node->method('getName')->willReturn('myFile'); @@ -476,7 +477,7 @@ class FederatedShareProviderTest extends \Test\TestCase { } public function testGetSharedBy() { - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $node->method('getId')->willReturn(42); $node->method('getName')->willReturn('myFile'); @@ -517,7 +518,7 @@ class FederatedShareProviderTest extends \Test\TestCase { } public function testGetSharedByWithNode() { - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $node->method('getId')->willReturn(42); $node->method('getName')->willReturn('myFile'); @@ -536,7 +537,7 @@ class FederatedShareProviderTest extends \Test\TestCase { ->setNode($node); $this->provider->create($share); - $node2 = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node2 = $this->getMockBuilder(File::class)->getMock(); $node2->method('getId')->willReturn(43); $node2->method('getName')->willReturn('myOtherFile'); @@ -555,7 +556,7 @@ class FederatedShareProviderTest extends \Test\TestCase { } public function testGetSharedByWithReshares() { - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $node->method('getId')->willReturn(42); $node->method('getName')->willReturn('myFile'); @@ -588,7 +589,7 @@ class FederatedShareProviderTest extends \Test\TestCase { } public function testGetSharedByWithLimit() { - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $node->method('getId')->willReturn(42); $node->method('getName')->willReturn('myFile'); diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index 007335b948d..3d8c8164abb 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -27,6 +27,8 @@ namespace OCA\Files\Tests\Controller; use OCA\Files\Controller\ViewController; use OCP\AppFramework\Http; +use OCP\Files\File; +use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\IUser; use OCP\Template; @@ -68,14 +70,14 @@ class ViewControllerTest extends TestCase { public function setUp() { parent::setUp(); - $this->request = $this->getMockBuilder('\OCP\IRequest')->getMock(); - $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->getMock(); - $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); + $this->request = $this->getMockBuilder(IRequest::class)->getMock(); + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock(); + $this->l10n = $this->getMockBuilder(IL10N::class)->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->eventDispatcher = $this->getMockBuilder('\Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); - $this->userSession = $this->getMockBuilder('\OCP\IUserSession')->getMock(); + $this->userSession = $this->getMockBuilder(IUserSession::class)->getMock(); $this->appManager = $this->getMockBuilder('\OCP\App\IAppManager')->getMock(); - $this->user = $this->getMockBuilder('\OCP\IUser')->getMock(); + $this->user = $this->getMockBuilder(IUser::class)->getMock(); $this->user->expects($this->any()) ->method('getUID') ->will($this->returnValue('testuser1')); @@ -281,12 +283,12 @@ class ViewControllerTest extends TestCase { } public function testShowFileRouteWithFolder() { - $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $node = $this->getMockBuilder(Folder::class)->getMock(); $node->expects($this->once()) ->method('getPath') ->will($this->returnValue('/testuser1/files/test/sub')); - $baseFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $baseFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') @@ -313,19 +315,19 @@ class ViewControllerTest extends TestCase { } public function testShowFileRouteWithFile() { - $parentNode = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $parentNode = $this->getMockBuilder(Folder::class)->getMock(); $parentNode->expects($this->once()) ->method('getPath') ->will($this->returnValue('testuser1/files/test')); - $baseFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $baseFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('testuser1') ->will($this->returnValue($baseFolder)); - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $node->expects($this->once()) ->method('getParent') ->will($this->returnValue($parentNode)); @@ -353,7 +355,7 @@ class ViewControllerTest extends TestCase { } public function testShowFileRouteWithInvalidFileId() { - $baseFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $baseFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('testuser1') @@ -380,13 +382,13 @@ class ViewControllerTest extends TestCase { ->with('files_trashbin') ->will($this->returnValue(true)); - $parentNode = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $parentNode = $this->getMockBuilder(Folder::class)->getMock(); $parentNode->expects($this->once()) ->method('getPath') ->will($this->returnValue('testuser1/files_trashbin/files/test.d1462861890/sub')); - $baseFolderFiles = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); - $baseFolderTrash = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $baseFolderFiles = $this->getMockBuilder(Folder::class)->getMock(); + $baseFolderTrash = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->at(0)) ->method('getUserFolder') @@ -402,7 +404,7 @@ class ViewControllerTest extends TestCase { ->with(123) ->will($this->returnValue([])); - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $node->expects($this->once()) ->method('getParent') ->will($this->returnValue($parentNode)); diff --git a/apps/files/tests/Settings/AdminTest.php b/apps/files/tests/Settings/AdminTest.php index 1ab8a992879..1bcfd111db5 100644 --- a/apps/files/tests/Settings/AdminTest.php +++ b/apps/files/tests/Settings/AdminTest.php @@ -41,7 +41,7 @@ class AdminTest extends TestCase { public function setUp() { parent::setUp(); $this->iniGetWrapper = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper')->disableOriginalConstructor()->getMock(); - $this->request = $this->getMockBuilder('\OCP\IRequest')->getMock(); + $this->request = $this->getMockBuilder(IRequest::class)->getMock(); $this->admin = new Admin( $this->iniGetWrapper, $this->request diff --git a/apps/files_external/tests/Auth/AuthMechanismTest.php b/apps/files_external/tests/Auth/AuthMechanismTest.php index 5d635a5036a..11eee7b8824 100644 --- a/apps/files_external/tests/Auth/AuthMechanismTest.php +++ b/apps/files_external/tests/Auth/AuthMechanismTest.php @@ -22,10 +22,14 @@ namespace OCA\Files_External\Tests\Auth; +use OCA\Files_External\Lib\Auth\AuthMechanism; +use OCA\Files_External\Lib\Backend\Backend; +use OCA\Files_External\Lib\StorageConfig; + class AuthMechanismTest extends \Test\TestCase { public function testJsonSerialization() { - $mechanism = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\AuthMechanism') + $mechanism = $this->getMockBuilder(AuthMechanism::class) ->setMethods(['jsonSerializeDefinition']) ->getMock(); $mechanism->expects($this->once()) @@ -52,7 +56,7 @@ class AuthMechanismTest extends \Test\TestCase { * @dataProvider validateStorageProvider */ public function testValidateStorage($expectedSuccess, $scheme, $definitionSuccess) { - $mechanism = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\AuthMechanism') + $mechanism = $this->getMockBuilder(AuthMechanism::class) ->setMethods(['validateStorageDefinition']) ->getMock(); $mechanism->expects($this->atMost(1)) @@ -61,14 +65,14 @@ class AuthMechanismTest extends \Test\TestCase { $mechanism->setScheme($scheme); - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); $backend->expects($this->once()) ->method('getAuthSchemes') ->willReturn(['scheme' => true, 'foobar' => true]); - $storageConfig = $this->getMockBuilder('\OCA\Files_External\Lib\StorageConfig') + $storageConfig = $this->getMockBuilder(StorageConfig::class) ->disableOriginalConstructor() ->getMock(); $storageConfig->expects($this->once()) diff --git a/apps/files_external/tests/Backend/BackendTest.php b/apps/files_external/tests/Backend/BackendTest.php index 762b9f4c0e8..1a1c386240a 100644 --- a/apps/files_external/tests/Backend/BackendTest.php +++ b/apps/files_external/tests/Backend/BackendTest.php @@ -23,11 +23,12 @@ namespace OCA\Files_External\Tests\Backend; use \OCA\Files_External\Lib\Backend\Backend; +use OCA\Files_External\Lib\StorageConfig; class BackendTest extends \Test\TestCase { public function testJsonSerialization() { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->setMethods(['jsonSerializeDefinition']) ->getMock(); $backend->expects($this->once()) @@ -59,14 +60,14 @@ class BackendTest extends \Test\TestCase { * @dataProvider validateStorageProvider */ public function testValidateStorage($expectedSuccess, $definitionSuccess) { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->setMethods(['validateStorageDefinition']) ->getMock(); $backend->expects($this->atMost(1)) ->method('validateStorageDefinition') ->willReturn($definitionSuccess); - $storageConfig = $this->getMockBuilder('\OCA\Files_External\Lib\StorageConfig') + $storageConfig = $this->getMockBuilder(StorageConfig::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/files_external/tests/Controller/StoragesControllerTest.php b/apps/files_external/tests/Controller/StoragesControllerTest.php index 35a055e6be5..f854b25676c 100644 --- a/apps/files_external/tests/Controller/StoragesControllerTest.php +++ b/apps/files_external/tests/Controller/StoragesControllerTest.php @@ -23,6 +23,8 @@ */ namespace OCA\Files_External\Tests\Controller; +use OCA\Files_External\Lib\Auth\AuthMechanism; +use OCA\Files_External\Lib\Backend\Backend; use \OCP\AppFramework\Http; use \OCA\Files_External\Controller\GlobalStoragesController; @@ -54,7 +56,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { * @return \OCA\Files_External\Lib\Backend\Backend */ protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OCA\Files_External\Lib\Storage\SMB') { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); $backend->method('getStorageClass') @@ -68,7 +70,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { * @return \OCA\Files_External\Lib\Auth\AuthMechanism */ protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') { - $authMech = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\AuthMechanism') + $authMech = $this->getMockBuilder(AuthMechanism::class) ->disableOriginalConstructor() ->getMock(); $authMech->method('getScheme') diff --git a/apps/files_external/tests/FrontendDefinitionTraitTest.php b/apps/files_external/tests/FrontendDefinitionTraitTest.php index 7efc7c66586..4154ac6092c 100644 --- a/apps/files_external/tests/FrontendDefinitionTraitTest.php +++ b/apps/files_external/tests/FrontendDefinitionTraitTest.php @@ -23,10 +23,13 @@ namespace OCA\Files_External\Tests; +use OCA\Files_External\Lib\DefinitionParameter; +use OCA\Files_External\Lib\StorageConfig; + class FrontendDefinitionTraitTest extends \Test\TestCase { public function testJsonSerialization() { - $param = $this->getMockBuilder('\OCA\Files_External\Lib\DefinitionParameter') + $param = $this->getMockBuilder(DefinitionParameter::class) ->disableOriginalConstructor() ->getMock(); $param->method('getName')->willReturn('foo'); @@ -60,7 +63,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase { public function testValidateStorage($expectedSuccess, $params) { $backendParams = []; foreach ($params as $name => $valid) { - $param = $this->getMockBuilder('\OCA\Files_External\Lib\DefinitionParameter') + $param = $this->getMockBuilder(DefinitionParameter::class) ->disableOriginalConstructor() ->getMock(); $param->method('getName') @@ -73,7 +76,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase { $backendParams[] = $param; } - $storageConfig = $this->getMockBuilder('\OCA\Files_External\Lib\StorageConfig') + $storageConfig = $this->getMockBuilder(StorageConfig::class) ->disableOriginalConstructor() ->getMock(); $storageConfig->expects($this->any()) @@ -90,7 +93,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase { } public function testValidateStorageSet() { - $param = $this->getMockBuilder('\OCA\Files_External\Lib\DefinitionParameter') + $param = $this->getMockBuilder(DefinitionParameter::class) ->disableOriginalConstructor() ->getMock(); $param->method('getName') @@ -102,7 +105,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase { return true; })); - $storageConfig = $this->getMockBuilder('\OCA\Files_External\Lib\StorageConfig') + $storageConfig = $this->getMockBuilder(StorageConfig::class) ->disableOriginalConstructor() ->getMock(); $storageConfig->expects($this->once()) diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php index cbb25579e11..6916d47a02a 100644 --- a/apps/files_external/tests/Service/BackendServiceTest.php +++ b/apps/files_external/tests/Service/BackendServiceTest.php @@ -21,6 +21,8 @@ */ namespace OCA\Files_External\Tests\Service; +use OCA\Files_External\Lib\Auth\AuthMechanism; +use OCA\Files_External\Lib\Backend\Backend; use OCA\Files_External\Lib\Config\IAuthMechanismProvider; use OCA\Files_External\Lib\Config\IBackendProvider; use \OCA\Files_External\Service\BackendService; @@ -46,7 +48,7 @@ class BackendServiceTest extends \Test\TestCase { * @return \OCA\Files_External\Lib\Backend\Backend */ protected function getBackendMock($class) { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); $backend->method('getIdentifier')->will($this->returnValue('identifier:'.$class)); @@ -60,7 +62,7 @@ class BackendServiceTest extends \Test\TestCase { * @return \OCA\Files_External\Lib\Auth\AuthMechanism */ protected function getAuthMechanismMock($class) { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\AuthMechanism') + $backend = $this->getMockBuilder(AuthMechanism::class) ->disableOriginalConstructor() ->getMock(); $backend->method('getIdentifier')->will($this->returnValue('identifier:'.$class)); @@ -73,7 +75,7 @@ class BackendServiceTest extends \Test\TestCase { $backend = $this->getBackendMock('\Foo\Bar'); - $backendAlias = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backendAlias = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); $backendAlias->method('getIdentifierAliases') @@ -175,7 +177,7 @@ class BackendServiceTest extends \Test\TestCase { ->method('removeVisibility') ->with(BackendService::VISIBILITY_PERSONAL); - $backendAlias = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backendAlias = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); $backendAlias->method('getIdentifierAliases') diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php index 056a03d24c8..22409ea9dbd 100644 --- a/apps/files_external/tests/Service/StoragesServiceTest.php +++ b/apps/files_external/tests/Service/StoragesServiceTest.php @@ -27,7 +27,9 @@ namespace OCA\Files_External\Tests\Service; use \OC\Files\Filesystem; +use OCA\Files_External\Lib\Auth\AuthMechanism; use OCA\Files_External\Lib\Auth\InvalidAuth; +use OCA\Files_External\Lib\Backend\Backend; use OCA\Files_External\Lib\Backend\InvalidBackend; use OCA\Files_External\NotFoundException; use OCA\Files_External\Lib\StorageConfig; @@ -179,7 +181,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { } protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OCA\Files_External\Lib\Storage\SMB') { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); $backend->method('getStorageClass') @@ -190,7 +192,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { } protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') { - $authMech = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\AuthMechanism') + $authMech = $this->getMockBuilder(AuthMechanism::class) ->disableOriginalConstructor() ->getMock(); $authMech->method('getScheme') @@ -204,7 +206,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { /** * Creates a StorageConfig instance based on array data * - * @param array data + * @param array $data * * @return StorageConfig storage config instance */ diff --git a/apps/files_external/tests/Settings/SectionTest.php b/apps/files_external/tests/Settings/SectionTest.php index ee501b1270b..93aee61b47d 100644 --- a/apps/files_external/tests/Settings/SectionTest.php +++ b/apps/files_external/tests/Settings/SectionTest.php @@ -38,8 +38,8 @@ class SectionTest extends TestCase { public function setUp() { parent::setUp(); - $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->disableOriginalConstructor()->getMock(); - $this->l = $this->getMockBuilder('\OCP\IL10N')->disableOriginalConstructor()->getMock(); + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->disableOriginalConstructor()->getMock(); + $this->l = $this->getMockBuilder(IL10N::class)->disableOriginalConstructor()->getMock(); $this->section = new Section( $this->urlGenerator, diff --git a/apps/files_external/tests/StorageConfigTest.php b/apps/files_external/tests/StorageConfigTest.php index 96d4fda5050..f357c0c6990 100644 --- a/apps/files_external/tests/StorageConfigTest.php +++ b/apps/files_external/tests/StorageConfigTest.php @@ -25,15 +25,18 @@ namespace OCA\Files_External\Tests; +use OCA\Files_External\Lib\Auth\AuthMechanism; +use OCA\Files_External\Lib\Backend\Backend; +use OCA\Files_External\Lib\DefinitionParameter; use OCA\Files_External\Lib\StorageConfig; class StorageConfigTest extends \Test\TestCase { public function testJsonSerialization() { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); - $parameter = $this->getMockBuilder('\OCA\Files_External\Lib\DefinitionParameter') + $parameter = $this->getMockBuilder(DefinitionParameter::class) ->disableOriginalConstructor() ->getMock(); $parameter @@ -47,7 +50,7 @@ class StorageConfigTest extends \Test\TestCase { $backend->method('getIdentifier') ->willReturn('storage::identifier'); - $authMech = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\AuthMechanism') + $authMech = $this->getMockBuilder(AuthMechanism::class) ->disableOriginalConstructor() ->getMock(); $authMech->method('getIdentifier') diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index 1b629f66a81..8a976108b3f 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -35,6 +35,8 @@ use OCP\AppFramework\OCS\OCSBadRequestException; use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCS\OCSForbiddenException; use OCP\AppFramework\OCS\OCSNotFoundException; +use OCP\IL10N; +use OCP\IRequest; /** * Class ApiTest @@ -96,7 +98,7 @@ class ApiTest extends TestCase { * @return \OCA\Files_Sharing\Controller\ShareAPIController */ private function createOCS($userId) { - $l = $this->getMockBuilder('\OCP\IL10N')->getMock(); + $l = $this->getMockBuilder(IL10N::class)->getMock(); $l->method('t') ->will($this->returnCallback(function($text, $parameters = []) { return vsprintf($text, $parameters); @@ -104,7 +106,7 @@ class ApiTest extends TestCase { return new ShareAPIController( self::APP_NAME, - $this->getMockBuilder('OCP\IRequest')->getMock(), + $this->getMockBuilder(IRequest::class)->getMock(), $this->shareManager, \OC::$server->getGroupManager(), \OC::$server->getUserManager(), diff --git a/apps/files_sharing/tests/CapabilitiesTest.php b/apps/files_sharing/tests/CapabilitiesTest.php index 1747bbc4ed2..e65131bf45f 100644 --- a/apps/files_sharing/tests/CapabilitiesTest.php +++ b/apps/files_sharing/tests/CapabilitiesTest.php @@ -24,6 +24,7 @@ namespace OCA\Files_Sharing\Tests; use OCA\Files_Sharing\Capabilities; +use OCP\IConfig; /** @@ -54,7 +55,7 @@ class CapabilitiesTest extends \Test\TestCase { * @return string[] */ private function getResults(array $map) { - $config = $this->getMockBuilder('\OCP\IConfig')->disableOriginalConstructor()->getMock(); + $config = $this->getMockBuilder(IConfig::class)->disableOriginalConstructor()->getMock(); $config->method('getAppValue')->will($this->returnValueMap($map)); $cap = new Capabilities($config); $result = $this->getFilesSharingPart($cap->getCapabilities()); diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 45134df36b7..14852b3354f 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -25,7 +25,9 @@ namespace OCA\Files_Sharing\Tests\Controller; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSNotFoundException; +use OCP\Files\File; use OCP\Files\Folder; +use OCP\Files\Storage; use OCP\IL10N; use OCA\Files_Sharing\Controller\ShareAPIController; use OCP\Files\NotFoundException; @@ -156,7 +158,7 @@ class ShareAPIControllerTest extends TestCase { } public function testDeleteShare() { - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); $share->setSharedBy($this->currentUser) @@ -187,7 +189,7 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage could not delete share */ public function testDeleteShareLocked() { - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); $share->setSharedBy($this->currentUser) @@ -464,15 +466,15 @@ class ShareAPIControllerTest extends TestCase { ->method('linkToRouteAbsolute') ->willReturn('url'); - $initiator = $this->getMockBuilder('OCP\IUser')->getMock(); + $initiator = $this->getMockBuilder(IUser::class)->getMock(); $initiator->method('getUID')->willReturn('initiatorId'); $initiator->method('getDisplayName')->willReturn('initiatorDisplay'); - $owner = $this->getMockBuilder('OCP\IUser')->getMock(); + $owner = $this->getMockBuilder(IUser::class)->getMock(); $owner->method('getUID')->willReturn('ownerId'); $owner->method('getDisplayName')->willReturn('ownerDisplay'); - $user = $this->getMockBuilder('OCP\IUser')->getMock(); + $user = $this->getMockBuilder(IUser::class)->getMock(); $user->method('getUID')->willReturn('userId'); $user->method('getDisplayName')->willReturn('userDisplay'); @@ -526,7 +528,7 @@ class ShareAPIControllerTest extends TestCase { $share = $this->getMockBuilder('OCP\Share\IShare')->getMock(); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); - $share->method('getSharedWith')->willReturn($this->getMockBuilder('OCP\IUser')->getMock()); + $share->method('getSharedWith')->willReturn($this->getMockBuilder(IUser::class)->getMock()); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); $share = $this->getMockBuilder('OCP\Share\IShare')->getMock(); @@ -579,7 +581,7 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage Wrong path, file/folder doesn't exist */ public function testCreateShareInvalidPath() { - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') @@ -601,13 +603,13 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $path = $this->getMockBuilder(File::class)->getMock(); $userFolder->expects($this->once()) ->method('get') ->with('valid-path') @@ -628,13 +630,13 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $path = $this->getMockBuilder(File::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -660,13 +662,13 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $path = $this->getMockBuilder(File::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -705,13 +707,13 @@ class ShareAPIControllerTest extends TestCase { ])->setMethods(['formatShare']) ->getMock(); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $path = $this->getMockBuilder(File::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -759,13 +761,13 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->method('createShare')->will($this->returnArgument(0)); $this->shareManager->method('allowGroupSharing')->willReturn(true); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $path = $this->getMockBuilder(File::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -811,13 +813,13 @@ class ShareAPIControllerTest extends TestCase { ['shareWith', null, 'validGroup'], ])); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -863,13 +865,13 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -901,7 +903,7 @@ class ShareAPIControllerTest extends TestCase { ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK], ])); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -920,7 +922,7 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage Public upload disabled by the administrator */ public function testCreateShareLinkNoPublicUpload() { - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -940,7 +942,7 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage Public upload is only possible for publicly shared folders */ public function testCreateShareLinkPublicUploadFile() { - $path = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $path = $this->getMockBuilder(File::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -959,7 +961,7 @@ class ShareAPIControllerTest extends TestCase { public function testCreateShareLinkPublicUploadFolder() { $ocs = $this->mockFormatShare(); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -993,7 +995,7 @@ class ShareAPIControllerTest extends TestCase { public function testCreateShareLinkPassword() { $ocs = $this->mockFormatShare(); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -1037,7 +1039,7 @@ class ShareAPIControllerTest extends TestCase { ['password', '', ''], ])); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -1078,7 +1080,7 @@ class ShareAPIControllerTest extends TestCase { public function testCreateShareInvalidExpireDate() { $ocs = $this->mockFormatShare(); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -1117,13 +1119,13 @@ class ShareAPIControllerTest extends TestCase { ])->setMethods(['formatShare']) ->getMock(); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') @@ -1153,7 +1155,7 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage Wrong share ID, share doesn't exist */ public function testUpdateShareCantAccess() { - $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $node = $this->getMockBuilder(Folder::class)->getMock(); $share = $this->newShare(); $share->setNode($node); @@ -1171,7 +1173,7 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage Wrong or no update parameter given */ public function testUpdateNoParametersLink() { - $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $node = $this->getMockBuilder(Folder::class)->getMock(); $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) @@ -1192,7 +1194,7 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage Wrong or no update parameter given */ public function testUpdateNoParametersOther() { - $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $node = $this->getMockBuilder(Folder::class)->getMock(); $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) @@ -1248,7 +1250,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateLinkShareSet() { $ocs = $this->mockFormatShare(); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1286,7 +1288,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateLinkShareEnablePublicUpload($permissions, $publicUpload, $expireDate, $password) { $ocs = $this->mockFormatShare(); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1321,7 +1323,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateLinkShareInvalidDate() { $ocs = $this->mockFormatShare(); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1359,7 +1361,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateLinkSharePublicUploadNotAllowed($permissions, $publicUpload, $expireDate, $password) { $ocs = $this->mockFormatShare(); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1380,7 +1382,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateLinkSharePublicUploadOnFile() { $ocs = $this->mockFormatShare(); - $file = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $file = $this->getMockBuilder(File::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1400,7 +1402,7 @@ class ShareAPIControllerTest extends TestCase { $date = new \DateTime('2000-01-01'); $date->setTime(0,0,0); - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) @@ -1434,7 +1436,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateLinkShareExpireDateDoesNotChangeOther() { $ocs = $this->mockFormatShare(); - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) @@ -1473,7 +1475,7 @@ class ShareAPIControllerTest extends TestCase { $date = new \DateTime('2000-01-01'); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1510,7 +1512,7 @@ class ShareAPIControllerTest extends TestCase { $date = new \DateTime('2000-01-01'); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1546,7 +1548,7 @@ class ShareAPIControllerTest extends TestCase { $date = new \DateTime('2000-01-01'); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1580,7 +1582,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateOtherPermissions() { $ocs = $this->mockFormatShare(); - $file = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $file = $this->getMockBuilder(File::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1750,9 +1752,9 @@ class ShareAPIControllerTest extends TestCase { } public function dataFormatShare() { - $file = $this->getMockBuilder('\OCP\Files\File')->getMock(); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); - $parent = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $file = $this->getMockBuilder(File::class)->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); + $parent = $this->getMockBuilder(Folder::class)->getMock(); $file->method('getMimeType')->willReturn('myMimeType'); $folder->method('getMimeType')->willReturn('myFolderMimeType'); @@ -1769,18 +1771,18 @@ class ShareAPIControllerTest extends TestCase { $cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock(); $cache->method('getNumericStorageId')->willReturn(100); - $storage = $this->getMockBuilder('\OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('getId')->willReturn('storageId'); $storage->method('getCache')->willReturn($cache); $file->method('getStorage')->willReturn($storage); $folder->method('getStorage')->willReturn($storage); - $owner = $this->getMockBuilder('\OCP\IUser')->getMock(); + $owner = $this->getMockBuilder(IUser::class)->getMock(); $owner->method('getDisplayName')->willReturn('ownerDN'); - $initiator = $this->getMockBuilder('\OCP\IUser')->getMock(); + $initiator = $this->getMockBuilder(IUser::class)->getMock(); $initiator->method('getDisplayName')->willReturn('initiatorDN'); - $recipient = $this->getMockBuilder('\OCP\IUser')->getMock(); + $recipient = $this->getMockBuilder(IUser::class)->getMock(); $recipient->method('getDisplayName')->willReturn('recipientDN'); $result = []; diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index 7a017b5e3b7..d1b30d77f32 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -35,6 +35,12 @@ use OC\Files\Filesystem; use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\Files_Sharing\Controller\ShareController; use OCP\AppFramework\Http\DataResponse; +use OCP\IConfig; +use OCP\IL10N; +use OCP\ILogger; +use OCP\IPreview; +use OCP\IRequest; +use OCP\IUser; use OCP\Share\Exceptions\ShareNotFound; use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Http\RedirectResponse; @@ -83,11 +89,11 @@ class ShareControllerTest extends \Test\TestCase { $this->appName = 'files_sharing'; $this->shareManager = $this->getMockBuilder('\OC\Share20\Manager')->disableOriginalConstructor()->getMock(); - $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->getMock(); - $this->session = $this->getMockBuilder('\OCP\ISession')->getMock(); - $this->previewManager = $this->getMockBuilder('\OCP\IPreview')->getMock(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock(); + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock(); + $this->session = $this->getMockBuilder(ISession::class)->getMock(); + $this->previewManager = $this->getMockBuilder(IPreview::class)->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); + $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); $this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider') ->disableOriginalConstructor()->getMock(); $this->federatedShareProvider->expects($this->any()) @@ -98,11 +104,11 @@ class ShareControllerTest extends \Test\TestCase { $this->shareController = new \OCA\Files_Sharing\Controller\ShareController( $this->appName, - $this->getMockBuilder('\OCP\IRequest')->getMock(), + $this->getMockBuilder(IRequest::class)->getMock(), $this->config, $this->urlGenerator, $this->userManager, - $this->getMockBuilder('\OCP\ILogger')->getMock(), + $this->getMockBuilder(ILogger::class)->getMock(), $this->getMockBuilder('\OCP\Activity\IManager')->getMock(), $this->shareManager, $this->session, @@ -110,7 +116,7 @@ class ShareControllerTest extends \Test\TestCase { $this->getMockBuilder('\OCP\Files\IRootFolder')->getMock(), $this->federatedShareProvider, $this->eventDispatcher, - $this->getMockBuilder('\OCP\IL10N')->getMock(), + $this->getMockBuilder(IL10N::class)->getMock(), $this->getMockBuilder('\OCP\Defaults')->getMock() ); @@ -320,7 +326,7 @@ class ShareControllerTest extends \Test\TestCase { public function testShowShare() { - $owner = $this->getMockBuilder('OCP\IUser')->getMock(); + $owner = $this->getMockBuilder(IUser::class)->getMock(); $owner->method('getDisplayName')->willReturn('ownerDisplay'); $owner->method('getUID')->willReturn('ownerUID'); @@ -412,7 +418,7 @@ class ShareControllerTest extends \Test\TestCase { * @expectedException \OCP\Files\NotFoundException */ public function testShowShareInvalid() { - $owner = $this->getMockBuilder('OCP\IUser')->getMock(); + $owner = $this->getMockBuilder(IUser::class)->getMock(); $owner->method('getDisplayName')->willReturn('ownerDisplay'); $owner->method('getUID')->willReturn('ownerUID'); diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index 9f60261c203..37319dd17b2 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -27,7 +27,6 @@ namespace OCA\Files_Sharing\Tests\External; use OC\Federation\CloudIdManager; use OC\Files\Storage\StorageFactory; -use OCA\FederatedFileSharing\DiscoveryManager; use OCA\Files_Sharing\External\Manager; use OCA\Files_Sharing\External\MountProvider; use OCA\Files_Sharing\Tests\TestCase; @@ -68,7 +67,7 @@ class ManagerTest extends TestCase { $this->createUser($this->uid, ''); $this->user = \OC::$server->getUserManager()->get($this->uid); $this->mountManager = new \OC\Files\Mount\Manager(); - $this->clientService = $this->getMockBuilder('\OCP\Http\Client\IClientService') + $this->clientService = $this->getMockBuilder(IClientService::class) ->disableOriginalConstructor()->getMock(); $this->manager = new Manager( diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php index 04476987a32..68c62427e34 100644 --- a/apps/files_sharing/tests/MountProviderTest.php +++ b/apps/files_sharing/tests/MountProviderTest.php @@ -60,11 +60,11 @@ class MountProviderTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('OCP\IConfig')->getMock(); - $this->user = $this->getMockBuilder('OCP\IUser')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); + $this->user = $this->getMockBuilder(IUser::class)->getMock(); $this->loader = $this->getMockBuilder('OCP\Files\Storage\IStorageFactory')->getMock(); - $this->shareManager = $this->getMockBuilder('\OCP\Share\IManager')->getMock(); - $this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock(); + $this->shareManager = $this->getMockBuilder(IManager::class)->getMock(); + $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); $this->provider = new MountProvider($this->config, $this->shareManager, $this->logger); } diff --git a/apps/files_trashbin/tests/ExpirationTest.php b/apps/files_trashbin/tests/ExpirationTest.php index 86c9d21fe57..9d9f8ec027e 100644 --- a/apps/files_trashbin/tests/ExpirationTest.php +++ b/apps/files_trashbin/tests/ExpirationTest.php @@ -23,6 +23,7 @@ use OCA\Files_Trashbin\Expiration; use \OCA\Files_Trashbin\Tests; +use OCP\IConfig; class ExpirationTest extends \Test\TestCase { const SECONDS_PER_DAY = 86400; //60*60*24 @@ -200,10 +201,10 @@ class ExpirationTest extends \Test\TestCase { /** * * @param string $returnValue - * @return \OCP\IConfig + * @return IConfig */ private function getMockedConfig($returnValue){ - $mockedConfig = $this->getMockBuilder('\OCP\IConfig') + $mockedConfig = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->setMethods( [ diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php index bdddafcf016..a05fd33f306 100644 --- a/apps/files_trashbin/tests/StorageTest.php +++ b/apps/files_trashbin/tests/StorageTest.php @@ -37,6 +37,7 @@ use OCP\Files\Cache\ICache; use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\ILogger; +use OCP\IUserManager; use Symfony\Component\EventDispatcher\EventDispatcher; /** @@ -535,7 +536,7 @@ class StorageTest extends \Test\TestCase { $tmpStorage = $this->getMockBuilder('\OC\Files\Storage\Temporary') ->disableOriginalConstructor()->getMock($cache); $tmpStorage->expects($this->any())->method('getCache')->willReturn($cache); - $userManager = $this->getMockBuilder('OCP\IUserManager') + $userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor()->getMock(); $userManager->expects($this->any()) ->method('userExists')->willReturn($userExists); diff --git a/apps/files_versions/tests/ExpirationTest.php b/apps/files_versions/tests/ExpirationTest.php index 7fe6b279b9a..4e4f500d812 100644 --- a/apps/files_versions/tests/ExpirationTest.php +++ b/apps/files_versions/tests/ExpirationTest.php @@ -24,6 +24,7 @@ namespace OCA\Files_Versions\Tests; use \OCA\Files_Versions\Expiration; +use OCP\IConfig; class ExpirationTest extends \Test\TestCase { const SECONDS_PER_DAY = 86400; //60*60*24 @@ -172,7 +173,7 @@ class ExpirationTest extends \Test\TestCase { * @return \OCP\IConfig */ private function getMockedConfig($returnValue){ - $mockedConfig = $this->getMockBuilder('\OCP\IConfig') + $mockedConfig = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->setMethods( [ diff --git a/apps/provisioning_api/tests/Controller/AppsControllerTest.php b/apps/provisioning_api/tests/Controller/AppsControllerTest.php index c891433258f..7bd20e4233f 100644 --- a/apps/provisioning_api/tests/Controller/AppsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/AppsControllerTest.php @@ -28,10 +28,9 @@ namespace OCA\Provisioning_API\Tests\Controller; -use OC\OCSClient; use OCA\Provisioning_API\Controller\AppsController; -use OCP\API; use OCP\App\IAppManager; +use OCP\IRequest; use OCP\IUserSession; /** @@ -56,7 +55,7 @@ class AppsControllerTest extends \OCA\Provisioning_API\Tests\TestCase { $this->groupManager = \OC::$server->getGroupManager(); $this->userSession = \OC::$server->getUserSession(); - $request = $this->getMockBuilder('OCP\IRequest') + $request = $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index 344f1fe6352..9d70e123cde 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -29,6 +29,8 @@ namespace OCA\Provisioning_API\Tests\Controller; use OCA\Provisioning_API\Controller\GroupsController; use OCP\IGroupManager; use OCP\ILogger; +use OCP\IRequest; +use OCP\IUser; use OCP\IUserSession; class GroupsControllerTest extends \Test\TestCase { @@ -59,7 +61,7 @@ class GroupsControllerTest extends \Test\TestCase { $this->userSession = $this->getMockBuilder('OCP\IUserSession') ->disableOriginalConstructor() ->getMock(); - $request = $this->getMockBuilder('OCP\IRequest') + $request = $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor() ->getMock(); @@ -91,7 +93,7 @@ class GroupsControllerTest extends \Test\TestCase { * @return \OCP\IUser|\PHPUnit_Framework_MockObject_MockObject */ private function createUser($uid) { - $user = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $user = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $user ->method('getUID') ->willReturn($uid); diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index 692b94556c5..e9d0a704f4f 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -1128,12 +1128,12 @@ class UsersControllerTest extends TestCase { } public function testEditUserAdminUserSelfEditChangeValidQuota() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('UID')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser->expects($this->once()) ->method('setQuota') ->with('2.9 MB'); @@ -1166,12 +1166,12 @@ class UsersControllerTest extends TestCase { * @expectedExceptionMessage Invalid quota value ABC */ public function testEditUserAdminUserSelfEditChangeInvalidQuota() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('UID')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) ->method('getUser') @@ -1195,12 +1195,12 @@ class UsersControllerTest extends TestCase { } public function testEditUserAdminUserEditChangeValidQuota() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('admin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser->expects($this->once()) ->method('setQuota') ->with('2.9 MB'); @@ -1413,12 +1413,12 @@ class UsersControllerTest extends TestCase { } public function testEditUserSubadminUserAccessible() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('subadmin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser->expects($this->once()) ->method('setQuota') ->with('2.9 MB'); @@ -1456,12 +1456,12 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 997 */ public function testEditUserSubadminUserInaccessible() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('subadmin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) ->method('getUser') @@ -1496,7 +1496,7 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 101 */ public function testDeleteUserNotExistingUser() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') @@ -1519,12 +1519,12 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 101 */ public function testDeleteUserSelf() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('UID')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser ->expects($this->once()) ->method('getUID') @@ -1543,12 +1543,12 @@ class UsersControllerTest extends TestCase { } public function testDeleteSuccessfulUserAsAdmin() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('admin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser ->expects($this->once()) ->method('getUID') @@ -1580,12 +1580,12 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 101 */ public function testDeleteUnsuccessfulUserAsAdmin() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('admin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser ->expects($this->once()) ->method('getUID') @@ -1613,12 +1613,12 @@ class UsersControllerTest extends TestCase { } public function testDeleteSuccessfulUserAsSubadmin() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('subadmin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser ->expects($this->once()) ->method('getUID') @@ -1661,12 +1661,12 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 101 */ public function testDeleteUnsuccessfulUserAsSubadmin() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('subadmin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser ->expects($this->once()) ->method('getUID') @@ -1709,12 +1709,12 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 997 */ public function testDeleteUserAsSubAdminAndUserIsNotAccessible() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('subadmin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser ->expects($this->once()) ->method('getUID') @@ -1753,7 +1753,7 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 998 */ public function testGetUsersGroupsTargetUserNotExisting() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) ->method('getUser') @@ -1763,12 +1763,12 @@ class UsersControllerTest extends TestCase { } public function testGetUsersGroupsSelfTargetted() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->once()) ->method('getUID') ->will($this->returnValue('UserToLookup')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser ->expects($this->once()) ->method('getUID') @@ -1792,12 +1792,12 @@ class UsersControllerTest extends TestCase { } public function testGetUsersGroupsForAdminUser() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->exactly(2)) ->method('getUID') ->will($this->returnValue('admin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser ->expects($this->once()) ->method('getUID') @@ -1826,12 +1826,12 @@ class UsersControllerTest extends TestCase { } public function testGetUsersGroupsForSubAdminUserAndUserIsAccessible() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->exactly(2)) ->method('getUID') ->will($this->returnValue('subadmin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser ->expects($this->once()) ->method('getUID') @@ -1890,12 +1890,12 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 997 */ public function testGetUsersGroupsForSubAdminUserAndUserIsInaccessible() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->exactly(2)) ->method('getUID') ->will($this->returnValue('subadmin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser ->expects($this->once()) ->method('getUID') @@ -2108,7 +2108,7 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 101 */ public function testRemoveFromGroupWithNoTargetGroup() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) ->method('getUser') @@ -2122,7 +2122,7 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 101 */ public function testRemoveFromGroupWithEmptyTargetGroup() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) ->method('getUser') @@ -2136,7 +2136,7 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 102 */ public function testRemoveFromGroupWithNotExistingTargetGroup() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) ->method('getUser') @@ -2155,7 +2155,7 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 103 */ public function testRemoveFromGroupWithNotExistingTargetUser() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) @@ -2180,12 +2180,12 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 104 */ public function testRemoveFromGroupWithoutPermission() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->once()) ->method('getUID') ->will($this->returnValue('unauthorizedUser')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) @@ -2222,12 +2222,12 @@ class UsersControllerTest extends TestCase { * @expectedExceptionMessage Cannot remove yourself from the admin group */ public function testRemoveFromGroupAsAdminFromAdmin() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('admin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser ->expects($this->once()) ->method('getUID') @@ -2272,12 +2272,12 @@ class UsersControllerTest extends TestCase { * @expectedExceptionMessage Cannot remove yourself from this group as you are a SubAdmin */ public function testRemoveFromGroupAsSubAdminFromSubAdmin() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('subadmin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser ->expects($this->once()) ->method('getUID') @@ -2327,12 +2327,12 @@ class UsersControllerTest extends TestCase { * @expectedExceptionMessage Cannot remove user from this group as this is the only remaining group you are a SubAdmin of */ public function testRemoveFromGroupAsSubAdminFromLastSubAdminGroup() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('subadmin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); $targetGroup ->expects($this->any()) @@ -2384,12 +2384,12 @@ class UsersControllerTest extends TestCase { } public function testRemoveFromGroupSuccessful() { - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->any()) ->method('getUID') ->will($this->returnValue('admin')); - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) @@ -2446,7 +2446,7 @@ class UsersControllerTest extends TestCase { */ public function testAddSubAdminWithNotExistingTargetGroup() { - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $this->userManager ->expects($this->once()) ->method('get') @@ -2467,7 +2467,7 @@ class UsersControllerTest extends TestCase { * @expectedExceptionMessage Cannot create subadmins for admin group */ public function testAddSubAdminToAdminGroup() { - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); $targetGroup ->expects($this->once()) @@ -2488,7 +2488,7 @@ class UsersControllerTest extends TestCase { } public function testAddSubAdminTwice() { - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); $this->userManager ->expects($this->once()) @@ -2516,7 +2516,7 @@ class UsersControllerTest extends TestCase { } public function testAddSubAdminSuccessful() { - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); $this->userManager ->expects($this->once()) @@ -2554,7 +2554,7 @@ class UsersControllerTest extends TestCase { * @expectedExceptionMessage Unknown error occurred */ public function testAddSubAdminUnsuccessful() { - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); $this->userManager ->expects($this->once()) @@ -2607,7 +2607,7 @@ class UsersControllerTest extends TestCase { * @expectedExceptionMessage Group does not exist */ public function testRemoveSubAdminNotExistingTargetGroup() { - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $this->userManager ->expects($this->once()) ->method('get') @@ -2629,7 +2629,7 @@ class UsersControllerTest extends TestCase { * @expectedExceptionMessage User is not a subadmin of this group */ public function testRemoveSubAdminFromNotASubadmin() { - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); $this->userManager ->expects($this->once()) @@ -2657,7 +2657,7 @@ class UsersControllerTest extends TestCase { } public function testRemoveSubAdminSuccessful() { - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); $this->userManager ->expects($this->once()) @@ -2695,7 +2695,7 @@ class UsersControllerTest extends TestCase { * @expectedExceptionMessage Unknown error occurred */ public function testRemoveSubAdminUnsuccessful() { - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); $this->userManager ->expects($this->once()) @@ -2743,7 +2743,7 @@ class UsersControllerTest extends TestCase { } public function testGetUserSubAdminGroupsWithGroups() { - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); $targetGroup ->expects($this->once()) @@ -2775,7 +2775,7 @@ class UsersControllerTest extends TestCase { * @expectedExceptionMessage Unknown error occurred */ public function testGetUserSubAdminGroupsWithoutGroups() { - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $this->userManager ->expects($this->once()) ->method('get') @@ -2797,7 +2797,7 @@ class UsersControllerTest extends TestCase { } public function testEnableUser() { - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser->expects($this->once()) ->method('setEnabled') ->with(true); @@ -2806,7 +2806,7 @@ class UsersControllerTest extends TestCase { ->method('get') ->with('RequestedUser') ->will($this->returnValue($targetUser)); - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->exactly(2)) ->method('getUID') @@ -2824,7 +2824,7 @@ class UsersControllerTest extends TestCase { } public function testDisableUser() { - $targetUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $targetUser->expects($this->once()) ->method('setEnabled') ->with(false); @@ -2833,7 +2833,7 @@ class UsersControllerTest extends TestCase { ->method('get') ->with('RequestedUser') ->will($this->returnValue($targetUser)); - $loggedInUser = $this->getMockBuilder('\OCP\IUser')->disableOriginalConstructor()->getMock(); + $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $loggedInUser ->expects($this->exactly(2)) ->method('getUID') @@ -2974,14 +2974,14 @@ class UsersControllerTest extends TestCase { * @expectedExceptionCode 997 */ public function testResendWelcomeMessageAsSubAdminAndUserIsNotAccessible() { - $loggedInUser = $this->getMockBuilder('OCP\IUser') + $loggedInUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $loggedInUser ->expects($this->exactly(1)) ->method('getUID') ->will($this->returnValue('subadmin')); - $targetUser = $this->getMockBuilder('OCP\IUser') + $targetUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $this->userSession @@ -3020,10 +3020,10 @@ class UsersControllerTest extends TestCase { * @expectedExceptionMessage Email address not available */ public function testResendWelcomeMessageNoEmail() { - $loggedInUser = $this->getMockBuilder('OCP\IUser') + $loggedInUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); - $targetUser = $this->getMockBuilder('OCP\IUser') + $targetUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $this->userSession @@ -3061,10 +3061,10 @@ class UsersControllerTest extends TestCase { * @expectedExceptionMessage Email address not available */ public function testResendWelcomeMessageNullEmail() { - $loggedInUser = $this->getMockBuilder('OCP\IUser') + $loggedInUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); - $targetUser = $this->getMockBuilder('OCP\IUser') + $targetUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $this->userSession @@ -3097,10 +3097,10 @@ class UsersControllerTest extends TestCase { } public function testResendWelcomeMessageSuccess() { - $loggedInUser = $this->getMockBuilder('OCP\IUser') + $loggedInUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); - $targetUser = $this->getMockBuilder('OCP\IUser') + $targetUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $targetUser @@ -3167,10 +3167,10 @@ class UsersControllerTest extends TestCase { } public function testResendWelcomeMessageSuccessWithFallbackLanguage() { - $loggedInUser = $this->getMockBuilder('OCP\IUser') + $loggedInUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); - $targetUser = $this->getMockBuilder('OCP\IUser') + $targetUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $targetUser @@ -3242,10 +3242,10 @@ class UsersControllerTest extends TestCase { * @expectedExceptionMessage Sending email failed */ public function testResendWelcomeMessageFailed() { - $loggedInUser = $this->getMockBuilder('OCP\IUser') + $loggedInUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); - $targetUser = $this->getMockBuilder('OCP\IUser') + $targetUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $targetUser diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index 68a645ec0e6..a04b0a355cf 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -103,17 +103,17 @@ class ShareByMailProviderTest extends TestCase { $this->shareManager = \OC::$server->getShareManager(); $this->connection = \OC::$server->getDatabaseConnection(); - $this->l = $this->getMockBuilder('OCP\IL10N')->getMock(); + $this->l = $this->getMockBuilder(IL10N::class)->getMock(); $this->l->method('t') ->will($this->returnCallback(function($text, $parameters = []) { return vsprintf($text, $parameters); })); - $this->logger = $this->getMockBuilder('OCP\ILogger')->getMock(); + $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock(); - $this->userManager = $this->getMockBuilder('OCP\IUserManager')->getMock(); + $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); $this->secureRandom = $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(); $this->mailer = $this->getMockBuilder('\OCP\Mail\IMailer')->getMock(); - $this->urlGenerator = $this->getMockBuilder('\OCP\IUrlGenerator')->getMock(); + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock(); $this->share = $this->getMockBuilder('\OCP\Share\IShare')->getMock(); $this->activityManager = $this->getMockBuilder('OCP\Activity\IManager')->getMock(); $this->settingsManager = $this->getMockBuilder(SettingsManager::class)->disableOriginalConstructor()->getMock(); diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php index c6a40b5942e..ca1f7fe0ff7 100644 --- a/apps/theming/tests/Controller/IconControllerTest.php +++ b/apps/theming/tests/Controller/IconControllerTest.php @@ -61,7 +61,7 @@ class IconControllerTest extends TestCase { private $imageManager; public function setUp() { - $this->request = $this->getMockBuilder('OCP\IRequest')->getMock(); + $this->request = $this->getMockBuilder(IRequest::class)->getMock(); $this->themingDefaults = $this->getMockBuilder('OCA\Theming\ThemingDefaults') ->disableOriginalConstructor()->getMock(); $this->util = $this->getMockBuilder('\OCA\Theming\Util')->disableOriginalConstructor() @@ -69,7 +69,7 @@ class IconControllerTest extends TestCase { $this->timeFactory = $this->getMockBuilder('OCP\AppFramework\Utility\ITimeFactory') ->disableOriginalConstructor() ->getMock(); - $this->config = $this->getMockBuilder('OCP\IConfig')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->iconBuilder = $this->getMockBuilder('OCA\Theming\IconBuilder') ->disableOriginalConstructor()->getMock(); $this->imageManager = $this->getMockBuilder('OCA\Theming\ImageManager')->disableOriginalConstructor()->getMock(); diff --git a/apps/theming/tests/IconBuilderTest.php b/apps/theming/tests/IconBuilderTest.php index 9b5b1933201..6821655eafe 100644 --- a/apps/theming/tests/IconBuilderTest.php +++ b/apps/theming/tests/IconBuilderTest.php @@ -51,7 +51,7 @@ class IconBuilderTest extends TestCase { protected function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->appData = $this->createMock(IAppData::class); $this->themingDefaults = $this->getMockBuilder('OCA\Theming\ThemingDefaults') ->disableOriginalConstructor()->getMock(); diff --git a/apps/theming/tests/ImageManagerTest.php b/apps/theming/tests/ImageManagerTest.php index 4df49633d80..65bcb4dbc06 100644 --- a/apps/theming/tests/ImageManagerTest.php +++ b/apps/theming/tests/ImageManagerTest.php @@ -40,7 +40,7 @@ class ImageManager extends TestCase { protected function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->appData = $this->getMockBuilder('OCP\Files\IAppData')->getMock(); $this->imageManager = new \OCA\Theming\ImageManager( $this->config, diff --git a/apps/theming/tests/Settings/AdminTest.php b/apps/theming/tests/Settings/AdminTest.php index 70939677582..fb55640e968 100644 --- a/apps/theming/tests/Settings/AdminTest.php +++ b/apps/theming/tests/Settings/AdminTest.php @@ -45,10 +45,10 @@ class AdminTest extends TestCase { public function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); - $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); + $this->l10n = $this->getMockBuilder(IL10N::class)->getMock(); $this->themingDefaults = $this->getMockBuilder('\OCA\Theming\ThemingDefaults')->disableOriginalConstructor()->getMock(); - $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->getMock(); + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock(); $this->admin = new Admin( $this->config, diff --git a/apps/user_ldap/tests/Settings/AdminTest.php b/apps/user_ldap/tests/Settings/AdminTest.php index cd06b27f913..86234861536 100644 --- a/apps/user_ldap/tests/Settings/AdminTest.php +++ b/apps/user_ldap/tests/Settings/AdminTest.php @@ -43,7 +43,7 @@ class AdminTest extends TestCase { public function setUp() { parent::setUp(); - $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock(); + $this->l10n = $this->getMockBuilder(IL10N::class)->getMock(); $this->admin = new Admin( $this->l10n diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php index 5f6148b1332..b118a613e87 100644 --- a/apps/user_ldap/tests/User/UserTest.php +++ b/apps/user_ldap/tests/User/UserTest.php @@ -38,6 +38,7 @@ use OCP\Image; use OCP\IUser; use OCP\IUserManager; use OCP\Notification\IManager as INotificationManager; +use OCP\Notification\INotification; /** * Class UserTest @@ -134,7 +135,7 @@ class UserTest extends \Test\TestCase { $uid = 'alice'; $dn = 'uid=alice,dc=foo,dc=bar'; - $uuser = $this->getMockBuilder('\OCP\IUser') + $uuser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $uuser->expects($this->once()) @@ -1279,7 +1280,7 @@ class UserTest extends \Test\TestCase { return array(); })); - $notification = $this->getMockBuilder('OCP\Notification\INotification') + $notification = $this->getMockBuilder(INotification::class) ->disableOriginalConstructor() ->getMock(); $notification->expects($this->any()) @@ -1353,7 +1354,7 @@ class UserTest extends \Test\TestCase { return array(); })); - $notification = $this->getMockBuilder('OCP\Notification\INotification') + $notification = $this->getMockBuilder(INotification::class) ->disableOriginalConstructor() ->getMock(); $notification->expects($this->any()) diff --git a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php index 91da8931604..b7051870115 100644 --- a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php +++ b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php @@ -21,11 +21,12 @@ namespace OCA\WorkflowEngine\Tests\Check; +use OCP\IL10N; class AbstractStringCheckTest extends \Test\TestCase { protected function getCheckMock() { - $l = $this->getMockBuilder('OCP\IL10N') + $l = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor() ->getMock(); $l->expects($this->any()) diff --git a/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php b/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php index efe8f6372dd..9e313122a1f 100644 --- a/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php +++ b/apps/workflowengine/tests/Check/RequestRemoteAddressTest.php @@ -21,6 +21,8 @@ namespace OCA\WorkflowEngine\Tests\Check; +use OCP\IL10N; +use OCP\IRequest; class RequestRemoteAddressTest extends \Test\TestCase { @@ -31,7 +33,7 @@ class RequestRemoteAddressTest extends \Test\TestCase { * @return \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject */ protected function getL10NMock() { - $l = $this->getMockBuilder('OCP\IL10N') + $l = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor() ->getMock(); $l->expects($this->any()) @@ -45,7 +47,7 @@ class RequestRemoteAddressTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->request = $this->getMockBuilder('OCP\IRequest') + $this->request = $this->getMockBuilder(IRequest::class) ->getMock(); } diff --git a/apps/workflowengine/tests/Check/RequestTimeTest.php b/apps/workflowengine/tests/Check/RequestTimeTest.php index c07b4bf8775..7249f5109f2 100644 --- a/apps/workflowengine/tests/Check/RequestTimeTest.php +++ b/apps/workflowengine/tests/Check/RequestTimeTest.php @@ -21,6 +21,7 @@ namespace OCA\WorkflowEngine\Tests\Check; +use OCP\IL10N; class RequestTimeTest extends \Test\TestCase { @@ -31,7 +32,7 @@ class RequestTimeTest extends \Test\TestCase { * @return \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject */ protected function getL10NMock() { - $l = $this->getMockBuilder('OCP\IL10N') + $l = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor() ->getMock(); $l->expects($this->any()) diff --git a/tests/Core/Controller/AvatarControllerTest.php b/tests/Core/Controller/AvatarControllerTest.php index 1a1f1130480..de568438022 100644 --- a/tests/Core/Controller/AvatarControllerTest.php +++ b/tests/Core/Controller/AvatarControllerTest.php @@ -85,16 +85,16 @@ class AvatarControllerTest extends \Test\TestCase { $this->avatarManager = $this->getMockBuilder('OCP\IAvatarManager')->getMock(); $this->cache = $this->getMockBuilder('OCP\ICache') ->disableOriginalConstructor()->getMock(); - $this->l = $this->getMockBuilder('OCP\IL10N')->getMock(); + $this->l = $this->getMockBuilder(IL10N::class)->getMock(); $this->l->method('t')->will($this->returnArgument(0)); - $this->userManager = $this->getMockBuilder('OCP\IUserManager')->getMock(); - $this->request = $this->getMockBuilder('OCP\IRequest')->getMock(); + $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); + $this->request = $this->getMockBuilder(IRequest::class)->getMock(); $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock(); - $this->logger = $this->getMockBuilder('OCP\ILogger')->getMock(); + $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); $this->timeFactory = $this->getMockBuilder('OC\AppFramework\Utility\TimeFactory')->getMock(); $this->avatarMock = $this->getMockBuilder('OCP\IAvatar')->getMock(); - $this->userMock = $this->getMockBuilder('OCP\IUser')->getMock(); + $this->userMock = $this->getMockBuilder(IUser::class)->getMock(); $this->avatarController = new AvatarController( 'core', diff --git a/tests/Core/Controller/ChangePasswordControllerTest.php b/tests/Core/Controller/ChangePasswordControllerTest.php index ea3abb58e2f..851b5bd6c76 100644 --- a/tests/Core/Controller/ChangePasswordControllerTest.php +++ b/tests/Core/Controller/ChangePasswordControllerTest.php @@ -29,6 +29,7 @@ use OCP\AppFramework\Http\JSONResponse; use OCP\IGroupManager; use OCP\IL10N; use OCP\IRequest; +use OCP\IUser; use OCP\IUserManager; class ChangePasswordControllerTest extends \Test\TestCase { @@ -91,7 +92,7 @@ class ChangePasswordControllerTest extends \Test\TestCase { } public function testChangePersonalPasswordCommonPassword() { - $user = $this->getMockBuilder('OCP\IUser')->getMock(); + $user = $this->getMockBuilder(IUser::class)->getMock(); $this->userManager->expects($this->once()) ->method('checkPassword') ->with($this->userId, 'old') @@ -114,7 +115,7 @@ class ChangePasswordControllerTest extends \Test\TestCase { } public function testChangePersonalPasswordNoNewPassword() { - $user = $this->getMockBuilder('OCP\IUser')->getMock(); + $user = $this->getMockBuilder(IUser::class)->getMock(); $this->userManager->expects($this->once()) ->method('checkPassword') ->with($this->userId, 'old') @@ -130,7 +131,7 @@ class ChangePasswordControllerTest extends \Test\TestCase { } public function testChangePersonalPasswordCantSetPassword() { - $user = $this->getMockBuilder('OCP\IUser')->getMock(); + $user = $this->getMockBuilder(IUser::class)->getMock(); $this->userManager->expects($this->once()) ->method('checkPassword') ->with($this->userId, 'old') @@ -150,7 +151,7 @@ class ChangePasswordControllerTest extends \Test\TestCase { } public function testChangePersonalPassword() { - $user = $this->getMockBuilder('OCP\IUser')->getMock(); + $user = $this->getMockBuilder(IUser::class)->getMock(); $this->userManager->expects($this->once()) ->method('checkPassword') ->with($this->userId, 'old') diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php index 196b1da352b..1e51de649e3 100644 --- a/tests/Core/Controller/LostControllerTest.php +++ b/tests/Core/Controller/LostControllerTest.php @@ -105,9 +105,9 @@ class LostControllerTest extends \Test\TestCase { })); $this->defaults = $this->getMockBuilder('\OCP\Defaults') ->disableOriginalConstructor()->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager') + $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor()->getMock(); - $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor()->getMock(); $this->mailer = $this->getMockBuilder('\OCP\Mail\IMailer') ->disableOriginalConstructor()->getMock(); @@ -115,7 +115,7 @@ class LostControllerTest extends \Test\TestCase { ->disableOriginalConstructor()->getMock(); $this->timeFactory = $this->getMockBuilder('\OCP\AppFramework\Utility\ITimeFactory') ->disableOriginalConstructor()->getMock(); - $this->request = $this->getMockBuilder('OCP\IRequest') + $this->request = $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor()->getMock(); $this->encryptionManager = $this->getMockBuilder(IManager::class) ->disableOriginalConstructor()->getMock(); diff --git a/tests/Core/Middleware/TwoFactorMiddlewareTest.php b/tests/Core/Middleware/TwoFactorMiddlewareTest.php index 56022c78bdd..eb72b3e6796 100644 --- a/tests/Core/Middleware/TwoFactorMiddlewareTest.php +++ b/tests/Core/Middleware/TwoFactorMiddlewareTest.php @@ -22,8 +22,10 @@ namespace Test\Core\Middleware; +use OC\Authentication\TwoFactorAuth\Manager; use OC\Core\Middleware\TwoFactorMiddleware; use OC\AppFramework\Http\Request; +use OC\User\Session; use OCP\AppFramework\Controller; use OCP\AppFramework\Utility\IControllerMethodReflector; use OCP\IConfig; @@ -51,10 +53,10 @@ class TwoFactorMiddlewareTest extends TestCase { protected function setUp() { parent::setUp(); - $this->twoFactorManager = $this->getMockBuilder('\OC\Authentication\TwoFactorAuth\Manager') + $this->twoFactorManager = $this->getMockBuilder(Manager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSession = $this->getMockBuilder('\OC\User\Session') + $this->userSession = $this->getMockBuilder(Session::class) ->disableOriginalConstructor() ->getMock(); $this->session = $this->createMock(ISession::class); diff --git a/tests/Settings/Controller/AdminSettingsControllerTest.php b/tests/Settings/Controller/AdminSettingsControllerTest.php index 51357f67a2d..d5650b397fa 100644 --- a/tests/Settings/Controller/AdminSettingsControllerTest.php +++ b/tests/Settings/Controller/AdminSettingsControllerTest.php @@ -25,6 +25,7 @@ namespace Tests\Settings\Controller; use OC\Settings\Admin\TipsTricks; use OC\Settings\Controller\AdminSettingsController; use OCP\AppFramework\Http\TemplateResponse; +use OCP\IConfig; use OCP\INavigationManager; use OCP\IRequest; use OCP\Settings\IManager; @@ -52,9 +53,9 @@ class AdminSettingsControllerTest extends TestCase { public function setUp() { parent::setUp(); - $this->request = $this->getMockBuilder('\OCP\IRequest')->getMock(); - $this->navigationManager = $this->getMockBuilder('\OCP\INavigationManager')->getMock(); - $this->settingsManager = $this->getMockBuilder('\OCP\Settings\IManager')->getMock(); + $this->request = $this->getMockBuilder(IRequest::class)->getMock(); + $this->navigationManager = $this->getMockBuilder(INavigationManager::class)->getMock(); + $this->settingsManager = $this->getMockBuilder(IManager::class)->getMock(); $this->adminSettingsController = new AdminSettingsController( 'settings', @@ -87,7 +88,7 @@ class AdminSettingsControllerTest extends TestCase { ->expects($this->once()) ->method('getAdminSettings') ->with('test') - ->willReturn([5 => new TipsTricks($this->getMockBuilder('\OCP\IConfig')->getMock())]); + ->willReturn([5 => new TipsTricks($this->getMockBuilder(IConfig::class)->getMock())]); $expected = new TemplateResponse('settings', 'settings/frame', ['forms' => ['personal' => [], 'admin' => []], 'content' => '']); $this->assertEquals($expected, $this->adminSettingsController->index('test')); diff --git a/tests/Settings/Controller/CertificateControllerTest.php b/tests/Settings/Controller/CertificateControllerTest.php index 48d34a1542b..fb5076dc012 100644 --- a/tests/Settings/Controller/CertificateControllerTest.php +++ b/tests/Settings/Controller/CertificateControllerTest.php @@ -51,10 +51,10 @@ class CertificateControllerTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->request = $this->getMockBuilder('\OCP\IRequest')->getMock(); + $this->request = $this->getMockBuilder(IRequest::class)->getMock(); $this->certificateManager = $this->getMockBuilder('\OCP\ICertificateManager')->getMock(); $this->systemCertificateManager = $this->getMockBuilder('\OCP\ICertificateManager')->getMock(); - $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock(); + $this->l10n = $this->getMockBuilder(IL10N::class)->getMock(); $this->appManager = $this->getMockBuilder('OCP\App\IAppManager')->getMock(); $this->certificateController = $this->getMockBuilder('OC\Settings\Controller\CertificateController') diff --git a/tests/Settings/Controller/CheckSetupControllerTest.php b/tests/Settings/Controller/CheckSetupControllerTest.php index 74eee3fea41..f0e203e714b 100644 --- a/tests/Settings/Controller/CheckSetupControllerTest.php +++ b/tests/Settings/Controller/CheckSetupControllerTest.php @@ -64,17 +64,17 @@ class CheckSetupControllerTest extends TestCase { public function setUp() { parent::setUp(); - $this->request = $this->getMockBuilder('\OCP\IRequest') + $this->request = $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor()->getMock(); - $this->config = $this->getMockBuilder('\OCP\IConfig') + $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor()->getMock(); - $this->clientService = $this->getMockBuilder('\OCP\Http\Client\IClientService') + $this->clientService = $this->getMockBuilder(IClientService::class) ->disableOriginalConstructor()->getMock(); $this->util = $this->getMockBuilder('\OC_Util') ->disableOriginalConstructor()->getMock(); - $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor()->getMock(); - $this->l10n = $this->getMockBuilder('\OCP\IL10N') + $this->l10n = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor()->getMock(); $this->l10n->expects($this->any()) ->method('t') @@ -83,7 +83,7 @@ class CheckSetupControllerTest extends TestCase { })); $this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker') ->disableOriginalConstructor()->getMock(); - $this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock(); + $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); $this->checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController') ->setConstructorArgs([ 'settings', diff --git a/tests/Settings/Controller/EncryptionControllerTest.php b/tests/Settings/Controller/EncryptionControllerTest.php index e57f36353a6..b15a71fc016 100644 --- a/tests/Settings/Controller/EncryptionControllerTest.php +++ b/tests/Settings/Controller/EncryptionControllerTest.php @@ -25,11 +25,13 @@ use OC\DB\Connection; use OC\Files\View; use OC\Settings\Controller\EncryptionController; use OCP\App\IAppManager; +use OCA\Encryption\Migration; use OCP\IConfig; use OCP\IL10N; use OCP\ILogger; use OCP\IRequest; use OCP\IUserManager; +use OCP\UserInterface; use Test\TestCase; /** @@ -59,29 +61,29 @@ class EncryptionControllerTest extends TestCase { public function setUp() { parent::setUp(); - $this->request = $this->getMockBuilder('\\OCP\\IRequest') + $this->request = $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor()->getMock(); - $this->l10n = $this->getMockBuilder('\\OCP\\IL10N') + $this->l10n = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor()->getMock(); $this->l10n->expects($this->any()) ->method('t') ->will($this->returnCallback(function($message, array $replace) { return vsprintf($message, $replace); })); - $this->config = $this->getMockBuilder('\\OCP\\IConfig') + $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor()->getMock(); - $this->connection = $this->getMockBuilder('\\OC\\DB\\Connection') + $this->connection = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor()->getMock(); - $this->userManager = $this->getMockBuilder('\\OCP\\IUserManager') + $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor()->getMock(); - $this->view = $this->getMockBuilder('\\OC\\Files\\View') + $this->view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); - $this->logger = $this->getMockBuilder('\\OCP\\ILogger') + $this->logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor()->getMock(); $this->appManager = $this->getMockBuilder('\\OCP\\App\\IAppManager') ->disableOriginalConstructor()->getMock(); - $this->encryptionController = $this->getMockBuilder('\\OC\\Settings\\Controller\\EncryptionController') + $this->encryptionController = $this->getMockBuilder(EncryptionController::class) ->setConstructorArgs([ 'settings', $this->request, @@ -101,7 +103,7 @@ class EncryptionControllerTest extends TestCase { // we need to be able to autoload the class we're mocking \OC_App::registerAutoloading('encryption', \OC_App::getAppPath('encryption')); - $migration = $this->getMockBuilder('\\OCA\\Encryption\\Migration') + $migration = $this->getMockBuilder(Migration::class) ->disableOriginalConstructor()->getMock(); $this->encryptionController ->expects($this->once()) @@ -114,7 +116,7 @@ class EncryptionControllerTest extends TestCase { $migration ->expects($this->once()) ->method('updateDB'); - $backend = $this->getMockBuilder('\OCP\UserInterface') + $backend = $this->getMockBuilder(UserInterface::class) ->getMock(); $this->userManager ->expects($this->once()) diff --git a/tests/Settings/Controller/GroupsControllerTest.php b/tests/Settings/Controller/GroupsControllerTest.php index 340b39bf9dd..78df5f3a3cb 100644 --- a/tests/Settings/Controller/GroupsControllerTest.php +++ b/tests/Settings/Controller/GroupsControllerTest.php @@ -10,6 +10,7 @@ namespace Tests\Settings\Controller; +use OC\Group\Group; use OC\Group\MetaData; use OC\Settings\Controller\GroupsController; use OCP\AppFramework\Http; @@ -59,7 +60,7 @@ class GroupsControllerTest extends \Test\TestCase { * to test for subadmins. Thus the test always assumes you have admin permissions... */ public function testIndexSortByName() { - $firstGroup = $this->getMockBuilder('\OC\Group\Group') + $firstGroup = $this->getMockBuilder(Group::class) ->disableOriginalConstructor()->getMock(); $firstGroup ->method('getGID') @@ -67,7 +68,7 @@ class GroupsControllerTest extends \Test\TestCase { $firstGroup ->method('count') ->will($this->returnValue(12)); - $secondGroup = $this->getMockBuilder('\OC\Group\Group') + $secondGroup = $this->getMockBuilder(Group::class) ->disableOriginalConstructor()->getMock(); $secondGroup ->method('getGID') @@ -75,7 +76,7 @@ class GroupsControllerTest extends \Test\TestCase { $secondGroup ->method('count') ->will($this->returnValue(25)); - $thirdGroup = $this->getMockBuilder('\OC\Group\Group') + $thirdGroup = $this->getMockBuilder(Group::class) ->disableOriginalConstructor()->getMock(); $thirdGroup ->method('getGID') @@ -83,7 +84,7 @@ class GroupsControllerTest extends \Test\TestCase { $thirdGroup ->method('count') ->will($this->returnValue(14)); - $fourthGroup = $this->getMockBuilder('\OC\Group\Group') + $fourthGroup = $this->getMockBuilder(Group::class) ->disableOriginalConstructor()->getMock(); $fourthGroup ->method('getGID') @@ -151,7 +152,7 @@ class GroupsControllerTest extends \Test\TestCase { * to test for subadmins. Thus the test always assumes you have admin permissions... */ public function testIndexSortbyCount() { - $firstGroup = $this->getMockBuilder('\OC\Group\Group') + $firstGroup = $this->getMockBuilder(Group::class) ->disableOriginalConstructor()->getMock(); $firstGroup ->method('getGID') @@ -159,7 +160,7 @@ class GroupsControllerTest extends \Test\TestCase { $firstGroup ->method('count') ->will($this->returnValue(12)); - $secondGroup = $this->getMockBuilder('\OC\Group\Group') + $secondGroup = $this->getMockBuilder(Group::class) ->disableOriginalConstructor()->getMock(); $secondGroup ->method('getGID') @@ -167,7 +168,7 @@ class GroupsControllerTest extends \Test\TestCase { $secondGroup ->method('count') ->will($this->returnValue(25)); - $thirdGroup = $this->getMockBuilder('\OC\Group\Group') + $thirdGroup = $this->getMockBuilder(Group::class) ->disableOriginalConstructor()->getMock(); $thirdGroup ->method('getGID') @@ -175,7 +176,7 @@ class GroupsControllerTest extends \Test\TestCase { $thirdGroup ->method('count') ->will($this->returnValue(14)); - $fourthGroup = $this->getMockBuilder('\OC\Group\Group') + $fourthGroup = $this->getMockBuilder(Group::class) ->disableOriginalConstructor()->getMock(); $fourthGroup ->method('getGID') @@ -302,7 +303,7 @@ class GroupsControllerTest extends \Test\TestCase { } public function testDestroySuccessful() { - $group = $this->getMockBuilder('\OC\Group\Group') + $group = $this->getMockBuilder(Group::class) ->disableOriginalConstructor()->getMock(); $this->groupManager ->expects($this->once()) diff --git a/tests/Settings/Controller/UsersControllerTest.php b/tests/Settings/Controller/UsersControllerTest.php index cd08c834147..15c18fb7f08 100644 --- a/tests/Settings/Controller/UsersControllerTest.php +++ b/tests/Settings/Controller/UsersControllerTest.php @@ -11,9 +11,11 @@ namespace Tests\Settings\Controller; use OC\Accounts\AccountManager; +use OC\Group\Group; use OC\Group\Manager; use OC\Settings\Controller\UsersController; use OC\Settings\Mailer\NewUserMailHelper; +use OC\SubAdmin; use OCP\App\IAppManager; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; @@ -326,7 +328,7 @@ class UsersControllerTest extends \Test\TestCase { ->with('bar') ->will($this->returnValue($bar)); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin @@ -546,19 +548,19 @@ class UsersControllerTest extends \Test\TestCase { ->with('admin') ->will($this->returnValue($admin)); - $subgroup1 = $this->getMockBuilder('\OCP\IGroup') + $subgroup1 = $this->getMockBuilder(IGroup::class) ->disableOriginalConstructor() ->getMock(); $subgroup1->expects($this->any()) ->method('getGID') ->will($this->returnValue('SubGroup1')); - $subgroup2 = $this->getMockBuilder('\OCP\IGroup') + $subgroup2 = $this->getMockBuilder(IGroup::class) ->disableOriginalConstructor() ->getMock(); $subgroup2->expects($this->any()) ->method('getGID') ->will($this->returnValue('SubGroup2')); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin @@ -746,7 +748,7 @@ class UsersControllerTest extends \Test\TestCase { ->method('getUserGroupIds') ->will($this->onConsecutiveCalls(array('Users', 'Support'), array('admins', 'Support'), array('External Users'))); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin->expects($this->any()) @@ -865,7 +867,7 @@ class UsersControllerTest extends \Test\TestCase { ->with('') ->will($this->returnValue([$user])); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin->expects($this->once()) @@ -951,7 +953,7 @@ class UsersControllerTest extends \Test\TestCase { ->method('createUser') ->will($this->onConsecutiveCalls($user)); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin @@ -1006,13 +1008,13 @@ class UsersControllerTest extends \Test\TestCase { $user->expects($this->any()) ->method('isEnabled') ->willReturn(true); - $existingGroup = $this->getMockBuilder('\OCP\IGroup') + $existingGroup = $this->getMockBuilder(IGroup::class) ->disableOriginalConstructor()->getMock(); $existingGroup ->expects($this->once()) ->method('addUser') ->with($user); - $newGroup = $this->getMockBuilder('\OCP\IGroup') + $newGroup = $this->getMockBuilder(IGroup::class) ->disableOriginalConstructor()->getMock(); $newGroup ->expects($this->once()) @@ -1038,7 +1040,7 @@ class UsersControllerTest extends \Test\TestCase { ->with($user) ->will($this->onConsecutiveCalls(array('NewGroup', 'ExistingGroup'))); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin @@ -1358,7 +1360,7 @@ class UsersControllerTest extends \Test\TestCase { ->with('UserToDelete') ->will($this->returnValue($toDeleteUser)); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin->expects($this->once()) @@ -1441,7 +1443,7 @@ class UsersControllerTest extends \Test\TestCase { ->with('UserToDelete') ->will($this->returnValue($toDeleteUser)); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin->expects($this->once()) @@ -1487,7 +1489,7 @@ class UsersControllerTest extends \Test\TestCase { ->with('UserToDelete') ->will($this->returnValue($toDeleteUser)); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin->expects($this->once()) @@ -1571,7 +1573,7 @@ class UsersControllerTest extends \Test\TestCase { ->expects($this->once()) ->method('createUser') ->will($this->onConsecutiveCalls($user)); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin->expects($this->once()) @@ -1637,7 +1639,7 @@ class UsersControllerTest extends \Test\TestCase { list($user, $expectedResult) = $this->mockUser(); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin->expects($this->once()) @@ -1684,7 +1686,7 @@ class UsersControllerTest extends \Test\TestCase { ) ->will($this->returnValue('1')); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin->expects($this->once()) @@ -1722,7 +1724,7 @@ class UsersControllerTest extends \Test\TestCase { // without the master key enabled we use per-user keys -> restore is disabled $expectedResult['isRestoreDisabled'] = !$masterKeyEnabled; - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin->expects($this->once()) @@ -1779,7 +1781,7 @@ class UsersControllerTest extends \Test\TestCase { $expectedResult['isRestoreDisabled'] = true; - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin->expects($this->once()) @@ -1801,7 +1803,7 @@ class UsersControllerTest extends \Test\TestCase { list($user, $expectedResult) = $this->mockUser(); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin->expects($this->once()) @@ -1853,21 +1855,21 @@ class UsersControllerTest extends \Test\TestCase { ->method('getUser') ->will($this->returnValue($user)); - $group1 = $this->getMockBuilder('\OC\Group\Group') + $group1 = $this->getMockBuilder(Group::class) ->disableOriginalConstructor()->getMock(); $group1 ->expects($this->once()) ->method('getUsers') ->will($this->returnValue(['foo' => 'M. Foo', 'admin' => 'S. Admin'])); - $group2 = $this->getMockBuilder('\OC\Group\Group') + $group2 = $this->getMockBuilder(Group::class) ->disableOriginalConstructor()->getMock(); $group2 ->expects($this->once()) ->method('getUsers') ->will($this->returnValue(['bar' => 'B. Ar'])); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin @@ -1971,7 +1973,7 @@ class UsersControllerTest extends \Test\TestCase { ->willReturn($editUser); $this->accountManager->expects($this->any())->method('getUser')->willReturn([]); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin @@ -2036,7 +2038,7 @@ class UsersControllerTest extends \Test\TestCase { ->with($user->getUID()) ->willReturn($user); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin @@ -2437,7 +2439,7 @@ class UsersControllerTest extends \Test\TestCase { ->method('createUser') ->will($this->onConsecutiveCalls($user)); - $subadmin = $this->getMockBuilder('\OC\SubAdmin') + $subadmin = $this->getMockBuilder(SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subadmin @@ -2576,7 +2578,7 @@ class UsersControllerTest extends \Test\TestCase { } public function testDisableUserFailsDueSameUser() { - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user->expects($this->once()) ->method('getUID') @@ -2599,7 +2601,7 @@ class UsersControllerTest extends \Test\TestCase { } public function testDisableUserFailsDueNoAdminAndNoSubadmin() { - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user->expects($this->once()) ->method('getUID') @@ -2608,7 +2610,7 @@ class UsersControllerTest extends \Test\TestCase { ->expects($this->exactly(2)) ->method('getUser') ->will($this->returnValue($user)); - $user2 = $this->getMockBuilder('\OC\User\User') + $user2 = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user2->expects($this->never()) ->method('setEnabled'); @@ -2618,7 +2620,7 @@ class UsersControllerTest extends \Test\TestCase { ->with('abc') ->willReturn($user2); - $subadmin = $this->createMock('\OC\SubAdmin'); + $subadmin = $this->createMock(SubAdmin::class); $subadmin->expects($this->once()) ->method('isUserAccessible') ->will($this->returnValue(false)); @@ -2641,7 +2643,7 @@ class UsersControllerTest extends \Test\TestCase { } public function testDisableUserFailsDueNoUser() { - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user->expects($this->once()) ->method('getUID') @@ -2674,7 +2676,7 @@ class UsersControllerTest extends \Test\TestCase { } public function testDisableUserFailsDueNoUserForSubAdmin() { - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user->expects($this->once()) ->method('getUID') @@ -2707,7 +2709,7 @@ class UsersControllerTest extends \Test\TestCase { } public function testDisableUserSuccessForAdmin() { - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user->expects($this->once()) ->method('getUID') @@ -2716,7 +2718,7 @@ class UsersControllerTest extends \Test\TestCase { ->expects($this->exactly(1)) ->method('getUser') ->will($this->returnValue($user)); - $user2 = $this->getMockBuilder('\OC\User\User') + $user2 = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user2->expects($this->once()) ->method('setEnabled') @@ -2745,7 +2747,7 @@ class UsersControllerTest extends \Test\TestCase { } public function testDisableUserSuccessForSubAdmin() { - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user->expects($this->once()) ->method('getUID') @@ -2754,7 +2756,7 @@ class UsersControllerTest extends \Test\TestCase { ->expects($this->exactly(2)) ->method('getUser') ->will($this->returnValue($user)); - $user2 = $this->getMockBuilder('\OC\User\User') + $user2 = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user2->expects($this->once()) ->method('setEnabled'); @@ -2764,7 +2766,7 @@ class UsersControllerTest extends \Test\TestCase { ->with('abc') ->willReturn($user2); - $subadmin = $this->createMock('\OC\SubAdmin'); + $subadmin = $this->createMock(SubAdmin::class); $subadmin->expects($this->once()) ->method('isUserAccessible') ->will($this->returnValue(true)); @@ -2787,7 +2789,7 @@ class UsersControllerTest extends \Test\TestCase { } public function testEnableUserFailsDueSameUser() { - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user->expects($this->once()) ->method('getUID') @@ -2810,7 +2812,7 @@ class UsersControllerTest extends \Test\TestCase { } public function testEnableUserFailsDueNoAdminAndNoSubadmin() { - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user->expects($this->once()) ->method('getUID') @@ -2819,7 +2821,7 @@ class UsersControllerTest extends \Test\TestCase { ->expects($this->exactly(2)) ->method('getUser') ->will($this->returnValue($user)); - $user2 = $this->getMockBuilder('\OC\User\User') + $user2 = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user2->expects($this->never()) ->method('setEnabled'); @@ -2829,7 +2831,7 @@ class UsersControllerTest extends \Test\TestCase { ->with('abc') ->willReturn($user2); - $subadmin = $this->createMock('\OC\SubAdmin'); + $subadmin = $this->createMock(SubAdmin::class); $subadmin->expects($this->once()) ->method('isUserAccessible') ->will($this->returnValue(false)); @@ -2852,7 +2854,7 @@ class UsersControllerTest extends \Test\TestCase { } public function testEnableUserFailsDueNoUser() { - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user->expects($this->once()) ->method('getUID') @@ -2885,7 +2887,7 @@ class UsersControllerTest extends \Test\TestCase { } public function testEnableUserFailsDueNoUserForSubAdmin() { - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user->expects($this->once()) ->method('getUID') @@ -2918,7 +2920,7 @@ class UsersControllerTest extends \Test\TestCase { } public function testEnableUserSuccessForAdmin() { - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user->expects($this->once()) ->method('getUID') @@ -2927,7 +2929,7 @@ class UsersControllerTest extends \Test\TestCase { ->expects($this->exactly(1)) ->method('getUser') ->will($this->returnValue($user)); - $user2 = $this->getMockBuilder('\OC\User\User') + $user2 = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user2->expects($this->once()) ->method('setEnabled'); @@ -2955,7 +2957,7 @@ class UsersControllerTest extends \Test\TestCase { } public function testEnableUserSuccessForSubAdmin() { - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user->expects($this->once()) ->method('getUID') @@ -2964,7 +2966,7 @@ class UsersControllerTest extends \Test\TestCase { ->expects($this->exactly(2)) ->method('getUser') ->will($this->returnValue($user)); - $user2 = $this->getMockBuilder('\OC\User\User') + $user2 = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user2->expects($this->once()) ->method('setEnabled') @@ -2975,7 +2977,7 @@ class UsersControllerTest extends \Test\TestCase { ->with('abc') ->willReturn($user2); - $subadmin = $this->createMock('\OC\SubAdmin'); + $subadmin = $this->createMock(SubAdmin::class); $subadmin->expects($this->once()) ->method('isUserAccessible') ->will($this->returnValue(true)); diff --git a/tests/Settings/Middleware/SubadminMiddlewareTest.php b/tests/Settings/Middleware/SubadminMiddlewareTest.php index b2724047750..834a3fedf23 100644 --- a/tests/Settings/Middleware/SubadminMiddlewareTest.php +++ b/tests/Settings/Middleware/SubadminMiddlewareTest.php @@ -34,9 +34,9 @@ class SubadminMiddlewareTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->reflector = $this->getMockBuilder('\OC\AppFramework\Utility\ControllerMethodReflector') + $this->reflector = $this->getMockBuilder(ControllerMethodReflector::class) ->disableOriginalConstructor()->getMock(); - $this->controller = $this->getMockBuilder('\OCP\AppFramework\Controller') + $this->controller = $this->getMockBuilder(Controller::class) ->disableOriginalConstructor()->getMock(); $this->subadminMiddlewareAsSubAdmin = new SubadminMiddleware($this->reflector, true); diff --git a/tests/lib/APITest.php b/tests/lib/APITest.php index c2a25d1306c..b1ac8fbb24f 100644 --- a/tests/lib/APITest.php +++ b/tests/lib/APITest.php @@ -8,6 +8,8 @@ namespace Test; +use OCP\IRequest; + class APITest extends \Test\TestCase { // Helps build a response variable @@ -71,7 +73,7 @@ class APITest extends \Test\TestCase { * @param bool $expected */ public function testIsV2($scriptName, $expected) { - $request = $this->getMockBuilder('\OCP\IRequest') + $request = $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor() ->getMock(); $request diff --git a/tests/lib/Accounts/AccountsManagerTest.php b/tests/lib/Accounts/AccountsManagerTest.php index 6cefebdea86..c4add0244bd 100644 --- a/tests/lib/Accounts/AccountsManagerTest.php +++ b/tests/lib/Accounts/AccountsManagerTest.php @@ -71,7 +71,7 @@ class AccountsManagerTest extends TestCase { * @return \PHPUnit_Framework_MockObject_MockObject | AccountManager */ public function getInstance($mockedMethods = null) { - return $this->getMockBuilder('OC\Accounts\AccountManager') + return $this->getMockBuilder(AccountManager::class) ->setConstructorArgs([$this->connection, $this->eventDispatcher, $this->jobList]) ->setMethods($mockedMethods) ->getMock(); @@ -146,7 +146,7 @@ class AccountsManagerTest extends TestCase { * @param array $setData * @param IUser $askUser * @param array $expectedData - * @param book $userAlreadyExists + * @param bool $userAlreadyExists */ public function testGetUser($setUser, $setData, $askUser, $expectedData, $userAlreadyExists) { $accountManager = $this->getInstance(['buildDefaultUserRecord', 'insertNewUser', 'addMissingDefaultValues']); @@ -172,9 +172,9 @@ class AccountsManagerTest extends TestCase { } public function dataTestGetUser() { - $user1 = $this->getMockBuilder('OCP\IUser')->getMock(); + $user1 = $this->getMockBuilder(IUser::class)->getMock(); $user1->expects($this->any())->method('getUID')->willReturn('user1'); - $user2 = $this->getMockBuilder('OCP\IUser')->getMock(); + $user2 = $this->getMockBuilder(IUser::class)->getMock(); $user2->expects($this->any())->method('getUID')->willReturn('user2'); return [ ['user1', ['key' => 'value'], $user1, ['key' => 'value'], true], @@ -183,7 +183,7 @@ class AccountsManagerTest extends TestCase { } public function testUpdateExistingUser() { - $user = $this->getMockBuilder('OCP\IUser')->getMock(); + $user = $this->getMockBuilder(IUser::class)->getMock(); $user->expects($this->once())->method('getUID')->willReturn('uid'); $oldData = ['key' => 'value']; $newData = ['newKey' => 'newValue']; @@ -196,7 +196,7 @@ class AccountsManagerTest extends TestCase { } public function testInsertNewUser() { - $user = $this->getMockBuilder('OCP\IUser')->getMock(); + $user = $this->getMockBuilder(IUser::class)->getMock(); $uid = 'uid'; $data = ['key' => 'value']; diff --git a/tests/lib/Activity/ManagerTest.php b/tests/lib/Activity/ManagerTest.php index 13932f389f8..a1877d3fcc6 100644 --- a/tests/lib/Activity/ManagerTest.php +++ b/tests/lib/Activity/ManagerTest.php @@ -12,6 +12,7 @@ namespace Test\Activity; use OCP\IConfig; use OCP\IRequest; +use OCP\IUser; use OCP\IUserSession; use OCP\RichObjectStrings\IValidator; use Test\TestCase; @@ -247,7 +248,7 @@ class ManagerTest extends TestCase { } protected function mockUserSession($user) { - $mockUser = $this->getMockBuilder('\OCP\IUser') + $mockUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $mockUser->expects($this->any()) @@ -314,7 +315,7 @@ class ManagerTest extends TestCase { */ public function testPublish($author, $expected) { if ($author !== null) { - $authorObject = $this->getMockBuilder('OCP\IUser') + $authorObject = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); $authorObject->expects($this->once()) diff --git a/tests/lib/App/DependencyAnalyzerTest.php b/tests/lib/App/DependencyAnalyzerTest.php index 65b45a002d4..081f6d767db 100644 --- a/tests/lib/App/DependencyAnalyzerTest.php +++ b/tests/lib/App/DependencyAnalyzerTest.php @@ -59,7 +59,7 @@ class DependencyAnalyzerTest extends TestCase { ->method('getOcVersion') ->will( $this->returnValue('8.0.2')); - $this->l10nMock = $this->getMockBuilder('\OCP\IL10N') + $this->l10nMock = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor() ->getMock(); $this->l10nMock->expects($this->any()) diff --git a/tests/lib/AppFramework/Controller/ApiControllerTest.php b/tests/lib/AppFramework/Controller/ApiControllerTest.php index 74231b8d6ac..b7172ab6a9f 100644 --- a/tests/lib/AppFramework/Controller/ApiControllerTest.php +++ b/tests/lib/AppFramework/Controller/ApiControllerTest.php @@ -26,6 +26,7 @@ namespace Test\AppFramework\Controller; use OC\AppFramework\Http\Request; use OCP\AppFramework\ApiController; +use OCP\IConfig; class ChildApiController extends ApiController {}; @@ -41,7 +42,7 @@ class ApiControllerTest extends \Test\TestCase { $this->getMockBuilder('\OCP\Security\ISecureRandom') ->disableOriginalConstructor() ->getMock(), - $this->getMockBuilder('\OCP\IConfig') + $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock() ); diff --git a/tests/lib/AppFramework/Controller/ControllerTest.php b/tests/lib/AppFramework/Controller/ControllerTest.php index 5c8124c5e7f..ca71e9154ef 100644 --- a/tests/lib/AppFramework/Controller/ControllerTest.php +++ b/tests/lib/AppFramework/Controller/ControllerTest.php @@ -29,6 +29,7 @@ use OCP\AppFramework\Controller; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\DataResponse; +use OCP\IConfig; class ChildController extends Controller { @@ -79,7 +80,7 @@ class ControllerTest extends \Test\TestCase { $this->getMockBuilder('\OCP\Security\ISecureRandom') ->disableOriginalConstructor() ->getMock(), - $this->getMockBuilder('\OCP\IConfig') + $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock() ); diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php index c2d73adfd7b..eb08d00e358 100644 --- a/tests/lib/AppFramework/Http/DispatcherTest.php +++ b/tests/lib/AppFramework/Http/DispatcherTest.php @@ -31,6 +31,7 @@ use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Controller; +use OCP\IConfig; class TestController extends Controller { @@ -301,7 +302,7 @@ class DispatcherTest extends \Test\TestCase { $this->getMockBuilder('\OCP\Security\ISecureRandom') ->disableOriginalConstructor() ->getMock(), - $this->getMockBuilder('\OCP\IConfig') + $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock() ); @@ -332,7 +333,7 @@ class DispatcherTest extends \Test\TestCase { $this->getMockBuilder('\OCP\Security\ISecureRandom') ->disableOriginalConstructor() ->getMock(), - $this->getMockBuilder('\OCP\IConfig') + $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock() ); @@ -366,7 +367,7 @@ class DispatcherTest extends \Test\TestCase { $this->getMockBuilder('\OCP\Security\ISecureRandom') ->disableOriginalConstructor() ->getMock(), - $this->getMockBuilder('\OCP\IConfig') + $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock() ); @@ -399,7 +400,7 @@ class DispatcherTest extends \Test\TestCase { $this->getMockBuilder('\OCP\Security\ISecureRandom') ->disableOriginalConstructor() ->getMock(), - $this->getMockBuilder('\OCP\IConfig') + $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock() ); @@ -433,7 +434,7 @@ class DispatcherTest extends \Test\TestCase { $this->getMockBuilder('\OCP\Security\ISecureRandom') ->disableOriginalConstructor() ->getMock(), - $this->getMockBuilder('\OCP\IConfig') + $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock() ); @@ -469,7 +470,7 @@ class DispatcherTest extends \Test\TestCase { $this->getMockBuilder('\OCP\Security\ISecureRandom') ->disableOriginalConstructor() ->getMock(), - $this->getMockBuilder('\OCP\IConfig') + $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock() ); diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php index 40698ef8d73..d3f36a6d886 100644 --- a/tests/lib/AppFramework/Http/RequestTest.php +++ b/tests/lib/AppFramework/Http/RequestTest.php @@ -40,7 +40,7 @@ class RequestTest extends \Test\TestCase { stream_wrapper_register('fakeinput', 'Test\AppFramework\Http\RequestStream'); $this->secureRandom = $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->csrfTokenManager = $this->getMockBuilder('\OC\Security\CSRF\CsrfTokenManager') ->disableOriginalConstructor()->getMock(); } diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php index f948e184f53..e71be9c5f16 100644 --- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php +++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php @@ -29,6 +29,7 @@ use OC\AppFramework\Middleware\MiddlewareDispatcher; use OCP\AppFramework\Controller; use OCP\AppFramework\Middleware; use OCP\AppFramework\Http\Response; +use OCP\IConfig; // needed to test ordering @@ -133,7 +134,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { new Request( ['method' => 'GET'], $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), - $this->getMockBuilder('\OCP\IConfig')->getMock() + $this->getMockBuilder(IConfig::class)->getMock() ) ])->getMock(); } diff --git a/tests/lib/AppFramework/Middleware/MiddlewareTest.php b/tests/lib/AppFramework/Middleware/MiddlewareTest.php index c5c812839b2..07028745676 100644 --- a/tests/lib/AppFramework/Middleware/MiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/MiddlewareTest.php @@ -27,6 +27,7 @@ namespace Test\AppFramework\Middleware; use OC\AppFramework\Http\Request; use OCP\AppFramework\Middleware; use OCP\AppFramework\Http\Response; +use OCP\IConfig; class ChildMiddleware extends Middleware {}; @@ -59,7 +60,7 @@ class MiddlewareTest extends \Test\TestCase { new Request( [], $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), - $this->getMockBuilder('\OCP\IConfig')->getMock() + $this->getMockBuilder(IConfig::class)->getMock() ) ])->getMock(); $this->exception = new \Exception(); diff --git a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php index 3c218bb53c7..8d097e3a8a1 100644 --- a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php @@ -17,6 +17,7 @@ use OC\AppFramework\Middleware\SessionMiddleware; use OC\AppFramework\Utility\ControllerMethodReflector; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\Response; +use OCP\IConfig; class SessionMiddlewareTest extends \Test\TestCase { @@ -36,7 +37,7 @@ class SessionMiddlewareTest extends \Test\TestCase { $this->request = new Request( [], $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), - $this->getMockBuilder('\OCP\IConfig')->getMock() + $this->getMockBuilder(IConfig::class)->getMock() ); $this->reflector = new ControllerMethodReflector(); $this->controller = $this->createMock(Controller::class); diff --git a/tests/lib/AppFramework/Routing/RoutingTest.php b/tests/lib/AppFramework/Routing/RoutingTest.php index d395584d011..76533fff014 100644 --- a/tests/lib/AppFramework/Routing/RoutingTest.php +++ b/tests/lib/AppFramework/Routing/RoutingTest.php @@ -5,6 +5,7 @@ namespace Test\AppFramework\Routing; use OC\AppFramework\DependencyInjection\DIContainer; use OC\AppFramework\Routing\RouteActionHandler; use OC\AppFramework\Routing\RouteConfig; +use OCP\ILogger; class RoutingTest extends \Test\TestCase { @@ -130,7 +131,7 @@ class RoutingTest extends \Test\TestCase // router mock $router = $this->getMockBuilder('\OC\Route\Router') ->setMethods(['create']) - ->setConstructorArgs([$this->getMockBuilder('\OCP\ILogger')->getMock()]) + ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()]) ->getMock(); // load route configuration @@ -151,7 +152,7 @@ class RoutingTest extends \Test\TestCase // router mock $router = $this->getMockBuilder('\OC\Route\Router') ->setMethods(['create']) - ->setConstructorArgs([$this->getMockBuilder('\OCP\ILogger')->getMock()]) + ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()]) ->getMock(); // load route configuration @@ -212,7 +213,7 @@ class RoutingTest extends \Test\TestCase // router mock $router = $this->getMockBuilder('\OC\Route\Router') ->setMethods(['create']) - ->setConstructorArgs([$this->getMockBuilder('\OCP\ILogger')->getMock()]) + ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()]) ->getMock(); // we expect create to be called once: @@ -260,7 +261,7 @@ class RoutingTest extends \Test\TestCase // router mock $router = $this->getMockBuilder('\OC\Route\Router') ->setMethods(['create']) - ->setConstructorArgs([$this->getMockBuilder('\OCP\ILogger')->getMock()]) + ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()]) ->getMock(); // we expect create to be called once: @@ -287,7 +288,7 @@ class RoutingTest extends \Test\TestCase // router mock $router = $this->getMockBuilder('\OC\Route\Router') ->setMethods(['create']) - ->setConstructorArgs([$this->getMockBuilder('\OCP\ILogger')->getMock()]) + ->setConstructorArgs([$this->getMockBuilder(ILogger::class)->getMock()]) ->getMock(); // route mocks diff --git a/tests/lib/BackgroundJob/JobTest.php b/tests/lib/BackgroundJob/JobTest.php index 7923eef11ef..ecd8bde8626 100644 --- a/tests/lib/BackgroundJob/JobTest.php +++ b/tests/lib/BackgroundJob/JobTest.php @@ -8,6 +8,8 @@ namespace Test\BackgroundJob; +use OCP\ILogger; + class JobTest extends \Test\TestCase { private $run = false; @@ -24,7 +26,7 @@ class JobTest extends \Test\TestCase { }); $jobList->add($job); - $logger = $this->getMockBuilder('OCP\ILogger') + $logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); $logger->expects($this->once()) diff --git a/tests/lib/CapabilitiesManagerTest.php b/tests/lib/CapabilitiesManagerTest.php index 139940eb306..8df385e6ef9 100644 --- a/tests/lib/CapabilitiesManagerTest.php +++ b/tests/lib/CapabilitiesManagerTest.php @@ -37,7 +37,7 @@ class CapabilitiesManagerTest extends TestCase { public function setUp() { parent::setUp(); - $this->logger = $this->getMockBuilder('OCP\ILogger')->getMock(); + $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); $this->manager = new CapabilitiesManager($this->logger); } diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php index 289e7de27ab..c52619c3b12 100644 --- a/tests/lib/Encryption/DecryptAllTest.php +++ b/tests/lib/Encryption/DecryptAllTest.php @@ -29,6 +29,7 @@ use OC\Encryption\Manager; use OC\Files\FileInfo; use OC\Files\View; use OCP\IUserManager; +use OCP\UserInterface; use Symfony\Component\Console\Formatter\OutputFormatterInterface; use Test\TestCase; @@ -65,7 +66,7 @@ class DecryptAllTest extends TestCase { public function setUp() { parent::setUp(); - $this->userManager = $this->getMockBuilder('OCP\IUserManager') + $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor()->getMock(); $this->encryptionManager = $this->getMockBuilder('OC\Encryption\Manager') ->disableOriginalConstructor()->getMock(); @@ -75,7 +76,7 @@ class DecryptAllTest extends TestCase { ->disableOriginalConstructor()->getMock(); $this->outputInterface = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') ->disableOriginalConstructor()->getMock(); - $this->userInterface = $this->getMockBuilder('OCP\UserInterface') + $this->userInterface = $this->getMockBuilder(UserInterface::class) ->disableOriginalConstructor()->getMock(); $this->outputInterface->expects($this->any())->method('getFormatter') diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php index 4e9719351f3..a5924d1dc88 100644 --- a/tests/lib/Encryption/Keys/StorageTest.php +++ b/tests/lib/Encryption/Keys/StorageTest.php @@ -24,6 +24,7 @@ namespace Test\Encryption\Keys; use OC\Encryption\Keys\Storage; +use OCP\IConfig; use Test\TestCase; class StorageTest extends TestCase { @@ -51,7 +52,7 @@ class StorageTest extends TestCase { ->disableOriginalConstructor() ->getMock(); - $this->config = $this->getMockBuilder('OCP\IConfig') + $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Encryption/UpdateTest.php b/tests/lib/Encryption/UpdateTest.php index b222bc42d7a..ccd2bb796fc 100644 --- a/tests/lib/Encryption/UpdateTest.php +++ b/tests/lib/Encryption/UpdateTest.php @@ -24,6 +24,7 @@ namespace Test\Encryption; use OC\Encryption\Update; +use OC\Files\View; use Test\TestCase; class UpdateTest extends TestCase { @@ -55,7 +56,7 @@ class UpdateTest extends TestCase { protected function setUp() { parent::setUp(); - $this->view = $this->getMockBuilder('\OC\Files\View') + $this->view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); $this->util = $this->getMockBuilder('\OC\Encryption\Util') ->disableOriginalConstructor()->getMock(); diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php index 609f6ae1e68..e313274516e 100644 --- a/tests/lib/Encryption/UtilTest.php +++ b/tests/lib/Encryption/UtilTest.php @@ -4,6 +4,7 @@ namespace Test\Encryption; use OC\Encryption\Util; use OCP\Encryption\IEncryptionModule; +use OCP\IConfig; use Test\TestCase; class UtilTest extends TestCase { @@ -44,7 +45,7 @@ class UtilTest extends TestCase { ->disableOriginalConstructor() ->getMock(); - $this->config = $this->getMockBuilder('OCP\IConfig') + $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php index 5e18caa2014..160787411f1 100644 --- a/tests/lib/Files/Node/NodeTest.php +++ b/tests/lib/Files/Node/NodeTest.php @@ -13,7 +13,10 @@ use OC\Files\View; use OCP\Files\Config\IUserMountCache; use OCP\Files\IRootFolder; use OCP\Files\Node; +use OCP\Files\Storage; +use OCP\IConfig; use OCP\ILogger; +use OCP\IURLGenerator; use OCP\IUserManager; use OCP\Files\NotFoundException; @@ -41,17 +44,18 @@ abstract class NodeTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $config = $this->getMockBuilder('\OCP\IConfig') + $config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); - $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') + $urlGenerator = $this->getMockBuilder(IURLGenerator + ::class) ->disableOriginalConstructor() ->getMock(); $this->user = new \OC\User\User('', new \Test\Util\User\Dummy, null, $config, $urlGenerator); $this->manager = $this->getMockBuilder('\OC\Files\Mount\Manager') ->disableOriginalConstructor() ->getMock(); - $this->view = $this->getMockBuilder('\OC\Files\View') + $this->view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); $this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache') @@ -88,7 +92,7 @@ abstract class NodeTest extends \Test\TestCase { protected abstract function getViewDeleteMethod(); protected function getMockStorage() { - $storage = $this->getMockBuilder('\OCP\Files\Storage') + $storage = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor() ->getMock(); $storage->expects($this->any()) diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php index fbc33cafcd8..2f81a96d486 100644 --- a/tests/lib/Files/Node/RootTest.php +++ b/tests/lib/Files/Node/RootTest.php @@ -13,7 +13,9 @@ use OC\Files\FileInfo; use OC\Files\Mount\Manager; use OC\Files\Node\Folder; use OC\Files\View; +use OCP\IConfig; use OCP\ILogger; +use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; @@ -37,10 +39,10 @@ class RootTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $config = $this->getMockBuilder('\OCP\IConfig') + $config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); - $urlgenerator = $this->getMockBuilder('\OCP\IURLGenerator') + $urlgenerator = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor() ->getMock(); @@ -69,7 +71,7 @@ class RootTest extends \Test\TestCase { /** * @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view */ - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); $root = new \OC\Files\Node\Root( @@ -105,7 +107,7 @@ class RootTest extends \Test\TestCase { /** * @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view */ - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); $root = new \OC\Files\Node\Root( @@ -133,7 +135,7 @@ class RootTest extends \Test\TestCase { /** * @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view */ - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); $root = new \OC\Files\Node\Root( @@ -155,7 +157,7 @@ class RootTest extends \Test\TestCase { /** * @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view */ - $view = $this->getMockBuilder('\OC\Files\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); $root = new \OC\Files\Node\Root( diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php index 80d62b16578..459abf3b64c 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -16,6 +16,7 @@ use OCP\Encryption\IFile; use OCP\Encryption\Keys\IStorage; use OCP\Files\Cache\ICache; use OCP\Files\Mount\IMountPoint; +use OCP\IConfig; use OCP\ILogger; use Test\Files\Storage\Storage; @@ -120,7 +121,7 @@ class EncryptionTest extends Storage { ->willReturn($mockModule); $this->arrayCache = $this->createMock(ArrayCache::class); - $this->config = $this->getMockBuilder('\OCP\IConfig') + $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); $this->groupManager = $this->getMockBuilder('\OC\Group\Manager') diff --git a/tests/lib/Files/Storage/Wrapper/QuotaTest.php b/tests/lib/Files/Storage/Wrapper/QuotaTest.php index ee01d0c3f26..b796e767a7b 100644 --- a/tests/lib/Files/Storage/Wrapper/QuotaTest.php +++ b/tests/lib/Files/Storage/Wrapper/QuotaTest.php @@ -185,7 +185,7 @@ class QuotaTest extends \Test\Files\Storage\Storage { } public function testSpaceRoot() { - $storage = $this->getMockBuilder('\OC\Files\Storage\Local')->disableOriginalConstructor()->getMock(); + $storage = $this->getMockBuilder(Local::class)->disableOriginalConstructor()->getMock(); $cache = $this->getMockBuilder('\OC\Files\Cache\Cache')->disableOriginalConstructor()->getMock(); $storage->expects($this->once()) ->method('getCache') diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php index 1dc9dca0aad..983428ee51d 100644 --- a/tests/lib/Files/Stream/EncryptionTest.php +++ b/tests/lib/Files/Stream/EncryptionTest.php @@ -4,6 +4,7 @@ namespace Test\Files\Stream; use OC\Files\View; use OC\Memcache\ArrayCache; +use OCP\IConfig; class EncryptionTest extends \Test\TestCase { @@ -29,7 +30,7 @@ class EncryptionTest extends \Test\TestCase { ->disableOriginalConstructor()->getMock(); $encStorage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') ->disableOriginalConstructor()->getMock(); - $config = $this->getMockBuilder('\OCP\IConfig') + $config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); $arrayCache = $this->createMock(ArrayCache::class); diff --git a/tests/lib/Files/Type/DetectionTest.php b/tests/lib/Files/Type/DetectionTest.php index 5c1f48a806e..295b9bf9fac 100644 --- a/tests/lib/Files/Type/DetectionTest.php +++ b/tests/lib/Files/Type/DetectionTest.php @@ -21,7 +21,8 @@ namespace Test\Files\Type; -use \OC\Files\Type\Detection; +use OC\Files\Type\Detection; +use OCP\IURLGenerator; class DetectionTest extends \Test\TestCase { /** @var Detection */ @@ -107,7 +108,7 @@ class DetectionTest extends \Test\TestCase { */ //Mock UrlGenerator - $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') + $urlGenerator = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor() ->getMock(); @@ -126,7 +127,7 @@ class DetectionTest extends \Test\TestCase { * Test dir-shareed mimetype */ //Mock UrlGenerator - $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') + $urlGenerator = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor() ->getMock(); @@ -146,7 +147,7 @@ class DetectionTest extends \Test\TestCase { */ //Mock UrlGenerator - $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') + $urlGenerator = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor() ->getMock(); @@ -166,7 +167,7 @@ class DetectionTest extends \Test\TestCase { */ //Mock UrlGenerator - $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') + $urlGenerator = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor() ->getMock(); @@ -186,7 +187,7 @@ class DetectionTest extends \Test\TestCase { */ //Mock UrlGenerator - $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') + $urlGenerator = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor() ->getMock(); @@ -216,7 +217,7 @@ class DetectionTest extends \Test\TestCase { */ //Mock UrlGenerator - $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') + $urlGenerator = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor() ->getMock(); @@ -246,7 +247,7 @@ class DetectionTest extends \Test\TestCase { */ //Mock UrlGenerator - $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') + $urlGenerator = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor() ->getMock(); @@ -272,7 +273,7 @@ class DetectionTest extends \Test\TestCase { $mimetypealiases_dist->setContent(json_encode(['foo' => 'foobar/baz'], JSON_FORCE_OBJECT)); //Mock UrlGenerator - $urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator') + $urlGenerator = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Group/GroupTest.php b/tests/lib/Group/GroupTest.php index c1824566733..c7cbbc2321b 100644 --- a/tests/lib/Group/GroupTest.php +++ b/tests/lib/Group/GroupTest.php @@ -10,6 +10,8 @@ namespace Test\Group; use OC\User\User; +use OCP\IConfig; +use OCP\IURLGenerator; class GroupTest extends \Test\TestCase { @@ -19,10 +21,10 @@ class GroupTest extends \Test\TestCase { * @return User */ private function newUser($uid, \OC\User\Backend $backend) { - $config = $this->getMockBuilder('\OCP\IConfig') + $config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); - $urlgenerator = $this->getMockBuilder('\OCP\IURLGenerator') + $urlgenerator = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/HTTPHelperTest.php b/tests/lib/HTTPHelperTest.php index d241acb2f93..d39cc34c464 100644 --- a/tests/lib/HTTPHelperTest.php +++ b/tests/lib/HTTPHelperTest.php @@ -9,6 +9,7 @@ namespace Test; use OCP\Http\Client\IClientService; +use OCP\IConfig; class HTTPHelperTest extends \Test\TestCase { @@ -22,7 +23,7 @@ class HTTPHelperTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig') + $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor()->getMock(); $this->clientService = $this->createMock(IClientService::class); $this->httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper') diff --git a/tests/lib/Memcache/FactoryTest.php b/tests/lib/Memcache/FactoryTest.php index 8607ea7de9b..ce6c25cd87f 100644 --- a/tests/lib/Memcache/FactoryTest.php +++ b/tests/lib/Memcache/FactoryTest.php @@ -20,6 +20,8 @@ */ namespace Test\Memcache; +use OCP\ILogger; + class Test_Factory_Available_Cache1 { public function __construct($prefix = '') { } @@ -114,7 +116,7 @@ class FactoryTest extends \Test\TestCase { */ public function testCacheAvailability($localCache, $distributedCache, $lockingCache, $expectedLocalCache, $expectedDistributedCache, $expectedLockingCache) { - $logger = $this->getMockBuilder('\OCP\ILogger')->getMock(); + $logger = $this->getMockBuilder(ILogger::class)->getMock(); $factory = new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache, $lockingCache); $this->assertTrue(is_a($factory->createLocal(), $expectedLocalCache)); $this->assertTrue(is_a($factory->createDistributed(), $expectedDistributedCache)); @@ -126,7 +128,7 @@ class FactoryTest extends \Test\TestCase { * @expectedException \OC\HintException */ public function testCacheNotAvailableException($localCache, $distributedCache) { - $logger = $this->getMockBuilder('\OCP\ILogger')->getMock(); + $logger = $this->getMockBuilder(ILogger::class)->getMock(); new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache); } } diff --git a/tests/lib/Migration/BackgroundRepairTest.php b/tests/lib/Migration/BackgroundRepairTest.php index 2de55f647e7..7a3a960074f 100644 --- a/tests/lib/Migration/BackgroundRepairTest.php +++ b/tests/lib/Migration/BackgroundRepairTest.php @@ -72,7 +72,7 @@ class BackgroundRepairTest extends TestCase { $this->jobList = $this->getMockBuilder('OC\BackgroundJob\JobList') ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->getMockBuilder('OCP\ILogger') + $this->logger = $this->getMockBuilder(ILogger::class) ->disableOriginalConstructor() ->getMock(); $this->job = $this->getMockBuilder(BackgroundRepair::class) diff --git a/tests/lib/Notification/ManagerTest.php b/tests/lib/Notification/ManagerTest.php index e280838424b..cb6504b67e7 100644 --- a/tests/lib/Notification/ManagerTest.php +++ b/tests/lib/Notification/ManagerTest.php @@ -22,7 +22,10 @@ namespace Test\Notification; use OC\Notification\Manager; +use OCP\Notification\IApp; use OCP\Notification\IManager; +use OCP\Notification\INotification; +use OCP\Notification\INotifier; use OCP\RichObjectStrings\IValidator; use Test\TestCase; @@ -37,7 +40,7 @@ class ManagerTest extends TestCase { } public function testRegisterApp() { - $app = $this->getMockBuilder('OCP\Notification\IApp') + $app = $this->getMockBuilder(IApp::class) ->disableOriginalConstructor() ->getMock(); @@ -61,7 +64,7 @@ class ManagerTest extends TestCase { * @expectedException \InvalidArgumentException */ public function testRegisterAppInvalid() { - $notifier = $this->getMockBuilder('OCP\Notification\INotifier') + $notifier = $this->getMockBuilder(INotifier::class) ->disableOriginalConstructor() ->getMock(); @@ -75,7 +78,7 @@ class ManagerTest extends TestCase { } public function testRegisterNotifier() { - $notifier = $this->getMockBuilder('OCP\Notification\INotifier') + $notifier = $this->getMockBuilder(INotifier::class) ->disableOriginalConstructor() ->getMock(); @@ -107,7 +110,7 @@ class ManagerTest extends TestCase { * @expectedException \InvalidArgumentException */ public function testRegisterNotifierInvalid() { - $app = $this->getMockBuilder('OCP\Notification\IApp') + $app = $this->getMockBuilder(IApp::class) ->disableOriginalConstructor() ->getMock(); @@ -138,7 +141,7 @@ class ManagerTest extends TestCase { * @param mixed $data */ public function testRegisterNotifierInfoInvalid($data) { - $app = $this->getMockBuilder('OCP\Notification\IApp') + $app = $this->getMockBuilder(IApp::class) ->disableOriginalConstructor() ->getMock(); @@ -158,7 +161,7 @@ class ManagerTest extends TestCase { * @expectedExceptionMessage The given notifier ID test1 is already in use */ public function testRegisterNotifierInfoDuplicate() { - $app = $this->getMockBuilder('OCP\Notification\IApp') + $app = $this->getMockBuilder(IApp::class) ->disableOriginalConstructor() ->getMock(); @@ -184,7 +187,7 @@ class ManagerTest extends TestCase { public function testNotify() { /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder('OCP\Notification\INotification') + $notification = $this->getMockBuilder(INotification::class) ->disableOriginalConstructor() ->getMock(); $notification->expects($this->once()) @@ -192,7 +195,7 @@ class ManagerTest extends TestCase { ->willReturn(true); /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app */ - $app = $this->getMockBuilder('OCP\Notification\IApp') + $app = $this->getMockBuilder(IApp::class) ->disableOriginalConstructor() ->getMock(); $app->expects($this->once()) @@ -200,7 +203,7 @@ class ManagerTest extends TestCase { ->with($notification); /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app2 */ - $app2 = $this->getMockBuilder('OCP\Notification\IApp') + $app2 = $this->getMockBuilder(IApp::class) ->disableOriginalConstructor() ->getMock(); $app2->expects($this->once()) @@ -222,7 +225,7 @@ class ManagerTest extends TestCase { */ public function testNotifyInvalid() { /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder('OCP\Notification\INotification') + $notification = $this->getMockBuilder(INotification::class) ->disableOriginalConstructor() ->getMock(); $notification->expects($this->once()) @@ -234,14 +237,14 @@ class ManagerTest extends TestCase { public function testPrepare() { /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder('OCP\Notification\INotification') + $notification = $this->getMockBuilder(INotification::class) ->disableOriginalConstructor() ->getMock(); $notification->expects($this->once()) ->method('isValidParsed') ->willReturn(true); /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification2 */ - $notification2 = $this->getMockBuilder('OCP\Notification\INotification') + $notification2 = $this->getMockBuilder(INotification::class) ->disableOriginalConstructor() ->getMock(); $notification2->expects($this->exactly(2)) @@ -249,7 +252,7 @@ class ManagerTest extends TestCase { ->willReturn(true); /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $notifier */ - $notifier = $this->getMockBuilder('OCP\Notification\INotifier') + $notifier = $this->getMockBuilder(INotifier::class) ->disableOriginalConstructor() ->getMock(); $notifier->expects($this->once()) @@ -258,7 +261,7 @@ class ManagerTest extends TestCase { ->willReturnArgument(0); /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $notifier2 */ - $notifier2 = $this->getMockBuilder('OCP\Notification\INotifier') + $notifier2 = $this->getMockBuilder(INotifier::class) ->disableOriginalConstructor() ->getMock(); $notifier2->expects($this->once()) @@ -285,7 +288,7 @@ class ManagerTest extends TestCase { */ public function testPrepareInvalid() { /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder('OCP\Notification\INotification') + $notification = $this->getMockBuilder(INotification::class) ->disableOriginalConstructor() ->getMock(); $notification->expects($this->once()) @@ -293,7 +296,7 @@ class ManagerTest extends TestCase { ->willReturn(false); /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $notifier */ - $notifier = $this->getMockBuilder('OCP\Notification\INotifier') + $notifier = $this->getMockBuilder(INotifier::class) ->disableOriginalConstructor() ->getMock(); $notifier->expects($this->once()) @@ -312,7 +315,7 @@ class ManagerTest extends TestCase { public function testPrepareNotifierThrows() { /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder('OCP\Notification\INotification') + $notification = $this->getMockBuilder(INotification::class) ->disableOriginalConstructor() ->getMock(); $notification->expects($this->once()) @@ -320,7 +323,7 @@ class ManagerTest extends TestCase { ->willReturn(true); /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $notifier */ - $notifier = $this->getMockBuilder('OCP\Notification\INotifier') + $notifier = $this->getMockBuilder(INotifier::class) ->disableOriginalConstructor() ->getMock(); $notifier->expects($this->once()) @@ -342,7 +345,7 @@ class ManagerTest extends TestCase { */ public function testPrepareNoNotifier() { /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder('OCP\Notification\INotification') + $notification = $this->getMockBuilder(INotification::class) ->disableOriginalConstructor() ->getMock(); $notification->expects($this->once()) @@ -354,12 +357,12 @@ class ManagerTest extends TestCase { public function testMarkProcessed() { /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder('OCP\Notification\INotification') + $notification = $this->getMockBuilder(INotification::class) ->disableOriginalConstructor() ->getMock(); /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app */ - $app = $this->getMockBuilder('OCP\Notification\IApp') + $app = $this->getMockBuilder(IApp::class) ->disableOriginalConstructor() ->getMock(); $app->expects($this->once()) @@ -367,7 +370,7 @@ class ManagerTest extends TestCase { ->with($notification); /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app2 */ - $app2 = $this->getMockBuilder('OCP\Notification\IApp') + $app2 = $this->getMockBuilder(IApp::class) ->disableOriginalConstructor() ->getMock(); $app2->expects($this->once()) @@ -386,12 +389,12 @@ class ManagerTest extends TestCase { public function testGetCount() { /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ - $notification = $this->getMockBuilder('OCP\Notification\INotification') + $notification = $this->getMockBuilder(INotification::class) ->disableOriginalConstructor() ->getMock(); /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app */ - $app = $this->getMockBuilder('OCP\Notification\IApp') + $app = $this->getMockBuilder(IApp::class) ->disableOriginalConstructor() ->getMock(); $app->expects($this->once()) @@ -400,7 +403,7 @@ class ManagerTest extends TestCase { ->willReturn(21); /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app2 */ - $app2 = $this->getMockBuilder('OCP\Notification\IApp') + $app2 = $this->getMockBuilder(IApp::class) ->disableOriginalConstructor() ->getMock(); $app2->expects($this->once()) diff --git a/tests/lib/Repair/CleanTagsTest.php b/tests/lib/Repair/CleanTagsTest.php index ac79907c525..115bce49f71 100644 --- a/tests/lib/Repair/CleanTagsTest.php +++ b/tests/lib/Repair/CleanTagsTest.php @@ -8,6 +8,7 @@ namespace Test\Repair; use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\IUserManager; use OCP\Migration\IOutput; /** @@ -41,7 +42,7 @@ class CleanTagsTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager') + $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php index fa75f58472a..0c67cc992ef 100644 --- a/tests/lib/Repair/RepairInvalidSharesTest.php +++ b/tests/lib/Repair/RepairInvalidSharesTest.php @@ -11,6 +11,7 @@ namespace Test\Repair; use OC\Repair\RepairInvalidShares; use OC\Share\Constants; +use OCP\IConfig; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; use Test\TestCase; @@ -33,7 +34,7 @@ class RepairInvalidSharesTest extends TestCase { protected function setUp() { parent::setUp(); - $config = $this->getMockBuilder('OCP\IConfig') + $config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); $config->expects($this->any()) diff --git a/tests/lib/Repair/RepairMimeTypesTest.php b/tests/lib/Repair/RepairMimeTypesTest.php index 6f3ed5ce318..b9d73d27d00 100644 --- a/tests/lib/Repair/RepairMimeTypesTest.php +++ b/tests/lib/Repair/RepairMimeTypesTest.php @@ -39,7 +39,7 @@ class RepairMimeTypesTest extends \Test\TestCase { $this->mimetypeLoader = \OC::$server->getMimeTypeLoader(); /** @var IConfig | \PHPUnit_Framework_MockObject_MockObject $config */ - $config = $this->getMockBuilder('OCP\IConfig') + $config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); $config->expects($this->any()) diff --git a/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php b/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php index d1e76684507..92a6557f8e3 100644 --- a/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php +++ b/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php @@ -31,7 +31,7 @@ class SessionStorageTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->session = $this->getMockBuilder('\OCP\ISession') + $this->session = $this->getMockBuilder(ISession::class) ->disableOriginalConstructor()->getMock(); $this->sessionStorage = new \OC\Security\CSRF\TokenStorage\SessionStorage($this->session); } diff --git a/tests/lib/Security/HasherTest.php b/tests/lib/Security/HasherTest.php index 913f4d703e8..5f7613a823d 100644 --- a/tests/lib/Security/HasherTest.php +++ b/tests/lib/Security/HasherTest.php @@ -9,6 +9,7 @@ namespace Test\Security; use OC\Security\Hasher; +use OCP\IConfig; /** * Class HasherTest @@ -75,13 +76,13 @@ class HasherTest extends \Test\TestCase { /** @var Hasher */ protected $hasher; - /** @var \OCP\IConfig */ + /** @var IConfig */ protected $config; protected function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig') + $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor()->getMock(); $this->hasher = new Hasher($this->config); diff --git a/tests/lib/Security/TrustedDomainHelperTest.php b/tests/lib/Security/TrustedDomainHelperTest.php index 1beb7a66717..25586a1bc27 100644 --- a/tests/lib/Security/TrustedDomainHelperTest.php +++ b/tests/lib/Security/TrustedDomainHelperTest.php @@ -21,7 +21,7 @@ class TrustedDomainHelperTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); } /** diff --git a/tests/lib/Settings/Admin/AdditionalTest.php b/tests/lib/Settings/Admin/AdditionalTest.php index 84c63f3aeb1..4a254da060b 100644 --- a/tests/lib/Settings/Admin/AdditionalTest.php +++ b/tests/lib/Settings/Admin/AdditionalTest.php @@ -36,7 +36,7 @@ class AdditionalTest extends TestCase { public function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->admin = new Additional( $this->config diff --git a/tests/lib/Settings/Admin/EncryptionTest.php b/tests/lib/Settings/Admin/EncryptionTest.php index a5f483863e6..41196a9bc41 100644 --- a/tests/lib/Settings/Admin/EncryptionTest.php +++ b/tests/lib/Settings/Admin/EncryptionTest.php @@ -40,7 +40,7 @@ class EncryptionTest extends TestCase { public function setUp() { parent::setUp(); $this->manager = $this->getMockBuilder('\OC\Encryption\Manager')->disableOriginalConstructor()->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock(); + $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); $this->admin = new Encryption( $this->manager, diff --git a/tests/lib/Settings/Admin/ServerTest.php b/tests/lib/Settings/Admin/ServerTest.php index 106390f25a5..b8317540117 100644 --- a/tests/lib/Settings/Admin/ServerTest.php +++ b/tests/lib/Settings/Admin/ServerTest.php @@ -49,11 +49,11 @@ class ServerTest extends TestCase { public function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->request = $this->createMock(IRequest::class); $this->dbConnection = $this->getMockBuilder('\OCP\IDBConnection')->getMock(); $this->lockingProvider = $this->getMockBuilder('\OCP\Lock\ILockingProvider')->getMock(); - $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock(); + $this->l10n = $this->getMockBuilder(IL10N::class)->getMock(); $this->admin = new Server( $this->dbConnection, diff --git a/tests/lib/Settings/Admin/SharingTest.php b/tests/lib/Settings/Admin/SharingTest.php index d9aa14fecea..9498a1466d3 100644 --- a/tests/lib/Settings/Admin/SharingTest.php +++ b/tests/lib/Settings/Admin/SharingTest.php @@ -36,7 +36,7 @@ class SharingTest extends TestCase { public function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->admin = new Sharing( $this->config diff --git a/tests/lib/Settings/Admin/TipsTricksTest.php b/tests/lib/Settings/Admin/TipsTricksTest.php index cbecd51ed55..2bbadab52cb 100644 --- a/tests/lib/Settings/Admin/TipsTricksTest.php +++ b/tests/lib/Settings/Admin/TipsTricksTest.php @@ -36,7 +36,7 @@ class TipsTrickTest extends TestCase { public function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->admin = new TipsTricks( $this->config diff --git a/tests/lib/SystemTag/SystemTagManagerTest.php b/tests/lib/SystemTag/SystemTagManagerTest.php index 61fac99ca6c..f81bbaf1643 100644 --- a/tests/lib/SystemTag/SystemTagManagerTest.php +++ b/tests/lib/SystemTag/SystemTagManagerTest.php @@ -13,6 +13,7 @@ namespace Test\SystemTag; use OC\SystemTag\SystemTagManager; use OC\SystemTag\SystemTagObjectMapper; use OCP\IDBConnection; +use OCP\IUser; use OCP\SystemTag\ISystemTag; use OCP\SystemTag\ISystemTagManager; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -56,7 +57,7 @@ class SystemTagManagerTest extends TestCase { $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface') ->getMock(); - $this->groupManager = $this->getMockBuilder('\OCP\IGroupManager')->getMock(); + $this->groupManager = $this->getMockBuilder(IGroupManager::class)->getMock(); $this->tagManager = new SystemTagManager( $this->connection, @@ -433,7 +434,7 @@ class SystemTagManagerTest extends TestCase { * @dataProvider visibilityCheckProvider */ public function testVisibilityCheck($userVisible, $userAssignable, $isAdmin, $expectedResult) { - $user = $this->getMockBuilder('\OCP\IUser')->getMock(); + $user = $this->getMockBuilder(IUser::class)->getMock(); $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('test')); @@ -480,7 +481,7 @@ class SystemTagManagerTest extends TestCase { * @dataProvider assignabilityCheckProvider */ public function testAssignabilityCheck($userVisible, $userAssignable, $isAdmin, $expectedResult, $userGroupIds = [], $tagGroupIds = []) { - $user = $this->getMockBuilder('\OCP\IUser')->getMock(); + $user = $this->getMockBuilder(IUser::class)->getMock(); $user->expects($this->any()) ->method('getUID') ->will($this->returnValue('test')); diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php index 818b3454c3a..64036084dc2 100644 --- a/tests/lib/TestCase.php +++ b/tests/lib/TestCase.php @@ -491,7 +491,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase { ->method('getName') ->willReturn('Nextcloud'); /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject $l10n */ - $l10n = $this->getMockBuilder('\OCP\IL10N') + $l10n = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor()->getMock(); $l10n ->expects($this->any()) diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php index 6f6c6c1ad0c..ff04aa17681 100644 --- a/tests/lib/Updater/VersionCheckTest.php +++ b/tests/lib/Updater/VersionCheckTest.php @@ -23,6 +23,7 @@ namespace Test\Updater; use OC\Updater\VersionCheck; +use OCP\Http\Client\IClientService; use OCP\IConfig; use OCP\Util; @@ -34,10 +35,10 @@ class VersionCheckTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('\OCP\IConfig') + $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); - $clientService = $this->getMockBuilder('\OCP\Http\Client\IClientService') + $clientService = $this->getMockBuilder(IClientService::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php index 9520cd640fd..0d98a9825de 100644 --- a/tests/lib/User/ManagerTest.php +++ b/tests/lib/User/ManagerTest.php @@ -615,7 +615,7 @@ class ManagerTest extends TestCase { } public function testDeleteUser() { - $config = $this->getMockBuilder('OCP\IConfig') + $config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); $config diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php index c4d29b979ae..9cbac8dfc29 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -769,7 +769,7 @@ class SessionTest extends \Test\TestCase { $session = new Memory(''); $session->set('user_id', 'foo'); - $userSession = $this->getMockBuilder('\OC\User\Session') + $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager]) ->setMethods([ 'validateSession' @@ -950,7 +950,7 @@ class SessionTest extends \Test\TestCase { $token->setUid('fritz0'); $token->setLastCheck(100); // Needs check $user = $this->createMock(IUser::class); - $userSession = $this->getMockBuilder('\OC\User\Session') + $userSession = $this->getMockBuilder(Session::class) ->setMethods(['logout']) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager]) ->getMock(); @@ -980,7 +980,7 @@ class SessionTest extends \Test\TestCase { $session = $this->createMock(ISession::class); $timeFactory = $this->createMock(ITimeFactory::class); $tokenProvider = $this->createMock(IProvider::class); - $userSession = $this->getMockBuilder('\OC\User\Session') + $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$userManager, $session, $timeFactory, $tokenProvider, $this->config, $this->random, $this->lockdownManager]) ->setMethods(['logout']) ->getMock(); @@ -1027,7 +1027,7 @@ class SessionTest extends \Test\TestCase { $session = $this->createMock(ISession::class); $timeFactory = $this->createMock(ITimeFactory::class); $tokenProvider = $this->createMock(IProvider::class); - $userSession = $this->getMockBuilder('\OC\User\Session') + $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$userManager, $session, $timeFactory, $tokenProvider, $this->config, $this->random, $this->lockdownManager]) ->setMethods(['logout']) ->getMock(); diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php index 089f30a1fef..acb171d92e3 100644 --- a/tests/lib/User/UserTest.php +++ b/tests/lib/User/UserTest.php @@ -276,7 +276,7 @@ class UserTest extends TestCase { ->method('implementsActions') ->will($this->returnValue(false)); - $allConfig = $this->getMockBuilder('\OCP\IConfig') + $allConfig = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); $allConfig->expects($this->any()) diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php index 52d18571647..49dc4ddebb1 100644 --- a/tests/lib/UtilTest.php +++ b/tests/lib/UtilTest.php @@ -10,6 +10,8 @@ namespace Test; use OC_Util; use OCP\App\IAppManager; +use OCP\IConfig; +use OCP\IUser; /** * Class UtilTest @@ -259,9 +261,9 @@ class UtilTest extends \Test\TestCase { * @param bool $expected expected result */ function testIsSharingDisabledForUser($groups, $membership, $excludedGroups, $expected) { - $config = $this->getMockBuilder('OCP\IConfig')->disableOriginalConstructor()->getMock(); + $config = $this->getMockBuilder(IConfig::class)->disableOriginalConstructor()->getMock(); $groupManager = $this->getMockBuilder('OCP\IGroupManager')->disableOriginalConstructor()->getMock(); - $user = $this->getMockBuilder('OCP\IUser')->disableOriginalConstructor()->getMock(); + $user = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); $config ->expects($this->at(0)) -- cgit v1.2.3 From 43b92b8e06a7dbf0c70ee9433eae050227af6419 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 25 Oct 2017 11:18:05 +0200 Subject: Add unit tests for SearchResult Signed-off-by: Joas Schilling --- .../Collaboration/Collaborators/SearchResult.php | 2 +- .../Collaborators/SearchResultTest.php | 105 +++++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 tests/lib/Collaboration/Collaborators/SearchResultTest.php (limited to 'tests/lib') diff --git a/lib/private/Collaboration/Collaborators/SearchResult.php b/lib/private/Collaboration/Collaborators/SearchResult.php index 1ab61e257f0..184c1f69a1b 100644 --- a/lib/private/Collaboration/Collaborators/SearchResult.php +++ b/lib/private/Collaboration/Collaborators/SearchResult.php @@ -52,7 +52,7 @@ class SearchResult implements ISearchResult { $this->exactIdMatches[$type->getLabel()] = 1; } - public function hasExactIdMatch(SearchResultType$type) { + public function hasExactIdMatch(SearchResultType $type) { return isset($this->exactIdMatches[$type->getLabel()]); } diff --git a/tests/lib/Collaboration/Collaborators/SearchResultTest.php b/tests/lib/Collaboration/Collaborators/SearchResultTest.php new file mode 100644 index 00000000000..90ea90237a1 --- /dev/null +++ b/tests/lib/Collaboration/Collaborators/SearchResultTest.php @@ -0,0 +1,105 @@ + + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace Test\Collaboration\Collaborators; + + +use OC\Collaboration\Collaborators\Search; +use OC\Collaboration\Collaborators\SearchResult; +use OCP\Collaboration\Collaborators\ISearch; +use OCP\Collaboration\Collaborators\ISearchPlugin; +use OCP\Collaboration\Collaborators\SearchResultType; +use OCP\IContainer; +use OCP\Share; +use Test\TestCase; + +class SearchResultTest extends TestCase { + /** @var IContainer|\PHPUnit_Framework_MockObject_MockObject */ + protected $container; + /** @var ISearch */ + protected $search; + + public function setUp() { + parent::setUp(); + + $this->container = $this->createMock(IContainer::class); + + $this->search = new Search($this->container); + } + + public function dataAddResultSet() { + return [ + [[], ['exact' => []]], + [['users' => ['exact' => null, 'loose' => []]], ['exact' => ['users' => []], 'users' => []]], + [['groups' => ['exact' => null, 'loose' => ['l1']]], ['exact' => ['groups' => []], 'groups' => ['l1']]], + [['users' => ['exact' => ['e1'], 'loose' => []]], ['exact' => ['users' => ['e1']], 'users' => []]], + ]; + } + + /** + * @dataProvider dataAddResultSet + * @param array $toAdd + * @param array $expected + */ + public function testAddResultSet(array $toAdd, array $expected) { + $result = new SearchResult(); + + foreach ($toAdd as $type => $results) { + $result->addResultSet(new SearchResultType($type), $results['loose'], $results['exact']); + } + + $this->assertEquals($expected, $result->asArray()); + } + + public function dataHasResult() { + $result = ['value' => ['shareWith' => 'l1']]; + return [ + [[],'users', 'n1', false], + [['users' => ['exact' => null, 'loose' => [$result]]], 'users', 'l1', true], + [['users' => ['exact' => null, 'loose' => [$result]]], 'users', 'l2', false], + [['users' => ['exact' => null, 'loose' => [$result]]], 'groups', 'l1', false], + [['users' => ['exact' => [$result], 'loose' => []]], 'users', 'l1', true], + [['users' => ['exact' => [$result], 'loose' => []]], 'users', 'l2', false], + [['users' => ['exact' => [$result], 'loose' => []]], 'groups', 'l1', false], + + ]; + } + + /** + * @dataProvider dataHasResult + * @param array $toAdd + * @param string $type + * @param string $id + * @param bool $expected + */ + public function testHasResult(array $toAdd, $type, $id, $expected) { + $result = new SearchResult(); + + foreach ($toAdd as $addType => $results) { + $result->addResultSet(new SearchResultType($addType), $results['loose'], $results['exact']); + } + + $this->assertSame($expected, $result->hasResult(new SearchResultType($type), $id)); + } + +} -- cgit v1.2.3 From ab36980d20feb895d9b33ff5dbaacc2cd9fbd3fc Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 25 Oct 2017 00:03:28 +0200 Subject: Use ::class in test mocks of dav app Signed-off-by: Morris Jobke --- apps/dav/tests/unit/CardDAV/ConverterTest.php | 4 ++-- apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php | 4 ++-- apps/dav/tests/unit/Comments/CommentsNodeTest.php | 3 ++- apps/dav/tests/unit/Connector/PublicAuthTest.php | 17 +++++++-------- .../Sabre/CommentsPropertiesPluginTest.php | 3 ++- .../Connector/Sabre/CopyEtagHeaderPluginTest.php | 6 ++++-- .../tests/unit/Connector/Sabre/DirectoryTest.php | 9 ++++---- .../Connector/Sabre/DummyGetResponsePluginTest.php | 6 ++++-- .../unit/Connector/Sabre/FakeLockerPluginTest.php | 13 +++++++----- apps/dav/tests/unit/Connector/Sabre/FileTest.php | 2 +- .../tests/unit/Connector/Sabre/FilesPluginTest.php | 14 +++++++------ .../unit/Connector/Sabre/FilesReportPluginTest.php | 13 ++++++------ apps/dav/tests/unit/Connector/Sabre/NodeTest.php | 14 ++++++++----- .../tests/unit/Connector/Sabre/ObjectTreeTest.php | 9 ++++---- .../tests/unit/Connector/Sabre/QuotaPluginTest.php | 4 ++-- .../unit/Connector/Sabre/SharesPluginTest.php | 6 ++++-- .../tests/unit/Connector/Sabre/TagsPluginTest.php | 15 ++++++++------ .../tests/unit/DAV/BrowserErrorPagePluginTest.php | 5 +++-- apps/dav/tests/unit/DAV/HookManagerTest.php | 2 +- apps/dav/tests/unit/DAV/Sharing/PluginTest.php | 4 ++-- .../unit/SystemTag/SystemTagMappingNodeTest.php | 6 ++++-- .../dav/tests/unit/SystemTag/SystemTagNodeTest.php | 3 ++- .../tests/unit/SystemTag/SystemTagPluginTest.php | 24 +++++++++++++--------- .../SystemTag/SystemTagsByIdCollectionTest.php | 3 ++- .../SystemTagsObjectMappingCollectionTest.php | 6 ++++-- .../SystemTagsObjectTypeCollectionTest.php | 6 ++++-- apps/dav/tests/unit/Upload/AssemblyStreamTest.php | 4 +++- apps/dav/tests/unit/Upload/FutureFileTest.php | 6 ++++-- .../Controller/MountPublicLinkControllerTest.php | 2 +- .../Controller/RequestHandlerControllerTest.php | 2 +- .../tests/Controller/ShareAPIControllerTest.php | 12 +++++------ .../tests/Controller/ShareControllerTest.php | 5 +++-- apps/files_versions/tests/VersioningTest.php | 2 +- apps/sharebymail/tests/ShareByMailProviderTest.php | 4 ++-- tests/Settings/Controller/GroupsControllerTest.php | 5 +++-- tests/lib/Encryption/UpdateTest.php | 3 ++- tests/lib/FileChunkingTest.php | 2 +- tests/lib/Files/Node/FolderTest.php | 6 +++--- tests/lib/Files/Node/NodeTest.php | 3 ++- tests/lib/Files/Node/RootTest.php | 2 +- tests/lib/Files/ViewTest.php | 4 ++-- 41 files changed, 154 insertions(+), 109 deletions(-) (limited to 'tests/lib') diff --git a/apps/dav/tests/unit/CardDAV/ConverterTest.php b/apps/dav/tests/unit/CardDAV/ConverterTest.php index e4b78485114..9ab0631e93a 100644 --- a/apps/dav/tests/unit/CardDAV/ConverterTest.php +++ b/apps/dav/tests/unit/CardDAV/ConverterTest.php @@ -46,8 +46,8 @@ class ConverterTest extends TestCase { public function setUp() { parent::setUp(); - $this->databaseConnection = $this->getMockBuilder('OCP\IDBConnection')->getMock(); - $this->eventDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') + $this->databaseConnection = $this->getMockBuilder(IDBConnection::class)->getMock(); + $this->eventDispatcher = $this->getMockBuilder(EventDispatcher::class) ->disableOriginalConstructor()->getMock(); $this->accountManager = $this->getMockBuilder(AccountManager::class) ->disableOriginalConstructor()->getMock(); diff --git a/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php b/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php index 8536deb8e6e..4d4070511bb 100644 --- a/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php +++ b/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php @@ -47,7 +47,7 @@ class PluginTest extends TestCase { parent::setUp(); /** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */ - $authBackend = $this->getMockBuilder('OCA\DAV\Connector\Sabre\Auth')->disableOriginalConstructor()->getMock(); + $authBackend = $this->getMockBuilder(Auth::class)->disableOriginalConstructor()->getMock(); $authBackend->method('isDavAuthenticated')->willReturn(true); /** @var IRequest $request */ @@ -57,7 +57,7 @@ class PluginTest extends TestCase { $root = new SimpleCollection('root'); $this->server = new \Sabre\DAV\Server($root); /** @var SimpleCollection $node */ - $this->book = $this->getMockBuilder('OCA\DAV\DAV\Sharing\IShareable')->disableOriginalConstructor()->getMock(); + $this->book = $this->getMockBuilder(IShareable::class)->disableOriginalConstructor()->getMock(); $this->book->method('getName')->willReturn('addressbook1.vcf'); $root->addChild($this->book); $this->plugin->initialize($this->server); diff --git a/apps/dav/tests/unit/Comments/CommentsNodeTest.php b/apps/dav/tests/unit/Comments/CommentsNodeTest.php index 57a15a6dc76..a0ff029efa7 100644 --- a/apps/dav/tests/unit/Comments/CommentsNodeTest.php +++ b/apps/dav/tests/unit/Comments/CommentsNodeTest.php @@ -33,6 +33,7 @@ use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; +use Sabre\DAV\PropPatch; class CommentsNodeTest extends \Test\TestCase { @@ -361,7 +362,7 @@ class CommentsNodeTest extends \Test\TestCase { } public function testPropPatch() { - $propPatch = $this->getMockBuilder('Sabre\DAV\PropPatch') + $propPatch = $this->getMockBuilder(PropPatch::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/Connector/PublicAuthTest.php b/apps/dav/tests/unit/Connector/PublicAuthTest.php index 90401e03853..dbb39bac6d2 100644 --- a/apps/dav/tests/unit/Connector/PublicAuthTest.php +++ b/apps/dav/tests/unit/Connector/PublicAuthTest.php @@ -28,6 +28,7 @@ use OCP\IRequest; use OCP\ISession; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; +use OCP\Share\IShare; /** * Class PublicAuthTest @@ -94,7 +95,7 @@ class PublicAuthTest extends \Test\TestCase { } public function testShareNoPassword() { - $share = $this->getMockBuilder('OCP\Share\IShare') + $share = $this->getMockBuilder(IShare::class) ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn(null); @@ -109,7 +110,7 @@ class PublicAuthTest extends \Test\TestCase { } public function testSharePasswordFancyShareType() { - $share = $this->getMockBuilder('OCP\Share\IShare') + $share = $this->getMockBuilder(IShare::class) ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); @@ -126,7 +127,7 @@ class PublicAuthTest extends \Test\TestCase { public function testSharePasswordRemote() { - $share = $this->getMockBuilder('OCP\Share\IShare') + $share = $this->getMockBuilder(IShare::class) ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); @@ -142,7 +143,7 @@ class PublicAuthTest extends \Test\TestCase { } public function testSharePasswordLinkValidPassword() { - $share = $this->getMockBuilder('OCP\Share\IShare') + $share = $this->getMockBuilder(IShare::class) ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); @@ -164,7 +165,7 @@ class PublicAuthTest extends \Test\TestCase { } public function testSharePasswordMailValidPassword() { - $share = $this->getMockBuilder('OCP\Share\IShare') + $share = $this->getMockBuilder(IShare::class) ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); @@ -186,7 +187,7 @@ class PublicAuthTest extends \Test\TestCase { } public function testSharePasswordLinkValidSession() { - $share = $this->getMockBuilder('OCP\Share\IShare') + $share = $this->getMockBuilder(IShare::class) ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); @@ -212,7 +213,7 @@ class PublicAuthTest extends \Test\TestCase { } public function testSharePasswordLinkInvalidSession() { - $share = $this->getMockBuilder('OCP\Share\IShare') + $share = $this->getMockBuilder(IShare::class) ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); @@ -239,7 +240,7 @@ class PublicAuthTest extends \Test\TestCase { public function testSharePasswordMailInvalidSession() { - $share = $this->getMockBuilder('OCP\Share\IShare') + $share = $this->getMockBuilder(IShare::class) ->disableOriginalConstructor() ->getMock(); $share->method('getPassword')->willReturn('password'); diff --git a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php index c02bd5046d8..c31a3af980b 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php @@ -29,6 +29,7 @@ use OCA\DAV\Connector\Sabre\File; use OCP\Comments\ICommentsManager; use OCP\IUser; use OCP\IUserSession; +use Sabre\DAV\PropFind; class CommentsPropertiesPluginTest extends \Test\TestCase { @@ -77,7 +78,7 @@ class CommentsPropertiesPluginTest extends \Test\TestCase { * @param $expectedSuccessful */ public function testHandleGetProperties($node, $expectedSuccessful) { - $propFind = $this->getMockBuilder('\Sabre\DAV\PropFind') + $propFind = $this->getMockBuilder(PropFind::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php index 773d5d7f98b..f44a4abf634 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php @@ -24,7 +24,9 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre; use OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin; +use OCA\DAV\Connector\Sabre\File; use Sabre\DAV\Server; +use Sabre\DAV\Tree; use Test\TestCase; /** @@ -68,13 +70,13 @@ class CopyEtagHeaderPluginTest extends TestCase { } public function testAfterMove() { - $node = $this->getMockBuilder('OCA\DAV\Connector\Sabre\File') + $node = $this->getMockBuilder(File::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) ->method('getETag') ->willReturn('123456'); - $tree = $this->getMockBuilder('Sabre\DAV\Tree') + $tree = $this->getMockBuilder(Tree::class) ->disableOriginalConstructor() ->getMock(); $tree->expects($this->once()) diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php index f27f67b0aae..d5da0dce0d1 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -26,6 +26,7 @@ namespace OCA\DAV\Tests\Unit\Connector\Sabre; +use OC\Files\Storage\Wrapper\Quota; use OCP\Files\ForbiddenException; use OC\Files\FileInfo; use OCA\DAV\Connector\Sabre\Directory; @@ -179,10 +180,10 @@ class DirectoryTest extends \Test\TestCase { } public function testGetChildren() { - $info1 = $this->getMockBuilder('OC\Files\FileInfo') + $info1 = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor() ->getMock(); - $info2 = $this->getMockBuilder('OC\Files\FileInfo') + $info2 = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor() ->getMock(); $info1->expects($this->any()) @@ -269,7 +270,7 @@ class DirectoryTest extends \Test\TestCase { } public function testGetQuotaInfoUnlimited() { - $storage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Quota') + $storage = $this->getMockBuilder(Quota::class) ->disableOriginalConstructor() ->getMock(); @@ -300,7 +301,7 @@ class DirectoryTest extends \Test\TestCase { } public function testGetQuotaInfoSpecific() { - $storage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Quota') + $storage = $this->getMockBuilder(Quota::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php index f16c374a0e1..fa6f849f12f 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php @@ -27,6 +27,8 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre; use OCA\DAV\Connector\Sabre\DummyGetResponsePlugin; use Sabre\DAV\Server; +use Sabre\HTTP\RequestInterface; +use Sabre\HTTP\ResponseInterface; use Test\TestCase; /** @@ -60,11 +62,11 @@ class DummyGetResponsePluginTest extends TestCase { public function testHttpGet() { /** @var \Sabre\HTTP\RequestInterface $request */ - $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); /** @var \Sabre\HTTP\ResponseInterface $response */ - $response = $server = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface') + $response = $server = $this->getMockBuilder(ResponseInterface::class) ->disableOriginalConstructor() ->getMock(); $response diff --git a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php index 1fd2b05c23d..e42bb1704f0 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php @@ -26,8 +26,11 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre; use OCA\DAV\Connector\Sabre\FakeLockerPlugin; use Sabre\DAV\INode; +use Sabre\DAV\PropFind; use Sabre\DAV\Server; +use Sabre\HTTP\RequestInterface; use Sabre\HTTP\Response; +use Sabre\HTTP\ResponseInterface; use Test\TestCase; /** @@ -85,7 +88,7 @@ class FakeLockerPluginTest extends TestCase { } public function testPropFind() { - $propFind = $this->getMockBuilder('\Sabre\DAV\PropFind') + $propFind = $this->getMockBuilder(PropFind::class) ->disableOriginalConstructor() ->getMock(); $node = $this->getMockBuilder(INode::class) @@ -145,7 +148,7 @@ class FakeLockerPluginTest extends TestCase { * @param array $expected */ public function testValidateTokens(array $input, array $expected) { - $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); $this->fakeLockerPlugin->validateTokens($request, $input); @@ -153,7 +156,7 @@ class FakeLockerPluginTest extends TestCase { } public function testFakeLockProvider() { - $request = $this->getMockBuilder('\Sabre\HTTP\RequestInterface') + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); $response = new Response(); @@ -173,10 +176,10 @@ class FakeLockerPluginTest extends TestCase { } public function testFakeUnlockProvider() { - $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/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php index 3a2075941ae..bf9daebdc5b 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php @@ -882,7 +882,7 @@ class FileTest extends \Test\TestCase { $wasLockedPre = false; $wasLockedPost = false; - $eventHandler = $this->getMockBuilder('\stdclass') + $eventHandler = $this->getMockBuilder(\stdclass::class) ->setMethods(['writeCallback', 'postWriteCallback']) ->getMock(); diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php index a33ece3c4b3..e3cf1ff4453 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php @@ -25,8 +25,10 @@ */ namespace OCA\DAV\Tests\unit\Connector\Sabre; +use OC\User\User; use OCA\DAV\Connector\Sabre\File; use OCA\DAV\Connector\Sabre\FilesPlugin; +use OCA\DAV\Connector\Sabre\Node; use OCP\Files\StorageNotAvailableException; use OCP\IConfig; use OCP\IPreview; @@ -188,7 +190,7 @@ class FilesPluginTest extends TestCase { 0 ); - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $user ->expects($this->once()) @@ -457,14 +459,14 @@ class FilesPluginTest extends TestCase { * @expectedExceptionMessage FolderA/test.txt cannot be deleted */ public function testMoveSrcNotDeletable() { - $fileInfoFolderATestTXT = $this->getMockBuilder('\OCP\Files\FileInfo') + $fileInfoFolderATestTXT = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor() ->getMock(); $fileInfoFolderATestTXT->expects($this->once()) ->method('isDeletable') ->willReturn(false); - $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Node') + $node = $this->getMockBuilder(Node::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -478,14 +480,14 @@ class FilesPluginTest extends TestCase { } public function testMoveSrcDeletable() { - $fileInfoFolderATestTXT = $this->getMockBuilder('\OCP\Files\FileInfo') + $fileInfoFolderATestTXT = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor() ->getMock(); $fileInfoFolderATestTXT->expects($this->once()) ->method('isDeletable') ->willReturn(true); - $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Node') + $node = $this->getMockBuilder(Node::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) @@ -503,7 +505,7 @@ class FilesPluginTest extends TestCase { * @expectedExceptionMessage FolderA/test.txt does not exist */ public function testMoveSrcNotExist() { - $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Node') + $node = $this->getMockBuilder(Node::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->once()) diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php index 374557c6b67..c46e4b14805 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php @@ -33,6 +33,7 @@ use OCP\IRequest; use OCP\ITagManager; use OCP\IUser; use OCP\IUserSession; +use OCP\SystemTag\ISystemTag; use OCP\SystemTag\ISystemTagObjectMapper; use OC\Files\View; use OCP\Files\Folder; @@ -550,7 +551,7 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('isAdmin') ->will($this->returnValue(true)); - $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag') + $tag1 = $this->getMockBuilder(ISystemTag::class) ->disableOriginalConstructor() ->getMock(); $tag1->expects($this->any()) @@ -560,7 +561,7 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('isUserVisible') ->will($this->returnValue(true)); - $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag') + $tag2 = $this->getMockBuilder(ISystemTag::class) ->disableOriginalConstructor() ->getMock(); $tag2->expects($this->any()) @@ -599,7 +600,7 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('isAdmin') ->will($this->returnValue(false)); - $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag') + $tag1 = $this->getMockBuilder(ISystemTag::class) ->disableOriginalConstructor() ->getMock(); $tag1->expects($this->any()) @@ -609,7 +610,7 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('isUserVisible') ->will($this->returnValue(true)); - $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag') + $tag2 = $this->getMockBuilder(ISystemTag::class) ->disableOriginalConstructor() ->getMock(); $tag2->expects($this->any()) @@ -637,7 +638,7 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('isAdmin') ->will($this->returnValue(false)); - $tag1 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag') + $tag1 = $this->getMockBuilder(ISystemTag::class) ->disableOriginalConstructor() ->getMock(); $tag1->expects($this->any()) @@ -647,7 +648,7 @@ class FilesReportPluginTest extends \Test\TestCase { ->method('isUserVisible') ->will($this->returnValue(true)); - $tag2 = $this->getMockBuilder('\OCP\SystemTag\ISystemTag') + $tag2 = $this->getMockBuilder(ISystemTag::class) ->disableOriginalConstructor() ->getMock(); $tag2->expects($this->any()) diff --git a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php index e7ab94ac926..fe6cbd97829 100644 --- a/apps/dav/tests/unit/Connector/Sabre/NodeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/NodeTest.php @@ -25,8 +25,12 @@ */ namespace OCA\DAV\Tests\unit\Connector\Sabre; +use OC\Files\FileInfo; use OC\Files\View; +use OCP\Files\Mount\IMountPoint; use OCP\Files\Storage; +use OCP\Share\IManager; +use OCP\Share\IShare; /** * Class NodeTest @@ -53,7 +57,7 @@ class NodeTest extends \Test\TestCase { * @dataProvider davPermissionsProvider */ public function testDavPermissions($permissions, $type, $shared, $mounted, $expected) { - $info = $this->getMockBuilder('\OC\Files\FileInfo') + $info = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor() ->setMethods(array('getPermissions', 'isShared', 'isMounted', 'getType')) ->getMock(); @@ -126,12 +130,12 @@ class NodeTest extends \Test\TestCase { ->getMock(); $storage->method('getPermissions')->willReturn($permissions); - $mountpoint = $this->getMockBuilder('\OCP\Files\Mount\IMountPoint') + $mountpoint = $this->getMockBuilder(IMountPoint::class) ->disableOriginalConstructor() ->getMock(); $mountpoint->method('getMountPoint')->willReturn('myPath'); - $shareManager = $this->getMockBuilder('OCP\Share\IManager')->disableOriginalConstructor()->getMock(); - $share = $this->getMockBuilder('OCP\Share\IShare')->disableOriginalConstructor()->getMock(); + $shareManager = $this->getMockBuilder(IManager::class)->disableOriginalConstructor()->getMock(); + $share = $this->getMockBuilder(IShare::class)->disableOriginalConstructor()->getMock(); if ($user === null) { $shareManager->expects($this->never())->method('getShareByToken'); @@ -142,7 +146,7 @@ class NodeTest extends \Test\TestCase { $share->expects($this->once())->method('getPermissions')->willReturn($permissions); } - $info = $this->getMockBuilder('\OC\Files\FileInfo') + $info = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor() ->setMethods(['getStorage', 'getType', 'getMountPoint']) ->getMock(); diff --git a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php index c9c55adc9e8..d1b37541dc3 100644 --- a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php @@ -31,6 +31,7 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre; use OC\Files\FileInfo; use OC\Files\Filesystem; +use OC\Files\Mount\Manager; use OC\Files\Storage\Temporary; use OC\Files\View; use OCA\DAV\Connector\Sabre\Directory; @@ -159,13 +160,13 @@ class ObjectTreeTest extends \Test\TestCase { $rootNode = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); - $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager') + $mountManager = $this->getMockBuilder(Manager::class) ->disableOriginalConstructor() ->getMock(); $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); - $fileInfo = $this->getMockBuilder('\OCP\Files\FileInfo') + $fileInfo = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor() ->getMock(); $fileInfo->expects($this->once()) @@ -287,7 +288,7 @@ class ObjectTreeTest extends \Test\TestCase { $rootNode = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); - $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager') + $mountManager = $this->getMockBuilder(Manager::class) ->getMock(); $tree = new \OCA\DAV\Connector\Sabre\ObjectTree(); @@ -314,7 +315,7 @@ class ObjectTreeTest extends \Test\TestCase { $rootNode = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->getMock(); - $mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager') + $mountManager = $this->getMockBuilder(Manager::class) ->getMock(); $tree = new \OCA\DAV\Connector\Sabre\ObjectTree(); diff --git a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php index d29080539e6..927178996c9 100644 --- a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php @@ -176,7 +176,7 @@ class QuotaPluginTest extends TestCase { public function testCheckQuotaChunkedOk($quota, $chunkTotalSize, $headers) { $this->init($quota, 'sub/test.txt'); - $mockChunking = $this->getMockBuilder('\OC_FileChunking') + $mockChunking = $this->getMockBuilder(\OC_FileChunking::class) ->disableOriginalConstructor() ->getMock(); $mockChunking->expects($this->once()) @@ -212,7 +212,7 @@ class QuotaPluginTest extends TestCase { public function testCheckQuotaChunkedFail($quota, $chunkTotalSize, $headers) { $this->init($quota, 'sub/test.txt'); - $mockChunking = $this->getMockBuilder('\OC_FileChunking') + $mockChunking = $this->getMockBuilder(\OC_FileChunking::class) ->disableOriginalConstructor() ->getMock(); $mockChunking->expects($this->once()) diff --git a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php index 7c735ca2334..57be6e5a9e2 100644 --- a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php @@ -25,10 +25,12 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre; use OCA\DAV\Connector\Sabre\Directory; use OCA\DAV\Connector\Sabre\File; +use OCA\DAV\Connector\Sabre\Node; use OCP\Files\Folder; use OCP\IUser; use OCP\IUserSession; use OCP\Share\IManager; +use OCP\Share\IShare; use Sabre\DAV\Tree; class SharesPluginTest extends \Test\TestCase { @@ -99,7 +101,7 @@ class SharesPluginTest extends \Test\TestCase { * @dataProvider sharesGetPropertiesDataProvider */ public function testGetProperties($shareTypes) { - $sabreNode = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Node') + $sabreNode = $this->getMockBuilder(Node::class) ->disableOriginalConstructor() ->getMock(); $sabreNode->expects($this->any()) @@ -214,7 +216,7 @@ class SharesPluginTest extends \Test\TestCase { ->will($this->returnValue($node)); $dummyShares = array_map(function($type) { - $share = $this->getMockBuilder('\OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->expects($this->any()) ->method('getShareType') ->will($this->returnValue($type)); diff --git a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php index 48d02cad690..af156310887 100644 --- a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php @@ -26,6 +26,9 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre; use OCA\DAV\Connector\Sabre\Directory; use OCA\DAV\Connector\Sabre\File; +use OCA\DAV\Connector\Sabre\Node; +use OCP\ITagManager; +use OCP\ITags; use Sabre\DAV\Tree; /** @@ -71,10 +74,10 @@ class TagsPluginTest extends \Test\TestCase { $this->tree = $this->getMockBuilder(Tree::class) ->disableOriginalConstructor() ->getMock(); - $this->tagger = $this->getMockBuilder('\OCP\ITags') + $this->tagger = $this->getMockBuilder(ITags::class) ->disableOriginalConstructor() ->getMock(); - $this->tagManager = $this->getMockBuilder('\OCP\ITagManager') + $this->tagManager = $this->getMockBuilder(ITagManager::class) ->disableOriginalConstructor() ->getMock(); $this->tagManager->expects($this->any()) @@ -89,7 +92,7 @@ class TagsPluginTest extends \Test\TestCase { * @dataProvider tagsGetPropertiesDataProvider */ public function testGetProperties($tags, $requestedProperties, $expectedProperties) { - $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Node') + $node = $this->getMockBuilder(Node::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any()) @@ -264,7 +267,7 @@ class TagsPluginTest extends \Test\TestCase { public function testUpdateTags() { // this test will replace the existing tags "tagremove" with "tag1" and "tag2" // and keep "tagkeep" - $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Node') + $node = $this->getMockBuilder(Node::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any()) @@ -315,7 +318,7 @@ class TagsPluginTest extends \Test\TestCase { } public function testUpdateTagsFromScratch() { - $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Node') + $node = $this->getMockBuilder(Node::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any()) @@ -363,7 +366,7 @@ class TagsPluginTest extends \Test\TestCase { public function testUpdateFav() { // this test will replace the existing tags "tagremove" with "tag1" and "tag2" // and keep "tagkeep" - $node = $this->getMockBuilder('\OCA\DAV\Connector\Sabre\Node') + $node = $this->getMockBuilder(Node::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any()) diff --git a/apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php b/apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php index cdeaceefedf..32f19e9ddb9 100644 --- a/apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php +++ b/apps/dav/tests/unit/DAV/BrowserErrorPagePluginTest.php @@ -26,6 +26,7 @@ namespace OCA\DAV\Tests\unit\DAV; use OCA\DAV\Files\BrowserErrorPagePlugin; use PHPUnit_Framework_MockObject_MockObject; use Sabre\DAV\Exception\NotFound; +use Sabre\HTTP\Response; class BrowserErrorPagePluginTest extends \Test\TestCase { @@ -36,13 +37,13 @@ class BrowserErrorPagePluginTest extends \Test\TestCase { */ public function test($expectedCode, $exception) { /** @var BrowserErrorPagePlugin | PHPUnit_Framework_MockObject_MockObject $plugin */ - $plugin = $this->getMockBuilder('OCA\DAV\Files\BrowserErrorPagePlugin')->setMethods(['sendResponse', 'generateBody'])->getMock(); + $plugin = $this->getMockBuilder(BrowserErrorPagePlugin::class)->setMethods(['sendResponse', 'generateBody'])->getMock(); $plugin->expects($this->once())->method('generateBody')->willReturn(':boom:'); $plugin->expects($this->once())->method('sendResponse'); /** @var \Sabre\DAV\Server | PHPUnit_Framework_MockObject_MockObject $server */ $server = $this->getMockBuilder('Sabre\DAV\Server')->disableOriginalConstructor()->getMock(); $server->expects($this->once())->method('on'); - $httpResponse = $this->getMockBuilder('Sabre\HTTP\Response')->disableOriginalConstructor()->getMock(); + $httpResponse = $this->getMockBuilder(Response::class)->disableOriginalConstructor()->getMock(); $httpResponse->expects($this->once())->method('addHeaders'); $httpResponse->expects($this->once())->method('setStatus')->with($expectedCode); $httpResponse->expects($this->once())->method('setBody')->with(':boom:'); diff --git a/apps/dav/tests/unit/DAV/HookManagerTest.php b/apps/dav/tests/unit/DAV/HookManagerTest.php index a78ffea5af4..3296d550a6b 100644 --- a/apps/dav/tests/unit/DAV/HookManagerTest.php +++ b/apps/dav/tests/unit/DAV/HookManagerTest.php @@ -42,7 +42,7 @@ class HookManagerTest extends TestCase { public function setUp() { parent::setUp(); - $this->eventDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock(); + $this->eventDispatcher = $this->getMockBuilder(EventDispatcher::class)->disableOriginalConstructor()->getMock(); $this->l10n = $this->createMock(IL10N::class); $this->l10n ->expects($this->any()) diff --git a/apps/dav/tests/unit/DAV/Sharing/PluginTest.php b/apps/dav/tests/unit/DAV/Sharing/PluginTest.php index 1a9015c6cbb..d6291467e47 100644 --- a/apps/dav/tests/unit/DAV/Sharing/PluginTest.php +++ b/apps/dav/tests/unit/DAV/Sharing/PluginTest.php @@ -47,7 +47,7 @@ class PluginTest extends TestCase { parent::setUp(); /** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */ - $authBackend = $this->getMockBuilder('OCA\DAV\Connector\Sabre\Auth')->disableOriginalConstructor()->getMock(); + $authBackend = $this->getMockBuilder(Auth::class)->disableOriginalConstructor()->getMock(); $authBackend->method('isDavAuthenticated')->willReturn(true); /** @var IRequest $request */ @@ -57,7 +57,7 @@ class PluginTest extends TestCase { $root = new SimpleCollection('root'); $this->server = new \Sabre\DAV\Server($root); /** @var SimpleCollection $node */ - $this->book = $this->getMockBuilder('OCA\DAV\DAV\Sharing\IShareable')-> + $this->book = $this->getMockBuilder(IShareable::class)-> disableOriginalConstructor()-> getMock(); $this->book->method('getName')->willReturn('addressbook1.vcf'); diff --git a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php index ac4e9016434..f67160af8d0 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php @@ -26,6 +26,8 @@ namespace OCA\DAV\Tests\unit\SystemTag; use OC\SystemTag\SystemTag; use OCP\IUser; +use OCP\SystemTag\ISystemTagManager; +use OCP\SystemTag\ISystemTagObjectMapper; use OCP\SystemTag\TagNotFoundException; use OCP\SystemTag\ISystemTag; @@ -49,9 +51,9 @@ class SystemTagMappingNodeTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager') + $this->tagManager = $this->getMockBuilder(ISystemTagManager::class) ->getMock(); - $this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper') + $this->tagMapper = $this->getMockBuilder(ISystemTagObjectMapper::class) ->getMock(); $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 e50c3d30758..dd6892fe6ea 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php @@ -27,6 +27,7 @@ namespace OCA\DAV\Tests\unit\SystemTag; use OC\SystemTag\SystemTag; use OCP\IUser; +use OCP\SystemTag\ISystemTagManager; use OCP\SystemTag\TagNotFoundException; use OCP\SystemTag\TagAlreadyExistsException; use OCP\SystemTag\ISystemTag; @@ -47,7 +48,7 @@ class SystemTagNodeTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager') + $this->tagManager = $this->getMockBuilder(ISystemTagManager::class) ->getMock(); $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 f1c18cf45a3..b231577845c 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php @@ -27,8 +27,12 @@ namespace OCA\DAV\Tests\unit\SystemTag; use OC\SystemTag\SystemTag; +use OCA\DAV\SystemTag\SystemTagNode; +use OCA\DAV\SystemTag\SystemTagsByIdCollection; +use OCA\DAV\SystemTag\SystemTagsObjectMappingCollection; use OCP\IGroupManager; use OCP\IUserSession; +use OCP\SystemTag\ISystemTagManager; use OCP\SystemTag\TagAlreadyExistsException; use OCP\IUser; use OCP\SystemTag\ISystemTag; @@ -88,7 +92,7 @@ class SystemTagPluginTest extends \Test\TestCase { $this->server = new \Sabre\DAV\Server($this->tree); - $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager') + $this->tagManager = $this->getMockBuilder(ISystemTagManager::class) ->getMock(); $this->groupManager = $this->getMockBuilder(IGroupManager::class) ->getMock(); @@ -192,7 +196,7 @@ class SystemTagPluginTest extends \Test\TestCase { ->with('admin') ->willReturn(true); - $node = $this->getMockBuilder('\OCA\DAV\SystemTag\SystemTagNode') + $node = $this->getMockBuilder(SystemTagNode::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any()) @@ -247,7 +251,7 @@ class SystemTagPluginTest extends \Test\TestCase { ->with('admin') ->willReturn(false); - $node = $this->getMockBuilder('\OCA\DAV\SystemTag\SystemTagNode') + $node = $this->getMockBuilder(SystemTagNode::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any()) @@ -282,7 +286,7 @@ class SystemTagPluginTest extends \Test\TestCase { ->with('admin') ->willReturn(true); - $node = $this->getMockBuilder('\OCA\DAV\SystemTag\SystemTagNode') + $node = $this->getMockBuilder(SystemTagNode::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any()) @@ -340,7 +344,7 @@ class SystemTagPluginTest extends \Test\TestCase { ->with('admin') ->willReturn(false); - $node = $this->getMockBuilder('\OCA\DAV\SystemTag\SystemTagNode') + $node = $this->getMockBuilder(SystemTagNode::class) ->disableOriginalConstructor() ->getMock(); $node->expects($this->any()) @@ -403,7 +407,7 @@ class SystemTagPluginTest extends \Test\TestCase { } $requestData = json_encode($requestData); - $node = $this->getMockBuilder('\OCA\DAV\SystemTag\SystemTagsByIdCollection') + $node = $this->getMockBuilder(SystemTagsByIdCollection::class) ->disableOriginalConstructor() ->getMock(); $this->tagManager->expects($this->never()) @@ -448,7 +452,7 @@ class SystemTagPluginTest extends \Test\TestCase { 'userAssignable' => true, ]); - $node = $this->getMockBuilder('\OCA\DAV\SystemTag\SystemTagsByIdCollection') + $node = $this->getMockBuilder(SystemTagsByIdCollection::class) ->disableOriginalConstructor() ->getMock(); $this->tagManager->expects($this->once()) @@ -525,7 +529,7 @@ class SystemTagPluginTest extends \Test\TestCase { } $requestData = json_encode($requestData); - $node = $this->getMockBuilder('\OCA\DAV\SystemTag\SystemTagsByIdCollection') + $node = $this->getMockBuilder(SystemTagsByIdCollection::class) ->disableOriginalConstructor() ->getMock(); $this->tagManager->expects($this->once()) @@ -604,7 +608,7 @@ class SystemTagPluginTest extends \Test\TestCase { 'userAssignable' => false, ]); - $node = $this->getMockBuilder('\OCA\DAV\SystemTag\SystemTagsObjectMappingCollection') + $node = $this->getMockBuilder(SystemTagsObjectMappingCollection::class) ->disableOriginalConstructor() ->getMock(); @@ -657,7 +661,7 @@ class SystemTagPluginTest extends \Test\TestCase { * @expectedException \Sabre\DAV\Exception\NotFound */ public function testCreateTagToUnknownNode() { - $node = $this->getMockBuilder('\OCA\DAV\SystemTag\SystemTagsObjectMappingCollection') + $node = $this->getMockBuilder(SystemTagsObjectMappingCollection::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php index 53f54e19f0a..ec52de0536a 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php @@ -29,6 +29,7 @@ use OC\SystemTag\SystemTag; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserSession; +use OCP\SystemTag\ISystemTagManager; use OCP\SystemTag\TagNotFoundException; class SystemTagsByIdCollectionTest extends \Test\TestCase { @@ -46,7 +47,7 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager') + $this->tagManager = $this->getMockBuilder(ISystemTagManager::class) ->getMock(); } diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php index 61f94c9e60b..f99e4df1f69 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php @@ -27,6 +27,8 @@ namespace OCA\DAV\Tests\unit\SystemTag; use OC\SystemTag\SystemTag; use OCP\IUser; +use OCP\SystemTag\ISystemTagManager; +use OCP\SystemTag\ISystemTagObjectMapper; use OCP\SystemTag\TagNotFoundException; class SystemTagsObjectMappingCollectionTest extends \Test\TestCase { @@ -49,9 +51,9 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager') + $this->tagManager = $this->getMockBuilder(ISystemTagManager::class) ->getMock(); - $this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper') + $this->tagMapper = $this->getMockBuilder(ISystemTagObjectMapper::class) ->getMock(); $this->user = $this->getMockBuilder(IUser::class) diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php index e3de7db1584..0dc7ace2b89 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php @@ -28,6 +28,8 @@ use OCP\Files\Folder; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserSession; +use OCP\SystemTag\ISystemTagManager; +use OCP\SystemTag\ISystemTagObjectMapper; class SystemTagsObjectTypeCollectionTest extends \Test\TestCase { @@ -54,9 +56,9 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager') + $this->tagManager = $this->getMockBuilder(ISystemTagManager::class) ->getMock(); - $this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper') + $this->tagMapper = $this->getMockBuilder(ISystemTagObjectMapper::class) ->getMock(); $user = $this->getMockBuilder(IUser::class) diff --git a/apps/dav/tests/unit/Upload/AssemblyStreamTest.php b/apps/dav/tests/unit/Upload/AssemblyStreamTest.php index 69ee52299e9..0396f80c9f4 100644 --- a/apps/dav/tests/unit/Upload/AssemblyStreamTest.php +++ b/apps/dav/tests/unit/Upload/AssemblyStreamTest.php @@ -23,6 +23,8 @@ */ namespace OCA\DAV\Tests\unit\Upload; +use Sabre\DAV\File; + class AssemblyStreamTest extends \Test\TestCase { /** @@ -120,7 +122,7 @@ class AssemblyStreamTest extends \Test\TestCase { } private function buildNode($name, $data) { - $node = $this->getMockBuilder('\Sabre\DAV\File') + $node = $this->getMockBuilder(File::class) ->setMethods(['getName', 'get', 'getSize']) ->getMockForAbstractClass(); diff --git a/apps/dav/tests/unit/Upload/FutureFileTest.php b/apps/dav/tests/unit/Upload/FutureFileTest.php index d94f14ab097..10669912530 100644 --- a/apps/dav/tests/unit/Upload/FutureFileTest.php +++ b/apps/dav/tests/unit/Upload/FutureFileTest.php @@ -23,6 +23,8 @@ */ namespace OCA\DAV\Tests\unit\Upload; +use OCA\DAV\Connector\Sabre\Directory; + class FutureFileTest extends \Test\TestCase { public function testGetContentType() { @@ -57,7 +59,7 @@ class FutureFileTest extends \Test\TestCase { } public function testDelete() { - $d = $this->getMockBuilder('OCA\DAV\Connector\Sabre\Directory') + $d = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->setMethods(['delete']) ->getMock(); @@ -89,7 +91,7 @@ class FutureFileTest extends \Test\TestCase { * @return \OCA\DAV\Upload\FutureFile */ private function mockFutureFile() { - $d = $this->getMockBuilder('OCA\DAV\Connector\Sabre\Directory') + $d = $this->getMockBuilder(Directory::class) ->disableOriginalConstructor() ->setMethods(['getETag', 'getLastModified', 'getChildren']) ->getMock(); diff --git a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php index b5ea08af8d5..a565102a088 100644 --- a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php @@ -89,7 +89,7 @@ class MountPublicLinkControllerTest extends \Test\TestCase { $this->request = $this->getMockBuilder(IRequest::class)->disableOriginalConstructor()->getMock(); $this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider') ->disableOriginalConstructor()->getMock(); - $this->shareManager = $this->getMockBuilder('OCP\Share\IManager')->disableOriginalConstructor()->getMock(); + $this->shareManager = $this->getMockBuilder(IManager::class)->disableOriginalConstructor()->getMock(); $this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler') ->disableOriginalConstructor()->getMock(); $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->disableOriginalConstructor()->getMock(); diff --git a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php index 538c6ae5a08..585102d687a 100644 --- a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php @@ -90,7 +90,7 @@ class RequestHandlerControllerTest extends TestCase { ->setConstructorArgs([$config, $clientService]) ->getMock(); $httpHelperMock->expects($this->any())->method('post')->with($this->anything())->will($this->returnValue(true)); - $this->share = $this->getMockBuilder('\OCP\Share\IShare')->getMock(); + $this->share = $this->getMockBuilder(IShare::class)->getMock(); $this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider') ->disableOriginalConstructor()->getMock(); $this->federatedShareProvider->expects($this->any()) diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 14852b3354f..e73ebb62c6a 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -230,7 +230,7 @@ class ShareAPIControllerTest extends TestCase { public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner, $path, $permissions, $shareTime, $expiration, $parent, $target, $mail_send, $token=null, $password=null) { - $share = $this->getMockBuilder('\OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getId')->willReturn($id); $share->method('getShareType')->willReturn($shareType); $share->method('getSharedWith')->willReturn($sharedWith); @@ -513,25 +513,25 @@ class ShareAPIControllerTest extends TestCase { } public function testCanAccessShare() { - $share = $this->getMockBuilder('OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getShareOwner')->willReturn($this->currentUser); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMockBuilder('OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getSharedBy')->willReturn($this->currentUser); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMockBuilder('OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); $share->method('getSharedWith')->willReturn($this->currentUser); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMockBuilder('OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); $share->method('getSharedWith')->willReturn($this->getMockBuilder(IUser::class)->getMock()); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMockBuilder('OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); $share->method('getSharedWith')->willReturn('group'); diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index d1b30d77f32..6f0b3f9c2da 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -49,6 +49,7 @@ use OCP\ISession; use OCP\IUserManager; use OCP\Security\ISecureRandom; use OCP\IURLGenerator; +use OCP\Share\IShare; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -463,7 +464,7 @@ class ShareControllerTest extends \Test\TestCase { } public function testDownloadShare() { - $share = $this->getMockBuilder('\OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getPassword')->willReturn('password'); $share ->expects($this->once()) @@ -488,7 +489,7 @@ class ShareControllerTest extends \Test\TestCase { } public function testDownloadShareWithCreateOnlyShare() { - $share = $this->getMockBuilder('\OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getPassword')->willReturn('password'); $share ->expects($this->once()) diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php index 4cd202113dd..812a068f070 100644 --- a/apps/files_versions/tests/VersioningTest.php +++ b/apps/files_versions/tests/VersioningTest.php @@ -682,7 +682,7 @@ class VersioningTest extends \Test\TestCase { return; } - $eventHandler = $this->getMockBuilder('\stdclass') + $eventHandler = $this->getMockBuilder(\stdclass::class) ->setMethods(['callback']) ->getMock(); diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index a04b0a355cf..95d746cfb46 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -114,7 +114,7 @@ class ShareByMailProviderTest extends TestCase { $this->secureRandom = $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(); $this->mailer = $this->getMockBuilder('\OCP\Mail\IMailer')->getMock(); $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock(); - $this->share = $this->getMockBuilder('\OCP\Share\IShare')->getMock(); + $this->share = $this->getMockBuilder(IShare::class)->getMock(); $this->activityManager = $this->getMockBuilder('OCP\Activity\IManager')->getMock(); $this->settingsManager = $this->getMockBuilder(SettingsManager::class)->disableOriginalConstructor()->getMock(); $this->defaults = $this->createMock(Defaults::class); @@ -181,7 +181,7 @@ class ShareByMailProviderTest extends TestCase { } public function testCreate() { - $share = $this->getMockBuilder('\OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->expects($this->any())->method('getSharedWith')->willReturn('user1'); $node = $this->getMockBuilder(File::class)->getMock(); diff --git a/tests/Settings/Controller/GroupsControllerTest.php b/tests/Settings/Controller/GroupsControllerTest.php index 78df5f3a3cb..ecbfa9ea05e 100644 --- a/tests/Settings/Controller/GroupsControllerTest.php +++ b/tests/Settings/Controller/GroupsControllerTest.php @@ -13,6 +13,7 @@ namespace Tests\Settings\Controller; use OC\Group\Group; use OC\Group\MetaData; use OC\Settings\Controller\GroupsController; +use OC\User\User; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\IGroupManager; @@ -99,7 +100,7 @@ class GroupsControllerTest extends \Test\TestCase { $groups[] = $thirdGroup; $groups[] = $fourthGroup; - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) @@ -191,7 +192,7 @@ class GroupsControllerTest extends \Test\TestCase { $groups[] = $thirdGroup; $groups[] = $fourthGroup; - $user = $this->getMockBuilder('\OC\User\User') + $user = $this->getMockBuilder(User::class) ->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) diff --git a/tests/lib/Encryption/UpdateTest.php b/tests/lib/Encryption/UpdateTest.php index ccd2bb796fc..a8cbef70d75 100644 --- a/tests/lib/Encryption/UpdateTest.php +++ b/tests/lib/Encryption/UpdateTest.php @@ -24,6 +24,7 @@ namespace Test\Encryption; use OC\Encryption\Update; +use OC\Files\Mount\Manager; use OC\Files\View; use Test\TestCase; @@ -60,7 +61,7 @@ class UpdateTest extends TestCase { ->disableOriginalConstructor()->getMock(); $this->util = $this->getMockBuilder('\OC\Encryption\Util') ->disableOriginalConstructor()->getMock(); - $this->mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager') + $this->mountManager = $this->getMockBuilder(Manager::class) ->disableOriginalConstructor()->getMock(); $this->encryptionManager = $this->getMockBuilder('\OC\Encryption\Manager') ->disableOriginalConstructor()->getMock(); diff --git a/tests/lib/FileChunkingTest.php b/tests/lib/FileChunkingTest.php index cf0fed251a4..42fc820c5d0 100644 --- a/tests/lib/FileChunkingTest.php +++ b/tests/lib/FileChunkingTest.php @@ -47,7 +47,7 @@ class FileChunkingTest extends \Test\TestCase { * @param $expected */ public function testIsComplete($total, array $present, $expected) { - $fileChunking = $this->getMockBuilder('\OC_FileChunking') + $fileChunking = $this->getMockBuilder(\OC_FileChunking::class) ->setMethods(['getCache']) ->setConstructorArgs([[ 'name' => 'file', diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php index ec043c7b81e..6479dad58d3 100644 --- a/tests/lib/Files/Node/FolderTest.php +++ b/tests/lib/Files/Node/FolderTest.php @@ -786,7 +786,7 @@ class FolderTest extends NodeTest { ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager]) ->getMock(); /** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\FileInfo $folderInfo */ - $folderInfo = $this->getMockBuilder('\OC\Files\FileInfo') + $folderInfo = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor()->getMock(); $baseTime = 1000; @@ -847,7 +847,7 @@ class FolderTest extends NodeTest { ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager]) ->getMock(); /** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\FileInfo $folderInfo */ - $folderInfo = $this->getMockBuilder('\OC\Files\FileInfo') + $folderInfo = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor()->getMock(); $baseTime = 1000; @@ -906,7 +906,7 @@ class FolderTest extends NodeTest { ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager]) ->getMock(); /** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\FileInfo $folderInfo */ - $folderInfo = $this->getMockBuilder('\OC\Files\FileInfo') + $folderInfo = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor()->getMock(); $baseTime = 1000; diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php index 160787411f1..9200ae69f75 100644 --- a/tests/lib/Files/Node/NodeTest.php +++ b/tests/lib/Files/Node/NodeTest.php @@ -9,6 +9,7 @@ namespace Test\Files\Node; use OC\Files\FileInfo; +use OC\Files\Mount\Manager; use OC\Files\View; use OCP\Files\Config\IUserMountCache; use OCP\Files\IRootFolder; @@ -52,7 +53,7 @@ abstract class NodeTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); $this->user = new \OC\User\User('', new \Test\Util\User\Dummy, null, $config, $urlGenerator); - $this->manager = $this->getMockBuilder('\OC\Files\Mount\Manager') + $this->manager = $this->getMockBuilder(Manager::class) ->disableOriginalConstructor() ->getMock(); $this->view = $this->getMockBuilder(View::class) diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php index 2f81a96d486..fd050c8d90c 100644 --- a/tests/lib/Files/Node/RootTest.php +++ b/tests/lib/Files/Node/RootTest.php @@ -47,7 +47,7 @@ class RootTest extends \Test\TestCase { ->getMock(); $this->user = new \OC\User\User('', new \Test\Util\User\Dummy, null, $config, $urlgenerator); - $this->manager = $this->getMockBuilder('\OC\Files\Mount\Manager') + $this->manager = $this->getMockBuilder(Manager::class) ->disableOriginalConstructor() ->getMock(); $this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache') diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index cab8bd62739..33d5cc0a8a6 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -2350,7 +2350,7 @@ class ViewTest extends \Test\TestCase { return; } - $eventHandler = $this->getMockBuilder('\stdclass') + $eventHandler = $this->getMockBuilder(\stdclass::class) ->setMethods(['preCallback', 'postCallback']) ->getMock(); @@ -2425,7 +2425,7 @@ class ViewTest extends \Test\TestCase { Filesystem::getMountManager()->addMount($mount); // Listen for events - $eventHandler = $this->getMockBuilder('\stdclass') + $eventHandler = $this->getMockBuilder(\stdclass::class) ->setMethods(['umount', 'post_umount']) ->getMock(); $eventHandler->expects($this->once()) -- cgit v1.2.3 From c733cdaa65ea473b848fb8329674145f54c1277b Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 26 Oct 2017 13:46:16 +0200 Subject: Use ::class in test mocks of encryption app Signed-off-by: Morris Jobke --- .../tests/Command/TestEnableMasterKey.php | 11 ++++--- .../tests/Controller/RecoveryControllerTest.php | 3 +- .../tests/Controller/SettingsControllerTest.php | 17 ++++++---- .../tests/Controller/StatusControllerTest.php | 2 +- apps/encryption/tests/Crypto/CryptTest.php | 5 +-- apps/encryption/tests/Crypto/DecryptAllTest.php | 10 +++--- apps/encryption/tests/Crypto/EncryptAllTest.php | 37 ++++++++++++++-------- apps/encryption/tests/Crypto/EncryptionTest.php | 21 ++++++++---- apps/encryption/tests/HookManagerTest.php | 7 ++-- apps/encryption/tests/Hooks/UserHooksTest.php | 30 +++++++++++------- apps/encryption/tests/KeyManagerTest.php | 32 +++++++++++-------- apps/encryption/tests/RecoveryTest.php | 9 ++++-- apps/encryption/tests/Users/SetupTest.php | 9 ++++-- apps/encryption/tests/UtilTest.php | 9 ++++-- .../Controller/MountPublicLinkControllerTest.php | 4 +-- .../tests/TokenHandlerTest.php | 2 +- .../tests/Command/DeleteOrphanedFilesTest.php | 6 ++-- .../tests/Command/CleanupRemoteStoragesTest.php | 6 ++-- .../tests/Controller/ShareAPIControllerTest.php | 30 +++++++++--------- .../tests/Controller/GroupsControllerTest.php | 2 +- tests/lib/Encryption/DecryptAllTest.php | 16 ++++++---- tests/lib/Encryption/EncryptionWrapperTest.php | 3 +- tests/lib/Encryption/Keys/StorageTest.php | 3 +- tests/lib/Encryption/UtilTest.php | 3 +- tests/lib/Files/Storage/Wrapper/EncryptionTest.php | 8 ++--- tests/lib/Security/CertificateManagerTest.php | 3 +- tests/lib/Session/CryptoWrappingTest.php | 3 +- 27 files changed, 176 insertions(+), 115 deletions(-) (limited to 'tests/lib') diff --git a/apps/encryption/tests/Command/TestEnableMasterKey.php b/apps/encryption/tests/Command/TestEnableMasterKey.php index dac26c5d3c7..58118db8c53 100644 --- a/apps/encryption/tests/Command/TestEnableMasterKey.php +++ b/apps/encryption/tests/Command/TestEnableMasterKey.php @@ -28,6 +28,9 @@ namespace OCA\Encryption\Tests\Command; use OCA\Encryption\Command\EnableMasterKey; use OCA\Encryption\Util; use OCP\IConfig; +use Symfony\Component\Console\Helper\QuestionHelper; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; use Test\TestCase; class TestEnableMasterKey extends TestCase { @@ -53,15 +56,15 @@ class TestEnableMasterKey extends TestCase { public function setUp() { parent::setUp(); - $this->util = $this->getMockBuilder('OCA\Encryption\Util') + $this->util = $this->getMockBuilder(Util::class) ->disableOriginalConstructor()->getMock(); $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor()->getMock(); - $this->questionHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper') + $this->questionHelper = $this->getMockBuilder(QuestionHelper::class) ->disableOriginalConstructor()->getMock(); - $this->output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') + $this->output = $this->getMockBuilder(OutputInterface::class) ->disableOriginalConstructor()->getMock(); - $this->input = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') + $this->input = $this->getMockBuilder(InputInterface::class) ->disableOriginalConstructor()->getMock(); $this->enableMasterKey = new EnableMasterKey($this->util, $this->config, $this->questionHelper); diff --git a/apps/encryption/tests/Controller/RecoveryControllerTest.php b/apps/encryption/tests/Controller/RecoveryControllerTest.php index 384cce94c42..7ab3bc7eebb 100644 --- a/apps/encryption/tests/Controller/RecoveryControllerTest.php +++ b/apps/encryption/tests/Controller/RecoveryControllerTest.php @@ -26,6 +26,7 @@ namespace OCA\Encryption\Tests\Controller; use OCA\Encryption\Controller\RecoveryController; +use OCA\Encryption\Recovery; use OCP\AppFramework\Http; use OCP\IConfig; use OCP\IL10N; @@ -171,7 +172,7 @@ class RecoveryControllerTest extends TestCase { ->method('t') ->willReturnArgument(0); - $this->recoveryMock = $this->getMockBuilder('OCA\Encryption\Recovery') + $this->recoveryMock = $this->getMockBuilder(Recovery::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/encryption/tests/Controller/SettingsControllerTest.php b/apps/encryption/tests/Controller/SettingsControllerTest.php index fcff78d77de..aceb94b23f7 100644 --- a/apps/encryption/tests/Controller/SettingsControllerTest.php +++ b/apps/encryption/tests/Controller/SettingsControllerTest.php @@ -24,11 +24,16 @@ namespace OCA\Encryption\Tests\Controller; use OCA\Encryption\Controller\SettingsController; +use OCA\Encryption\Crypto\Crypt; +use OCA\Encryption\KeyManager; use OCA\Encryption\Session; +use OCA\Encryption\Util; use OCP\AppFramework\Http; use OCP\IL10N; use OCP\IRequest; +use OCP\ISession; use OCP\IUserManager; +use OCP\IUserSession; use Test\TestCase; class SettingsControllerTest extends TestCase { @@ -81,13 +86,13 @@ class SettingsControllerTest extends TestCase { $this->userManagerMock = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor()->getMock(); - $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') + $this->keyManagerMock = $this->getMockBuilder(KeyManager::class) ->disableOriginalConstructor()->getMock(); - $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $this->cryptMock = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor()->getMock(); - $this->userSessionMock = $this->getMockBuilder('OCP\IUserSession') + $this->userSessionMock = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->setMethods([ 'isLoggedIn', @@ -100,7 +105,7 @@ class SettingsControllerTest extends TestCase { ]) ->getMock(); - $this->ocSessionMock = $this->getMockBuilder('OCP\ISession')->disableOriginalConstructor()->getMock(); + $this->ocSessionMock = $this->getMockBuilder(ISession::class)->disableOriginalConstructor()->getMock(); $this->userSessionMock->expects($this->any()) ->method('getUID') @@ -110,10 +115,10 @@ class SettingsControllerTest extends TestCase { ->method($this->anything()) ->will($this->returnSelf()); - $this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session') + $this->sessionMock = $this->getMockBuilder(Session::class) ->disableOriginalConstructor()->getMock(); - $this->utilMock = $this->getMockBuilder('OCA\Encryption\Util') + $this->utilMock = $this->getMockBuilder(Util::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/encryption/tests/Controller/StatusControllerTest.php b/apps/encryption/tests/Controller/StatusControllerTest.php index cd3a8fdaa72..d72fcd1ac36 100644 --- a/apps/encryption/tests/Controller/StatusControllerTest.php +++ b/apps/encryption/tests/Controller/StatusControllerTest.php @@ -53,7 +53,7 @@ class StatusControllerTest extends TestCase { parent::setUp(); - $this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session') + $this->sessionMock = $this->getMockBuilder(Session::class) ->disableOriginalConstructor()->getMock(); $this->requestMock = $this->createMock(IRequest::class); diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php index 4800be0a5ed..ace4453a803 100644 --- a/apps/encryption/tests/Crypto/CryptTest.php +++ b/apps/encryption/tests/Crypto/CryptTest.php @@ -30,6 +30,7 @@ use OCA\Encryption\Crypto\Crypt; use OCP\IConfig; use OCP\IL10N; use OCP\ILogger; +use OCP\IUserSession; use Test\TestCase; class CryptTest extends TestCase { @@ -59,7 +60,7 @@ class CryptTest extends TestCase { $this->logger->expects($this->any()) ->method('warning') ->willReturn(true); - $this->userSession = $this->getMockBuilder('OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); $this->config = $this->getMockBuilder(IConfig::class) @@ -391,7 +392,7 @@ class CryptTest extends TestCase { */ public function testDecryptPrivateKey($header, $privateKey, $expectedCipher, $isValidKey, $expected) { /** @var \OCA\Encryption\Crypto\Crypt | \PHPUnit_Framework_MockObject_MockObject $crypt */ - $crypt = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $crypt = $this->getMockBuilder(Crypt::class) ->setConstructorArgs( [ $this->logger, diff --git a/apps/encryption/tests/Crypto/DecryptAllTest.php b/apps/encryption/tests/Crypto/DecryptAllTest.php index fdef37adc84..99b1b47ba8e 100644 --- a/apps/encryption/tests/Crypto/DecryptAllTest.php +++ b/apps/encryption/tests/Crypto/DecryptAllTest.php @@ -56,15 +56,15 @@ class DecryptAllTest extends TestCase { public function setUp() { parent::setUp(); - $this->util = $this->getMockBuilder('OCA\Encryption\Util') + $this->util = $this->getMockBuilder(Util::class) ->disableOriginalConstructor()->getMock(); - $this->keyManager = $this->getMockBuilder('OCA\Encryption\KeyManager') + $this->keyManager = $this->getMockBuilder(KeyManager::class) ->disableOriginalConstructor()->getMock(); - $this->crypt = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $this->crypt = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor()->getMock(); - $this->session = $this->getMockBuilder('OCA\Encryption\Session') + $this->session = $this->getMockBuilder(Session::class) ->disableOriginalConstructor()->getMock(); - $this->questionHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper') + $this->questionHelper = $this->getMockBuilder(QuestionHelper::class) ->disableOriginalConstructor()->getMock(); $this->instance = new DecryptAll( diff --git a/apps/encryption/tests/Crypto/EncryptAllTest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php index 7d432a6d524..38b64a8b6bf 100644 --- a/apps/encryption/tests/Crypto/EncryptAllTest.php +++ b/apps/encryption/tests/Crypto/EncryptAllTest.php @@ -25,13 +25,22 @@ namespace OCA\Encryption\Tests\Crypto; +use OC\Files\View; use OCA\Encryption\Crypto\EncryptAll; +use OCA\Encryption\KeyManager; +use OCA\Encryption\Users\Setup; +use OCA\Encryption\Util; use OCP\IConfig; use OCP\IL10N; use OCP\IUserManager; use OCP\Mail\IMailer; +use OCP\Security\ISecureRandom; use OCP\UserInterface; use Symfony\Component\Console\Formatter\OutputFormatterInterface; +use Symfony\Component\Console\Helper\ProgressBar; +use Symfony\Component\Console\Helper\QuestionHelper; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; use Test\TestCase; class EncryptAllTest extends TestCase { @@ -80,15 +89,15 @@ class EncryptAllTest extends TestCase { function setUp() { parent::setUp(); - $this->setupUser = $this->getMockBuilder('OCA\Encryption\Users\Setup') + $this->setupUser = $this->getMockBuilder(Setup::class) ->disableOriginalConstructor()->getMock(); - $this->keyManager = $this->getMockBuilder('OCA\Encryption\KeyManager') + $this->keyManager = $this->getMockBuilder(KeyManager::class) ->disableOriginalConstructor()->getMock(); - $this->util = $this->getMockBuilder('OCA\Encryption\Util') + $this->util = $this->getMockBuilder(Util::class) ->disableOriginalConstructor()->getMock(); $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor()->getMock(); - $this->view = $this->getMockBuilder('OC\Files\View') + $this->view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor()->getMock(); @@ -96,11 +105,11 @@ class EncryptAllTest extends TestCase { ->disableOriginalConstructor()->getMock(); $this->l = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor()->getMock(); - $this->questionHelper = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper') + $this->questionHelper = $this->getMockBuilder(QuestionHelper::class) ->disableOriginalConstructor()->getMock(); - $this->inputInterface = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') + $this->inputInterface = $this->getMockBuilder(InputInterface::class) ->disableOriginalConstructor()->getMock(); - $this->outputInterface = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') + $this->outputInterface = $this->getMockBuilder(OutputInterface::class) ->disableOriginalConstructor()->getMock(); $this->userInterface = $this->getMockBuilder(UserInterface::class) ->disableOriginalConstructor()->getMock(); @@ -112,7 +121,7 @@ class EncryptAllTest extends TestCase { $this->userManager->expects($this->any())->method('getBackends')->willReturn([$this->userInterface]); $this->userInterface->expects($this->any())->method('getUsers')->willReturn(['user1', 'user2']); - $this->secureRandom = $this->getMockBuilder('OCP\Security\ISecureRandom')->disableOriginalConstructor()->getMock(); + $this->secureRandom = $this->getMockBuilder(ISecureRandom::class)->disableOriginalConstructor()->getMock(); $this->secureRandom->expects($this->any())->method('getMediumStrengthGenerator')->willReturn($this->secureRandom); $this->secureRandom->expects($this->any())->method('getLowStrengthGenerator')->willReturn($this->secureRandom); $this->secureRandom->expects($this->any())->method('generate')->willReturn('12345678'); @@ -134,7 +143,7 @@ class EncryptAllTest extends TestCase { public function testEncryptAll() { /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ - $encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') + $encryptAll = $this->getMockBuilder(EncryptAll::class) ->setConstructorArgs( [ $this->setupUser, @@ -163,7 +172,7 @@ class EncryptAllTest extends TestCase { public function testEncryptAllWithMasterKey() { /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ - $encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') + $encryptAll = $this->getMockBuilder(EncryptAll::class) ->setConstructorArgs( [ $this->setupUser, @@ -193,7 +202,7 @@ class EncryptAllTest extends TestCase { public function testCreateKeyPairs() { /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ - $encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') + $encryptAll = $this->getMockBuilder(EncryptAll::class) ->setConstructorArgs( [ $this->setupUser, @@ -242,7 +251,7 @@ class EncryptAllTest extends TestCase { public function testEncryptAllUsersFiles() { /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ - $encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') + $encryptAll = $this->getMockBuilder(EncryptAll::class) ->setConstructorArgs( [ $this->setupUser, @@ -275,7 +284,7 @@ class EncryptAllTest extends TestCase { public function testEncryptUsersFiles() { /** @var EncryptAll | \PHPUnit_Framework_MockObject_MockObject $encryptAll */ - $encryptAll = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') + $encryptAll = $this->getMockBuilder(EncryptAll::class) ->setConstructorArgs( [ $this->setupUser, @@ -323,7 +332,7 @@ class EncryptAllTest extends TestCase { $encryptAll->expects($this->at(1))->method('encryptFile')->with('/user1/files/bar'); $encryptAll->expects($this->at(2))->method('encryptFile')->with('/user1/files/foo/subfile'); - $progressBar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar') + $progressBar = $this->getMockBuilder(ProgressBar::class) ->disableOriginalConstructor()->getMock(); $this->invokePrivate($encryptAll, 'encryptUsersFiles', ['user1', $progressBar, '']); diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php index 3bd4593d6bc..42da71b0eb1 100644 --- a/apps/encryption/tests/Crypto/EncryptionTest.php +++ b/apps/encryption/tests/Crypto/EncryptionTest.php @@ -23,7 +23,14 @@ namespace OCA\Encryption\Tests\Crypto; +use OCA\Encryption\Crypto\Crypt; +use OCA\Encryption\Crypto\DecryptAll; +use OCA\Encryption\Crypto\EncryptAll; use OCA\Encryption\Exceptions\PublicKeyMissingException; +use OCA\Encryption\KeyManager; +use OCA\Encryption\Session; +use OCA\Encryption\Util; +use OCP\Files\Storage; use OCP\IL10N; use OCP\ILogger; use Symfony\Component\Console\Input\InputInterface; @@ -66,24 +73,24 @@ class EncryptionTest extends TestCase { public function setUp() { parent::setUp(); - $this->storageMock = $this->getMockBuilder('OCP\Files\Storage') + $this->storageMock = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor()->getMock(); - $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $this->cryptMock = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor() ->getMock(); - $this->utilMock = $this->getMockBuilder('OCA\Encryption\Util') + $this->utilMock = $this->getMockBuilder(Util::class) ->disableOriginalConstructor() ->getMock(); - $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') + $this->keyManagerMock = $this->getMockBuilder(KeyManager::class) ->disableOriginalConstructor() ->getMock(); - $this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session') + $this->sessionMock = $this->getMockBuilder(Session::class) ->disableOriginalConstructor() ->getMock(); - $this->encryptAllMock = $this->getMockBuilder('OCA\Encryption\Crypto\EncryptAll') + $this->encryptAllMock = $this->getMockBuilder(EncryptAll::class) ->disableOriginalConstructor() ->getMock(); - $this->decryptAllMock = $this->getMockBuilder('OCA\Encryption\Crypto\DecryptAll') + $this->decryptAllMock = $this->getMockBuilder(DecryptAll::class) ->disableOriginalConstructor() ->getMock(); $this->loggerMock = $this->getMockBuilder(ILogger::class) diff --git a/apps/encryption/tests/HookManagerTest.php b/apps/encryption/tests/HookManagerTest.php index c5e5487dba5..109afb1ef8d 100644 --- a/apps/encryption/tests/HookManagerTest.php +++ b/apps/encryption/tests/HookManagerTest.php @@ -26,6 +26,7 @@ namespace OCA\Encryption\Tests; use OCA\Encryption\HookManager; +use OCA\Encryption\Hooks\Contracts\IHook; use OCP\IConfig; use Test\TestCase; @@ -41,8 +42,8 @@ class HookManagerTest extends TestCase { */ public function testRegisterHookWithArray() { self::$instance->registerHook([ - $this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock(), - $this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock(), + $this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock(), + $this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock(), $this->createMock(IConfig::class) ]); @@ -66,7 +67,7 @@ class HookManagerTest extends TestCase { * */ public function testRegisterHooksWithInstance() { - $mock = $this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock(); + $mock = $this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock(); /** @var \OCA\Encryption\Hooks\Contracts\IHook $mock */ self::$instance->registerHook($mock); diff --git a/apps/encryption/tests/Hooks/UserHooksTest.php b/apps/encryption/tests/Hooks/UserHooksTest.php index 506f46eb8e6..f4c7a5ae0f7 100644 --- a/apps/encryption/tests/Hooks/UserHooksTest.php +++ b/apps/encryption/tests/Hooks/UserHooksTest.php @@ -29,9 +29,15 @@ namespace OCA\Encryption\Tests\Hooks; use OCA\Encryption\Crypto\Crypt; use OCA\Encryption\Hooks\UserHooks; +use OCA\Encryption\KeyManager; +use OCA\Encryption\Recovery; +use OCA\Encryption\Session; +use OCA\Encryption\Users\Setup; +use OCA\Encryption\Util; use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; +use OCP\IUserSession; use Test\TestCase; /** @@ -152,7 +158,7 @@ class UserHooksTest extends TestCase { public function testPreSetPassphrase($canChange) { /** @var UserHooks | \PHPUnit_Framework_MockObject_MockObject $instance */ - $instance = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks') + $instance = $this->getMockBuilder(UserHooks::class) ->setConstructorArgs( [ $this->keyManagerMock, @@ -231,7 +237,7 @@ class UserHooksTest extends TestCase { ->willReturnOnConsecutiveCalls(true, false); - $this->instance = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks') + $this->instance = $this->getMockBuilder(UserHooks::class) ->setConstructorArgs( [ $this->keyManagerMock, @@ -292,7 +298,7 @@ class UserHooksTest extends TestCase { ->method('getPrivateKey') ->willReturn(true); - $userSessionMock = $this->getMockBuilder('OCP\IUserSession') + $userSessionMock = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); @@ -303,7 +309,7 @@ class UserHooksTest extends TestCase { ->with('testUser') ->willReturn(false); - $userHooks = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks') + $userHooks = $this->getMockBuilder(UserHooks::class) ->setConstructorArgs( [ $this->keyManagerMock, @@ -325,17 +331,17 @@ class UserHooksTest extends TestCase { protected function setUp() { parent::setUp(); $this->loggerMock = $this->createMock(ILogger::class); - $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') + $this->keyManagerMock = $this->getMockBuilder(KeyManager::class) ->disableOriginalConstructor() ->getMock(); $this->userManagerMock = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor() ->getMock(); - $this->userSetupMock = $this->getMockBuilder('OCA\Encryption\Users\Setup') + $this->userSetupMock = $this->getMockBuilder(Setup::class) ->disableOriginalConstructor() ->getMock(); - $this->userSessionMock = $this->getMockBuilder('OCP\IUserSession') + $this->userSessionMock = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->setMethods([ 'isLoggedIn', @@ -354,18 +360,18 @@ class UserHooksTest extends TestCase { ->method($this->anything()) ->will($this->returnSelf()); - $utilMock = $this->getMockBuilder('OCA\Encryption\Util') + $utilMock = $this->getMockBuilder(Util::class) ->disableOriginalConstructor() ->getMock(); - $sessionMock = $this->getMockBuilder('OCA\Encryption\Session') + $sessionMock = $this->getMockBuilder(Session::class) ->disableOriginalConstructor() ->getMock(); - $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $this->cryptMock = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor() ->getMock(); - $recoveryMock = $this->getMockBuilder('OCA\Encryption\Recovery') + $recoveryMock = $this->getMockBuilder(Recovery::class) ->disableOriginalConstructor() ->getMock(); @@ -374,7 +380,7 @@ class UserHooksTest extends TestCase { $this->utilMock = $utilMock; $this->utilMock->expects($this->any())->method('isMasterKeyEnabled')->willReturn(false); - $this->instance = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks') + $this->instance = $this->getMockBuilder(UserHooks::class) ->setConstructorArgs( [ $this->keyManagerMock, diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php index a8441427a2c..721b7f53a0c 100644 --- a/apps/encryption/tests/KeyManagerTest.php +++ b/apps/encryption/tests/KeyManagerTest.php @@ -27,9 +27,15 @@ namespace OCA\Encryption\Tests; +use OC\Files\FileInfo; +use OC\Files\View; +use OCA\Encryption\Crypto\Crypt; use OCA\Encryption\KeyManager; use OCA\Encryption\Session; +use OCA\Encryption\Util; use OCP\Encryption\Keys\IStorage; +use OCP\Files\Cache\ICache; +use OCP\Files\Storage; use OCP\IConfig; use OCP\ILogger; use OCP\IUserSession; @@ -74,7 +80,7 @@ class KeyManagerTest extends TestCase { $this->userId = 'user1'; $this->systemKeyId = 'systemKeyId'; $this->keyStorageMock = $this->createMock(IStorage::class); - $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $this->cryptMock = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor() ->getMock(); $this->configMock = $this->createMock(IConfig::class); @@ -82,11 +88,11 @@ class KeyManagerTest extends TestCase { ->method('getAppValue') ->willReturn($this->systemKeyId); $this->userMock = $this->createMock(IUserSession::class); - $this->sessionMock = $this->getMockBuilder('OCA\Encryption\Session') + $this->sessionMock = $this->getMockBuilder(Session::class) ->disableOriginalConstructor() ->getMock(); $this->logMock = $this->createMock(ILogger::class); - $this->utilMock = $this->getMockBuilder('OCA\Encryption\Util') + $this->utilMock = $this->getMockBuilder(Util::class) ->disableOriginalConstructor() ->getMock(); @@ -251,7 +257,7 @@ class KeyManagerTest extends TestCase { public function testInit($useMasterKey) { /** @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject $instance */ - $instance = $this->getMockBuilder('OCA\Encryption\KeyManager') + $instance = $this->getMockBuilder(KeyManager::class) ->setConstructorArgs( [ $this->keyStorageMock, @@ -544,7 +550,7 @@ class KeyManagerTest extends TestCase { public function testValidateMasterKey($masterKey) { /** @var \OCA\Encryption\KeyManager | \PHPUnit_Framework_MockObject_MockObject $instance */ - $instance = $this->getMockBuilder('OCA\Encryption\KeyManager') + $instance = $this->getMockBuilder(KeyManager::class) ->setConstructorArgs( [ $this->keyStorageMock, @@ -592,7 +598,7 @@ class KeyManagerTest extends TestCase { } public function testGetVersionWithoutFileInfo() { - $view = $this->getMockBuilder('\\OC\\Files\\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); $view->expects($this->once()) ->method('getFileInfo') @@ -604,9 +610,9 @@ class KeyManagerTest extends TestCase { } public function testGetVersionWithFileInfo() { - $view = $this->getMockBuilder('\\OC\\Files\\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); - $fileInfo = $this->getMockBuilder('\\OC\\Files\\FileInfo') + $fileInfo = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor()->getMock(); $fileInfo->expects($this->once()) ->method('getEncryptedVersion') @@ -621,19 +627,19 @@ class KeyManagerTest extends TestCase { } public function testSetVersionWithFileInfo() { - $view = $this->getMockBuilder('\\OC\\Files\\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); - $cache = $this->getMockBuilder('\\OCP\\Files\\Cache\\ICache') + $cache = $this->getMockBuilder(ICache::class) ->disableOriginalConstructor()->getMock(); $cache->expects($this->once()) ->method('update') ->with(123, ['encrypted' => 5, 'encryptedVersion' => 5]); - $storage = $this->getMockBuilder('\\OCP\\Files\\Storage') + $storage = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor()->getMock(); $storage->expects($this->once()) ->method('getCache') ->willReturn($cache); - $fileInfo = $this->getMockBuilder('\\OC\\Files\\FileInfo') + $fileInfo = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor()->getMock(); $fileInfo->expects($this->once()) ->method('getStorage') @@ -651,7 +657,7 @@ class KeyManagerTest extends TestCase { } public function testSetVersionWithoutFileInfo() { - $view = $this->getMockBuilder('\\OC\\Files\\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); $view->expects($this->once()) ->method('getFileInfo') diff --git a/apps/encryption/tests/RecoveryTest.php b/apps/encryption/tests/RecoveryTest.php index d73b5d48c91..2dda774565c 100644 --- a/apps/encryption/tests/RecoveryTest.php +++ b/apps/encryption/tests/RecoveryTest.php @@ -28,10 +28,13 @@ namespace OCA\Encryption\Tests; use OC\Files\View; +use OCA\Encryption\Crypto\Crypt; +use OCA\Encryption\KeyManager; use OCA\Encryption\Recovery; use OCP\Encryption\IFile; use OCP\Encryption\Keys\IStorage; use OCP\IConfig; +use OCP\IUserSession; use OCP\Security\ISecureRandom; use Test\TestCase; @@ -253,7 +256,7 @@ class RecoveryTest extends TestCase { parent::setUp(); - $this->userSessionMock = $this->getMockBuilder('OCP\IUserSession') + $this->userSessionMock = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->setMethods([ 'isLoggedIn', @@ -271,10 +274,10 @@ class RecoveryTest extends TestCase { ->method($this->anything()) ->will($this->returnSelf()); - $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt')->disableOriginalConstructor()->getMock(); + $this->cryptMock = $this->getMockBuilder(Crypt::class)->disableOriginalConstructor()->getMock(); /** @var \OCP\Security\ISecureRandom $randomMock */ $randomMock = $this->createMock(ISecureRandom::class); - $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager')->disableOriginalConstructor()->getMock(); + $this->keyManagerMock = $this->getMockBuilder(KeyManager::class)->disableOriginalConstructor()->getMock(); $this->configMock = $this->createMock(IConfig::class); /** @var \OCP\Encryption\Keys\IStorage $keyStorageMock */ $keyStorageMock = $this->createMock(IStorage::class); diff --git a/apps/encryption/tests/Users/SetupTest.php b/apps/encryption/tests/Users/SetupTest.php index 9e856861046..27866ef3927 100644 --- a/apps/encryption/tests/Users/SetupTest.php +++ b/apps/encryption/tests/Users/SetupTest.php @@ -26,8 +26,11 @@ namespace OCA\Encryption\Tests\Users; +use OCA\Encryption\Crypto\Crypt; +use OCA\Encryption\KeyManager; use OCA\Encryption\Users\Setup; use OCP\ILogger; +use OCP\IUserSession; use Test\TestCase; class SetupTest extends TestCase { @@ -47,14 +50,14 @@ class SetupTest extends TestCase { protected function setUp() { parent::setUp(); $logMock = $this->createMock(ILogger::class); - $userSessionMock = $this->getMockBuilder('OCP\IUserSession') + $userSessionMock = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); - $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $this->cryptMock = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor() ->getMock(); - $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager') + $this->keyManagerMock = $this->getMockBuilder(KeyManager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/encryption/tests/UtilTest.php b/apps/encryption/tests/UtilTest.php index 40fc5537251..e59565d3b84 100644 --- a/apps/encryption/tests/UtilTest.php +++ b/apps/encryption/tests/UtilTest.php @@ -27,11 +27,14 @@ namespace OCA\Encryption\Tests; use OC\Files\View; +use OCA\Encryption\Crypto\Crypt; use OCA\Encryption\Util; use OCP\Files\Mount\IMountPoint; +use OCP\Files\Storage; use OCP\IConfig; use OCP\ILogger; use OCP\IUserManager; +use OCP\IUserSession; use Test\TestCase; class UtilTest extends TestCase { @@ -80,13 +83,13 @@ class UtilTest extends TestCase { $this->userManagerMock = $this->createMock(IUserManager::class); /** @var \OCA\Encryption\Crypto\Crypt $cryptMock */ - $cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') + $cryptMock = $this->getMockBuilder(Crypt::class) ->disableOriginalConstructor() ->getMock(); /** @var \OCP\ILogger $loggerMock */ $loggerMock = $this->createMock(ILogger::class); /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSessionMock */ - $userSessionMock = $this->getMockBuilder('OCP\IUserSession') + $userSessionMock = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->setMethods([ 'isLoggedIn', @@ -205,7 +208,7 @@ class UtilTest extends TestCase { } public function testGetStorage() { - $return = $this->getMockBuilder('OC\Files\Storage\Storage') + $return = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php index a565102a088..cef341fdc81 100644 --- a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php @@ -95,9 +95,9 @@ class MountPublicLinkControllerTest extends \Test\TestCase { $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->disableOriginalConstructor()->getMock(); $this->userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock(); $this->share = new \OC\Share20\Share($this->rootFolder, $this->userManager); - $this->session = $this->getMockBuilder('OCP\ISession')->disableOriginalConstructor()->getMock(); + $this->session = $this->getMockBuilder(ISession::class)->disableOriginalConstructor()->getMock(); $this->l10n = $this->getMockBuilder(IL10N::class)->disableOriginalConstructor()->getMock(); - $this->userSession = $this->getMockBuilder('OCP\IUserSession')->disableOriginalConstructor()->getMock(); + $this->userSession = $this->getMockBuilder(IUserSession::class)->disableOriginalConstructor()->getMock(); $this->clientService = $this->getMockBuilder('OCP\Http\Client\IClientService')->disableOriginalConstructor()->getMock(); $this->cloudIdManager = new CloudIdManager(); diff --git a/apps/federatedfilesharing/tests/TokenHandlerTest.php b/apps/federatedfilesharing/tests/TokenHandlerTest.php index 10e5fc5df51..2025b90e00b 100644 --- a/apps/federatedfilesharing/tests/TokenHandlerTest.php +++ b/apps/federatedfilesharing/tests/TokenHandlerTest.php @@ -42,7 +42,7 @@ class TokenHandlerTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->secureRandom = $this->getMockBuilder('OCP\Security\ISecureRandom')->getMock(); + $this->secureRandom = $this->getMockBuilder(ISecureRandom::class)->getMock(); $this->tokenHandler = new TokenHandler($this->secureRandom); } diff --git a/apps/files/tests/Command/DeleteOrphanedFilesTest.php b/apps/files/tests/Command/DeleteOrphanedFilesTest.php index 32c8d628a80..8c48b9feca7 100644 --- a/apps/files/tests/Command/DeleteOrphanedFilesTest.php +++ b/apps/files/tests/Command/DeleteOrphanedFilesTest.php @@ -27,6 +27,8 @@ namespace OCA\Files\Tests\Command; use OC\Files\View; use OCA\Files\Command\DeleteOrphanedFiles; use OCP\Files\StorageNotAvailableException; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; use Test\TestCase; /** @@ -87,10 +89,10 @@ class DeleteOrphanedFilesTest extends TestCase { * Test clearing orphaned files */ public function testClearFiles() { - $input = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') + $input = $this->getMockBuilder(InputInterface::class) ->disableOriginalConstructor() ->getMock(); - $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') + $output = $this->getMockBuilder(OutputInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php index 827fcc15797..5480874615e 100644 --- a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php +++ b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php @@ -22,6 +22,8 @@ namespace OCA\Files_Sharing\Tests\Command; use OCA\Files_Sharing\Command\CleanupRemoteStorages; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; use Test\TestCase; /** @@ -158,10 +160,10 @@ class CleanupRemoteStoragesTest extends TestCase { * Test cleanup of orphaned storages */ public function testCleanup() { - $input = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') + $input = $this->getMockBuilder(InputInterface::class) ->disableOriginalConstructor() ->getMock(); - $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') + $output = $this->getMockBuilder(OutputInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index e73ebb62c6a..3bebb9e1195 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -264,7 +264,7 @@ class ShareAPIControllerTest extends TestCase { ->getMock(); $cache->method('getNumericStorageId')->willReturn(101); - $storage = $this->getMockBuilder('OC\Files\Storage\Storage') + $storage = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor() ->getMock(); $storage->method('getId')->willReturn('STORAGE'); @@ -637,7 +637,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(File::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -669,7 +669,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(File::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -714,7 +714,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(File::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -768,7 +768,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(File::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -820,7 +820,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -872,7 +872,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -904,7 +904,7 @@ class ShareAPIControllerTest extends TestCase { ])); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -923,7 +923,7 @@ class ShareAPIControllerTest extends TestCase { */ public function testCreateShareLinkNoPublicUpload() { $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -943,7 +943,7 @@ class ShareAPIControllerTest extends TestCase { */ public function testCreateShareLinkPublicUploadFile() { $path = $this->getMockBuilder(File::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -962,7 +962,7 @@ class ShareAPIControllerTest extends TestCase { $ocs = $this->mockFormatShare(); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -996,7 +996,7 @@ class ShareAPIControllerTest extends TestCase { $ocs = $this->mockFormatShare(); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1040,7 +1040,7 @@ class ShareAPIControllerTest extends TestCase { ])); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1081,7 +1081,7 @@ class ShareAPIControllerTest extends TestCase { $ocs = $this->mockFormatShare(); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1126,7 +1126,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(true); diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index 9d70e123cde..cd3dae79336 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -58,7 +58,7 @@ class GroupsControllerTest extends \Test\TestCase { ->method('getSubAdmin') ->willReturn($this->subAdminManager); - $this->userSession = $this->getMockBuilder('OCP\IUserSession') + $this->userSession = $this->getMockBuilder(IUserSession::class) ->disableOriginalConstructor() ->getMock(); $request = $this->getMockBuilder(IRequest::class) diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php index c52619c3b12..06c5e0e2df8 100644 --- a/tests/lib/Encryption/DecryptAllTest.php +++ b/tests/lib/Encryption/DecryptAllTest.php @@ -28,9 +28,13 @@ use OC\Encryption\Exceptions\DecryptionFailedException; use OC\Encryption\Manager; use OC\Files\FileInfo; use OC\Files\View; +use OCP\Files\Storage; use OCP\IUserManager; use OCP\UserInterface; use Symfony\Component\Console\Formatter\OutputFormatterInterface; +use Symfony\Component\Console\Helper\ProgressBar; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; use Test\TestCase; /** @@ -70,11 +74,11 @@ class DecryptAllTest extends TestCase { ->disableOriginalConstructor()->getMock(); $this->encryptionManager = $this->getMockBuilder('OC\Encryption\Manager') ->disableOriginalConstructor()->getMock(); - $this->view = $this->getMockBuilder('OC\Files\View') + $this->view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); - $this->inputInterface = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') + $this->inputInterface = $this->getMockBuilder(InputInterface::class) ->disableOriginalConstructor()->getMock(); - $this->outputInterface = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') + $this->outputInterface = $this->getMockBuilder(OutputInterface::class) ->disableOriginalConstructor()->getMock(); $this->userInterface = $this->getMockBuilder(UserInterface::class) ->disableOriginalConstructor()->getMock(); @@ -253,11 +257,11 @@ class DecryptAllTest extends TestCase { ->setMethods(['decryptFile']) ->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage') + $storage = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor()->getMock(); - $sharedStorage = $this->getMockBuilder('OCP\Files\Storage') + $sharedStorage = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor()->getMock(); $sharedStorage->expects($this->once())->method('instanceOfStorage') @@ -296,7 +300,7 @@ class DecryptAllTest extends TestCase { ->method('decryptFile') ->with('/user1/files/foo/subfile'); - $progressBar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar') + $progressBar = $this->getMockBuilder(ProgressBar::class) ->disableOriginalConstructor()->getMock(); $this->invokePrivate($instance, 'decryptUsersFiles', ['user1', $progressBar, '']); diff --git a/tests/lib/Encryption/EncryptionWrapperTest.php b/tests/lib/Encryption/EncryptionWrapperTest.php index 6a6a3db2f68..d20efa8821f 100644 --- a/tests/lib/Encryption/EncryptionWrapperTest.php +++ b/tests/lib/Encryption/EncryptionWrapperTest.php @@ -26,6 +26,7 @@ namespace Test\Encryption; use OC\Encryption\EncryptionWrapper; use OC\Encryption\Manager; use OC\Memcache\ArrayCache; +use OCP\Files\Storage; use OCP\ILogger; use Test\TestCase; @@ -59,7 +60,7 @@ class EncryptionWrapperTest extends TestCase { * @dataProvider provideWrapStorage */ public function testWrapStorage($expectedWrapped, $wrappedStorages) { - $storage = $this->getMockBuilder('OC\Files\Storage\Storage') + $storage = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php index a5924d1dc88..cd8f1e9b953 100644 --- a/tests/lib/Encryption/Keys/StorageTest.php +++ b/tests/lib/Encryption/Keys/StorageTest.php @@ -24,6 +24,7 @@ namespace Test\Encryption\Keys; use OC\Encryption\Keys\Storage; +use OC\Files\View; use OCP\IConfig; use Test\TestCase; @@ -48,7 +49,7 @@ class StorageTest extends TestCase { ->disableOriginalConstructor() ->getMock(); - $this->view = $this->getMockBuilder('OC\Files\View') + $this->view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php index e313274516e..1e1b21d3671 100644 --- a/tests/lib/Encryption/UtilTest.php +++ b/tests/lib/Encryption/UtilTest.php @@ -3,6 +3,7 @@ namespace Test\Encryption; use OC\Encryption\Util; +use OC\Files\View; use OCP\Encryption\IEncryptionModule; use OCP\IConfig; use Test\TestCase; @@ -33,7 +34,7 @@ class UtilTest extends TestCase { public function setUp() { parent::setUp(); - $this->view = $this->getMockBuilder('OC\Files\View') + $this->view = $this->getMockBuilder(View::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php index 459abf3b64c..c184752ff7e 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -719,7 +719,7 @@ class EncryptionTest extends Storage { } public function testCopyBetweenStorageMinimumEncryptedVersion() { - $storage2 = $this->getMockBuilder('OCP\Files\Storage') + $storage2 = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor() ->getMock(); @@ -768,7 +768,7 @@ class EncryptionTest extends Storage { * @param bool $expectedEncrypted */ public function testCopyBetweenStorage($encryptionEnabled, $mountPointEncryptionEnabled, $expectedEncrypted) { - $storage2 = $this->getMockBuilder('OCP\Files\Storage') + $storage2 = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor() ->getMock(); @@ -830,11 +830,11 @@ class EncryptionTest extends Storage { */ public function testCopyBetweenStorageVersions($sourceInternalPath, $targetInternalPath, $copyResult, $encrypted) { - $sourceStorage = $this->getMockBuilder('OCP\Files\Storage') + $sourceStorage = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor() ->getMock(); - $targetStorage = $this->getMockBuilder('OCP\Files\Storage') + $targetStorage = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php index 6bdb647abc5..2804ad99c0f 100644 --- a/tests/lib/Security/CertificateManagerTest.php +++ b/tests/lib/Security/CertificateManagerTest.php @@ -9,6 +9,7 @@ namespace Test\Security; use OC\Files\Storage\Temporary; +use OC\Files\View; use \OC\Security\CertificateManager; use OCP\IConfig; use OCP\ILogger; @@ -152,7 +153,7 @@ class CertificateManagerTest extends \Test\TestCase { $expected ) { - $view = $this->getMockBuilder('OC\Files\View') + $view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); $config = $this->createMock(IConfig::class); diff --git a/tests/lib/Session/CryptoWrappingTest.php b/tests/lib/Session/CryptoWrappingTest.php index e1fadbf933f..f34148fb50e 100644 --- a/tests/lib/Session/CryptoWrappingTest.php +++ b/tests/lib/Session/CryptoWrappingTest.php @@ -22,6 +22,7 @@ namespace Test\Session; use OC\Session\CryptoSessionData; +use OCP\ISession; use Test\TestCase; class CryptoWrappingTest extends TestCase { @@ -37,7 +38,7 @@ class CryptoWrappingTest extends TestCase { protected function setUp() { parent::setUp(); - $this->wrappedSession = $this->getMockBuilder('OCP\ISession') + $this->wrappedSession = $this->getMockBuilder(ISession::class) ->disableOriginalConstructor() ->getMock(); $this->crypto = $this->getMockBuilder('OCP\Security\ICrypto') -- cgit v1.2.3 From 405bbc1c6195f7735d920451fe18476ec4bd0054 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 25 Oct 2017 17:57:21 +0200 Subject: Improve mimetype detection for object storages Object storage instances always fall back to the content based mimetype detection, because the file name for object storage was always random due to the fact that it was temporarily storage in a generated temp file. This patch adds a check before that to make sure to use the original file name for this purpose and also remove possible other extensions like the versioning or part file extension. Signed-off-by: Morris Jobke --- lib/private/Files/ObjectStore/ObjectStoreStorage.php | 10 +++++++++- lib/private/Files/Type/Detection.php | 4 ++++ tests/lib/Files/Type/DetectionTest.php | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'tests/lib') diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index ded69e8079b..15df808684b 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -390,7 +390,15 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common { $stat['size'] = filesize($tmpFile); $stat['mtime'] = $mTime; $stat['storage_mtime'] = $mTime; - $stat['mimetype'] = \OC::$server->getMimeTypeDetector()->detect($tmpFile); + + // run path based detection first, to use file extension because $tmpFile is only a random string + $mimetypeDetector = \OC::$server->getMimeTypeDetector(); + $mimetype = $mimetypeDetector->detectPath($path); + if ($mimetype === 'application/octet-stream') { + $mimetype = $mimetypeDetector->detect($tmpFile); + } + + $stat['mimetype'] = $mimetype; $stat['etag'] = $this->getETag($path); $fileId = $this->getCache()->put($path, $stat); diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index cd4ddc2f067..928c68251cf 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -173,6 +173,10 @@ class Detection implements IMimeTypeDetector { // note: leading dot doesn't qualify as extension if (strpos($fileName, '.') > 0) { + + // remove versioning extension: name.v1508946057 and transfer extension: name.ocTransferId2057600214.part + $fileName = preg_replace('!((\.v\d+)|((.ocTransferId\d+)?.part))$!', '', $fileName); + //try to guess the type by the file extension $extension = strtolower(strrchr($fileName, '.')); $extension = substr($extension, 1); //remove leading . diff --git a/tests/lib/Files/Type/DetectionTest.php b/tests/lib/Files/Type/DetectionTest.php index 295b9bf9fac..1d01a96fcc0 100644 --- a/tests/lib/Files/Type/DetectionTest.php +++ b/tests/lib/Files/Type/DetectionTest.php @@ -84,6 +84,8 @@ class DetectionTest extends \Test\TestCase { $this->assertEquals('application/octet-stream', $this->detection->detectPath('..hidden')); $this->assertEquals('application/octet-stream', $this->detection->detectPath('foo')); $this->assertEquals('application/octet-stream', $this->detection->detectPath('')); + $this->assertEquals('image/png', $this->detection->detectPath('foo.png.ocTransferId123456789.part')); + $this->assertEquals('image/png', $this->detection->detectPath('foo.png.v1234567890')); } public function testDetectString() { -- cgit v1.2.3 From 8660b9f0afa37983b66895a78a0f41417365efe0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 27 Oct 2017 11:46:20 +0200 Subject: Unit tests for #6977 Signed-off-by: Joas Schilling --- tests/lib/LoggerTest.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/lib') diff --git a/tests/lib/LoggerTest.php b/tests/lib/LoggerTest.php index da9cedc9f56..3a30bbd1d3b 100644 --- a/tests/lib/LoggerTest.php +++ b/tests/lib/LoggerTest.php @@ -138,6 +138,32 @@ class LoggerTest extends TestCase { } } + /** + * @dataProvider userAndPasswordData + */ + public function testDetectclosure($user, $password) { + $a = function($user, $password) { + throw new \Exception('test'); + }; + + try { + $a($user, $password); + } catch (\Exception $e) { + $this->logger->logException($e); + } + $logLines = $this->getLogs(); + + foreach($logLines as $logLine) { + $log = explode('\n', $logLine); + unset($log[1]); // Remove `testDetectclosure(` because we are not testing this here, but the closure on stack trace 0 + $logLine = implode('\n', $log); + + $this->assertNotContains($user, $logLine); + $this->assertNotContains($password, $logLine); + $this->assertContains('{closure}(*** sensitive parameters replaced ***)', $logLine); + } + } + public function dataGetLogClass() { return [ ['file', \OC\Log\File::class], -- cgit v1.2.3 From 6a51c1bc4fd0f2496103f901fef3b550688c2364 Mon Sep 17 00:00:00 2001 From: Piotr Mrowczynski Date: Mon, 2 Oct 2017 12:32:21 +0200 Subject: Add foreign key support to OC --- lib/private/DB/OracleMigrator.php | 40 +++++++++++++++++++++++++++++++++++---- tests/lib/DB/MigratorTest.php | 39 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 6 deletions(-) (limited to 'tests/lib') diff --git a/lib/private/DB/OracleMigrator.php b/lib/private/DB/OracleMigrator.php index b01ec78684b..4541f9cb72f 100644 --- a/lib/private/DB/OracleMigrator.php +++ b/lib/private/DB/OracleMigrator.php @@ -30,6 +30,7 @@ use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Table; +use Doctrine\DBAL\Schema\ForeignKeyConstraint; class OracleMigrator extends NoCheckMigrator { @@ -81,6 +82,27 @@ class OracleMigrator extends NoCheckMigrator { ); } + /** + * Quote an ForeignKeyConstraint's name but changing the name requires recreating + * the ForeignKeyConstraint instance and copying over all properties. + * + * @param ForeignKeyConstraint $fkc old fkc + * @return ForeignKeyConstraint new fkc instance with new name + */ + protected function quoteForeignKeyConstraint($fkc) { + return new ForeignKeyConstraint( + array_map(function($columnName) { + return $this->connection->quoteIdentifier($columnName); + }, $fkc->getLocalColumns()), + $this->connection->quoteIdentifier($fkc->getForeignTableName()), + array_map(function($columnName) { + return $this->connection->quoteIdentifier($columnName); + }, $fkc->getForeignColumns()), + $fkc->getName(), + $fkc->getOptions() + ); + } + /** * @param Schema $targetSchema * @param \Doctrine\DBAL\Connection $connection @@ -100,7 +122,9 @@ class OracleMigrator extends NoCheckMigrator { array_map(function(Index $index) { return $this->quoteIndex($index); }, $table->getIndexes()), - $table->getForeignKeys(), + array_map(function(ForeignKeyConstraint $fck) { + return $this->quoteForeignKeyConstraint($fck); + }, $table->getForeignKeys()), 0, $table->getOptions() ); @@ -158,9 +182,17 @@ class OracleMigrator extends NoCheckMigrator { return $this->quoteIndex($index); }, $tableDiff->renamedIndexes); - // TODO handle $tableDiff->addedForeignKeys - // TODO handle $tableDiff->changedForeignKeys - // TODO handle $tableDiff->removedForeignKeys + $tableDiff->addedForeignKeys = array_map(function(ForeignKeyConstraint $fkc) { + return $this->quoteForeignKeyConstraint($fkc); + }, $tableDiff->addedForeignKeys); + + $tableDiff->changedForeignKeys = array_map(function(ForeignKeyConstraint $fkc) { + return $this->quoteForeignKeyConstraint($fkc); + }, $tableDiff->changedForeignKeys); + + $tableDiff->removedForeignKeys = array_map(function(ForeignKeyConstraint $fkc) { + return $this->quoteForeignKeyConstraint($fkc); + }, $tableDiff->removedForeignKeys); } return $schemaDiff; diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php index e4f45c4bb86..ea718240c5e 100644 --- a/tests/lib/DB/MigratorTest.php +++ b/tests/lib/DB/MigratorTest.php @@ -41,6 +41,9 @@ class MigratorTest extends \Test\TestCase { /** @var string */ private $tableName; + /** @var string */ + private $tableNameTmp; + protected function setUp() { parent::setUp(); @@ -50,11 +53,23 @@ class MigratorTest extends \Test\TestCase { $this->markTestSkipped('DB migration tests are not supported on OCI'); } $this->manager = new \OC\DB\MDB2SchemaManager($this->connection); - $this->tableName = strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_')); + $this->tableName = $this->getUniqueTableName(); + $this->tableNameTmp = $this->getUniqueTableName(); + } + + private function getUniqueTableName() { + return strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_')); } protected function tearDown() { - $this->connection->exec('DROP TABLE ' . $this->tableName); + // Try to delete if exists (IF EXISTS NOT SUPPORTED IN ORACLE) + try { + $this->connection->exec('DROP TABLE ' . $this->connection->quoteIdentifier($this->tableNameTmp)); + } catch (\Doctrine\DBAL\DBALException $e) {} + + try { + $this->connection->exec('DROP TABLE ' . $this->connection->quoteIdentifier($this->tableName)); + } catch (\Doctrine\DBAL\DBALException $e) {} parent::tearDown(); } @@ -200,4 +215,24 @@ class MigratorTest extends \Test\TestCase { $this->assertTrue(true); } + + public function testAddingForeignKey() { + $startSchema = new Schema([], [], $this->getSchemaConfig()); + $table = $startSchema->createTable($this->tableName); + $table->addColumn('id', 'integer', ['autoincrement' => true]); + $table->addColumn('name', 'string'); + $table->setPrimaryKey(['id']); + + $fkName = "fkc"; + $tableFk = $startSchema->createTable($this->tableNameTmp); + $tableFk->addColumn('fk_id', 'integer'); + $tableFk->addColumn('name', 'string'); + $tableFk->addForeignKeyConstraint($this->tableName, array('fk_id'), array('id'), array(), $fkName); + + $migrator = $this->manager->getMigrator(); + $migrator->migrate($startSchema); + + + $this->assertTrue($startSchema->getTable($this->tableNameTmp)->hasForeignKey($fkName)); + } } -- cgit v1.2.3