From 275a8ce1dc69e3ae6e27a34d3c8501c1e3078f09 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Sun, 15 Sep 2024 22:09:12 +0200 Subject: [PATCH 1/2] refactor: Replace class strings with ::class constants Signed-off-by: Christoph Wurst --- apps/admin_audit/lib/AppInfo/Application.php | 2 +- .../tests/Unit/AppInfo/ApplicationTest.php | 12 +- .../tests/Unit/Notification/ListenerTest.php | 2 +- .../Xml/Request/CalendarSearchReport.php | 12 +- .../unit/CalDAV/PublicCalendarRootTest.php | 2 +- .../Request/CalendarSearchReportTest.php | 2 +- .../unit/CalDAV/Search/SearchPluginTest.php | 2 +- .../Sabre/CommentsPropertiesPluginTest.php | 2 +- .../unit/Connector/Sabre/DirectoryTest.php | 12 +- .../tests/unit/Connector/Sabre/FileTest.php | 12 +- .../unit/Connector/Sabre/FilesPluginTest.php | 12 +- .../Connector/Sabre/FilesReportPluginTest.php | 8 +- .../Sabre/RequestTest/DeleteTest.php | 2 +- .../EncryptionMasterKeyUploadTest.php | 2 +- .../RequestTest/EncryptionUploadTest.php | 2 +- .../Sabre/RequestTest/RequestTestCase.php | 2 +- .../Sabre/RequestTest/UploadTest.php | 4 +- .../BirthdayCalendarControllerTest.php | 4 +- .../unit/SystemTag/SystemTagPluginTest.php | 4 +- .../SystemTagsByIdCollectionTest.php | 10 +- .../SystemTagsObjectMappingCollectionTest.php | 6 +- .../SystemTagsObjectTypeCollectionTest.php | 2 +- .../lib/Command/FixEncryptedVersion.php | 2 +- apps/encryption/lib/Crypto/Encryption.php | 2 +- .../tests/Command/FixEncryptedVersionTest.php | 2 +- .../tests/Crypto/EncryptionTest.php | 2 +- .../lib/Notifications.php | 2 +- .../MountPublicLinkControllerTest.php | 8 +- .../RequestHandlerControllerTest.php | 6 +- .../tests/FederatedShareProviderTest.php | 10 +- .../tests/NotificationsTest.php | 10 +- .../lib/Controller/OCSAuthAPIController.php | 2 +- .../BackgroundJob/RequestSharedSecretTest.php | 2 +- .../Controller/OCSAuthAPIControllerTest.php | 4 +- apps/federation/tests/DAV/FedAuthTest.php | 2 +- apps/federation/tests/Settings/AdminTest.php | 2 +- .../tests/SyncFederationAddressbooksTest.php | 12 +- apps/federation/tests/TrustedServersTest.php | 6 +- apps/files/lib/AppInfo/Application.php | 2 +- apps/files/lib/Command/Scan.php | 8 +- apps/files/lib/Command/ScanAppData.php | 8 +- .../tests/BackgroundJob/ScanFilesTest.php | 2 +- .../tests/Controller/ViewControllerTest.php | 4 +- .../3rdparty/composer/InstalledVersions.php | 2 +- apps/files_external/lib/Command/Scan.php | 4 +- .../lib/Config/ConfigAdapter.php | 2 +- .../lib/Lib/Backend/AmazonS3.php | 2 +- apps/files_external/lib/Lib/Backend/DAV.php | 4 +- apps/files_external/lib/Lib/Backend/FTP.php | 2 +- .../lib/Lib/Backend/InvalidBackend.php | 2 +- apps/files_external/lib/Lib/Backend/Local.php | 4 +- .../lib/Lib/Backend/OwnCloud.php | 2 +- apps/files_external/lib/Lib/Backend/SFTP.php | 2 +- .../lib/Lib/Backend/SFTP_Key.php | 2 +- apps/files_external/lib/Lib/Backend/SMB.php | 2 +- .../files_external/lib/Lib/Backend/SMB_OC.php | 2 +- apps/files_external/lib/Lib/Backend/Swift.php | 2 +- .../tests/Backend/LegacyBackendTest.php | 10 +- .../tests/Command/CommandTest.php | 2 +- .../tests/Controller/AjaxControllerTest.php | 4 +- .../GlobalStoragesControllerTest.php | 2 +- .../Controller/StoragesControllerTest.php | 34 +-- .../Controller/UserStoragesControllerTest.php | 6 +- .../tests/FrontendDefinitionTraitTest.php | 6 +- .../LegacyDependencyCheckPolyfillTest.php | 4 +- .../tests/PersonalMountTest.php | 4 +- .../tests/Service/BackendServiceTest.php | 2 +- .../tests/Service/StoragesServiceTest.php | 14 +- .../tests/Service/UserStoragesServiceTest.php | 2 +- apps/files_sharing/lib/Helper.php | 6 +- .../lib/Listener/LoadAdditionalListener.php | 2 +- apps/files_sharing/lib/MountProvider.php | 2 +- apps/files_sharing/lib/Scanner.php | 2 +- apps/files_sharing/lib/SharedStorage.php | 8 +- apps/files_sharing/tests/ApiTest.php | 2 +- .../Controller/ShareAPIControllerTest.php | 56 ++--- .../tests/Controller/ShareControllerTest.php | 2 +- .../Controller/ShareesAPIControllerTest.php | 2 +- .../tests/EncryptedSizePropagationTest.php | 2 +- .../tests/EtagPropagationTest.php | 14 +- .../tests/External/CacheTest.php | 2 +- .../tests/External/ManagerTest.php | 16 +- .../tests/External/ScannerTest.php | 4 +- .../Middleware/OCSShareAPIMiddlewareTest.php | 2 +- .../files_sharing/tests/MountProviderTest.php | 12 +- .../tests/PropagationTestCase.php | 2 +- .../files_sharing/tests/SharedStorageTest.php | 6 +- .../tests/SizePropagationTest.php | 2 +- apps/files_sharing/tests/TestCase.php | 2 +- .../tests/UnshareChildrenTest.php | 2 +- .../lib/AppInfo/Application.php | 8 +- apps/files_trashbin/lib/Trashbin.php | 4 +- .../tests/Command/CleanUpTest.php | 8 +- apps/files_trashbin/tests/StorageTest.php | 6 +- apps/files_trashbin/tests/TrashbinTest.php | 2 +- apps/files_versions/lib/Storage.php | 2 +- .../tests/Command/CleanupTest.php | 10 +- .../tests/Controller/GroupsControllerTest.php | 2 +- .../tests/Controller/UsersControllerTest.php | 104 ++++---- .../lib/Controller/UsersController.php | 2 +- .../lib/SetupChecks/TempSpaceAvailable.php | 4 +- .../Controller/CheckSetupControllerTest.php | 4 +- .../tests/Controller/UsersControllerTest.php | 2 +- .../tests/Mailer/NewUserMailHelperTest.php | 6 +- .../tests/ShareByMailProviderTest.php | 22 +- .../tests/Controller/IconControllerTest.php | 2 +- apps/user_ldap/lib/AppInfo/Application.php | 2 +- apps/user_ldap/tests/ConnectionTest.php | 2 +- apps/user_ldap/tests/GroupLDAPPluginTest.php | 16 +- apps/user_ldap/tests/LDAPProviderTest.php | 78 +++--- apps/user_ldap/tests/UserLDAPPluginTest.php | 20 +- apps/user_ldap/tests/WizardTest.php | 6 +- .../tests/Check/AbstractStringCheckTest.php | 2 +- .../tests/Check/FileMimeTypeTest.php | 2 +- .../tests/Check/RequestTimeTest.php | 2 +- core/Command/Upgrade.php | 32 +-- core/Controller/OCMController.php | 2 +- core/ajax/update.php | 28 +-- lib/autoloader.php | 2 +- lib/base.php | 4 +- .../DependencyInjection/DIContainer.php | 2 +- lib/private/Encryption/DecryptAll.php | 2 +- lib/private/Encryption/Util.php | 2 +- lib/private/Files/Cache/Scanner.php | 32 +-- .../Files/Config/MountProviderCollection.php | 4 +- .../Files/Mount/CacheMountProvider.php | 4 +- .../Files/Mount/LocalHomeMountProvider.php | 2 +- .../Files/Mount/ObjectHomeMountProvider.php | 2 +- lib/private/Files/Storage/Common.php | 2 +- lib/private/Files/Storage/Wrapper/Wrapper.php | 8 +- lib/private/Files/Utils/Scanner.php | 34 +-- lib/private/Files/View.php | 6 +- lib/private/Server.php | 2 +- lib/private/Share/Share.php | 6 +- lib/private/Share20/Manager.php | 6 +- lib/private/SubAdmin.php | 4 +- lib/private/TemplateLayout.php | 2 +- lib/private/Updater.php | 74 +++--- lib/private/legacy/OC_App.php | 2 +- lib/private/legacy/OC_Helper.php | 8 +- tests/Core/Command/Config/ListConfigsTest.php | 4 +- .../Encryption/ChangeKeyStorageRootTest.php | 12 +- tests/Core/Command/User/SettingTest.php | 2 +- .../Core/Controller/AvatarControllerTest.php | 30 +-- tests/Core/Controller/LostControllerTest.php | 4 +- tests/lib/Activity/ManagerTest.php | 4 +- tests/lib/AllConfigTest.php | 4 +- tests/lib/AppFramework/AppTest.php | 4 +- .../lib/AppFramework/Http/DispatcherTest.php | 10 +- .../Http/FileDisplayResponseTest.php | 6 +- tests/lib/AppFramework/Http/RequestTest.php | 46 ++-- .../AppFramework/Http/StreamResponseTest.php | 2 +- .../Middleware/MiddlewareDispatcherTest.php | 6 +- .../Utility/ControllerMethodReflectorTest.php | 24 +- .../Utility/SimpleContainerTest.php | 30 +-- .../TwoFactorAuth/ManagerTest.php | 2 +- tests/lib/AutoLoaderTest.php | 2 +- tests/lib/BackgroundJob/JobListTest.php | 2 +- .../Collaborators/MailPluginTest.php | 2 +- tests/lib/Command/AsyncBusTest.php | 4 +- tests/lib/ContactsManagerTest.php | 20 +- tests/lib/DB/MigrationsTest.php | 26 +- .../DB/QueryBuilder/ExpressionBuilderTest.php | 2 +- tests/lib/Encryption/DecryptAllTest.php | 16 +- .../lib/Encryption/EncryptionWrapperTest.php | 6 +- tests/lib/Encryption/Keys/StorageTest.php | 4 +- tests/lib/Encryption/UpdateTest.php | 2 +- tests/lib/Files/Cache/CacheTest.php | 2 +- tests/lib/Files/Config/UserMountCacheTest.php | 10 +- tests/lib/Files/EtagTest.php | 4 +- tests/lib/Files/FilesystemTest.php | 18 +- tests/lib/Files/Mount/MountPointTest.php | 4 +- tests/lib/Files/Mount/MountTest.php | 14 +- .../Mount/ObjectHomeMountProviderTest.php | 32 +-- .../lib/Files/Mount/RootMountProviderTest.php | 4 +- tests/lib/Files/Node/FileTest.php | 14 +- tests/lib/Files/Node/FolderTest.php | 8 +- tests/lib/Files/Node/IntegrationTest.php | 6 +- tests/lib/Files/Node/NodeTest.php | 14 +- tests/lib/Files/Node/RootTest.php | 8 +- tests/lib/Files/ObjectStore/AzureTest.php | 2 +- tests/lib/Files/ObjectStore/SwiftTest.php | 2 +- tests/lib/Files/Storage/HomeTest.php | 2 +- tests/lib/Files/Storage/Storage.php | 2 +- .../lib/Files/Storage/StorageFactoryTest.php | 14 +- .../Files/Storage/Wrapper/EncryptionTest.php | 60 ++--- .../Storage/Wrapper/PermissionsMaskTest.php | 4 +- tests/lib/Files/Storage/Wrapper/QuotaTest.php | 10 +- .../lib/Files/Storage/Wrapper/WrapperTest.php | 4 +- tests/lib/Files/Stream/EncryptionTest.php | 30 +-- tests/lib/Files/ViewTest.php | 4 +- tests/lib/Group/GroupTest.php | 60 ++--- tests/lib/Group/MetaDataTest.php | 4 +- tests/lib/HookHelper.php | 12 +- tests/lib/Hooks/BasicEmitterTest.php | 2 +- tests/lib/ImageTest.php | 16 +- tests/lib/IntegrityCheck/CheckerTest.php | 16 +- tests/lib/Mail/MailerTest.php | 4 +- tests/lib/Memcache/CasTraitTest.php | 2 +- tests/lib/Migration/BackgroundRepairTest.php | 2 +- tests/lib/OCS/ProviderTest.php | 4 +- tests/lib/Repair/CleanTagsTest.php | 2 +- .../Repair/OldGroupMembershipSharesTest.php | 4 +- tests/lib/Repair/RepairCollationTest.php | 2 +- tests/lib/Repair/RepairInvalidSharesTest.php | 4 +- tests/lib/Repair/RepairMimeTypesTest.php | 2 +- .../Backend/MemoryCacheBackendTest.php | 2 +- .../Security/CSRF/CsrfTokenGeneratorTest.php | 2 +- .../Security/CSRF/CsrfTokenManagerTest.php | 4 +- tests/lib/Security/CertificateManagerTest.php | 2 +- .../Backend/MemoryCacheBackendTest.php | 2 +- tests/lib/ServerTest.php | 224 +++++++++--------- tests/lib/Session/CryptoWrappingTest.php | 2 +- tests/lib/Share/ShareTest.php | 4 +- tests/lib/Share20/LegacyHooksTest.php | 12 +- tests/lib/Share20/ManagerTest.php | 90 +++---- tests/lib/Template/ResourceLocatorTest.php | 2 +- tests/lib/TestCase.php | 2 +- tests/lib/Traits/MountProviderTrait.php | 2 +- tests/lib/Updater/ReleaseMetadataTest.php | 26 +- tests/lib/UtilCheckServerTest.php | 2 +- tests/preseed-config.php | 6 +- tests/redis-cluster.config.php | 6 +- tests/redis.config.php | 6 +- 224 files changed, 1079 insertions(+), 1079 deletions(-) diff --git a/apps/admin_audit/lib/AppInfo/Application.php b/apps/admin_audit/lib/AppInfo/Application.php index b6af8dbed04c2..dc68527d82244 100644 --- a/apps/admin_audit/lib/AppInfo/Application.php +++ b/apps/admin_audit/lib/AppInfo/Application.php @@ -232,6 +232,6 @@ private function versionsHooks(IAuditLogger $logger): void { private function trashbinHooks(IAuditLogger $logger): void { $trashActions = new Trashbin($logger); Util::connectHook('\OCP\Trashbin', 'preDelete', $trashActions, 'delete'); - Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', $trashActions, 'restore'); + Util::connectHook(\OCA\Files_Trashbin\Trashbin::class, 'post_restore', $trashActions, 'restore'); } } diff --git a/apps/comments/tests/Unit/AppInfo/ApplicationTest.php b/apps/comments/tests/Unit/AppInfo/ApplicationTest.php index c4e9bc7d45da0..3da14ec386573 100644 --- a/apps/comments/tests/Unit/AppInfo/ApplicationTest.php +++ b/apps/comments/tests/Unit/AppInfo/ApplicationTest.php @@ -35,12 +35,12 @@ public function test() { $c = $app->getContainer(); $services = [ - 'OCA\Comments\Controller\NotificationsController', - 'OCA\Comments\Activity\Filter', - 'OCA\Comments\Activity\Listener', - 'OCA\Comments\Activity\Provider', - 'OCA\Comments\Activity\Setting', - 'OCA\Comments\Notification\Listener', + \OCA\Comments\Controller\NotificationsController::class, + \OCA\Comments\Activity\Filter::class, + \OCA\Comments\Activity\Listener::class, + \OCA\Comments\Activity\Provider::class, + \OCA\Comments\Activity\Setting::class, + \OCA\Comments\Notification\Listener::class, Notifier::class, ]; diff --git a/apps/comments/tests/Unit/Notification/ListenerTest.php b/apps/comments/tests/Unit/Notification/ListenerTest.php index 3082333e8a310..3d2b2e59b968b 100644 --- a/apps/comments/tests/Unit/Notification/ListenerTest.php +++ b/apps/comments/tests/Unit/Notification/ListenerTest.php @@ -102,7 +102,7 @@ public function testEvaluate($eventType, $notificationMethod) { ->willReturn($notification); $this->notificationManager->expects($this->exactly(6)) ->method($notificationMethod) - ->with($this->isInstanceOf('\OCP\Notification\INotification')); + ->with($this->isInstanceOf(\OCP\Notification\INotification::class)); $this->userManager->expects($this->exactly(6)) ->method('userExists') diff --git a/apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php b/apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php index 639d0b3265561..f77b27147bac9 100644 --- a/apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php +++ b/apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php @@ -67,12 +67,12 @@ class CalendarSearchReport implements XmlDeserializable { */ public static function xmlDeserialize(Reader $reader) { $elems = $reader->parseInnerTree([ - '{http://nextcloud.com/ns}comp-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter', - '{http://nextcloud.com/ns}prop-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter', - '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter', - '{http://nextcloud.com/ns}search-term' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter', - '{http://nextcloud.com/ns}limit' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter', - '{http://nextcloud.com/ns}offset' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter', + '{http://nextcloud.com/ns}comp-filter' => \OCA\DAV\CalDAV\Search\Xml\Filter\CompFilter::class, + '{http://nextcloud.com/ns}prop-filter' => \OCA\DAV\CalDAV\Search\Xml\Filter\PropFilter::class, + '{http://nextcloud.com/ns}param-filter' => \OCA\DAV\CalDAV\Search\Xml\Filter\ParamFilter::class, + '{http://nextcloud.com/ns}search-term' => \OCA\DAV\CalDAV\Search\Xml\Filter\SearchTermFilter::class, + '{http://nextcloud.com/ns}limit' => \OCA\DAV\CalDAV\Search\Xml\Filter\LimitFilter::class, + '{http://nextcloud.com/ns}offset' => \OCA\DAV\CalDAV\Search\Xml\Filter\OffsetFilter::class, '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', ]); diff --git a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php index 4333754222bad..20473616761ff 100644 --- a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php +++ b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php @@ -52,7 +52,7 @@ protected function setUp(): void { parent::setUp(); $db = \OC::$server->getDatabaseConnection(); - $this->principal = $this->createMock('OCA\DAV\Connector\Sabre\Principal'); + $this->principal = $this->createMock(\OCA\DAV\Connector\Sabre\Principal::class); $this->userManager = $this->createMock(IUserManager::class); $this->groupManager = $this->createMock(IGroupManager::class); $this->random = \OC::$server->getSecureRandom(); diff --git a/apps/dav/tests/unit/CalDAV/Search/Request/CalendarSearchReportTest.php b/apps/dav/tests/unit/CalDAV/Search/Request/CalendarSearchReportTest.php index cbfd4639ed75e..0a93fb7a4c8a3 100644 --- a/apps/dav/tests/unit/CalDAV/Search/Request/CalendarSearchReportTest.php +++ b/apps/dav/tests/unit/CalDAV/Search/Request/CalendarSearchReportTest.php @@ -12,7 +12,7 @@ class CalendarSearchReportTest extends TestCase { private $elementMap = [ '{http://nextcloud.com/ns}calendar-search' => - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport', + \OCA\DAV\CalDAV\Search\Xml\Request\CalendarSearchReport::class, ]; public function testFoo(): void { diff --git a/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php b/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php index ae4519e2542ac..4c7d7faaf935e 100644 --- a/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php @@ -51,7 +51,7 @@ public function testInitialize(): void { $this->assertEquals( $server->xml->elementMap['{http://nextcloud.com/ns}calendar-search'], - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport' + \OCA\DAV\CalDAV\Search\Xml\Request\CalendarSearchReport::class ); } diff --git a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php index 1cda0e4dbdb08..830a4a7f417a8 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php @@ -42,7 +42,7 @@ protected function setUp(): void { public function nodeProvider() { $mocks = []; - foreach (['\OCA\DAV\Connector\Sabre\File', '\OCA\DAV\Connector\Sabre\Directory', '\Sabre\DAV\INode'] as $class) { + foreach ([\OCA\DAV\Connector\Sabre\File::class, \OCA\DAV\Connector\Sabre\Directory::class, '\Sabre\DAV\INode'] as $class) { $mocks[] = $this->getMockBuilder($class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php index fb180b7c65d72..46dde7e0641fc 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -65,8 +65,8 @@ class DirectoryTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->view = $this->createMock('OC\Files\View'); - $this->info = $this->createMock('OC\Files\FileInfo'); + $this->view = $this->createMock(\OC\Files\View::class); + $this->info = $this->createMock(\OC\Files\FileInfo::class); $this->info->method('isReadable') ->willReturn(true); $this->info->method('getType') @@ -283,8 +283,8 @@ public function testGetQuotaInfoUnlimited(): void { $storage->expects($this->any()) ->method('instanceOfStorage') ->willReturnMap([ - '\OCA\Files_Sharing\SharedStorage' => false, - '\OC\Files\Storage\Wrapper\Quota' => false, + \OCA\Files_Sharing\SharedStorage::class => false, + \OC\Files\Storage\Wrapper\Quota::class => false, ]); $storage->expects($this->once()) @@ -334,8 +334,8 @@ public function testGetQuotaInfoSpecific(): void { $storage->expects($this->any()) ->method('instanceOfStorage') ->willReturnMap([ - ['\OCA\Files_Sharing\SharedStorage', false], - ['\OC\Files\Storage\Wrapper\Quota', true], + [\OCA\Files_Sharing\SharedStorage::class, false], + [\OC\Files\Storage\Wrapper\Quota::class, true], ]); $storage->expects($this->once()) diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php index 6f9a214fab9f3..baea320261078 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php @@ -109,11 +109,11 @@ public function fopenFailuresProvider() { ], [ new \OCP\Files\EntityTooLargeException(), - 'OCA\DAV\Connector\Sabre\Exception\EntityTooLarge' + \OCA\DAV\Connector\Sabre\Exception\EntityTooLarge::class ], [ new \OCP\Files\InvalidContentException(), - 'OCA\DAV\Connector\Sabre\Exception\UnsupportedMediaType' + \OCA\DAV\Connector\Sabre\Exception\UnsupportedMediaType::class ], [ new \OCP\Files\InvalidPathException(), @@ -121,15 +121,15 @@ public function fopenFailuresProvider() { ], [ new \OCP\Files\ForbiddenException('', true), - 'OCA\DAV\Connector\Sabre\Exception\Forbidden' + \OCA\DAV\Connector\Sabre\Exception\Forbidden::class ], [ new \OCP\Files\LockNotAcquiredException('/test.txt', 1), - 'OCA\DAV\Connector\Sabre\Exception\FileLocked' + \OCA\DAV\Connector\Sabre\Exception\FileLocked::class ], [ new \OCP\Lock\LockedException('/test.txt'), - 'OCA\DAV\Connector\Sabre\Exception\FileLocked' + \OCA\DAV\Connector\Sabre\Exception\FileLocked::class ], [ new \OCP\Encryption\Exceptions\GenericEncryptionException(), @@ -454,7 +454,7 @@ public function testPutSingleFileCancelPreHook(): void { \OCP\Util::connectHook( Filesystem::CLASSNAME, Filesystem::signal_create, - '\Test\HookHelper', + \Test\HookHelper::class, 'cancellingCallback' ); diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php index 9d8f4e8d4c4f7..74d36a06f1f39 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php @@ -124,7 +124,7 @@ private function createTestNode($class, $path = '/dummypath') { public function testGetPropertiesForFile(): void { /** @var \OCA\DAV\Connector\Sabre\File | \PHPUnit\Framework\MockObject\MockObject $node */ - $node = $this->createTestNode('\OCA\DAV\Connector\Sabre\File'); + $node = $this->createTestNode(\OCA\DAV\Connector\Sabre\File::class); $propFind = new PropFind( '/dummyPath', @@ -181,7 +181,7 @@ public function testGetPropertiesForFile(): void { public function testGetPropertiesStorageNotAvailable(): void { /** @var \OCA\DAV\Connector\Sabre\File | \PHPUnit\Framework\MockObject\MockObject $node */ - $node = $this->createTestNode('\OCA\DAV\Connector\Sabre\File'); + $node = $this->createTestNode(\OCA\DAV\Connector\Sabre\File::class); $propFind = new PropFind( '/dummyPath', @@ -228,7 +228,7 @@ public function testGetPublicPermissions(): void { ); /** @var \OCA\DAV\Connector\Sabre\File | \PHPUnit\Framework\MockObject\MockObject $node */ - $node = $this->createTestNode('\OCA\DAV\Connector\Sabre\File'); + $node = $this->createTestNode(\OCA\DAV\Connector\Sabre\File::class); $node->expects($this->any()) ->method('getDavPermissions') ->willReturn('DWCKMSR'); @@ -243,7 +243,7 @@ public function testGetPublicPermissions(): void { public function testGetPropertiesForDirectory(): void { /** @var \OCA\DAV\Connector\Sabre\Directory | \PHPUnit\Framework\MockObject\MockObject $node */ - $node = $this->createTestNode('\OCA\DAV\Connector\Sabre\Directory'); + $node = $this->createTestNode(\OCA\DAV\Connector\Sabre\Directory::class); $propFind = new PropFind( '/dummyPath', @@ -345,7 +345,7 @@ public function testGetPropertiesWhenNoPermission(): void { } public function testUpdateProps(): void { - $node = $this->createTestNode('\OCA\DAV\Connector\Sabre\File'); + $node = $this->createTestNode(\OCA\DAV\Connector\Sabre\File::class); $testDate = 'Fri, 13 Feb 2015 00:01:02 GMT'; $testCreationDate = '2007-08-31T16:47+00:00'; @@ -615,7 +615,7 @@ public function testDownloadHeaders($isClumsyAgent, $contentDispositionHeader): public function testHasPreview(): void { /** @var \OCA\DAV\Connector\Sabre\Directory | \PHPUnit\Framework\MockObject\MockObject $node */ - $node = $this->createTestNode('\OCA\DAV\Connector\Sabre\Directory'); + $node = $this->createTestNode(\OCA\DAV\Connector\Sabre\Directory::class); $propFind = new PropFind( '/dummyPath', diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php index 76a70a93e1313..4a47d4c94b0d1 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php @@ -293,9 +293,9 @@ public function testFindNodesByFileIdsRoot(): void { $result = $this->plugin->findNodesByFileIds($reportTargetNode, ['111', '222']); $this->assertCount(2, $result); - $this->assertInstanceOf('\OCA\DAV\Connector\Sabre\Directory', $result[0]); + $this->assertInstanceOf(\OCA\DAV\Connector\Sabre\Directory::class, $result[0]); $this->assertEquals('first node', $result[0]->getName()); - $this->assertInstanceOf('\OCA\DAV\Connector\Sabre\File', $result[1]); + $this->assertInstanceOf(\OCA\DAV\Connector\Sabre\File::class, $result[1]); $this->assertEquals('second node', $result[1]->getName()); } @@ -346,9 +346,9 @@ public function testFindNodesByFileIdsSubDir(): void { $result = $this->plugin->findNodesByFileIds($reportTargetNode, ['111', '222']); $this->assertCount(2, $result); - $this->assertInstanceOf('\OCA\DAV\Connector\Sabre\Directory', $result[0]); + $this->assertInstanceOf(\OCA\DAV\Connector\Sabre\Directory::class, $result[0]); $this->assertEquals('first node', $result[0]->getName()); - $this->assertInstanceOf('\OCA\DAV\Connector\Sabre\File', $result[1]); + $this->assertInstanceOf(\OCA\DAV\Connector\Sabre\File::class, $result[1]); $this->assertEquals('second node', $result[1]->getName()); } diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php index e7f20fbadfac6..24a017b3a8bde 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/DeleteTest.php @@ -29,7 +29,7 @@ public function testBasicUpload(): void { $mount->getStorage()->unlink($mount->getInternalPath($internalPath)); // cache entry still exists - $this->assertInstanceOf('\OCP\Files\FileInfo', $view->getFileInfo('foo.txt')); + $this->assertInstanceOf(\OCP\Files\FileInfo::class, $view->getFileInfo('foo.txt')); $response = $this->request($view, $user, 'pass', 'DELETE', '/foo.txt'); diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionMasterKeyUploadTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionMasterKeyUploadTest.php index cbaa0c3101b57..575e37652ba2c 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionMasterKeyUploadTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionMasterKeyUploadTest.php @@ -23,7 +23,7 @@ class EncryptionMasterKeyUploadTest extends UploadTest { protected function setupUser($name, $password) { $this->createUser($name, $password); $tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder(); - $this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]); + $this->registerMount($name, \OC\Files\Storage\Local::class, '/' . $name, ['datadir' => $tmpFolder]); // we use the master key \OC::$server->getConfig()->setAppValue('encryption', 'useMasterKey', '1'); $this->setupForUser($name, $password); diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionUploadTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionUploadTest.php index f830c54fd0d29..86242c32e7827 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionUploadTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/EncryptionUploadTest.php @@ -23,7 +23,7 @@ class EncryptionUploadTest extends UploadTest { protected function setupUser($name, $password) { $this->createUser($name, $password); $tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder(); - $this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]); + $this->registerMount($name, \OC\Files\Storage\Local::class, '/' . $name, ['datadir' => $tmpFolder]); // we use per-user keys \OC::$server->getConfig()->setAppValue('encryption', 'useMasterKey', '0'); $this->setupForUser($name, $password); diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php index 29574d53bca25..599e9a8e5efb6 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php @@ -58,7 +58,7 @@ protected function setUp(): void { protected function setupUser($name, $password) { $this->createUser($name, $password); $tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder(); - $this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]); + $this->registerMount($name, \OC\Files\Storage\Local::class, '/' . $name, ['datadir' => $tmpFolder]); $this->loginAsUser($name); return new View('/' . $name . '/files'); } diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/UploadTest.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/UploadTest.php index 60decd4c8461e..80e758ba89cc7 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/UploadTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/UploadTest.php @@ -30,7 +30,7 @@ public function testBasicUpload(): void { $this->assertEquals('asd', $view->file_get_contents('foo.txt')); $info = $view->getFileInfo('foo.txt'); - $this->assertInstanceOf('\OC\Files\FileInfo', $info); + $this->assertInstanceOf(\OC\Files\FileInfo::class, $info); $this->assertEquals(3, $info->getSize()); } @@ -46,7 +46,7 @@ public function testUploadOverWrite(): void { $this->assertEquals('asd', $view->file_get_contents('foo.txt')); $info = $view->getFileInfo('foo.txt'); - $this->assertInstanceOf('\OC\Files\FileInfo', $info); + $this->assertInstanceOf(\OC\Files\FileInfo::class, $info); $this->assertEquals(3, $info->getSize()); } diff --git a/apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php b/apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php index c7c2bf0e43168..ad5d42cae59e5 100644 --- a/apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php +++ b/apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php @@ -83,7 +83,7 @@ public function testEnable(): void { ); $response = $this->controller->enable(); - $this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $response); + $this->assertInstanceOf(\OCP\AppFramework\Http\JSONResponse::class, $response); } public function testDisable(): void { @@ -97,6 +97,6 @@ public function testDisable(): void { ->method('deleteAllBirthdayCalendars'); $response = $this->controller->disable(); - $this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $response); + $this->assertInstanceOf(\OCP\AppFramework\Http\JSONResponse::class, $response); } } diff --git a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php index 67e7afa9c548a..db4feda0d40e1 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php @@ -575,8 +575,8 @@ public function testCreateTagInByIdCollection($userVisible, $userAssignable, $gr public function nodeClassProvider() { return [ - ['\OCA\DAV\SystemTag\SystemTagsByIdCollection'], - ['\OCA\DAV\SystemTag\SystemTagsObjectMappingCollection'], + [\OCA\DAV\SystemTag\SystemTagsByIdCollection::class], + [\OCA\DAV\SystemTag\SystemTagsObjectMappingCollection::class], ]; } diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php index db55d82adc98a..9629b1fcf7090 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php @@ -89,7 +89,7 @@ public function testGetChild(): void { $childNode = $this->getNode()->getChild('123'); - $this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagNode', $childNode); + $this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagNode::class, $childNode); $this->assertEquals('123', $childNode->getName()); $this->assertEquals($tag, $childNode->getSystemTag()); } @@ -145,8 +145,8 @@ public function testGetChildrenAdmin(): void { $this->assertCount(2, $children); - $this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagNode', $children[0]); - $this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagNode', $children[1]); + $this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagNode::class, $children[0]); + $this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagNode::class, $children[1]); $this->assertEquals($tag1, $children[0]->getSystemTag()); $this->assertEquals($tag2, $children[1]->getSystemTag()); } @@ -164,8 +164,8 @@ public function testGetChildrenNonAdmin(): void { $this->assertCount(2, $children); - $this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagNode', $children[0]); - $this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagNode', $children[1]); + $this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagNode::class, $children[0]); + $this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagNode::class, $children[1]); $this->assertEquals($tag1, $children[0]->getSystemTag()); $this->assertEquals($tag2, $children[1]->getSystemTag()); } diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php index c2e62f73828f8..252700de2a755 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php @@ -163,7 +163,7 @@ public function testGetChild(): void { $childNode = $this->getNode()->getChild('555'); - $this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagMappingNode', $childNode); + $this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagMappingNode::class, $childNode); $this->assertEquals('555', $childNode->getName()); } @@ -251,8 +251,8 @@ public function testGetChildren(): void { $this->assertCount(2, $children); - $this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagMappingNode', $children[0]); - $this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagMappingNode', $children[1]); + $this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagMappingNode::class, $children[0]); + $this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagMappingNode::class, $children[1]); $this->assertEquals(111, $children[0]->getObjectId()); $this->assertEquals('files', $children[0]->getObjectType()); diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php index b202f340e328f..d2868113efa7e 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php @@ -111,7 +111,7 @@ public function testGetChild(): void { ->willReturn($this->createMock(\OCP\Files\Node::class)); $childNode = $this->node->getChild('555'); - $this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagsObjectMappingCollection', $childNode); + $this->assertInstanceOf(\OCA\DAV\SystemTag\SystemTagsObjectMappingCollection::class, $childNode); $this->assertEquals('555', $childNode->getName()); } diff --git a/apps/encryption/lib/Command/FixEncryptedVersion.php b/apps/encryption/lib/Command/FixEncryptedVersion.php index 6635bb6cba95e..16181f2294240 100644 --- a/apps/encryption/lib/Command/FixEncryptedVersion.php +++ b/apps/encryption/lib/Command/FixEncryptedVersion.php @@ -242,7 +242,7 @@ private function correctEncryptedVersion(string $path, OutputInterface $output, return true; } - if ($storage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) { + if ($storage->instanceOfStorage(\OCA\Files_Sharing\ISharedStorage::class)) { $output->writeln("The file: \"$path\" is a share. Please also run the script for the owner of the share"); return true; } diff --git a/apps/encryption/lib/Crypto/Encryption.php b/apps/encryption/lib/Crypto/Encryption.php index f5b6a40aecc18..caf88cb2facbb 100644 --- a/apps/encryption/lib/Crypto/Encryption.php +++ b/apps/encryption/lib/Crypto/Encryption.php @@ -378,7 +378,7 @@ public function update($path, $uid, array $accessList) { public function shouldEncrypt($path) { if ($this->util->shouldEncryptHomeStorage() === false) { $storage = $this->util->getStorage($path); - if ($storage && $storage->instanceOfStorage('\OCP\Files\IHomeStorage')) { + if ($storage && $storage->instanceOfStorage(\OCP\Files\IHomeStorage::class)) { return false; } } diff --git a/apps/encryption/tests/Command/FixEncryptedVersionTest.php b/apps/encryption/tests/Command/FixEncryptedVersionTest.php index c021c366ad89b..8ec59c3db93ff 100644 --- a/apps/encryption/tests/Command/FixEncryptedVersionTest.php +++ b/apps/encryption/tests/Command/FixEncryptedVersionTest.php @@ -52,7 +52,7 @@ public function setUp(): void { $this->createUser($this->userId, 'foo12345678'); $tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder(); - $this->registerMount($this->userId, '\OC\Files\Storage\Local', '/' . $this->userId, ['datadir' => $tmpFolder]); + $this->registerMount($this->userId, \OC\Files\Storage\Local::class, '/' . $this->userId, ['datadir' => $tmpFolder]); $this->setupForUser($this->userId, 'foo12345678'); $this->loginWithEncryption($this->userId); diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php index 4767d22339da5..df9020579ce31 100644 --- a/apps/encryption/tests/Crypto/EncryptionTest.php +++ b/apps/encryption/tests/Crypto/EncryptionTest.php @@ -375,7 +375,7 @@ public function testShouldEncrypt($path, $shouldEncryptHomeStorage, $isHomeStora if ($shouldEncryptHomeStorage === false) { $this->storageMock->expects($this->once())->method('instanceOfStorage') - ->with('\OCP\Files\IHomeStorage')->willReturn($isHomeStorage); + ->with(\OCP\Files\IHomeStorage::class)->willReturn($isHomeStorage); $this->utilMock->expects($this->once())->method('getStorage')->with($path) ->willReturn($this->storageMock); } diff --git a/apps/federatedfilesharing/lib/Notifications.php b/apps/federatedfilesharing/lib/Notifications.php index e107065d0c19d..f9ecb98a0b97f 100644 --- a/apps/federatedfilesharing/lib/Notifications.php +++ b/apps/federatedfilesharing/lib/Notifications.php @@ -249,7 +249,7 @@ public function sendUpdateToRemote($remote, $remoteId, $token, $action, $data = return true; } elseif ($try === 0) { // only add new job on first try - $this->jobList->add('OCA\FederatedFileSharing\BackgroundJob\RetryJob', + $this->jobList->add(\OCA\FederatedFileSharing\BackgroundJob\RetryJob::class, [ 'remote' => $remote, 'remoteId' => $remoteId, diff --git a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php index 61487689cde3f..1fcca4e19cf1a 100644 --- a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php @@ -76,18 +76,18 @@ protected function setUp(): void { parent::setUp(); $this->request = $this->getMockBuilder(IRequest::class)->disableOriginalConstructor()->getMock(); - $this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider') + $this->federatedShareProvider = $this->getMockBuilder(\OCA\FederatedFileSharing\FederatedShareProvider::class) ->disableOriginalConstructor()->getMock(); $this->shareManager = $this->getMockBuilder(IManager::class)->disableOriginalConstructor()->getMock(); - $this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler') + $this->addressHandler = $this->getMockBuilder(\OCA\FederatedFileSharing\AddressHandler::class) ->disableOriginalConstructor()->getMock(); - $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->disableOriginalConstructor()->getMock(); + $this->rootFolder = $this->getMockBuilder(\OCP\Files\IRootFolder::class)->disableOriginalConstructor()->getMock(); $this->userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock(); $this->share = new \OC\Share20\Share($this->rootFolder, $this->userManager); $this->session = $this->getMockBuilder(ISession::class)->disableOriginalConstructor()->getMock(); $this->l10n = $this->getMockBuilder(IL10N::class)->disableOriginalConstructor()->getMock(); $this->userSession = $this->getMockBuilder(IUserSession::class)->disableOriginalConstructor()->getMock(); - $this->clientService = $this->getMockBuilder('OCP\Http\Client\IClientService')->disableOriginalConstructor()->getMock(); + $this->clientService = $this->getMockBuilder(\OCP\Http\Client\IClientService::class)->disableOriginalConstructor()->getMock(); $this->contactsManager = $this->createMock(IContactsManager::class); $this->cloudIdManager = new CloudIdManager( $this->contactsManager, diff --git a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php index dc128021b2824..b9616d6f7e181 100644 --- a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php @@ -86,7 +86,7 @@ class RequestHandlerControllerTest extends \Test\TestCase { protected function setUp(): void { $this->share = $this->getMockBuilder(IShare::class)->getMock(); - $this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider') + $this->federatedShareProvider = $this->getMockBuilder(\OCA\FederatedFileSharing\FederatedShareProvider::class) ->disableOriginalConstructor()->getMock(); $this->federatedShareProvider->expects($this->any()) ->method('isOutgoingServer2serverShareEnabled')->willReturn(true); @@ -95,9 +95,9 @@ protected function setUp(): void { $this->federatedShareProvider->expects($this->any())->method('getShareById') ->willReturn($this->share); - $this->notifications = $this->getMockBuilder('OCA\FederatedFileSharing\Notifications') + $this->notifications = $this->getMockBuilder(\OCA\FederatedFileSharing\Notifications::class) ->disableOriginalConstructor()->getMock(); - $this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler') + $this->addressHandler = $this->getMockBuilder(\OCA\FederatedFileSharing\AddressHandler::class) ->disableOriginalConstructor()->getMock(); $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); $this->cloudIdManager = $this->createMock(ICloudIdManager::class); diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index 8f54207626f8b..1ae206d9234eb 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -74,10 +74,10 @@ protected function setUp(): void { parent::setUp(); $this->connection = \OC::$server->getDatabaseConnection(); - $this->notifications = $this->getMockBuilder('OCA\FederatedFileSharing\Notifications') + $this->notifications = $this->getMockBuilder(\OCA\FederatedFileSharing\Notifications::class) ->disableOriginalConstructor() ->getMock(); - $this->tokenHandler = $this->getMockBuilder('OCA\FederatedFileSharing\TokenHandler') + $this->tokenHandler = $this->getMockBuilder(\OCA\FederatedFileSharing\TokenHandler::class) ->disableOriginalConstructor() ->getMock(); $this->l = $this->getMockBuilder(IL10N::class)->getMock(); @@ -86,11 +86,11 @@ protected function setUp(): void { return vsprintf($text, $parameters); }); $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); - $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock(); + $this->rootFolder = $this->getMockBuilder(\OCP\Files\IRootFolder::class)->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->addressHandler = $this->getMockBuilder(\OCA\FederatedFileSharing\AddressHandler::class)->disableOriginalConstructor()->getMock(); $this->contactsManager = $this->createMock(IContactsManager::class); $this->cloudIdManager = new CloudIdManager( $this->contactsManager, @@ -442,7 +442,7 @@ public function testCreateAlreadyShared() { * @dataProvider dataTestUpdate */ public function testUpdate($owner, $sharedBy, $expirationDate) { - $this->provider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider') + $this->provider = $this->getMockBuilder(\OCA\FederatedFileSharing\FederatedShareProvider::class) ->setConstructorArgs( [ $this->connection, diff --git a/apps/federatedfilesharing/tests/NotificationsTest.php b/apps/federatedfilesharing/tests/NotificationsTest.php index d0f5283e7a950..5f7b07d34ff12 100644 --- a/apps/federatedfilesharing/tests/NotificationsTest.php +++ b/apps/federatedfilesharing/tests/NotificationsTest.php @@ -46,10 +46,10 @@ class NotificationsTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->jobList = $this->getMockBuilder('OCP\BackgroundJob\IJobList')->getMock(); + $this->jobList = $this->getMockBuilder(\OCP\BackgroundJob\IJobList::class)->getMock(); $this->discoveryService = $this->getMockBuilder(IDiscoveryService::class)->getMock(); - $this->httpClientService = $this->getMockBuilder('OCP\Http\Client\IClientService')->getMock(); - $this->addressHandler = $this->getMockBuilder('OCA\FederatedFileSharing\AddressHandler') + $this->httpClientService = $this->getMockBuilder(\OCP\Http\Client\IClientService::class)->getMock(); + $this->addressHandler = $this->getMockBuilder(\OCA\FederatedFileSharing\AddressHandler::class) ->disableOriginalConstructor()->getMock(); $this->logger = $this->createMock(LoggerInterface::class); $this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class); @@ -76,7 +76,7 @@ private function getInstance(array $mockedMethods = []) { $this->logger, ); } else { - $instance = $this->getMockBuilder('OCA\FederatedFileSharing\Notifications') + $instance = $this->getMockBuilder(\OCA\FederatedFileSharing\Notifications::class) ->setConstructorArgs( [ $this->addressHandler, @@ -120,7 +120,7 @@ public function testSendUpdateToRemote($try, $httpRequestResult, $expected) { if ($try === 0 && $expected === false) { $this->jobList->expects($this->once())->method('add') ->with( - 'OCA\FederatedFileSharing\BackgroundJob\RetryJob', + \OCA\FederatedFileSharing\BackgroundJob\RetryJob::class, [ 'remote' => $remote, 'remoteId' => $id, diff --git a/apps/federation/lib/Controller/OCSAuthAPIController.php b/apps/federation/lib/Controller/OCSAuthAPIController.php index 8412868da42c8..31e87ff66d90f 100644 --- a/apps/federation/lib/Controller/OCSAuthAPIController.php +++ b/apps/federation/lib/Controller/OCSAuthAPIController.php @@ -130,7 +130,7 @@ public function requestSharedSecret(string $url, string $token): DataResponse { } $this->jobList->add( - 'OCA\Federation\BackgroundJob\GetSharedSecret', + \OCA\Federation\BackgroundJob\GetSharedSecret::class, [ 'url' => $url, 'token' => $token, diff --git a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php index 7d67de38f5f39..fca00a05b5a9f 100644 --- a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php +++ b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php @@ -89,7 +89,7 @@ protected function setUp(): void { */ public function testStart($isTrustedServer, $retainBackgroundJob) { /** @var RequestSharedSecret |MockObject $requestSharedSecret */ - $requestSharedSecret = $this->getMockBuilder('OCA\Federation\BackgroundJob\RequestSharedSecret') + $requestSharedSecret = $this->getMockBuilder(\OCA\Federation\BackgroundJob\RequestSharedSecret::class) ->setConstructorArgs( [ $this->httpClientService, diff --git a/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php b/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php index 9f2d41a10724c..1f1fd58b08813 100644 --- a/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php +++ b/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php @@ -91,7 +91,7 @@ public function testRequestSharedSecret(string $token, string $localToken, bool if ($ok) { $this->jobList->expects($this->once())->method('add') - ->with('OCA\Federation\BackgroundJob\GetSharedSecret', ['url' => $url, 'token' => $token, 'created' => $this->currentTime]); + ->with(\OCA\Federation\BackgroundJob\GetSharedSecret::class, ['url' => $url, 'token' => $token, 'created' => $this->currentTime]); } else { $this->jobList->expects($this->never())->method('add'); $this->jobList->expects($this->never())->method('remove'); @@ -127,7 +127,7 @@ public function testGetSharedSecret(bool $isTrustedServer, bool $isValidToken, b $token = 'token'; /** @var OCSAuthAPIController | \PHPUnit\Framework\MockObject\MockObject $ocsAuthApi */ - $ocsAuthApi = $this->getMockBuilder('OCA\Federation\Controller\OCSAuthAPIController') + $ocsAuthApi = $this->getMockBuilder(\OCA\Federation\Controller\OCSAuthAPIController::class) ->setConstructorArgs( [ 'federation', diff --git a/apps/federation/tests/DAV/FedAuthTest.php b/apps/federation/tests/DAV/FedAuthTest.php index 2d71137ae381b..f05863b97cc8c 100644 --- a/apps/federation/tests/DAV/FedAuthTest.php +++ b/apps/federation/tests/DAV/FedAuthTest.php @@ -22,7 +22,7 @@ class FedAuthTest extends TestCase { */ public function testFedAuth($expected, $user, $password) { /** @var DbHandler | \PHPUnit\Framework\MockObject\MockObject $db */ - $db = $this->getMockBuilder('OCA\Federation\DbHandler')->disableOriginalConstructor()->getMock(); + $db = $this->getMockBuilder(\OCA\Federation\DbHandler::class)->disableOriginalConstructor()->getMock(); $db->method('auth')->willReturn(true); $auth = new FedAuth($db); $result = $this->invokePrivate($auth, 'validateUserPass', [$user, $password]); diff --git a/apps/federation/tests/Settings/AdminTest.php b/apps/federation/tests/Settings/AdminTest.php index 3bbf4c4a9e73e..9322db9f7314f 100644 --- a/apps/federation/tests/Settings/AdminTest.php +++ b/apps/federation/tests/Settings/AdminTest.php @@ -19,7 +19,7 @@ class AdminTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->trustedServers = $this->getMockBuilder('\OCA\Federation\TrustedServers')->disableOriginalConstructor()->getMock(); + $this->trustedServers = $this->getMockBuilder(\OCA\Federation\TrustedServers::class)->disableOriginalConstructor()->getMock(); $this->admin = new Admin( $this->trustedServers, $this->createMock(IL10N::class) diff --git a/apps/federation/tests/SyncFederationAddressbooksTest.php b/apps/federation/tests/SyncFederationAddressbooksTest.php index 0f13dd0ec51c8..e27d2e7d26eab 100644 --- a/apps/federation/tests/SyncFederationAddressbooksTest.php +++ b/apps/federation/tests/SyncFederationAddressbooksTest.php @@ -35,7 +35,7 @@ protected function setUp(): void { public function testSync() { /** @var DbHandler | MockObject $dbHandler */ - $dbHandler = $this->getMockBuilder('OCA\Federation\DbHandler') + $dbHandler = $this->getMockBuilder(\OCA\Federation\DbHandler::class) ->disableOriginalConstructor() ->getMock(); $dbHandler->method('getAllServer') @@ -49,7 +49,7 @@ public function testSync() { ]); $dbHandler->expects($this->once())->method('setServerStatus')-> with('https://cloud.drop.box', 1, '1'); - $syncService = $this->getMockBuilder('OCA\DAV\CardDAV\SyncService') + $syncService = $this->getMockBuilder(\OCA\DAV\CardDAV\SyncService::class) ->disableOriginalConstructor() ->getMock(); $syncService->expects($this->once())->method('syncRemoteAddressBook') @@ -65,7 +65,7 @@ public function testSync() { public function testException() { /** @var DbHandler | MockObject $dbHandler */ - $dbHandler = $this->getMockBuilder('OCA\Federation\DbHandler')-> + $dbHandler = $this->getMockBuilder(\OCA\Federation\DbHandler::class)-> disableOriginalConstructor()-> getMock(); $dbHandler->method('getAllServer')-> @@ -77,7 +77,7 @@ public function testException() { 'sync_token' => '0' ] ]); - $syncService = $this->getMockBuilder('OCA\DAV\CardDAV\SyncService') + $syncService = $this->getMockBuilder(\OCA\DAV\CardDAV\SyncService::class) ->disableOriginalConstructor() ->getMock(); $syncService->expects($this->once())->method('syncRemoteAddressBook') @@ -93,7 +93,7 @@ public function testException() { public function testSuccessfulSyncWithoutChangesAfterFailure() { /** @var DbHandler | MockObject $dbHandler */ - $dbHandler = $this->getMockBuilder('OCA\Federation\DbHandler') + $dbHandler = $this->getMockBuilder(\OCA\Federation\DbHandler::class) ->disableOriginalConstructor() ->getMock(); $dbHandler->method('getAllServer') @@ -108,7 +108,7 @@ public function testSuccessfulSyncWithoutChangesAfterFailure() { $dbHandler->method('getServerStatus')->willReturn(\OCA\Federation\TrustedServers::STATUS_FAILURE); $dbHandler->expects($this->once())->method('setServerStatus')-> with('https://cloud.drop.box', 1); - $syncService = $this->getMockBuilder('OCA\DAV\CardDAV\SyncService') + $syncService = $this->getMockBuilder(\OCA\DAV\CardDAV\SyncService::class) ->disableOriginalConstructor() ->getMock(); $syncService->expects($this->once())->method('syncRemoteAddressBook') diff --git a/apps/federation/tests/TrustedServersTest.php b/apps/federation/tests/TrustedServersTest.php index 93c66ea8831e3..c97e815ec06b8 100644 --- a/apps/federation/tests/TrustedServersTest.php +++ b/apps/federation/tests/TrustedServersTest.php @@ -84,7 +84,7 @@ protected function setUp(): void { public function testAddServer(): void { /** @var \PHPUnit\Framework\MockObject\MockObject|TrustedServers $trustedServers */ - $trustedServers = $this->getMockBuilder('OCA\Federation\TrustedServers') + $trustedServers = $this->getMockBuilder(\OCA\Federation\TrustedServers::class) ->setConstructorArgs( [ $this->dbHandler, @@ -110,7 +110,7 @@ public function testAddServer(): void { ->willReturn('token'); $this->dbHandler->expects($this->once())->method('addToken')->with('https://url', 'token'); $this->jobList->expects($this->once())->method('add') - ->with('OCA\Federation\BackgroundJob\RequestSharedSecret', + ->with(\OCA\Federation\BackgroundJob\RequestSharedSecret::class, ['url' => 'https://url', 'token' => 'token', 'created' => 1234567]); $this->assertSame( @@ -195,7 +195,7 @@ public function testIsNextcloudServer(int $statusCode, bool $isValidNextcloudVer $server = 'server1'; /** @var \PHPUnit\Framework\MockObject\MockObject | TrustedServers $trustedServers */ - $trustedServers = $this->getMockBuilder('OCA\Federation\TrustedServers') + $trustedServers = $this->getMockBuilder(\OCA\Federation\TrustedServers::class) ->setConstructorArgs( [ $this->dbHandler, diff --git a/apps/files/lib/AppInfo/Application.php b/apps/files/lib/AppInfo/Application.php index 3d2d0527072a7..2a9c3f2bce31b 100644 --- a/apps/files/lib/AppInfo/Application.php +++ b/apps/files/lib/AppInfo/Application.php @@ -147,6 +147,6 @@ private function registerTemplates(): void { } private function registerHooks(): void { - Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig'); + Util::connectHook('\OCP\Config', 'js', \OCA\Files\App::class, 'extendJsConfig'); } } diff --git a/apps/files/lib/Command/Scan.php b/apps/files/lib/Command/Scan.php index 68c80f6559ab4..22852706804b3 100644 --- a/apps/files/lib/Command/Scan.php +++ b/apps/files/lib/Command/Scan.php @@ -106,7 +106,7 @@ protected function scanFiles(string $user, string $path, ?string $scanMetadata, ); # check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function (string $path) use ($output, $scanMetadata) { + $scanner->listen(\OC\Files\Utils\Scanner::class, 'scanFile', function (string $path) use ($output, $scanMetadata) { $output->writeln("\tFile\t$path", OutputInterface::VERBOSITY_VERBOSE); ++$this->filesCounter; $this->abortIfInterrupted(); @@ -120,18 +120,18 @@ protected function scanFiles(string $user, string $path, ?string $scanMetadata, } }); - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { + $scanner->listen(\OC\Files\Utils\Scanner::class, 'scanFolder', function ($path) use ($output) { $output->writeln("\tFolder\t$path", OutputInterface::VERBOSITY_VERBOSE); ++$this->foldersCounter; $this->abortIfInterrupted(); }); - $scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) { + $scanner->listen(\OC\Files\Utils\Scanner::class, 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) { $output->writeln('Error while scanning, storage not available (' . $e->getMessage() . ')', OutputInterface::VERBOSITY_VERBOSE); ++$this->errorsCounter; }); - $scanner->listen('\OC\Files\Utils\Scanner', 'normalizedNameMismatch', function ($fullPath) use ($output) { + $scanner->listen(\OC\Files\Utils\Scanner::class, 'normalizedNameMismatch', function ($fullPath) use ($output) { $output->writeln("\tEntry \"" . $fullPath . '" will not be accessible due to incompatible encoding'); ++$this->errorsCounter; }); diff --git a/apps/files/lib/Command/ScanAppData.php b/apps/files/lib/Command/ScanAppData.php index 5360d38bdb629..97f35cfc37443 100644 --- a/apps/files/lib/Command/ScanAppData.php +++ b/apps/files/lib/Command/ScanAppData.php @@ -73,23 +73,23 @@ protected function scanFiles(OutputInterface $output, string $folder): int { ); # check on each file/folder if there was a user interrupt (ctrl-c) and throw an exception - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) { + $scanner->listen(\OC\Files\Utils\Scanner::class, 'scanFile', function ($path) use ($output) { $output->writeln("\tFile $path", OutputInterface::VERBOSITY_VERBOSE); ++$this->filesCounter; $this->abortIfInterrupted(); }); - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { + $scanner->listen(\OC\Files\Utils\Scanner::class, 'scanFolder', function ($path) use ($output) { $output->writeln("\tFolder $path", OutputInterface::VERBOSITY_VERBOSE); ++$this->foldersCounter; $this->abortIfInterrupted(); }); - $scanner->listen('\OC\Files\Utils\Scanner', 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) { + $scanner->listen(\OC\Files\Utils\Scanner::class, 'StorageNotAvailable', function (StorageNotAvailableException $e) use ($output) { $output->writeln('Error while scanning, storage not available (' . $e->getMessage() . ')', OutputInterface::VERBOSITY_VERBOSE); }); - $scanner->listen('\OC\Files\Utils\Scanner', 'normalizedNameMismatch', function ($fullPath) use ($output) { + $scanner->listen(\OC\Files\Utils\Scanner::class, 'normalizedNameMismatch', function ($fullPath) use ($output) { $output->writeln("\tEntry \"" . $fullPath . '" will not be accessible due to incompatible encoding'); }); diff --git a/apps/files/tests/BackgroundJob/ScanFilesTest.php b/apps/files/tests/BackgroundJob/ScanFilesTest.php index e4ba8348d648a..9c0dd77dfb0d6 100644 --- a/apps/files/tests/BackgroundJob/ScanFilesTest.php +++ b/apps/files/tests/BackgroundJob/ScanFilesTest.php @@ -43,7 +43,7 @@ protected function setUp(): void { $connection = \OC::$server->getDatabaseConnection(); $this->mountCache = \OC::$server->getUserMountCache(); - $this->scanFiles = $this->getMockBuilder('\OCA\Files\BackgroundJob\ScanFiles') + $this->scanFiles = $this->getMockBuilder(\OCA\Files\BackgroundJob\ScanFiles::class) ->setConstructorArgs([ $config, $dispatcher, diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index c1bc27d42b53a..53984b5fc1c64 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -58,7 +58,7 @@ protected function setUp(): void { $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->eventDispatcher = $this->createMock(IEventDispatcher::class); $this->userSession = $this->getMockBuilder(IUserSession::class)->getMock(); - $this->appManager = $this->getMockBuilder('\OCP\App\IAppManager')->getMock(); + $this->appManager = $this->getMockBuilder(\OCP\App\IAppManager::class)->getMock(); $this->user = $this->getMockBuilder(IUser::class)->getMock(); $this->user->expects($this->any()) ->method('getUID') @@ -66,7 +66,7 @@ protected function setUp(): void { $this->userSession->expects($this->any()) ->method('getUser') ->willReturn($this->user); - $this->rootFolder = $this->getMockBuilder('\OCP\Files\IRootFolder')->getMock(); + $this->rootFolder = $this->getMockBuilder(\OCP\Files\IRootFolder::class)->getMock(); $this->initialState = $this->createMock(IInitialState::class); $this->templateManager = $this->createMock(ITemplateManager::class); $this->userConfig = $this->createMock(UserConfig::class); diff --git a/apps/files_external/3rdparty/composer/InstalledVersions.php b/apps/files_external/3rdparty/composer/InstalledVersions.php index 51e734a774b3e..7d297a8d4b29f 100644 --- a/apps/files_external/3rdparty/composer/InstalledVersions.php +++ b/apps/files_external/3rdparty/composer/InstalledVersions.php @@ -318,7 +318,7 @@ public static function reload($data) private static function getInstalled() { if (null === self::$canGetVendors) { - self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + self::$canGetVendors = method_exists(\Composer\Autoload\ClassLoader::class, 'getRegisteredLoaders'); } $installed = array(); diff --git a/apps/files_external/lib/Command/Scan.php b/apps/files_external/lib/Command/Scan.php index 575ee5989f543..b0f417d1f45e2 100644 --- a/apps/files_external/lib/Command/Scan.php +++ b/apps/files_external/lib/Command/Scan.php @@ -70,13 +70,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** @var Scanner $scanner */ $scanner = $storage->getScanner(); - $scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function (string $path) use ($output) { + $scanner->listen(\OC\Files\Cache\Scanner::class, 'scanFile', function (string $path) use ($output) { $output->writeln("\tFile\t$path", OutputInterface::VERBOSITY_VERBOSE); ++$this->filesCounter; $this->abortIfInterrupted(); }); - $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function (string $path) use ($output) { + $scanner->listen(\OC\Files\Cache\Scanner::class, 'scanFolder', function (string $path) use ($output) { $output->writeln("\tFolder\t$path", OutputInterface::VERBOSITY_VERBOSE); ++$this->foldersCounter; $this->abortIfInterrupted(); diff --git a/apps/files_external/lib/Config/ConfigAdapter.php b/apps/files_external/lib/Config/ConfigAdapter.php index 97bc4f78142e8..972ca5d80c5cf 100644 --- a/apps/files_external/lib/Config/ConfigAdapter.php +++ b/apps/files_external/lib/Config/ConfigAdapter.php @@ -46,7 +46,7 @@ private function prepareStorageConfig(StorageConfig &$storage, IUser $user) { $objectStore = $storage->getBackendOption('objectstore'); if ($objectStore) { $objectClass = $objectStore['class']; - if (!is_subclass_of($objectClass, '\OCP\Files\ObjectStore\IObjectStore')) { + if (!is_subclass_of($objectClass, \OCP\Files\ObjectStore\IObjectStore::class)) { throw new \InvalidArgumentException('Invalid object store'); } $storage->setBackendOption('objectstore', new $objectClass($objectStore)); diff --git a/apps/files_external/lib/Lib/Backend/AmazonS3.php b/apps/files_external/lib/Lib/Backend/AmazonS3.php index e345ed53f703a..a4f1b18f58c51 100644 --- a/apps/files_external/lib/Lib/Backend/AmazonS3.php +++ b/apps/files_external/lib/Lib/Backend/AmazonS3.php @@ -19,7 +19,7 @@ public function __construct(IL10N $l, AccessKey $legacyAuth) { $this ->setIdentifier('amazons3') ->addIdentifierAlias('\OC\Files\Storage\AmazonS3') // legacy compat - ->setStorageClass('\OCA\Files_External\Lib\Storage\AmazonS3') + ->setStorageClass(\OCA\Files_External\Lib\Storage\AmazonS3::class) ->setText($l->t('Amazon S3')) ->addParameters([ new DefinitionParameter('bucket', $l->t('Bucket')), diff --git a/apps/files_external/lib/Lib/Backend/DAV.php b/apps/files_external/lib/Lib/Backend/DAV.php index 9eb206f027293..34c79f198e5c6 100644 --- a/apps/files_external/lib/Lib/Backend/DAV.php +++ b/apps/files_external/lib/Lib/Backend/DAV.php @@ -18,8 +18,8 @@ class DAV extends Backend { public function __construct(IL10N $l, Password $legacyAuth) { $this ->setIdentifier('dav') - ->addIdentifierAlias('\OC\Files\Storage\DAV') // legacy compat - ->setStorageClass('\OC\Files\Storage\DAV') + ->addIdentifierAlias(\OC\Files\Storage\DAV::class) // legacy compat + ->setStorageClass(\OC\Files\Storage\DAV::class) ->setText($l->t('WebDAV')) ->addParameters([ new DefinitionParameter('host', $l->t('URL')), diff --git a/apps/files_external/lib/Lib/Backend/FTP.php b/apps/files_external/lib/Lib/Backend/FTP.php index cdf7d187b4da3..f942340f1e0c7 100644 --- a/apps/files_external/lib/Lib/Backend/FTP.php +++ b/apps/files_external/lib/Lib/Backend/FTP.php @@ -19,7 +19,7 @@ public function __construct(IL10N $l, Password $legacyAuth) { $this ->setIdentifier('ftp') ->addIdentifierAlias('\OC\Files\Storage\FTP') // legacy compat - ->setStorageClass('\OCA\Files_External\Lib\Storage\FTP') + ->setStorageClass(\OCA\Files_External\Lib\Storage\FTP::class) ->setText($l->t('FTP')) ->addParameters([ new DefinitionParameter('host', $l->t('Host')), diff --git a/apps/files_external/lib/Lib/Backend/InvalidBackend.php b/apps/files_external/lib/Lib/Backend/InvalidBackend.php index 22d0287244a92..a61fb0af8e51a 100644 --- a/apps/files_external/lib/Lib/Backend/InvalidBackend.php +++ b/apps/files_external/lib/Lib/Backend/InvalidBackend.php @@ -29,7 +29,7 @@ public function __construct($invalidId) { $this->invalidId = $invalidId; $this ->setIdentifier($invalidId) - ->setStorageClass('\OC\Files\Storage\FailedStorage') + ->setStorageClass(\OC\Files\Storage\FailedStorage::class) ->setText('Unknown storage backend ' . $invalidId); } diff --git a/apps/files_external/lib/Lib/Backend/Local.php b/apps/files_external/lib/Lib/Backend/Local.php index 2902ba770c6e3..505a3893b2d3e 100644 --- a/apps/files_external/lib/Lib/Backend/Local.php +++ b/apps/files_external/lib/Lib/Backend/Local.php @@ -18,8 +18,8 @@ class Local extends Backend { public function __construct(IL10N $l, NullMechanism $legacyAuth) { $this ->setIdentifier('local') - ->addIdentifierAlias('\OC\Files\Storage\Local') // legacy compat - ->setStorageClass('\OC\Files\Storage\Local') + ->addIdentifierAlias(\OC\Files\Storage\Local::class) // legacy compat + ->setStorageClass(\OC\Files\Storage\Local::class) ->setText($l->t('Local')) ->addParameters([ new DefinitionParameter('datadir', $l->t('Location')), diff --git a/apps/files_external/lib/Lib/Backend/OwnCloud.php b/apps/files_external/lib/Lib/Backend/OwnCloud.php index c0bd689186434..1c08bbe3a5325 100644 --- a/apps/files_external/lib/Lib/Backend/OwnCloud.php +++ b/apps/files_external/lib/Lib/Backend/OwnCloud.php @@ -16,7 +16,7 @@ public function __construct(IL10N $l, Password $legacyAuth) { $this ->setIdentifier('owncloud') ->addIdentifierAlias('\OC\Files\Storage\OwnCloud') // legacy compat - ->setStorageClass('\OCA\Files_External\Lib\Storage\OwnCloud') + ->setStorageClass(\OCA\Files_External\Lib\Storage\OwnCloud::class) ->setText($l->t('Nextcloud')) ->addParameters([ new DefinitionParameter('host', $l->t('URL')), diff --git a/apps/files_external/lib/Lib/Backend/SFTP.php b/apps/files_external/lib/Lib/Backend/SFTP.php index 93a5d87a5ff15..348e0370608f6 100644 --- a/apps/files_external/lib/Lib/Backend/SFTP.php +++ b/apps/files_external/lib/Lib/Backend/SFTP.php @@ -16,7 +16,7 @@ public function __construct(IL10N $l, Password $legacyAuth) { $this ->setIdentifier('sftp') ->addIdentifierAlias('\OC\Files\Storage\SFTP') // legacy compat - ->setStorageClass('\OCA\Files_External\Lib\Storage\SFTP') + ->setStorageClass(\OCA\Files_External\Lib\Storage\SFTP::class) ->setText($l->t('SFTP')) ->addParameters([ new DefinitionParameter('host', $l->t('Host')), diff --git a/apps/files_external/lib/Lib/Backend/SFTP_Key.php b/apps/files_external/lib/Lib/Backend/SFTP_Key.php index a657dce66e548..63c272d24320a 100644 --- a/apps/files_external/lib/Lib/Backend/SFTP_Key.php +++ b/apps/files_external/lib/Lib/Backend/SFTP_Key.php @@ -15,7 +15,7 @@ class SFTP_Key extends Backend { public function __construct(IL10N $l, RSA $legacyAuth, SFTP $sftpBackend) { $this ->setIdentifier('\OC\Files\Storage\SFTP_Key') - ->setStorageClass('\OCA\Files_External\Lib\Storage\SFTP') + ->setStorageClass(\OCA\Files_External\Lib\Storage\SFTP::class) ->setText($l->t('SFTP with secret key login')) ->addParameters([ new DefinitionParameter('host', $l->t('Host')), diff --git a/apps/files_external/lib/Lib/Backend/SMB.php b/apps/files_external/lib/Lib/Backend/SMB.php index c4a68fea6e18e..8e24b0c146dd4 100644 --- a/apps/files_external/lib/Lib/Backend/SMB.php +++ b/apps/files_external/lib/Lib/Backend/SMB.php @@ -27,7 +27,7 @@ public function __construct(IL10N $l, Password $legacyAuth) { $this ->setIdentifier('smb') ->addIdentifierAlias('\OC\Files\Storage\SMB')// legacy compat - ->setStorageClass('\OCA\Files_External\Lib\Storage\SMB') + ->setStorageClass(\OCA\Files_External\Lib\Storage\SMB::class) ->setText($l->t('SMB/CIFS')) ->addParameters([ new DefinitionParameter('host', $l->t('Host')), diff --git a/apps/files_external/lib/Lib/Backend/SMB_OC.php b/apps/files_external/lib/Lib/Backend/SMB_OC.php index 55edec8a4640e..bf7f855d18092 100644 --- a/apps/files_external/lib/Lib/Backend/SMB_OC.php +++ b/apps/files_external/lib/Lib/Backend/SMB_OC.php @@ -24,7 +24,7 @@ class SMB_OC extends Backend { public function __construct(IL10N $l, SessionCredentials $legacyAuth, SMB $smbBackend) { $this ->setIdentifier('\OC\Files\Storage\SMB_OC') - ->setStorageClass('\OCA\Files_External\Lib\Storage\SMB') + ->setStorageClass(\OCA\Files_External\Lib\Storage\SMB::class) ->setText($l->t('SMB/CIFS using OC login')) ->addParameters([ new DefinitionParameter('host', $l->t('Host')), diff --git a/apps/files_external/lib/Lib/Backend/Swift.php b/apps/files_external/lib/Lib/Backend/Swift.php index 386604e6e1de4..778e141a123ad 100644 --- a/apps/files_external/lib/Lib/Backend/Swift.php +++ b/apps/files_external/lib/Lib/Backend/Swift.php @@ -20,7 +20,7 @@ public function __construct(IL10N $l, OpenStackV2 $openstackAuth, Rackspace $rac $this ->setIdentifier('swift') ->addIdentifierAlias('\OC\Files\Storage\Swift') // legacy compat - ->setStorageClass('\OCA\Files_External\Lib\Storage\Swift') + ->setStorageClass(\OCA\Files_External\Lib\Storage\Swift::class) ->setText($l->t('OpenStack Object Storage')) ->addParameters([ (new DefinitionParameter('service_name', $l->t('Service name'))) diff --git a/apps/files_external/tests/Backend/LegacyBackendTest.php b/apps/files_external/tests/Backend/LegacyBackendTest.php index 2d041e69f2648..44aa4c32d182f 100644 --- a/apps/files_external/tests/Backend/LegacyBackendTest.php +++ b/apps/files_external/tests/Backend/LegacyBackendTest.php @@ -22,11 +22,11 @@ public static function checkDependencies() { } public function testConstructor() { - $auth = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\Builtin') + $auth = $this->getMockBuilder(\OCA\Files_External\Lib\Auth\Builtin::class) ->disableOriginalConstructor() ->getMock(); - $class = '\OCA\Files_External\Tests\Backend\LegacyBackendTest'; + $class = \OCA\Files_External\Tests\Backend\LegacyBackendTest::class; $definition = [ 'configuration' => [ 'textfield' => 'Text field', @@ -44,7 +44,7 @@ public function testConstructor() { $backend = new LegacyBackend($class, $definition, $auth); - $this->assertEquals('\OCA\Files_External\Tests\Backend\LegacyBackendTest', $backend->getStorageClass()); + $this->assertEquals(\OCA\Files_External\Tests\Backend\LegacyBackendTest::class, $backend->getStorageClass()); $this->assertEquals('Backend text', $backend->getText()); $this->assertEquals(123, $backend->getPriority()); $this->assertContains('foo/bar.js', $backend->getCustomJs()); @@ -78,11 +78,11 @@ public function testConstructor() { } public function testNoDependencies() { - $auth = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\Builtin') + $auth = $this->getMockBuilder(\OCA\Files_External\Lib\Auth\Builtin::class) ->disableOriginalConstructor() ->getMock(); - $class = '\OCA\Files_External\Tests\Backend\LegacyBackendTest'; + $class = \OCA\Files_External\Tests\Backend\LegacyBackendTest::class; $definition = [ 'configuration' => [ ], diff --git a/apps/files_external/tests/Command/CommandTest.php b/apps/files_external/tests/Command/CommandTest.php index eb47fe08ac4dc..8d26f92afe187 100644 --- a/apps/files_external/tests/Command/CommandTest.php +++ b/apps/files_external/tests/Command/CommandTest.php @@ -20,7 +20,7 @@ abstract class CommandTest extends TestCase { * @return \OCA\Files_External\Service\GlobalStoragesService|\PHPUnit\Framework\MockObject\MockObject */ protected function getGlobalStorageService(array $mounts = []) { - $mock = $this->getMockBuilder('OCA\Files_External\Service\GlobalStoragesService') + $mock = $this->getMockBuilder(\OCA\Files_External\Service\GlobalStoragesService::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/files_external/tests/Controller/AjaxControllerTest.php b/apps/files_external/tests/Controller/AjaxControllerTest.php index 4b2f973e9b02c..8b233903b75f7 100644 --- a/apps/files_external/tests/Controller/AjaxControllerTest.php +++ b/apps/files_external/tests/Controller/AjaxControllerTest.php @@ -31,10 +31,10 @@ class AjaxControllerTest extends TestCase { protected function setUp(): void { $this->request = $this->createMock(IRequest::class); - $this->rsa = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\PublicKey\\RSA') + $this->rsa = $this->getMockBuilder(\OCA\Files_External\Lib\Auth\PublicKey\RSA::class) ->disableOriginalConstructor() ->getMock(); - $this->globalAuth = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\Password\GlobalAuth') + $this->globalAuth = $this->getMockBuilder(\OCA\Files_External\Lib\Auth\Password\GlobalAuth::class) ->disableOriginalConstructor() ->getMock(); $this->userSession = $this->createMock(IUserSession::class); diff --git a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php index cc905a20ff447..6b1beca5374ae 100644 --- a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php +++ b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php @@ -21,7 +21,7 @@ class GlobalStoragesControllerTest extends StoragesControllerTest { protected function setUp(): void { parent::setUp(); - $this->service = $this->getMockBuilder('\OCA\Files_External\Service\GlobalStoragesService') + $this->service = $this->getMockBuilder(\OCA\Files_External\Service\GlobalStoragesService::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/files_external/tests/Controller/StoragesControllerTest.php b/apps/files_external/tests/Controller/StoragesControllerTest.php index 85f3ca814988b..d716a006e0e92 100644 --- a/apps/files_external/tests/Controller/StoragesControllerTest.php +++ b/apps/files_external/tests/Controller/StoragesControllerTest.php @@ -40,7 +40,7 @@ protected function tearDown(): void { /** * @return \OCA\Files_External\Lib\Backend\Backend|MockObject */ - protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OCA\Files_External\Lib\Storage\SMB') { + protected function getBackendMock($class = \OCA\Files_External\Lib\Backend\SMB::class, $storageClass = \OCA\Files_External\Lib\Storage\SMB::class) { $backend = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); @@ -56,7 +56,7 @@ protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB' /** * @return \OCA\Files_External\Lib\Auth\AuthMechanism|MockObject */ - protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') { + protected function getAuthMechMock($scheme = 'null', $class = \OCA\Files_External\Lib\Auth\NullMechanism::class) { $authMech = $this->getMockBuilder(AuthMechanism::class) ->disableOriginalConstructor() ->getMock(); @@ -97,8 +97,8 @@ public function testAddStorage() { $response = $this->controller->create( 'mount', - '\OCA\Files_External\Lib\Storage\SMB', - '\OCA\Files_External\Lib\Auth\NullMechanism', + \OCA\Files_External\Lib\Storage\SMB::class, + \OCA\Files_External\Lib\Auth\NullMechanism::class, [], [], [], @@ -129,7 +129,7 @@ public function testAddLocalStorageWhenDisabled() { $response = $this->controller->create( 'mount', 'local', - '\OCA\Files_External\Lib\Auth\NullMechanism', + \OCA\Files_External\Lib\Auth\NullMechanism::class, [], [], [], @@ -169,8 +169,8 @@ public function testUpdateStorage() { $response = $this->controller->update( 1, 'mount', - '\OCA\Files_External\Lib\Storage\SMB', - '\OCA\Files_External\Lib\Auth\NullMechanism', + \OCA\Files_External\Lib\Storage\SMB::class, + \OCA\Files_External\Lib\Auth\NullMechanism::class, [], [], [], @@ -211,8 +211,8 @@ public function testAddOrUpdateStorageInvalidMountPoint($mountPoint) { $response = $this->controller->create( $mountPoint, - '\OCA\Files_External\Lib\Storage\SMB', - '\OCA\Files_External\Lib\Auth\NullMechanism', + \OCA\Files_External\Lib\Storage\SMB::class, + \OCA\Files_External\Lib\Auth\NullMechanism::class, [], [], [], @@ -225,8 +225,8 @@ public function testAddOrUpdateStorageInvalidMountPoint($mountPoint) { $response = $this->controller->update( 1, $mountPoint, - '\OCA\Files_External\Lib\Storage\SMB', - '\OCA\Files_External\Lib\Auth\NullMechanism', + \OCA\Files_External\Lib\Storage\SMB::class, + \OCA\Files_External\Lib\Auth\NullMechanism::class, [], [], [], @@ -249,7 +249,7 @@ public function testAddOrUpdateStorageInvalidBackend() { $response = $this->controller->create( 'mount', '\OC\Files\Storage\InvalidStorage', - '\OCA\Files_External\Lib\Auth\NullMechanism', + \OCA\Files_External\Lib\Auth\NullMechanism::class, [], [], [], @@ -263,7 +263,7 @@ public function testAddOrUpdateStorageInvalidBackend() { 1, 'mount', '\OC\Files\Storage\InvalidStorage', - '\OCA\Files_External\Lib\Auth\NullMechanism', + \OCA\Files_External\Lib\Auth\NullMechanism::class, [], [], [], @@ -302,8 +302,8 @@ public function testUpdateStorageNonExisting() { $response = $this->controller->update( 255, 'mount', - '\OCA\Files_External\Lib\Storage\SMB', - '\OCA\Files_External\Lib\Auth\NullMechanism', + \OCA\Files_External\Lib\Storage\SMB::class, + \OCA\Files_External\Lib\Auth\NullMechanism::class, [], [], [], @@ -400,8 +400,8 @@ public function testValidateStorage($backendValidate, $authMechValidate, $expect $response = $this->controller->create( 'mount', - '\OCA\Files_External\Lib\Storage\SMB', - '\OCA\Files_External\Lib\Auth\NullMechanism', + \OCA\Files_External\Lib\Storage\SMB::class, + \OCA\Files_External\Lib\Auth\NullMechanism::class, [], [], [], diff --git a/apps/files_external/tests/Controller/UserStoragesControllerTest.php b/apps/files_external/tests/Controller/UserStoragesControllerTest.php index 0ac2197f67c08..4e2fc20d9ee26 100644 --- a/apps/files_external/tests/Controller/UserStoragesControllerTest.php +++ b/apps/files_external/tests/Controller/UserStoragesControllerTest.php @@ -28,7 +28,7 @@ class UserStoragesControllerTest extends StoragesControllerTest { protected function setUp(): void { parent::setUp(); - $this->service = $this->getMockBuilder('\OCA\Files_External\Service\UserStoragesService') + $this->service = $this->getMockBuilder(\OCA\Files_External\Service\UserStoragesService::class) ->disableOriginalConstructor() ->getMock(); @@ -88,7 +88,7 @@ public function testAddOrUpdateStorageDisallowedBackend() { $response = $this->controller->create( 'mount', - '\OCA\Files_External\Lib\Storage\SMB', + \OCA\Files_External\Lib\Storage\SMB::class, '\Auth\Mechanism', [], [], @@ -102,7 +102,7 @@ public function testAddOrUpdateStorageDisallowedBackend() { $response = $this->controller->update( 1, 'mount', - '\OCA\Files_External\Lib\Storage\SMB', + \OCA\Files_External\Lib\Storage\SMB::class, '\Auth\Mechanism', [], [], diff --git a/apps/files_external/tests/FrontendDefinitionTraitTest.php b/apps/files_external/tests/FrontendDefinitionTraitTest.php index e5dc0547d7401..ab2c6113050e9 100644 --- a/apps/files_external/tests/FrontendDefinitionTraitTest.php +++ b/apps/files_external/tests/FrontendDefinitionTraitTest.php @@ -16,7 +16,7 @@ public function testJsonSerialization() { ->getMock(); $param->method('getName')->willReturn('foo'); - $trait = $this->getMockForTrait('\OCA\Files_External\Lib\FrontendDefinitionTrait'); + $trait = $this->getMockForTrait(\OCA\Files_External\Lib\FrontendDefinitionTrait::class); $trait->setText('test'); $trait->addParameters([$param]); $trait->addCustomJs('foo/bar.js'); @@ -67,7 +67,7 @@ public function testValidateStorage($expectedSuccess, $params) { $storageConfig->expects($this->any()) ->method('setBackendOption'); - $trait = $this->getMockForTrait('\OCA\Files_External\Lib\FrontendDefinitionTrait'); + $trait = $this->getMockForTrait(\OCA\Files_External\Lib\FrontendDefinitionTrait::class); $trait->setText('test'); $trait->addParameters($backendParams); @@ -98,7 +98,7 @@ public function testValidateStorageSet() { ->method('setBackendOption') ->with('param', 'foobar'); - $trait = $this->getMockForTrait('\OCA\Files_External\Lib\FrontendDefinitionTrait'); + $trait = $this->getMockForTrait(\OCA\Files_External\Lib\FrontendDefinitionTrait::class); $trait->setText('test'); $trait->addParameter($param); diff --git a/apps/files_external/tests/LegacyDependencyCheckPolyfillTest.php b/apps/files_external/tests/LegacyDependencyCheckPolyfillTest.php index 931421551eb85..5b8f68ceb793a 100644 --- a/apps/files_external/tests/LegacyDependencyCheckPolyfillTest.php +++ b/apps/files_external/tests/LegacyDependencyCheckPolyfillTest.php @@ -21,10 +21,10 @@ public static function checkDependencies() { } public function testCheckDependencies() { - $trait = $this->getMockForTrait('\OCA\Files_External\Lib\LegacyDependencyCheckPolyfill'); + $trait = $this->getMockForTrait(\OCA\Files_External\Lib\LegacyDependencyCheckPolyfill::class); $trait->expects($this->once()) ->method('getStorageClass') - ->willReturn('\OCA\Files_External\Tests\LegacyDependencyCheckPolyfillTest'); + ->willReturn(\OCA\Files_External\Tests\LegacyDependencyCheckPolyfillTest::class); $dependencies = $trait->checkDependencies(); $this->assertCount(2, $dependencies); diff --git a/apps/files_external/tests/PersonalMountTest.php b/apps/files_external/tests/PersonalMountTest.php index aec0a8b6f7524..17dd632690ecc 100644 --- a/apps/files_external/tests/PersonalMountTest.php +++ b/apps/files_external/tests/PersonalMountTest.php @@ -16,11 +16,11 @@ class PersonalMountTest extends TestCase { public function testFindByStorageId() { $storageConfig = $this->createMock(StorageConfig::class); /** @var \OCA\Files_External\Service\UserStoragesService $storageService */ - $storageService = $this->getMockBuilder('\OCA\Files_External\Service\UserStoragesService') + $storageService = $this->getMockBuilder(\OCA\Files_External\Service\UserStoragesService::class) ->disableOriginalConstructor() ->getMock(); - $storage = $this->getMockBuilder('\OC\Files\Storage\Storage') + $storage = $this->getMockBuilder(\OC\Files\Storage\Storage::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php index bda9655031759..8685325471e8c 100644 --- a/apps/files_external/tests/Service/BackendServiceTest.php +++ b/apps/files_external/tests/Service/BackendServiceTest.php @@ -187,7 +187,7 @@ public function testGetAvailableBackends() { $backendNotAvailable->expects($this->once()) ->method('checkDependencies') ->willReturn([ - $this->getMockBuilder('\OCA\Files_External\Lib\MissingDependency') + $this->getMockBuilder(\OCA\Files_External\Lib\MissingDependency::class) ->disableOriginalConstructor() ->getMock() ]); diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php index 0936912b221ea..234ea12b8e71d 100644 --- a/apps/files_external/tests/Service/StoragesServiceTest.php +++ b/apps/files_external/tests/Service/StoragesServiceTest.php @@ -98,7 +98,7 @@ protected function setUp(): void { // prepare BackendService mock $this->backendService = - $this->getMockBuilder('\OCA\Files_External\Service\BackendService') + $this->getMockBuilder(\OCA\Files_External\Service\BackendService::class) ->disableOriginalConstructor() ->getMock(); @@ -123,10 +123,10 @@ protected function setUp(): void { $this->backendService->method('getAuthMechanisms') ->willReturn($authMechanisms); - $sftpBackend = $this->getBackendMock('\OCA\Files_External\Lib\Backend\SFTP', '\OCA\Files_External\Lib\Storage\SFTP'); + $sftpBackend = $this->getBackendMock(\OCA\Files_External\Lib\Backend\SFTP::class, \OCA\Files_External\Lib\Storage\SFTP::class); $backends = [ - 'identifier:\OCA\Files_External\Lib\Backend\DAV' => $this->getBackendMock('\OCA\Files_External\Lib\Backend\DAV', '\OC\Files\Storage\DAV'), - 'identifier:\OCA\Files_External\Lib\Backend\SMB' => $this->getBackendMock('\OCA\Files_External\Lib\Backend\SMB', '\OCA\Files_External\Lib\Storage\SMB'), + 'identifier:\OCA\Files_External\Lib\Backend\DAV' => $this->getBackendMock(\OCA\Files_External\Lib\Backend\DAV::class, \OC\Files\Storage\DAV::class), + 'identifier:\OCA\Files_External\Lib\Backend\SMB' => $this->getBackendMock(\OCA\Files_External\Lib\Backend\SMB::class, \OCA\Files_External\Lib\Storage\SMB::class), 'identifier:\OCA\Files_External\Lib\Backend\SFTP' => $sftpBackend, 'identifier:sftp_alias' => $sftpBackend, ]; @@ -155,7 +155,7 @@ protected function setUp(): void { $containerMock = $this->createMock(IAppContainer::class); $containerMock->method('query') ->willReturnCallback(function ($name) { - if ($name === 'OCA\Files_External\Service\BackendService') { + if ($name === \OCA\Files_External\Service\BackendService::class) { return $this->backendService; } }); @@ -169,7 +169,7 @@ protected function tearDown(): void { } } - protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OCA\Files_External\Lib\Storage\SMB') { + protected function getBackendMock($class = \OCA\Files_External\Lib\Backend\SMB::class, $storageClass = \OCA\Files_External\Lib\Storage\SMB::class) { $backend = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); @@ -180,7 +180,7 @@ protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB' return $backend; } - protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') { + protected function getAuthMechMock($scheme = 'null', $class = \OCA\Files_External\Lib\Auth\NullMechanism::class) { $authMech = $this->getMockBuilder(AuthMechanism::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php index 370b34245c216..e163a6247d2ef 100644 --- a/apps/files_external/tests/Service/UserStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php @@ -185,7 +185,7 @@ public function testGetAdminStorage() { $newStorage = $this->globalStoragesService->addStorage($storage); - $this->assertInstanceOf('\OCA\Files_External\Lib\StorageConfig', $this->globalStoragesService->getStorage($newStorage->getId())); + $this->assertInstanceOf(\OCA\Files_External\Lib\StorageConfig::class, $this->globalStoragesService->getStorage($newStorage->getId())); $this->service->getStorage($newStorage->getId()); } diff --git a/apps/files_sharing/lib/Helper.php b/apps/files_sharing/lib/Helper.php index f2f92679e2f91..4b3714ff10f25 100644 --- a/apps/files_sharing/lib/Helper.php +++ b/apps/files_sharing/lib/Helper.php @@ -12,10 +12,10 @@ class Helper { public static function registerHooks() { - \OCP\Util::connectHook('OC_Filesystem', 'post_rename', '\OCA\Files_Sharing\Updater', 'renameHook'); - \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren'); + \OCP\Util::connectHook('OC_Filesystem', 'post_rename', \OCA\Files_Sharing\Updater::class, 'renameHook'); + \OCP\Util::connectHook('OC_Filesystem', 'post_delete', \OCA\Files_Sharing\Hooks::class, 'unshareChildren'); - \OCP\Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Files_Sharing\Hooks', 'deleteUser'); + \OCP\Util::connectHook('OC_User', 'post_deleteUser', \OCA\Files_Sharing\Hooks::class, 'deleteUser'); } /** diff --git a/apps/files_sharing/lib/Listener/LoadAdditionalListener.php b/apps/files_sharing/lib/Listener/LoadAdditionalListener.php index fc6516a83e2c9..ccd60ec6dfc82 100644 --- a/apps/files_sharing/lib/Listener/LoadAdditionalListener.php +++ b/apps/files_sharing/lib/Listener/LoadAdditionalListener.php @@ -27,7 +27,7 @@ public function handle(Event $event): void { Util::addStyle(Application::APP_ID, 'icons'); $shareManager = \OC::$server->get(IManager::class); - if ($shareManager->shareApiEnabled() && class_exists('\OCA\Files\App')) { + if ($shareManager->shareApiEnabled() && class_exists(\OCA\Files\App::class)) { Util::addInitScript(Application::APP_ID, 'init'); } } diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php index 64847bf5a5f1d..3d38e99c1cdc4 100644 --- a/apps/files_sharing/lib/MountProvider.php +++ b/apps/files_sharing/lib/MountProvider.php @@ -80,7 +80,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) { $ownerViews[$owner] = new View('/' . $parentShare->getShareOwner() . '/files'); } $mount = new SharedMount( - '\OCA\Files_Sharing\SharedStorage', + \OCA\Files_Sharing\SharedStorage::class, $mounts, [ 'user' => $user->getUID(), diff --git a/apps/files_sharing/lib/Scanner.php b/apps/files_sharing/lib/Scanner.php index 1ff1046bce778..43fd5f0babf80 100644 --- a/apps/files_sharing/lib/Scanner.php +++ b/apps/files_sharing/lib/Scanner.php @@ -42,7 +42,7 @@ private function getSourceScanner() { if ($this->sourceScanner) { return $this->sourceScanner; } - if ($this->storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { + if ($this->storage->instanceOfStorage(\OCA\Files_Sharing\SharedStorage::class)) { /** @var \OC\Files\Storage\Storage $storage */ [$storage] = $this->storage->resolvePath(''); $this->sourceScanner = $storage->getScanner(); diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php index 00f757d473440..26f50aa2e02cc 100644 --- a/apps/files_sharing/lib/SharedStorage.php +++ b/apps/files_sharing/lib/SharedStorage.php @@ -202,13 +202,13 @@ private function init() { * @inheritdoc */ public function instanceOfStorage($class): bool { - if ($class === '\OC\Files\Storage\Common' || $class == Common::class) { + if ($class === \OC\Files\Storage\Common::class || $class == Common::class) { return true; } if (in_array($class, [ - '\OC\Files\Storage\Home', - '\OC\Files\ObjectStore\HomeObjectStoreStorage', - '\OCP\Files\IHomeStorage', + \OC\Files\Storage\Home::class, + \OC\Files\ObjectStore\HomeObjectStoreStorage::class, + \OCP\Files\IHomeStorage::class, Home::class, HomeObjectStoreStorage::class, IHomeStorage::class diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index 9b95ac7877069..7ce7d2e52261c 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -1264,7 +1264,7 @@ public function testShareStorageMountPoint() { $this->shareManager->deleteShare($share); \OC_Hook::clear('OC_Filesystem', 'post_initMountPoints'); - \OC_Hook::clear('\OCA\Files_Sharing\Tests\ApiTest', 'initTestMountPointsHook'); + \OC_Hook::clear(\OCA\Files_Sharing\Tests\ApiTest::class, 'initTestMountPointsHook'); } public function datesProvider() { diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index fd1c60ff842f1..c7163c7141ce8 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -521,7 +521,7 @@ public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner public function dataGetShare() { $data = []; - $cache = $this->getMockBuilder('OC\Files\Cache\Cache') + $cache = $this->getMockBuilder(\OC\Files\Cache\Cache::class) ->disableOriginalConstructor() ->getMock(); $cache->method('getNumericStorageId')->willReturn(101); @@ -535,7 +535,7 @@ public function dataGetShare() { $parentFolder = $this->getMockBuilder(Folder::class)->getMock(); $parentFolder->method('getId')->willReturn(3); - $file = $this->getMockBuilder('OCP\Files\File')->getMock(); + $file = $this->getMockBuilder(\OCP\Files\File::class)->getMock(); $file->method('getId')->willReturn(1); $file->method('getPath')->willReturn('file'); $file->method('getStorage')->willReturn($storage); @@ -1926,8 +1926,8 @@ public function testCreateShareLinkNoLinksAllowed() { $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->willReturnMap([ - ['OCA\Files_Sharing\External\Storage', false], - ['OCA\Files_Sharing\SharedStorage', false], + [\OCA\Files_Sharing\External\Storage::class, false], + [\OCA\Files_Sharing\SharedStorage::class, false], ]); $path->method('getStorage')->willReturn($storage); $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf(); @@ -1950,8 +1950,8 @@ public function testCreateShareLinkNoPublicUpload() { $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->willReturnMap([ - ['OCA\Files_Sharing\External\Storage', false], - ['OCA\Files_Sharing\SharedStorage', false], + [\OCA\Files_Sharing\External\Storage::class, false], + [\OCA\Files_Sharing\SharedStorage::class, false], ]); $path->method('getStorage')->willReturn($storage); $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf(); @@ -1975,8 +1975,8 @@ public function testCreateShareLinkPublicUploadFile() { $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->willReturnMap([ - ['OCA\Files_Sharing\External\Storage', false], - ['OCA\Files_Sharing\SharedStorage', false], + [\OCA\Files_Sharing\External\Storage::class, false], + [\OCA\Files_Sharing\SharedStorage::class, false], ]); $path->method('getStorage')->willReturn($storage); $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf(); @@ -1999,8 +1999,8 @@ public function testCreateShareLinkPublicUploadFolder() { $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->willReturnMap([ - ['OCA\Files_Sharing\External\Storage', false], - ['OCA\Files_Sharing\SharedStorage', false], + [\OCA\Files_Sharing\External\Storage::class, false], + [\OCA\Files_Sharing\SharedStorage::class, false], ]); $path->method('getStorage')->willReturn($storage); $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf(); @@ -2038,8 +2038,8 @@ public function testCreateShareLinkPassword() { $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->willReturnMap([ - ['OCA\Files_Sharing\External\Storage', false], - ['OCA\Files_Sharing\SharedStorage', false], + [\OCA\Files_Sharing\External\Storage::class, false], + [\OCA\Files_Sharing\SharedStorage::class, false], ]); $path->method('getStorage')->willReturn($storage); $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf(); @@ -2077,8 +2077,8 @@ public function testCreateShareLinkSendPasswordByTalk() { $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->willReturnMap([ - ['OCA\Files_Sharing\External\Storage', false], - ['OCA\Files_Sharing\SharedStorage', false], + [\OCA\Files_Sharing\External\Storage::class, false], + [\OCA\Files_Sharing\SharedStorage::class, false], ]); $path->method('getStorage')->willReturn($storage); $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf(); @@ -2123,8 +2123,8 @@ public function testCreateShareLinkSendPasswordByTalkWithTalkDisabled() { $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->willReturnMap([ - ['OCA\Files_Sharing\External\Storage', false], - ['OCA\Files_Sharing\SharedStorage', false], + [\OCA\Files_Sharing\External\Storage::class, false], + [\OCA\Files_Sharing\SharedStorage::class, false], ]); $path->method('getStorage')->willReturn($storage); $path->method('getPath')->willReturn('valid-path'); @@ -2162,8 +2162,8 @@ public function testCreateShareValidExpireDate() { $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->willReturnMap([ - ['OCA\Files_Sharing\External\Storage', false], - ['OCA\Files_Sharing\SharedStorage', false], + [\OCA\Files_Sharing\External\Storage::class, false], + [\OCA\Files_Sharing\SharedStorage::class, false], ]); $path->method('getStorage')->willReturn($storage); $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf(); @@ -2208,8 +2208,8 @@ public function testCreateShareInvalidExpireDate() { $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->willReturnMap([ - ['OCA\Files_Sharing\External\Storage', false], - ['OCA\Files_Sharing\SharedStorage', false], + [\OCA\Files_Sharing\External\Storage::class, false], + [\OCA\Files_Sharing\SharedStorage::class, false], ]); $path->method('getStorage')->willReturn($storage); $this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf(); @@ -2577,8 +2577,8 @@ public function testCreateReshareOfFederatedMountNoDeletePermissions() { $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->willReturnMap([ - ['OCA\Files_Sharing\External\Storage', true], - ['OCA\Files_Sharing\SharedStorage', false], + [\OCA\Files_Sharing\External\Storage::class, true], + [\OCA\Files_Sharing\SharedStorage::class, false], ]); $userFolder->method('getStorage')->willReturn($storage); $path->method('getStorage')->willReturn($storage); @@ -3760,7 +3760,7 @@ public function dataFormatShare() { $folder->method('getMTime')->willReturn(1234567890); $fileWithPreview->method('getMTime')->willReturn(1234567890); - $cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock(); + $cache = $this->getMockBuilder(\OCP\Files\Cache\ICache::class)->getMock(); $cache->method('getNumericStorageId')->willReturn(100); $storage = $this->createMock(Storage::class); $storage->method('getId')->willReturn('storageId'); @@ -4757,7 +4757,7 @@ public function dataFormatRoomShare() { $mountPoint->method('getMountType')->willReturn(''); $file->method('getMountPoint')->willReturn($mountPoint); - $cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock(); + $cache = $this->getMockBuilder(\OCP\Files\Cache\ICache::class)->getMock(); $cache->method('getNumericStorageId')->willReturn(100); $storage = $this->createMock(Storage::class); $storage->method('getId')->willReturn('storageId'); @@ -4926,8 +4926,8 @@ private function getNonSharedUserFolder(): array { $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->willReturnMap([ - ['OCA\Files_Sharing\External\Storage', false], - ['OCA\Files_Sharing\SharedStorage', false], + [\OCA\Files_Sharing\External\Storage::class, false], + [\OCA\Files_Sharing\SharedStorage::class, false], ]); $userFolder->method('getStorage')->willReturn($storage); $node->method('getStorage')->willReturn($storage); @@ -4941,8 +4941,8 @@ private function getNonSharedUserFile(): array { $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->willReturnMap([ - ['OCA\Files_Sharing\External\Storage', false], - ['OCA\Files_Sharing\SharedStorage', false], + [\OCA\Files_Sharing\External\Storage::class, false], + [\OCA\Files_Sharing\SharedStorage::class, false], ]); $userFolder->method('getStorage')->willReturn($storage); $node->method('getStorage')->willReturn($storage); diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index 09b02be5f6668..e20646966aaab 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -624,7 +624,7 @@ public function testShowShareInvalid() { $owner->method('getDisplayName')->willReturn('ownerDisplay'); $owner->method('getUID')->willReturn('ownerUID'); - $file = $this->getMockBuilder('OCP\Files\File')->getMock(); + $file = $this->getMockBuilder(\OCP\Files\File::class)->getMock(); $file->method('getName')->willReturn($filename); $file->method('getMimetype')->willReturn('text/plain'); $file->method('getSize')->willReturn(33); diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php index f787607f5a84b..250801a2599fc 100644 --- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php @@ -350,7 +350,7 @@ public function testSearchInvalid($getData, $message) { $urlGenerator = $this->createMock(IURLGenerator::class); /** @var MockObject|ShareesAPIController $sharees */ - $sharees = $this->getMockBuilder('\OCA\Files_Sharing\Controller\ShareesAPIController') + $sharees = $this->getMockBuilder(\OCA\Files_Sharing\Controller\ShareesAPIController::class) ->setConstructorArgs([ 'files_sharing', $request, diff --git a/apps/files_sharing/tests/EncryptedSizePropagationTest.php b/apps/files_sharing/tests/EncryptedSizePropagationTest.php index af2cf379358e3..657cf9f4b4230 100644 --- a/apps/files_sharing/tests/EncryptedSizePropagationTest.php +++ b/apps/files_sharing/tests/EncryptedSizePropagationTest.php @@ -18,7 +18,7 @@ class EncryptedSizePropagationTest extends SizePropagationTest { protected function setupUser($name, $password = '') { $this->createUser($name, $password); $tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder(); - $this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]); + $this->registerMount($name, \OC\Files\Storage\Local::class, '/' . $name, ['datadir' => $tmpFolder]); $this->config->setAppValue('encryption', 'useMasterKey', '0'); $this->setupForUser($name, $password); $this->loginWithEncryption($name); diff --git a/apps/files_sharing/tests/EtagPropagationTest.php b/apps/files_sharing/tests/EtagPropagationTest.php index 3f9ddfc413dc7..a1e453dc9bed6 100644 --- a/apps/files_sharing/tests/EtagPropagationTest.php +++ b/apps/files_sharing/tests/EtagPropagationTest.php @@ -45,9 +45,9 @@ protected function setUpShares() { $view1->file_put_contents('/sub1/sub2/folder/file.txt', 'foobar'); $view1->file_put_contents('/sub1/sub2/folder/inside/file.txt', 'foobar'); $folderInfo = $view1->getFileInfo('/sub1/sub2/folder'); - $this->assertInstanceOf('\OC\Files\FileInfo', $folderInfo); + $this->assertInstanceOf(\OC\Files\FileInfo::class, $folderInfo); $fileInfo = $view1->getFileInfo('/foo.txt'); - $this->assertInstanceOf('\OC\Files\FileInfo', $fileInfo); + $this->assertInstanceOf(\OC\Files\FileInfo::class, $fileInfo); $node = $rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER1) ->get('/foo.txt'); @@ -81,7 +81,7 @@ protected function setUpShares() { $this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER3); $folderInfo = $view1->getFileInfo('/directReshare'); - $this->assertInstanceOf('\OC\Files\FileInfo', $folderInfo); + $this->assertInstanceOf(\OC\Files\FileInfo::class, $folderInfo); $node = $rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER1) ->get('/directReshare'); @@ -108,7 +108,7 @@ protected function setUpShares() { $this->loginAsUser(self::TEST_FILES_SHARING_API_USER2); $insideInfo = $view2->getFileInfo('/sub1/sub2/folder/inside'); - $this->assertInstanceOf('\OC\Files\FileInfo', $insideInfo); + $this->assertInstanceOf(\OC\Files\FileInfo::class, $insideInfo); $node = $rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER2) ->get('/sub1/sub2/folder/inside'); @@ -122,7 +122,7 @@ protected function setUpShares() { $this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER4); $folderInfo = $view2->getFileInfo('/directReshare'); - $this->assertInstanceOf('\OC\Files\FileInfo', $folderInfo); + $this->assertInstanceOf(\OC\Files\FileInfo::class, $folderInfo); $node = $rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER2) ->get('/directReshare'); @@ -260,7 +260,7 @@ public function testOwnerDeleteInReShare() { public function testOwnerUnshares() { $this->loginAsUser(self::TEST_FILES_SHARING_API_USER1); $folderInfo = $this->rootView->getFileInfo('/' . self::TEST_FILES_SHARING_API_USER1 . '/files/sub1/sub2/folder'); - $this->assertInstanceOf('\OC\Files\FileInfo', $folderInfo); + $this->assertInstanceOf(\OC\Files\FileInfo::class, $folderInfo); $node = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1)->get('/sub1/sub2/folder'); $shareManager = \OC::$server->getShareManager(); @@ -283,7 +283,7 @@ public function testOwnerUnshares() { public function testOwnerUnsharesFlatReshares() { $this->loginAsUser(self::TEST_FILES_SHARING_API_USER1); $folderInfo = $this->rootView->getFileInfo('/' . self::TEST_FILES_SHARING_API_USER1 . '/files/sub1/sub2/folder/inside'); - $this->assertInstanceOf('\OC\Files\FileInfo', $folderInfo); + $this->assertInstanceOf(\OC\Files\FileInfo::class, $folderInfo); $node = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1)->get('/sub1/sub2/folder/inside'); $shareManager = \OC::$server->getShareManager(); diff --git a/apps/files_sharing/tests/External/CacheTest.php b/apps/files_sharing/tests/External/CacheTest.php index 6259fc98e1f26..09ce05aec1da5 100644 --- a/apps/files_sharing/tests/External/CacheTest.php +++ b/apps/files_sharing/tests/External/CacheTest.php @@ -58,7 +58,7 @@ protected function setUp(): void { ); $this->remoteUser = $this->getUniqueID('remoteuser'); - $this->storage = $this->getMockBuilder('\OCA\Files_Sharing\External\Storage') + $this->storage = $this->getMockBuilder(\OCA\Files_Sharing\External\Storage::class) ->disableOriginalConstructor() ->getMock(); $this->storage diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index 0687d56745349..7add0be88e0ae 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -252,7 +252,7 @@ public function doTestAddShare($shareData1, $isGroup = false) { $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1'); if (!$isGroup) { - $client = $this->getMockBuilder('OCP\Http\Client\IClient') + $client = $this->getMockBuilder(\OCP\Http\Client\IClient::class) ->disableOriginalConstructor()->getMock(); $this->clientService->expects($this->at(0)) ->method('newClient') @@ -308,7 +308,7 @@ public function doTestAddShare($shareData1, $isGroup = false) { $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1'); if (!$isGroup) { - $client = $this->getMockBuilder('OCP\Http\Client\IClient') + $client = $this->getMockBuilder(\OCP\Http\Client\IClient::class) ->disableOriginalConstructor()->getMock(); $this->clientService->expects($this->at(0)) ->method('newClient') @@ -364,9 +364,9 @@ public function doTestAddShare($shareData1, $isGroup = false) { // no http requests here $this->manager->removeGroupShares('group1'); } else { - $client1 = $this->getMockBuilder('OCP\Http\Client\IClient') + $client1 = $this->getMockBuilder(\OCP\Http\Client\IClient::class) ->disableOriginalConstructor()->getMock(); - $client2 = $this->getMockBuilder('OCP\Http\Client\IClient') + $client2 = $this->getMockBuilder(\OCP\Http\Client\IClient::class) ->disableOriginalConstructor()->getMock(); $this->clientService->expects($this->exactly(2)) ->method('newClient') @@ -728,18 +728,18 @@ protected function assertExternalShareEntry($expected, $actual, $share, $mountPo private function assertMount($mountPoint) { $mountPoint = rtrim($mountPoint, '/'); $mount = $this->mountManager->find($this->getFullPath($mountPoint)); - $this->assertInstanceOf('\OCA\Files_Sharing\External\Mount', $mount); - $this->assertInstanceOf('\OCP\Files\Mount\IMountPoint', $mount); + $this->assertInstanceOf(\OCA\Files_Sharing\External\Mount::class, $mount); + $this->assertInstanceOf(\OCP\Files\Mount\IMountPoint::class, $mount); $this->assertEquals($this->getFullPath($mountPoint), rtrim($mount->getMountPoint(), '/')); $storage = $mount->getStorage(); - $this->assertInstanceOf('\OCA\Files_Sharing\External\Storage', $storage); + $this->assertInstanceOf(\OCA\Files_Sharing\External\Storage::class, $storage); } private function assertNotMount($mountPoint) { $mountPoint = rtrim($mountPoint, '/'); try { $mount = $this->mountManager->find($this->getFullPath($mountPoint)); - $this->assertInstanceOf('\OCP\Files\Mount\IMountPoint', $mount); + $this->assertInstanceOf(\OCP\Files\Mount\IMountPoint::class, $mount); $this->assertNotEquals($this->getFullPath($mountPoint), rtrim($mount->getMountPoint(), '/')); } catch (NotFoundException $e) { diff --git a/apps/files_sharing/tests/External/ScannerTest.php b/apps/files_sharing/tests/External/ScannerTest.php index c828fd59a08aa..0e3c8de8e2e8e 100644 --- a/apps/files_sharing/tests/External/ScannerTest.php +++ b/apps/files_sharing/tests/External/ScannerTest.php @@ -22,10 +22,10 @@ class ScannerTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->storage = $this->getMockBuilder('\OCA\Files_Sharing\External\Storage') + $this->storage = $this->getMockBuilder(\OCA\Files_Sharing\External\Storage::class) ->disableOriginalConstructor() ->getMock(); - $this->cache = $this->getMockBuilder('\OC\Files\Cache\Cache') + $this->cache = $this->getMockBuilder(\OC\Files\Cache\Cache::class) ->disableOriginalConstructor() ->getMock(); $this->storage->expects($this->any()) diff --git a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php index b5c7e1ce89026..f6be80f11671c 100644 --- a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php +++ b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php @@ -114,7 +114,7 @@ public function testAfterController(Controller $controller) { $controller->expects($this->once())->method('cleanup'); } - $response = $this->getMockBuilder('OCP\AppFramework\Http\Response') + $response = $this->getMockBuilder(\OCP\AppFramework\Http\Response::class) ->disableOriginalConstructor() ->getMock(); $this->middleware->afterController($controller, 'foo', $response); diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php index f565d2e365693..1167c3f9fd3ca 100644 --- a/apps/files_sharing/tests/MountProviderTest.php +++ b/apps/files_sharing/tests/MountProviderTest.php @@ -47,7 +47,7 @@ protected function setUp(): void { $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->user = $this->getMockBuilder(IUser::class)->getMock(); - $this->loader = $this->getMockBuilder('OCP\Files\Storage\IStorageFactory')->getMock(); + $this->loader = $this->getMockBuilder(\OCP\Files\Storage\IStorageFactory::class)->getMock(); $this->shareManager = $this->getMockBuilder(IManager::class)->getMock(); $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $eventDispatcher = $this->createMock(IEventDispatcher::class); @@ -169,10 +169,10 @@ public function testExcludeShares() { }); $mounts = $this->provider->getMountsForUser($this->user, $this->loader); $this->assertCount(4, $mounts); - $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[0]); - $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[1]); - $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[2]); - $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mounts[3]); + $this->assertInstanceOf(\OCA\Files_Sharing\SharedMount::class, $mounts[0]); + $this->assertInstanceOf(\OCA\Files_Sharing\SharedMount::class, $mounts[1]); + $this->assertInstanceOf(\OCA\Files_Sharing\SharedMount::class, $mounts[2]); + $this->assertInstanceOf(\OCA\Files_Sharing\SharedMount::class, $mounts[3]); $mountedShare1 = $mounts[0]->getShare(); $this->assertEquals('2', $mountedShare1->getId()); $this->assertEquals('user2', $mountedShare1->getShareOwner()); @@ -401,7 +401,7 @@ public function testMergeShares($userShares, $groupShares, $expectedShares, $mov foreach ($mounts as $index => $mount) { $expectedShare = $expectedShares[$index]; - $this->assertInstanceOf('OCA\Files_Sharing\SharedMount', $mount); + $this->assertInstanceOf(\OCA\Files_Sharing\SharedMount::class, $mount); // supershare $share = $mount->getShare(); diff --git a/apps/files_sharing/tests/PropagationTestCase.php b/apps/files_sharing/tests/PropagationTestCase.php index dee056f0658fd..fd463ef0c6ff1 100644 --- a/apps/files_sharing/tests/PropagationTestCase.php +++ b/apps/files_sharing/tests/PropagationTestCase.php @@ -28,7 +28,7 @@ protected function tearDown(): void { \OC_Hook::clear('OC_Filesystem', 'post_write'); \OC_Hook::clear('OC_Filesystem', 'post_delete'); \OC_Hook::clear('OC_Filesystem', 'post_rename'); - \OC_Hook::clear('OCP\Share', 'post_update_permissions'); + \OC_Hook::clear(\OCP\Share::class, 'post_update_permissions'); parent::tearDown(); } diff --git a/apps/files_sharing/tests/SharedStorageTest.php b/apps/files_sharing/tests/SharedStorageTest.php index 521167f1d88a6..12b286939aea8 100644 --- a/apps/files_sharing/tests/SharedStorageTest.php +++ b/apps/files_sharing/tests/SharedStorageTest.php @@ -420,7 +420,7 @@ public function testCopyFromStorage() { * @var \OCP\Files\Storage $sharedStorage */ [$sharedStorage,] = $view->resolvePath($this->folder); - $this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')); + $this->assertTrue($sharedStorage->instanceOfStorage(\OCA\Files_Sharing\ISharedStorage::class)); $sourceStorage = new \OC\Files\Storage\Temporary([]); $sourceStorage->file_put_contents('foo.txt', 'asd'); @@ -453,7 +453,7 @@ public function testMoveFromStorage() { * @var \OCP\Files\Storage $sharedStorage */ [$sharedStorage,] = $view->resolvePath($this->folder); - $this->assertTrue($sharedStorage->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')); + $this->assertTrue($sharedStorage->instanceOfStorage(\OCA\Files_Sharing\ISharedStorage::class)); $sourceStorage = new \OC\Files\Storage\Temporary([]); $sourceStorage->file_put_contents('foo.txt', 'asd'); @@ -508,7 +508,7 @@ public function testNameConflict() { $this->assertTrue($view2->file_exists('/foo (2)')); $mount = $view2->getMount('/foo'); - $this->assertInstanceOf('\OCA\Files_Sharing\SharedMount', $mount); + $this->assertInstanceOf(\OCA\Files_Sharing\SharedMount::class, $mount); /** @var \OCA\Files_Sharing\SharedStorage $storage */ $storage = $mount->getStorage(); diff --git a/apps/files_sharing/tests/SizePropagationTest.php b/apps/files_sharing/tests/SizePropagationTest.php index 1112cb034256f..14223d86e4068 100644 --- a/apps/files_sharing/tests/SizePropagationTest.php +++ b/apps/files_sharing/tests/SizePropagationTest.php @@ -23,7 +23,7 @@ class SizePropagationTest extends TestCase { protected function setupUser($name, $password = '') { $this->createUser($name, $password); $tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder(); - $this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]); + $this->registerMount($name, \OC\Files\Storage\Local::class, '/' . $name, ['datadir' => $tmpFolder]); $this->loginAsUser($name); return new View('/' . $name . '/files'); } diff --git a/apps/files_sharing/tests/TestCase.php b/apps/files_sharing/tests/TestCase.php index 4545e67be3219..34332d4bdaa12 100644 --- a/apps/files_sharing/tests/TestCase.php +++ b/apps/files_sharing/tests/TestCase.php @@ -65,7 +65,7 @@ public static function setUpBeforeClass(): void { \OC::$server->getGroupManager()->clearBackends(); // clear share hooks - \OC_Hook::clear('OCP\\Share'); + \OC_Hook::clear(\OCP\Share::class); \OC::registerShareHooks(\OC::$server->getSystemConfig()); // create users diff --git a/apps/files_sharing/tests/UnshareChildrenTest.php b/apps/files_sharing/tests/UnshareChildrenTest.php index 70445635e38a9..892788db3dba2 100644 --- a/apps/files_sharing/tests/UnshareChildrenTest.php +++ b/apps/files_sharing/tests/UnshareChildrenTest.php @@ -25,7 +25,7 @@ class UnshareChildrenTest extends TestCase { protected function setUp(): void { parent::setUp(); - \OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren'); + \OCP\Util::connectHook('OC_Filesystem', 'post_delete', \OCA\Files_Sharing\Hooks::class, 'unshareChildren'); $this->folder = self::TEST_FOLDER_NAME; $this->subfolder = '/subfolder_share_api_test'; diff --git a/apps/files_trashbin/lib/AppInfo/Application.php b/apps/files_trashbin/lib/AppInfo/Application.php index e1a8e02afaf77..0979910b4a3e8 100644 --- a/apps/files_trashbin/lib/AppInfo/Application.php +++ b/apps/files_trashbin/lib/AppInfo/Application.php @@ -53,13 +53,13 @@ public function boot(IBootContext $context): void { $context->injectFn([$this, 'registerTrashBackends']); // create storage wrapper on setup - \OCP\Util::connectHook('OC_Filesystem', 'preSetup', 'OCA\Files_Trashbin\Storage', 'setupStorage'); + \OCP\Util::connectHook('OC_Filesystem', 'preSetup', \OCA\Files_Trashbin\Storage::class, 'setupStorage'); //Listen to delete user signal - \OCP\Util::connectHook('OC_User', 'pre_deleteUser', 'OCA\Files_Trashbin\Hooks', 'deleteUser_hook'); + \OCP\Util::connectHook('OC_User', 'pre_deleteUser', \OCA\Files_Trashbin\Hooks::class, 'deleteUser_hook'); //Listen to post write hook - \OCP\Util::connectHook('OC_Filesystem', 'post_write', 'OCA\Files_Trashbin\Hooks', 'post_write_hook'); + \OCP\Util::connectHook('OC_Filesystem', 'post_write', \OCA\Files_Trashbin\Hooks::class, 'post_write_hook'); // pre and post-rename, disable trash logic for the copy+unlink case - \OCP\Util::connectHook('OC_Filesystem', 'delete', 'OCA\Files_Trashbin\Trashbin', 'ensureFileScannedHook'); + \OCP\Util::connectHook('OC_Filesystem', 'delete', \OCA\Files_Trashbin\Trashbin::class, 'ensureFileScannedHook'); } public function registerTrashBackends(ContainerInterface $serverContainer, LoggerInterface $logger, IAppManager $appManager, ITrashManager $trashManager): void { diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index c9863241045f6..9eaa463033190 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -328,7 +328,7 @@ public static function move2trash($file_path, $ownerOnly = false) { if (!$result) { \OC::$server->get(LoggerInterface::class)->error('trash bin database couldn\'t be updated', ['app' => 'files_trashbin']); } - \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path), + \OCP\Util::emitHook(\OCA\Files_Trashbin\Trashbin::class, 'post_moveToTrash', ['filePath' => Filesystem::normalizePath($file_path), 'trashPath' => Filesystem::normalizePath(static::getTrashFilename($filename, $timestamp))]); self::retainVersions($filename, $owner, $ownerPath, $timestamp); @@ -504,7 +504,7 @@ public static function restore($file, $filename, $timestamp) { $view->chroot('/' . $user . '/files'); $view->touch('/' . $location . '/' . $uniqueFilename, $mtime); $view->chroot($fakeRoot); - \OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => $targetPath, 'trashPath' => $sourcePath]); + \OCP\Util::emitHook(\OCA\Files_Trashbin\Trashbin::class, 'post_restore', ['filePath' => $targetPath, 'trashPath' => $sourcePath]); $sourceNode = self::getNodeForPath($sourcePath); $targetNode = self::getNodeForPath($targetPath); diff --git a/apps/files_trashbin/tests/Command/CleanUpTest.php b/apps/files_trashbin/tests/Command/CleanUpTest.php index 3ab11ba96aa7a..dd8d5b5d3c2ea 100644 --- a/apps/files_trashbin/tests/Command/CleanUpTest.php +++ b/apps/files_trashbin/tests/Command/CleanUpTest.php @@ -45,9 +45,9 @@ class CleanUpTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder') + $this->rootFolder = $this->getMockBuilder(\OCP\Files\IRootFolder::class) ->disableOriginalConstructor()->getMock(); - $this->userManager = $this->getMockBuilder('OC\User\Manager') + $this->userManager = $this->getMockBuilder(\OC\User\Manager::class) ->disableOriginalConstructor()->getMock(); $this->dbConnection = \OC::$server->getDatabaseConnection(); @@ -139,7 +139,7 @@ public function dataTestRemoveDeletedFiles() { */ public function testExecuteDeleteListOfUsers() { $userIds = ['user1', 'user2', 'user3']; - $instance = $this->getMockBuilder('OCA\Files_Trashbin\Command\CleanUp') + $instance = $this->getMockBuilder(\OCA\Files_Trashbin\Command\CleanUp::class) ->setMethods(['removeDeletedFiles']) ->setConstructorArgs([$this->rootFolder, $this->userManager, $this->dbConnection]) ->getMock(); @@ -171,7 +171,7 @@ public function testExecuteDeleteListOfUsers() { public function testExecuteAllUsers() { $userIds = []; $backendUsers = ['user1', 'user2']; - $instance = $this->getMockBuilder('OCA\Files_Trashbin\Command\CleanUp') + $instance = $this->getMockBuilder(\OCA\Files_Trashbin\Command\CleanUp::class) ->setMethods(['removeDeletedFiles']) ->setConstructorArgs([$this->rootFolder, $this->userManager, $this->dbConnection]) ->getMock(); diff --git a/apps/files_trashbin/tests/StorageTest.php b/apps/files_trashbin/tests/StorageTest.php index 76c9829cf9c6f..5e8542fd051cb 100644 --- a/apps/files_trashbin/tests/StorageTest.php +++ b/apps/files_trashbin/tests/StorageTest.php @@ -503,7 +503,7 @@ public function testSingleStorageDeleteFileFail() { /** * @var \OC\Files\Storage\Temporary | \PHPUnit\Framework\MockObject\MockObject $storage */ - $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary') + $storage = $this->getMockBuilder(\OC\Files\Storage\Temporary::class) ->setConstructorArgs([[]]) ->setMethods(['rename', 'unlink', 'moveFromStorage']) ->getMock(); @@ -540,7 +540,7 @@ public function testSingleStorageDeleteFolderFail() { /** * @var \OC\Files\Storage\Temporary | \PHPUnit\Framework\MockObject\MockObject $storage */ - $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary') + $storage = $this->getMockBuilder(\OC\Files\Storage\Temporary::class) ->setConstructorArgs([[]]) ->setMethods(['rename', 'unlink', 'rmdir']) ->getMock(); @@ -574,7 +574,7 @@ public function testShouldMoveToTrash($mountPoint, $path, $userExists, $appDisab $fileID = 1; $cache = $this->createMock(ICache::class); $cache->expects($this->any())->method('getId')->willReturn($fileID); - $tmpStorage = $this->getMockBuilder('\OC\Files\Storage\Temporary') + $tmpStorage = $this->getMockBuilder(\OC\Files\Storage\Temporary::class) ->disableOriginalConstructor()->getMock($cache); $tmpStorage->expects($this->any())->method('getCache')->willReturn($cache); $userManager = $this->getMockBuilder(IUserManager::class) diff --git a/apps/files_trashbin/tests/TrashbinTest.php b/apps/files_trashbin/tests/TrashbinTest.php index 528dd86820f69..87f4bf5567967 100644 --- a/apps/files_trashbin/tests/TrashbinTest.php +++ b/apps/files_trashbin/tests/TrashbinTest.php @@ -45,7 +45,7 @@ public static function setUpBeforeClass(): void { \OC_User::useBackend('database'); // clear share hooks - \OC_Hook::clear('OCP\\Share'); + \OC_Hook::clear(\OCP\Share::class); \OC::registerShareHooks(\OC::$server->getSystemConfig()); // init files sharing diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index 41f04b5a1d1b1..532e598115d08 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -414,7 +414,7 @@ private static function copyFileContents($view, $path1, $path2) { try { // TODO add a proper way of overwriting a file while maintaining file ids - if ($storage1->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage') || $storage2->instanceOfStorage('\OC\Files\ObjectStore\ObjectStoreStorage')) { + if ($storage1->instanceOfStorage(\OC\Files\ObjectStore\ObjectStoreStorage::class) || $storage2->instanceOfStorage(\OC\Files\ObjectStore\ObjectStoreStorage::class)) { $source = $storage1->fopen($internalPath1, 'r'); $target = $storage2->fopen($internalPath2, 'w'); [, $result] = \OC_Helper::streamCopy($source, $target); diff --git a/apps/files_versions/tests/Command/CleanupTest.php b/apps/files_versions/tests/Command/CleanupTest.php index cd397e4a0984d..de222d61257c5 100644 --- a/apps/files_versions/tests/Command/CleanupTest.php +++ b/apps/files_versions/tests/Command/CleanupTest.php @@ -38,11 +38,11 @@ class CleanupTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder') + $this->rootFolder = $this->getMockBuilder(\OCP\Files\IRootFolder::class) ->disableOriginalConstructor()->getMock(); - $this->userManager = $this->getMockBuilder('OC\User\Manager') + $this->userManager = $this->getMockBuilder(\OC\User\Manager::class) ->disableOriginalConstructor()->getMock(); - $this->versionMapper = $this->getMockBuilder('OCA\Files_Versions\Db\VersionsMapper') + $this->versionMapper = $this->getMockBuilder(\OCA\Files_Versions\Db\VersionsMapper::class) ->disableOriginalConstructor()->getMock(); $this->cleanup = new CleanUp($this->rootFolder, $this->userManager, $this->versionMapper); @@ -105,7 +105,7 @@ public function dataTestDeleteVersions() { public function testExecuteDeleteListOfUsers() { $userIds = ['user1', 'user2', 'user3']; - $instance = $this->getMockBuilder('OCA\Files_Versions\Command\CleanUp') + $instance = $this->getMockBuilder(\OCA\Files_Versions\Command\CleanUp::class) ->setMethods(['deleteVersions']) ->setConstructorArgs([$this->rootFolder, $this->userManager, $this->versionMapper]) ->getMock(); @@ -137,7 +137,7 @@ public function testExecuteAllUsers() { $userIds = []; $backendUsers = ['user1', 'user2']; - $instance = $this->getMockBuilder('OCA\Files_Versions\Command\CleanUp') + $instance = $this->getMockBuilder(\OCA\Files_Versions\Command\CleanUp::class) ->setMethods(['deleteVersions']) ->setConstructorArgs([$this->rootFolder, $this->userManager, $this->versionMapper]) ->getMock(); diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php index f0f38bcac9b3e..1b6a956ea5280 100644 --- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php +++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php @@ -84,7 +84,7 @@ protected function setUp(): void { * @return \OCP\IGroup|\PHPUnit\Framework\MockObject\MockObject */ private function createGroup($gid) { - $group = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $group = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $group ->method('getGID') ->willReturn($gid); diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index d2b0a3a4c3863..fb132bcb5462e 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -170,21 +170,21 @@ public function testGetUsersAsSubAdmin() { ->expects($this->once()) ->method('isAdmin') ->willReturn(false); - $firstGroup = $this->getMockBuilder('OCP\IGroup') + $firstGroup = $this->getMockBuilder(\OCP\IGroup::class) ->disableOriginalConstructor() ->getMock(); $firstGroup ->expects($this->once()) ->method('getGID') ->willReturn('FirstGroup'); - $secondGroup = $this->getMockBuilder('OCP\IGroup') + $secondGroup = $this->getMockBuilder(\OCP\IGroup::class) ->disableOriginalConstructor() ->getMock(); $secondGroup ->expects($this->once()) ->method('getGID') ->willReturn('SecondGroup'); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -649,7 +649,7 @@ public function testAddUserExistingGroup() { ->method('createUser') ->with('NewUser', 'PasswordOfTheNewUser') ->willReturn($user); - $group = $this->getMockBuilder('OCP\IGroup') + $group = $this->getMockBuilder(\OCP\IGroup::class) ->disableOriginalConstructor() ->getMock(); $group @@ -744,7 +744,7 @@ public function testAddUserAsSubAdminNoGroup() { ->method('isAdmin') ->with('regularUser') ->willReturn(false); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $this->groupManager ->expects($this->once()) @@ -777,13 +777,13 @@ public function testAddUserAsSubAdminValidGroupNotSubAdmin() { ->method('isAdmin') ->with('regularUser') ->willReturn(false); - $existingGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $existingGroup = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $this->groupManager ->expects($this->once()) ->method('get') ->with('ExistingGroup') ->willReturn($existingGroup); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -842,10 +842,10 @@ public function testAddUserAsSubAdminExistingGroups() { ->method('createUser') ->with('NewUser', 'PasswordOfTheNewUser') ->willReturn($user); - $existingGroup1 = $this->getMockBuilder('OCP\IGroup') + $existingGroup1 = $this->getMockBuilder(\OCP\IGroup::class) ->disableOriginalConstructor() ->getMock(); - $existingGroup2 = $this->getMockBuilder('OCP\IGroup') + $existingGroup2 = $this->getMockBuilder(\OCP\IGroup::class) ->disableOriginalConstructor() ->getMock(); $existingGroup1 @@ -877,7 +877,7 @@ public function testAddUserAsSubAdminExistingGroups() { ['Added userid NewUser to group ExistingGroup1', ['app' => 'ocs_api']], ['Added userid NewUser to group ExistingGroup2', ['app' => 'ocs_api']] ); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $this->groupManager ->expects($this->once()) @@ -927,7 +927,7 @@ public function testGetUserDataAsAdmin() { $loggedInUser = $this->getMockBuilder(IUser::class) ->disableOriginalConstructor() ->getMock(); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $loggedInUser @@ -1105,7 +1105,7 @@ public function testGetUserDataAsSubAdminAndUserIsAccessible() { ->expects($this->any()) ->method('getUserGroups') ->willReturn([]); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subAdminManager @@ -1242,7 +1242,7 @@ public function testGetUserDataAsSubAdminAndUserIsNotAccessible() { ->method('isAdmin') ->with('subadmin') ->willReturn(false); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subAdminManager @@ -1283,7 +1283,7 @@ public function testGetUserDataAsSubAdminSelfLookup() { ->method('isAdmin') ->with('UID') ->willReturn(false); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subAdminManager @@ -2070,7 +2070,7 @@ public function testEditUserAdminUserEditChangeValidQuota() { ->method('isAdmin') ->with('admin') ->willReturn(true); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $this->groupManager @@ -2322,7 +2322,7 @@ public function testEditUserSubadminUserAccessible() { ->method('get') ->with('UserToEdit') ->willReturn($targetUser); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subAdminManager @@ -2368,7 +2368,7 @@ public function testEditUserSubadminUserInaccessible() { ->method('get') ->with('UserToEdit') ->willReturn($targetUser); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subAdminManager @@ -2534,7 +2534,7 @@ public function testDeleteSuccessfulUserAsSubadmin() { ->method('isAdmin') ->with('subadmin') ->willReturn(false); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -2582,7 +2582,7 @@ public function testDeleteUnsuccessfulUserAsSubadmin() { ->method('isAdmin') ->with('subadmin') ->willReturn(false); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -2630,7 +2630,7 @@ public function testDeleteUserAsSubAdminAndUserIsNotAccessible() { ->method('isAdmin') ->with('subadmin') ->willReturn(false); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -2747,7 +2747,7 @@ public function testGetUsersGroupsForSubAdminUserAndUserIsAccessible() { ->method('isAdmin') ->with('subadmin') ->willReturn(false); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -2758,12 +2758,12 @@ public function testGetUsersGroupsForSubAdminUserAndUserIsAccessible() { ->expects($this->once()) ->method('getSubAdmin') ->willReturn($subAdminManager); - $group1 = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $group1 = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $group1 ->expects($this->any()) ->method('getGID') ->willReturn('Group1'); - $group2 = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $group2 = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $group2 ->expects($this->any()) ->method('getGID') @@ -2811,7 +2811,7 @@ public function testGetUsersGroupsForSubAdminUserAndUserIsInaccessible() { ->method('isAdmin') ->with('subadmin') ->willReturn(false); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -3053,7 +3053,7 @@ public function testRemoveFromGroupWithNotExistingTargetUser() { $this->expectExceptionCode(103); $loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); - $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $targetGroup = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) ->method('getUser') @@ -3083,7 +3083,7 @@ public function testRemoveFromGroupWithoutPermission() { ->method('getUID') ->willReturn('unauthorizedUser'); $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); - $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $targetGroup = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) ->method('getUser') @@ -3098,7 +3098,7 @@ public function testRemoveFromGroupWithoutPermission() { ->method('get') ->with('TargetUser') ->willReturn($targetUser); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $this->groupManager ->expects($this->once()) @@ -3129,7 +3129,7 @@ public function testRemoveFromGroupAsAdminFromAdmin() { ->expects($this->once()) ->method('getUID') ->willReturn('admin'); - $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $targetGroup = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $targetGroup ->expects($this->once()) ->method('getGID') @@ -3148,7 +3148,7 @@ public function testRemoveFromGroupAsAdminFromAdmin() { ->method('get') ->with('Admin') ->willReturn($targetUser); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $this->groupManager ->expects($this->once()) @@ -3179,7 +3179,7 @@ public function testRemoveFromGroupAsSubAdminFromSubAdmin() { ->expects($this->once()) ->method('getUID') ->willReturn('subadmin'); - $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $targetGroup = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $targetGroup ->expects($this->any()) ->method('getGID') @@ -3198,7 +3198,7 @@ public function testRemoveFromGroupAsSubAdminFromSubAdmin() { ->method('get') ->with('SubAdmin') ->willReturn($targetUser); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -3230,7 +3230,7 @@ public function testRemoveFromGroupAsSubAdminFromLastSubAdminGroup() { ->method('getUID') ->willReturn('subadmin'); $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); - $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $targetGroup = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $targetGroup ->expects($this->any()) ->method('getGID') @@ -3249,7 +3249,7 @@ public function testRemoveFromGroupAsSubAdminFromLastSubAdminGroup() { ->method('get') ->with('AnotherUser') ->willReturn($targetUser); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -3287,7 +3287,7 @@ public function testRemoveFromGroupSuccessful() { ->method('getUID') ->willReturn('admin'); $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); - $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $targetGroup = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $this->userSession ->expects($this->once()) ->method('getUser') @@ -3302,7 +3302,7 @@ public function testRemoveFromGroupSuccessful() { ->method('get') ->with('AnotherUser') ->willReturn($targetUser); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $this->groupManager ->expects($this->once()) @@ -3365,7 +3365,7 @@ public function testAddSubAdminToAdminGroup() { $this->expectExceptionCode(103); $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); - $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $targetGroup = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $targetGroup ->expects($this->once()) ->method('getGID') @@ -3386,7 +3386,7 @@ public function testAddSubAdminToAdminGroup() { public function testAddSubAdminTwice() { $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); - $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $targetGroup = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $this->userManager ->expects($this->once()) ->method('get') @@ -3397,7 +3397,7 @@ public function testAddSubAdminTwice() { ->method('get') ->with('TargetGroup') ->willReturn($targetGroup); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -3414,7 +3414,7 @@ public function testAddSubAdminTwice() { public function testAddSubAdminSuccessful() { $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); - $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $targetGroup = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $this->userManager ->expects($this->once()) ->method('get') @@ -3425,7 +3425,7 @@ public function testAddSubAdminSuccessful() { ->method('get') ->with('TargetGroup') ->willReturn($targetGroup); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -3488,7 +3488,7 @@ public function testRemoveSubAdminFromNotASubadmin() { $this->expectExceptionCode(102); $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); - $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $targetGroup = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $this->userManager ->expects($this->once()) ->method('get') @@ -3499,7 +3499,7 @@ public function testRemoveSubAdminFromNotASubadmin() { ->method('get') ->with('GroupToDeleteFrom') ->willReturn($targetGroup); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -3516,7 +3516,7 @@ public function testRemoveSubAdminFromNotASubadmin() { public function testRemoveSubAdminSuccessful() { $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); - $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $targetGroup = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $this->userManager ->expects($this->once()) ->method('get') @@ -3527,7 +3527,7 @@ public function testRemoveSubAdminSuccessful() { ->method('get') ->with('GroupToDeleteFrom') ->willReturn($targetGroup); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -3563,7 +3563,7 @@ public function testGetUserSubAdminGroupsNotExistingTargetUser() { public function testGetUserSubAdminGroupsWithGroups() { $targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock(); - $targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock(); + $targetGroup = $this->getMockBuilder(\OCP\IGroup::class)->disableOriginalConstructor()->getMock(); $targetGroup ->expects($this->once()) ->method('getGID') @@ -3573,7 +3573,7 @@ public function testGetUserSubAdminGroupsWithGroups() { ->method('get') ->with('RequestedUser') ->willReturn($targetUser); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor()->getMock(); $subAdminManager ->expects($this->once()) @@ -3834,7 +3834,7 @@ public function testResendWelcomeMessageAsSubAdminAndUserIsNotAccessible() { ->method('isAdmin') ->with('subadmin') ->willReturn(false); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subAdminManager @@ -3871,7 +3871,7 @@ public function testResendWelcomeMessageNoEmail() { ->method('get') ->with('UserToGet') ->willReturn($targetUser); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subAdminManager @@ -3916,7 +3916,7 @@ public function testResendWelcomeMessageNullEmail() { ->method('get') ->with('UserToGet') ->willReturn($targetUser); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subAdminManager @@ -3962,7 +3962,7 @@ public function testResendWelcomeMessageSuccess() { ->method('get') ->with('UserToGet') ->willReturn($targetUser); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subAdminManager @@ -4013,7 +4013,7 @@ public function testResendWelcomeMessageSuccessWithFallbackLanguage() { ->method('get') ->with('UserToGet') ->willReturn($targetUser); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subAdminManager @@ -4070,7 +4070,7 @@ public function testResendWelcomeMessageFailed() { ->method('get') ->with('UserToGet') ->willReturn($targetUser); - $subAdminManager = $this->getMockBuilder('OC\SubAdmin') + $subAdminManager = $this->getMockBuilder(\OC\SubAdmin::class) ->disableOriginalConstructor() ->getMock(); $subAdminManager diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index 4ee359b6fe9b6..07c5e828d1ac1 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -108,7 +108,7 @@ public function usersList(): TemplateResponse { } else { if ($this->appManager->isEnabledForUser('user_ldap')) { $isLDAPUsed = - $this->groupManager->isBackendUsed('\OCA\User_LDAP\Group_Proxy'); + $this->groupManager->isBackendUsed(\OCA\User_LDAP\Group_Proxy::class); if ($isLDAPUsed) { // LDAP user count can be slow, so we sort by group name here $sortGroupsBy = \OC\Group\MetaData::SORT_GROUPNAME; diff --git a/apps/settings/lib/SetupChecks/TempSpaceAvailable.php b/apps/settings/lib/SetupChecks/TempSpaceAvailable.php index ef51ffe0e07a1..f33706df717be 100644 --- a/apps/settings/lib/SetupChecks/TempSpaceAvailable.php +++ b/apps/settings/lib/SetupChecks/TempSpaceAvailable.php @@ -40,11 +40,11 @@ private function isPrimaryStorageS3(): bool { return false; } - if (isset($objectStoreMultibucket['class']) && $objectStoreMultibucket['class'] !== 'OC\\Files\\ObjectStore\\S3') { + if (isset($objectStoreMultibucket['class']) && $objectStoreMultibucket['class'] !== \OC\Files\ObjectStore\S3::class) { return false; } - if (isset($objectStore['class']) && $objectStore['class'] !== 'OC\\Files\\ObjectStore\\S3') { + if (isset($objectStore['class']) && $objectStore['class'] !== \OC\Files\ObjectStore\S3::class) { return false; } diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index fde13cfee31c6..77ca9f257f779 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -62,7 +62,7 @@ protected function setUp(): void { ->willReturnCallback(function ($message, array $replace) { return vsprintf($message, $replace); }); - $this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker') + $this->checker = $this->getMockBuilder(\OC\IntegrityCheck\Checker::class) ->disableOriginalConstructor()->getMock(); $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $this->setupCheckManager = $this->createMock(ISetupCheckManager::class); @@ -195,7 +195,7 @@ public function testGetFailedIntegrityCheckFilesWithSomeErrorsFound() { $this->checker ->expects($this->once()) ->method('getResults') - ->willReturn([ 'core' => [ 'EXTRA_FILE' => ['/testfile' => []], 'INVALID_HASH' => [ '/.idea/workspace.xml' => [ 'expected' => 'f1c5e2630d784bc9cb02d5a28f55d6f24d06dae2a0fee685f3c2521b050955d9d452769f61454c9ddfa9c308146ade10546cfa829794448eaffbc9a04a29d216', 'current' => 'ce08bf30bcbb879a18b49239a9bec6b8702f52452f88a9d32142cad8d2494d5735e6bfa0d8642b2762c62ca5be49f9bf4ec231d4a230559d4f3e2c471d3ea094', ], '/lib/private/integritycheck/checker.php' => [ 'expected' => 'c5a03bacae8dedf8b239997901ba1fffd2fe51271d13a00cc4b34b09cca5176397a89fc27381cbb1f72855fa18b69b6f87d7d5685c3b45aee373b09be54742ea', 'current' => '88a3a92c11db91dec1ac3be0e1c87f862c95ba6ffaaaa3f2c3b8f682187c66f07af3a3b557a868342ef4a271218fe1c1e300c478e6c156c5955ed53c40d06585', ], '/settings/controller/checksetupcontroller.php' => [ 'expected' => '3e1de26ce93c7bfe0ede7c19cb6c93cadc010340225b375607a7178812e9de163179b0dc33809f451e01f491d93f6f5aaca7929685d21594cccf8bda732327c4', 'current' => '09563164f9904a837f9ca0b5f626db56c838e5098e0ccc1d8b935f68fa03a25c5ec6f6b2d9e44a868e8b85764dafd1605522b4af8db0ae269d73432e9a01e63a', ], ], ], 'bookmarks' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'dav' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'encryption' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'external' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'federation' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_antivirus' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_drop' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_external' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_pdfviewer' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_sharing' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_trashbin' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_versions' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'files_videoviewer' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'firstrunwizard' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'gitsmart' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'logreader' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature could not get verified.', ], ], 'password_policy' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'provisioning_api' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'sketch' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'threatblock' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'two_factor_auth' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'user_ldap' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], 'user_shibboleth' => [ 'EXCEPTION' => [ 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', 'message' => 'Signature data not found.', ], ], ]); + ->willReturn([ 'core' => [ 'EXTRA_FILE' => ['/testfile' => []], 'INVALID_HASH' => [ '/.idea/workspace.xml' => [ 'expected' => 'f1c5e2630d784bc9cb02d5a28f55d6f24d06dae2a0fee685f3c2521b050955d9d452769f61454c9ddfa9c308146ade10546cfa829794448eaffbc9a04a29d216', 'current' => 'ce08bf30bcbb879a18b49239a9bec6b8702f52452f88a9d32142cad8d2494d5735e6bfa0d8642b2762c62ca5be49f9bf4ec231d4a230559d4f3e2c471d3ea094', ], '/lib/private/integritycheck/checker.php' => [ 'expected' => 'c5a03bacae8dedf8b239997901ba1fffd2fe51271d13a00cc4b34b09cca5176397a89fc27381cbb1f72855fa18b69b6f87d7d5685c3b45aee373b09be54742ea', 'current' => '88a3a92c11db91dec1ac3be0e1c87f862c95ba6ffaaaa3f2c3b8f682187c66f07af3a3b557a868342ef4a271218fe1c1e300c478e6c156c5955ed53c40d06585', ], '/settings/controller/checksetupcontroller.php' => [ 'expected' => '3e1de26ce93c7bfe0ede7c19cb6c93cadc010340225b375607a7178812e9de163179b0dc33809f451e01f491d93f6f5aaca7929685d21594cccf8bda732327c4', 'current' => '09563164f9904a837f9ca0b5f626db56c838e5098e0ccc1d8b935f68fa03a25c5ec6f6b2d9e44a868e8b85764dafd1605522b4af8db0ae269d73432e9a01e63a', ], ], ], 'bookmarks' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'dav' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'encryption' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'external' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'federation' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'files' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'files_antivirus' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'files_drop' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'files_external' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'files_pdfviewer' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'files_sharing' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'files_trashbin' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'files_versions' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'files_videoviewer' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'firstrunwizard' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'gitsmart' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'logreader' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature could not get verified.', ], ], 'password_policy' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'provisioning_api' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'sketch' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'threatblock' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'two_factor_auth' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'user_ldap' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], 'user_shibboleth' => [ 'EXCEPTION' => [ 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ], ]); $expected = new DataDisplayResponse( 'Technical information diff --git a/apps/settings/tests/Controller/UsersControllerTest.php b/apps/settings/tests/Controller/UsersControllerTest.php index e1407cb1b55bc..93dfd4c4cd692 100644 --- a/apps/settings/tests/Controller/UsersControllerTest.php +++ b/apps/settings/tests/Controller/UsersControllerTest.php @@ -867,7 +867,7 @@ public function testGetVerificationCode($account, $type, $dataBefore, $expectedD if ($onlyVerificationCode === false) { $this->accountManager->expects($this->once())->method('updateAccount')->with($userAccount)->willReturnArgument(1); $this->jobList->expects($this->once())->method('add') - ->with('OCA\Settings\BackgroundJobs\VerifyUserData', + ->with(\OCA\Settings\BackgroundJobs\VerifyUserData::class, [ 'verificationCode' => $code, 'data' => $dataBefore[$type]['value'], diff --git a/apps/settings/tests/Mailer/NewUserMailHelperTest.php b/apps/settings/tests/Mailer/NewUserMailHelperTest.php index 2f9f7bcba7b7c..f3e21c1d4016c 100644 --- a/apps/settings/tests/Mailer/NewUserMailHelperTest.php +++ b/apps/settings/tests/Mailer/NewUserMailHelperTest.php @@ -354,7 +354,7 @@ public function testGenerateTemplateWithPasswordResetToken() { $result = $this->newUserMailHelper->generateTemplate($user, true); $this->assertEquals($expectedHtmlBody, $result->renderHtml()); $this->assertEquals($expectedTextBody, $result->renderText()); - $this->assertSame('OC\Mail\EMailTemplate', get_class($result)); + $this->assertSame(\OC\Mail\EMailTemplate::class, get_class($result)); } public function testGenerateTemplateWithoutPasswordResetToken() { @@ -590,7 +590,7 @@ public function testGenerateTemplateWithoutPasswordResetToken() { $result = $this->newUserMailHelper->generateTemplate($user, false); $this->assertEquals($expectedHtmlBody, $result->renderHtml()); $this->assertEquals($expectedTextBody, $result->renderText()); - $this->assertSame('OC\Mail\EMailTemplate', get_class($result)); + $this->assertSame(\OC\Mail\EMailTemplate::class, get_class($result)); } public function testGenerateTemplateWithoutUserId() { @@ -813,7 +813,7 @@ public function testGenerateTemplateWithoutUserId() { $result = $this->newUserMailHelper->generateTemplate($user, false); $this->assertEquals($expectedHtmlBody, $result->renderHtml()); $this->assertEquals($expectedTextBody, $result->renderText()); - $this->assertSame('OC\Mail\EMailTemplate', get_class($result)); + $this->assertSame(\OC\Mail\EMailTemplate::class, get_class($result)); } public function testSendMail() { diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index cad8dc49e34fa..e7fb3fa0abf20 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -73,13 +73,13 @@ protected function setUp(): void { }); $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); - $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock(); + $this->rootFolder = $this->getMockBuilder(\OCP\Files\IRootFolder::class)->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->secureRandom = $this->getMockBuilder(\OCP\Security\ISecureRandom::class)->getMock(); + $this->mailer = $this->getMockBuilder(\OCP\Mail\IMailer::class)->getMock(); $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock(); $this->share = $this->getMockBuilder(IShare::class)->getMock(); - $this->activityManager = $this->getMockBuilder('OCP\Activity\IManager')->getMock(); + $this->activityManager = $this->getMockBuilder(\OCP\Activity\IManager::class)->getMock(); $this->settingsManager = $this->getMockBuilder(SettingsManager::class)->disableOriginalConstructor()->getMock(); $this->defaults = $this->createMock(Defaults::class); $this->hasher = $this->getMockBuilder(IHasher::class)->getMock(); @@ -98,7 +98,7 @@ protected function setUp(): void { */ private function getInstance(array $mockedMethods = []) { if (!empty($mockedMethods)) { - return $this->getMockBuilder('OCA\ShareByMail\ShareByMailProvider') + return $this->getMockBuilder(\OCA\ShareByMail\ShareByMailProvider::class) ->setConstructorArgs([ $this->config, $this->connection, @@ -621,7 +621,7 @@ public function testCreateFailed() { $this->expectException(\Exception::class); $this->share->expects($this->once())->method('getSharedWith')->willReturn('user1'); - $node = $this->getMockBuilder('OCP\Files\Node')->getMock(); + $node = $this->getMockBuilder(\OCP\Files\Node::class)->getMock(); $node->expects($this->any())->method('getName')->willReturn('fileName'); $this->share->expects($this->any())->method('getNode')->willReturn($node); @@ -645,7 +645,7 @@ public function testCreateMailShare() { $this->share->expects($this->any())->method('getNote')->willReturn('Check this!'); $this->share->expects($this->any())->method('getMailSend')->willReturn(true); - $node = $this->getMockBuilder('OCP\Files\Node')->getMock(); + $node = $this->getMockBuilder(\OCP\Files\Node::class)->getMock(); $node->expects($this->any())->method('getName')->willReturn('fileName'); $this->share->expects($this->any())->method('getNode')->willReturn($node); @@ -878,7 +878,7 @@ function ($data) use ($uidOwner, $sharedBy, $id2) { $result = $instance->getShareById($id2); - $this->assertInstanceOf('OCP\Share\IShare', $result); + $this->assertInstanceOf(\OCP\Share\IShare::class, $result); } @@ -932,7 +932,7 @@ function ($data) use ($uidOwner, $sharedBy, $id) { $this->assertTrue(is_array($result)); $this->assertSame(1, count($result)); - $this->assertInstanceOf('OCP\Share\IShare', $result[0]); + $this->assertInstanceOf(\OCP\Share\IShare::class, $result[0]); } public function testGetShareByToken() { @@ -961,7 +961,7 @@ function ($data) use ($idMail) { $result = $instance->getShareByToken('token'); - $this->assertInstanceOf('OCP\Share\IShare', $result); + $this->assertInstanceOf(\OCP\Share\IShare::class, $result); } @@ -984,7 +984,7 @@ public function testGetShareByTokenFailed() { $this->assertTrue($idMail !== $idPublic); - $this->assertInstanceOf('OCP\Share\IShare', + $this->assertInstanceOf(\OCP\Share\IShare::class, $instance->getShareByToken('token2') ); } diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php index e0159c03082df..4fef05c7f230d 100644 --- a/apps/theming/tests/Controller/IconControllerTest.php +++ b/apps/theming/tests/Controller/IconControllerTest.php @@ -70,7 +70,7 @@ protected function setUp(): void { } private function iconFileMock($filename, $data) { - $icon = $this->getMockBuilder('OCP\Files\File')->getMock(); + $icon = $this->getMockBuilder(\OCP\Files\File::class)->getMock(); $icon->expects($this->any())->method('getContent')->willReturn($data); $icon->expects($this->any())->method('getMimeType')->willReturn('image type'); $icon->expects($this->any())->method('getEtag')->willReturn('my etag'); diff --git a/apps/user_ldap/lib/AppInfo/Application.php b/apps/user_ldap/lib/AppInfo/Application.php index 400315442bb93..1ed82c02c2b7f 100644 --- a/apps/user_ldap/lib/AppInfo/Application.php +++ b/apps/user_ldap/lib/AppInfo/Application.php @@ -132,7 +132,7 @@ public function boot(IBootContext $context): void { \OCP\Util::connectHook( '\OCA\Files_Sharing\API\Server2Server', 'preLoginNameUsedAsUserName', - '\OCA\User_LDAP\Helper', + \OCA\User_LDAP\Helper::class, 'loginName2UserName' ); } diff --git a/apps/user_ldap/tests/ConnectionTest.php b/apps/user_ldap/tests/ConnectionTest.php index dfa3cf6bedadb..9d8202ad1556d 100644 --- a/apps/user_ldap/tests/ConnectionTest.php +++ b/apps/user_ldap/tests/ConnectionTest.php @@ -29,7 +29,7 @@ protected function setUp(): void { $this->ldap = $this->createMock(ILDAPWrapper::class); // we use a mock here to replace the cache mechanism, due to missing DI in LDAP backend. - $this->connection = $this->getMockBuilder('OCA\User_LDAP\Connection') + $this->connection = $this->getMockBuilder(\OCA\User_LDAP\Connection::class) ->setMethods(['getFromCache', 'writeToCache']) ->setConstructorArgs([$this->ldap, '', null]) ->getMock(); diff --git a/apps/user_ldap/tests/GroupLDAPPluginTest.php b/apps/user_ldap/tests/GroupLDAPPluginTest.php index 24cfb5d51e9c6..62c7729844975 100644 --- a/apps/user_ldap/tests/GroupLDAPPluginTest.php +++ b/apps/user_ldap/tests/GroupLDAPPluginTest.php @@ -20,7 +20,7 @@ private function getGroupPluginManager() { public function testImplementsActions() { $pluginManager = $this->getGroupPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPGroupPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPGroupPluginDummy::class) ->setMethods(['respondToActions']) ->getMock(); @@ -28,7 +28,7 @@ public function testImplementsActions() { ->method('respondToActions') ->willReturn(GroupInterface::CREATE_GROUP); - $plugin2 = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPGroupPluginDummy') + $plugin2 = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPGroupPluginDummy::class) ->setMethods(['respondToActions']) ->getMock(); @@ -47,7 +47,7 @@ public function testImplementsActions() { public function testCreateGroup() { $pluginManager = $this->getGroupPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPGroupPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPGroupPluginDummy::class) ->setMethods(['respondToActions', 'createGroup']) ->getMock(); @@ -77,7 +77,7 @@ public function testCreateGroupNotRegistered() { public function testDeleteGroup() { $pluginManager = $this->getGroupPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPGroupPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPGroupPluginDummy::class) ->setMethods(['respondToActions', 'deleteGroup']) ->getMock(); @@ -107,7 +107,7 @@ public function testDeleteGroupNotRegistered() { public function testAddToGroup() { $pluginManager = $this->getGroupPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPGroupPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPGroupPluginDummy::class) ->setMethods(['respondToActions', 'addToGroup']) ->getMock(); @@ -138,7 +138,7 @@ public function testAddToGroupNotRegistered() { public function testRemoveFromGroup() { $pluginManager = $this->getGroupPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPGroupPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPGroupPluginDummy::class) ->setMethods(['respondToActions', 'removeFromGroup']) ->getMock(); @@ -169,7 +169,7 @@ public function testRemoveFromGroupNotRegistered() { public function testCountUsersInGroup() { $pluginManager = $this->getGroupPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPGroupPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPGroupPluginDummy::class) ->setMethods(['respondToActions', 'countUsersInGroup']) ->getMock(); @@ -200,7 +200,7 @@ public function testCountUsersInGroupNotRegistered() { public function testgetGroupDetails() { $pluginManager = $this->getGroupPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPGroupPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPGroupPluginDummy::class) ->setMethods(['respondToActions', 'getGroupDetails']) ->getMock(); diff --git a/apps/user_ldap/tests/LDAPProviderTest.php b/apps/user_ldap/tests/LDAPProviderTest.php index d240b6d65c5b7..1688c2a960fbe 100644 --- a/apps/user_ldap/tests/LDAPProviderTest.php +++ b/apps/user_ldap/tests/LDAPProviderTest.php @@ -30,7 +30,7 @@ protected function setUp(): void { } private function getServerMock(IUserLDAP $userBackend, IGroupLDAP $groupBackend) { - $server = $this->getMockBuilder('OC\Server') + $server = $this->getMockBuilder(\OC\Server::class) ->setMethods(['getUserManager', 'getBackends', 'getGroupManager']) ->setConstructorArgs(['', new \OC\Config(\OC::$configDir)]) ->getMock(); @@ -63,7 +63,7 @@ private function getUserManagerMock(IUserLDAP $userBackend) { } private function getGroupManagerMock(IGroupLDAP $groupBackend) { - $groupManager = $this->getMockBuilder('OC\Group\Manager') + $groupManager = $this->getMockBuilder(\OC\Group\Manager::class) ->setMethods(['getBackends']) ->disableOriginalConstructor() ->getMock(); @@ -74,7 +74,7 @@ private function getGroupManagerMock(IGroupLDAP $groupBackend) { } private function getDefaultGroupBackendMock() { - $groupBackend = $this->getMockBuilder('OCA\User_LDAP\Group_LDAP') + $groupBackend = $this->getMockBuilder(\OCA\User_LDAP\Group_LDAP::class) ->disableOriginalConstructor() ->getMock(); @@ -91,7 +91,7 @@ public function testGetUserDNUserIDNotFound() { $this->expectException(\Exception::class); $this->expectExceptionMessage('User id not found in LDAP'); - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists']) ->disableOriginalConstructor() ->getMock(); @@ -104,7 +104,7 @@ public function testGetUserDNUserIDNotFound() { } public function testGetUserDN() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists', 'getLDAPAccess', 'username2dn']) ->disableOriginalConstructor() ->getMock(); @@ -130,11 +130,11 @@ public function testGetGroupDNGroupIDNotFound() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Group id not found in LDAP'); - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->disableOriginalConstructor() ->getMock(); - $groupBackend = $this->getMockBuilder('OCA\User_LDAP\Group_LDAP') + $groupBackend = $this->getMockBuilder(\OCA\User_LDAP\Group_LDAP::class) ->setMethods(['groupExists']) ->disableOriginalConstructor() ->getMock(); @@ -148,12 +148,12 @@ public function testGetGroupDNGroupIDNotFound() { } public function testGetGroupDN() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists', 'getLDAPAccess', 'username2dn']) ->disableOriginalConstructor() ->getMock(); - $groupBackend = $this->getMockBuilder('OCA\User_LDAP\Group_LDAP') + $groupBackend = $this->getMockBuilder(\OCA\User_LDAP\Group_LDAP::class) ->setMethods(['groupExists', 'getLDAPAccess', 'groupname2dn']) ->disableOriginalConstructor() ->getMock(); @@ -176,7 +176,7 @@ public function testGetGroupDN() { } public function testGetUserName() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['dn2UserName']) ->disableOriginalConstructor() ->getMock(); @@ -192,7 +192,7 @@ public function testGetUserName() { } public function testDNasBaseParameter() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods([]) ->disableOriginalConstructor() ->getMock(); @@ -208,7 +208,7 @@ public function testDNasBaseParameter() { } public function testSanitizeDN() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods([]) ->disableOriginalConstructor() ->getMock(); @@ -228,7 +228,7 @@ public function testGetLDAPConnectionUserIDNotFound() { $this->expectException(\Exception::class); $this->expectExceptionMessage('User id not found in LDAP'); - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists']) ->disableOriginalConstructor() ->getMock(); @@ -241,7 +241,7 @@ public function testGetLDAPConnectionUserIDNotFound() { } public function testGetLDAPConnection() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists', 'getNewLDAPConnection']) ->disableOriginalConstructor() ->getMock(); @@ -264,11 +264,11 @@ public function testGetGroupLDAPConnectionGroupIDNotFound() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Group id not found in LDAP'); - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->disableOriginalConstructor() ->getMock(); - $groupBackend = $this->getMockBuilder('OCA\User_LDAP\Group_LDAP') + $groupBackend = $this->getMockBuilder(\OCA\User_LDAP\Group_LDAP::class) ->setMethods(['groupExists']) ->disableOriginalConstructor() ->getMock(); @@ -282,11 +282,11 @@ public function testGetGroupLDAPConnectionGroupIDNotFound() { } public function testGetGroupLDAPConnection() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->disableOriginalConstructor() ->getMock(); - $groupBackend = $this->getMockBuilder('OCA\User_LDAP\Group_LDAP') + $groupBackend = $this->getMockBuilder(\OCA\User_LDAP\Group_LDAP::class) ->setMethods(['groupExists','getNewLDAPConnection']) ->disableOriginalConstructor() ->getMock(); @@ -311,7 +311,7 @@ public function testGetLDAPBaseUsersUserIDNotFound() { $this->expectException(\Exception::class); $this->expectExceptionMessage('User id not found in LDAP'); - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists']) ->disableOriginalConstructor() ->getMock(); @@ -352,7 +352,7 @@ public function testGetLDAPBaseUsers() { ->method('username2dn') ->willReturn($dn); - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists', 'getLDAPAccess', 'getConnection', 'getConfiguration']) ->disableOriginalConstructor() ->getMock(); @@ -374,7 +374,7 @@ public function testGetLDAPBaseGroupsUserIDNotFound() { $this->expectException(\Exception::class); $this->expectExceptionMessage('User id not found in LDAP'); - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists']) ->disableOriginalConstructor() ->getMock(); @@ -408,7 +408,7 @@ public function testGetLDAPBaseGroups() { ->method('getConnection') ->willReturn($connection); - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists', 'getLDAPAccess', 'getConnection', 'getConfiguration']) ->disableOriginalConstructor() ->getMock(); @@ -430,7 +430,7 @@ public function testClearCacheUserIDNotFound() { $this->expectException(\Exception::class); $this->expectExceptionMessage('User id not found in LDAP'); - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists']) ->disableOriginalConstructor() ->getMock(); @@ -443,7 +443,7 @@ public function testClearCacheUserIDNotFound() { } public function testClearCache() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists', 'getLDAPAccess', 'getConnection', 'clearCache']) ->disableOriginalConstructor() ->getMock(); @@ -469,10 +469,10 @@ public function testClearGroupCacheGroupIDNotFound() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Group id not found in LDAP'); - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->disableOriginalConstructor() ->getMock(); - $groupBackend = $this->getMockBuilder('OCA\User_LDAP\Group_LDAP') + $groupBackend = $this->getMockBuilder(\OCA\User_LDAP\Group_LDAP::class) ->setMethods(['groupExists']) ->disableOriginalConstructor() ->getMock(); @@ -485,10 +485,10 @@ public function testClearGroupCacheGroupIDNotFound() { } public function testClearGroupCache() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->disableOriginalConstructor() ->getMock(); - $groupBackend = $this->getMockBuilder('OCA\User_LDAP\Group_LDAP') + $groupBackend = $this->getMockBuilder(\OCA\User_LDAP\Group_LDAP::class) ->setMethods(['groupExists', 'getLDAPAccess', 'getConnection', 'clearCache']) ->disableOriginalConstructor() ->getMock(); @@ -510,7 +510,7 @@ public function testClearGroupCache() { } public function testDnExists() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['dn2UserName']) ->disableOriginalConstructor() ->getMock(); @@ -525,7 +525,7 @@ public function testDnExists() { } public function testFlagRecord() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods([]) ->disableOriginalConstructor() ->getMock(); @@ -538,7 +538,7 @@ public function testFlagRecord() { } public function testUnflagRecord() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods([]) ->disableOriginalConstructor() ->getMock(); @@ -555,7 +555,7 @@ public function testGetLDAPDisplayNameFieldUserIDNotFound() { $this->expectException(\Exception::class); $this->expectExceptionMessage('User id not found in LDAP'); - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists']) ->disableOriginalConstructor() ->getMock(); @@ -568,7 +568,7 @@ public function testGetLDAPDisplayNameFieldUserIDNotFound() { } public function testGetLDAPDisplayNameField() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists', 'getLDAPAccess', 'getConnection', 'getConfiguration']) ->disableOriginalConstructor() ->getMock(); @@ -593,7 +593,7 @@ public function testGetLDAPEmailFieldUserIDNotFound() { $this->expectException(\Exception::class); $this->expectExceptionMessage('User id not found in LDAP'); - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists']) ->disableOriginalConstructor() ->getMock(); @@ -606,7 +606,7 @@ public function testGetLDAPEmailFieldUserIDNotFound() { } public function testGetLDAPEmailField() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->setMethods(['userExists', 'getLDAPAccess', 'getConnection', 'getConfiguration']) ->disableOriginalConstructor() ->getMock(); @@ -631,11 +631,11 @@ public function testGetLDAPGroupMemberAssocUserIDNotFound() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Group id not found in LDAP'); - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->disableOriginalConstructor() ->getMock(); - $groupBackend = $this->getMockBuilder('OCA\User_LDAP\Group_LDAP') + $groupBackend = $this->getMockBuilder(\OCA\User_LDAP\Group_LDAP::class) ->setMethods(['groupExists']) ->disableOriginalConstructor() ->getMock(); @@ -649,11 +649,11 @@ public function testGetLDAPGroupMemberAssocUserIDNotFound() { } public function testgetLDAPGroupMemberAssoc() { - $userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP') + $userBackend = $this->getMockBuilder(\OCA\User_LDAP\User_LDAP::class) ->disableOriginalConstructor() ->getMock(); - $groupBackend = $this->getMockBuilder('OCA\User_LDAP\Group_LDAP') + $groupBackend = $this->getMockBuilder(\OCA\User_LDAP\Group_LDAP::class) ->setMethods(['groupExists', 'getLDAPAccess', 'getConnection', 'getConfiguration']) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/user_ldap/tests/UserLDAPPluginTest.php b/apps/user_ldap/tests/UserLDAPPluginTest.php index 1e3cd6afbf84f..48d52028f3739 100644 --- a/apps/user_ldap/tests/UserLDAPPluginTest.php +++ b/apps/user_ldap/tests/UserLDAPPluginTest.php @@ -20,7 +20,7 @@ private function getUserPluginManager() { public function testImplementsActions() { $pluginManager = $this->getUserPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPUserPluginDummy::class) ->setMethods(['respondToActions']) ->getMock(); @@ -28,7 +28,7 @@ public function testImplementsActions() { ->method('respondToActions') ->willReturn(Backend::CREATE_USER); - $plugin2 = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy') + $plugin2 = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPUserPluginDummy::class) ->setMethods(['respondToActions']) ->getMock(); @@ -47,7 +47,7 @@ public function testImplementsActions() { public function testCreateUser() { $pluginManager = $this->getUserPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPUserPluginDummy::class) ->setMethods(['respondToActions', 'createUser']) ->getMock(); @@ -78,7 +78,7 @@ public function testCreateUserNotRegistered() { public function testSetPassword() { $pluginManager = $this->getUserPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPUserPluginDummy::class) ->setMethods(['respondToActions', 'setPassword']) ->getMock(); @@ -109,7 +109,7 @@ public function testSetPasswordNotRegistered() { public function testGetHome() { $pluginManager = $this->getUserPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPUserPluginDummy::class) ->setMethods(['respondToActions', 'getHome']) ->getMock(); @@ -139,7 +139,7 @@ public function testGetHomeNotRegistered() { public function testGetDisplayName() { $pluginManager = $this->getUserPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPUserPluginDummy::class) ->setMethods(['respondToActions', 'getDisplayName']) ->getMock(); @@ -169,7 +169,7 @@ public function testGetDisplayNameNotRegistered() { public function testSetDisplayName() { $pluginManager = $this->getUserPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPUserPluginDummy::class) ->setMethods(['respondToActions', 'setDisplayName']) ->getMock(); @@ -200,7 +200,7 @@ public function testSetDisplayNameNotRegistered() { public function testCanChangeAvatar() { $pluginManager = $this->getUserPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPUserPluginDummy::class) ->setMethods(['respondToActions', 'canChangeAvatar']) ->getMock(); @@ -230,7 +230,7 @@ public function testCanChangeAvatarNotRegistered() { public function testCountUsers() { $pluginManager = $this->getUserPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPUserPluginDummy::class) ->setMethods(['respondToActions', 'countUsers']) ->getMock(); @@ -257,7 +257,7 @@ public function testCountUsersNotRegistered() { public function testDeleteUser() { $pluginManager = $this->getUserPluginManager(); - $plugin = $this->getMockBuilder('OCA\User_LDAP\Tests\LDAPUserPluginDummy') + $plugin = $this->getMockBuilder(\OCA\User_LDAP\Tests\LDAPUserPluginDummy::class) ->setMethods(['respondToActions', 'canDeleteUser','deleteUser']) ->getMock(); diff --git a/apps/user_ldap/tests/WizardTest.php b/apps/user_ldap/tests/WizardTest.php index d3cf6ffb0ae6c..cc5867a5ca054 100644 --- a/apps/user_ldap/tests/WizardTest.php +++ b/apps/user_ldap/tests/WizardTest.php @@ -41,9 +41,9 @@ private function getWizardAndMocks() { static $accMethods; if (is_null($confMethods)) { - $confMethods = get_class_methods('\OCA\User_LDAP\Configuration'); - $connMethods = get_class_methods('\OCA\User_LDAP\Connection'); - $accMethods = get_class_methods('\OCA\User_LDAP\Access'); + $confMethods = get_class_methods(\OCA\User_LDAP\Configuration::class); + $connMethods = get_class_methods(\OCA\User_LDAP\Connection::class); + $accMethods = get_class_methods(\OCA\User_LDAP\Access::class); } /** @var ILDAPWrapper|\PHPUnit\Framework\MockObject\MockObject $lw */ $lw = $this->createMock(ILDAPWrapper::class); diff --git a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php index e5182bea4837a..e924e0d3d1b71 100644 --- a/apps/workflowengine/tests/Check/AbstractStringCheckTest.php +++ b/apps/workflowengine/tests/Check/AbstractStringCheckTest.php @@ -18,7 +18,7 @@ protected function getCheckMock() { return sprintf($string, $args); }); - $check = $this->getMockBuilder('OCA\WorkflowEngine\Check\AbstractStringCheck') + $check = $this->getMockBuilder(\OCA\WorkflowEngine\Check\AbstractStringCheck::class) ->setConstructorArgs([ $l, ]) diff --git a/apps/workflowengine/tests/Check/FileMimeTypeTest.php b/apps/workflowengine/tests/Check/FileMimeTypeTest.php index 607880364081e..0420ea0120c12 100644 --- a/apps/workflowengine/tests/Check/FileMimeTypeTest.php +++ b/apps/workflowengine/tests/Check/FileMimeTypeTest.php @@ -17,7 +17,7 @@ class TemporaryNoLocal extends Temporary { public function instanceOfStorage($className) { - if ($className === '\OC\Files\Storage\Local') { + if ($className === \OC\Files\Storage\Local::class) { return false; } else { return parent::instanceOfStorage($className); diff --git a/apps/workflowengine/tests/Check/RequestTimeTest.php b/apps/workflowengine/tests/Check/RequestTimeTest.php index 3c261fe2de3a7..90cdc279bbf25 100644 --- a/apps/workflowengine/tests/Check/RequestTimeTest.php +++ b/apps/workflowengine/tests/Check/RequestTimeTest.php @@ -30,7 +30,7 @@ protected function getL10NMock() { protected function setUp(): void { parent::setUp(); - $this->timeFactory = $this->getMockBuilder('OCP\AppFramework\Utility\ITimeFactory') + $this->timeFactory = $this->getMockBuilder(\OCP\AppFramework\Utility\ITimeFactory::class) ->getMock(); } diff --git a/core/Command/Upgrade.php b/core/Command/Upgrade.php index 7b1526766f345..d367b263ff024 100644 --- a/core/Command/Upgrade.php +++ b/core/Command/Upgrade.php @@ -130,16 +130,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int $dispatcher->addListener(RepairErrorEvent::class, $repairListener); - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($output) { + $updater->listen(\OC\Updater::class, 'maintenanceEnabled', function () use ($output) { $output->writeln('Turned on maintenance mode'); }); - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($output) { + $updater->listen(\OC\Updater::class, 'maintenanceDisabled', function () use ($output) { $output->writeln('Turned off maintenance mode'); }); - $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($output) { + $updater->listen(\OC\Updater::class, 'maintenanceActive', function () use ($output) { $output->writeln('Maintenance mode is kept active'); }); - $updater->listen('\OC\Updater', 'updateEnd', + $updater->listen(\OC\Updater::class, 'updateEnd', function ($success) use ($output, $self) { if ($success) { $message = 'Update successful'; @@ -148,42 +148,42 @@ function ($success) use ($output, $self) { } $output->writeln($message); }); - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($output) { + $updater->listen(\OC\Updater::class, 'dbUpgradeBefore', function () use ($output) { $output->writeln('Updating database schema'); }); - $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output) { + $updater->listen(\OC\Updater::class, 'dbUpgrade', function () use ($output) { $output->writeln('Updated database'); }); - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output, &$incompatibleOverwrites) { + $updater->listen(\OC\Updater::class, 'incompatibleAppDisabled', function ($app) use ($output, &$incompatibleOverwrites) { if (!in_array($app, $incompatibleOverwrites)) { $output->writeln('Disabled incompatible app: ' . $app . ''); } }); - $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output) { + $updater->listen(\OC\Updater::class, 'upgradeAppStoreApp', function ($app) use ($output) { $output->writeln('Update app ' . $app . ' from App Store'); }); - $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) { + $updater->listen(\OC\Updater::class, 'appSimulateUpdate', function ($app) use ($output) { $output->writeln("Checking whether the database schema for <$app> can be updated (this can take a long time depending on the database size)"); }); - $updater->listen('\OC\Updater', 'appUpgradeStarted', function ($app, $version) use ($output) { + $updater->listen(\OC\Updater::class, 'appUpgradeStarted', function ($app, $version) use ($output) { $output->writeln("Updating <$app> ..."); }); - $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($output) { + $updater->listen(\OC\Updater::class, 'appUpgrade', function ($app, $version) use ($output) { $output->writeln("Updated <$app> to $version"); }); - $updater->listen('\OC\Updater', 'failure', function ($message) use ($output, $self) { + $updater->listen(\OC\Updater::class, 'failure', function ($message) use ($output, $self) { $output->writeln("$message"); }); - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($output) { + $updater->listen(\OC\Updater::class, 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($output) { $output->writeln('Setting log level to debug'); }); - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($output) { + $updater->listen(\OC\Updater::class, 'resetLogLevel', function ($logLevel, $logLevelName) use ($output) { $output->writeln('Resetting log level'); }); - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($output) { + $updater->listen(\OC\Updater::class, 'startCheckCodeIntegrity', function () use ($output) { $output->writeln('Starting code integrity check...'); }); - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($output) { + $updater->listen(\OC\Updater::class, 'finishedCheckCodeIntegrity', function () use ($output) { $output->writeln('Finished code integrity check'); }); diff --git a/core/Controller/OCMController.php b/core/Controller/OCMController.php index d79b5b1669e43..524313552d186 100644 --- a/core/Controller/OCMController.php +++ b/core/Controller/OCMController.php @@ -57,7 +57,7 @@ public function discovery(): DataResponse { $this->config->getAppValue( 'core', 'ocm_providers', - '\OCA\CloudFederationAPI\Capabilities' + \OCA\CloudFederationAPI\Capabilities::class ) ); diff --git a/core/ajax/update.php b/core/ajax/update.php index 575a1f159e550..49fe5ec3bbfd7 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -117,50 +117,50 @@ function (MigratorExecuteSqlEvent $event) use ($eventSource, $l): void { $dispatcher->addListener(RepairWarningEvent::class, [$feedBack, 'handleRepairFeedback']); $dispatcher->addListener(RepairErrorEvent::class, [$feedBack, 'handleRepairFeedback']); - $updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) { + $updater->listen(\OC\Updater::class, 'maintenanceEnabled', function () use ($eventSource, $l) { $eventSource->send('success', $l->t('Turned on maintenance mode')); }); - $updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) { + $updater->listen(\OC\Updater::class, 'maintenanceDisabled', function () use ($eventSource, $l) { $eventSource->send('success', $l->t('Turned off maintenance mode')); }); - $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) { + $updater->listen(\OC\Updater::class, 'maintenanceActive', function () use ($eventSource, $l) { $eventSource->send('success', $l->t('Maintenance mode is kept active')); }); - $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($eventSource, $l) { + $updater->listen(\OC\Updater::class, 'dbUpgradeBefore', function () use ($eventSource, $l) { $eventSource->send('success', $l->t('Updating database schema')); }); - $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) { + $updater->listen(\OC\Updater::class, 'dbUpgrade', function () use ($eventSource, $l) { $eventSource->send('success', $l->t('Updated database')); }); - $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) { + $updater->listen(\OC\Updater::class, 'upgradeAppStoreApp', function ($app) use ($eventSource, $l) { $eventSource->send('success', $l->t('Update app "%s" from App Store', [$app])); }); - $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) { + $updater->listen(\OC\Updater::class, 'appSimulateUpdate', function ($app) use ($eventSource, $l) { $eventSource->send('success', $l->t('Checking whether the database schema for %s can be updated (this can take a long time depending on the database size)', [$app])); }); - $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) { + $updater->listen(\OC\Updater::class, 'appUpgrade', function ($app, $version) use ($eventSource, $l) { $eventSource->send('success', $l->t('Updated "%1$s" to %2$s', [$app, $version])); }); - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps, &$incompatibleOverwrites) { + $updater->listen(\OC\Updater::class, 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps, &$incompatibleOverwrites) { if (!in_array($app, $incompatibleOverwrites)) { $incompatibleApps[] = $app; } }); - $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) { + $updater->listen(\OC\Updater::class, 'failure', function ($message) use ($eventSource, $config) { $eventSource->send('failure', $message); $eventSource->close(); $config->setSystemValue('maintenance', false); }); - $updater->listen('\OC\Updater', 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l) { + $updater->listen(\OC\Updater::class, 'setDebugLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l) { $eventSource->send('success', $l->t('Set log level to debug')); }); - $updater->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l) { + $updater->listen(\OC\Updater::class, 'resetLogLevel', function ($logLevel, $logLevelName) use ($eventSource, $l) { $eventSource->send('success', $l->t('Reset log level')); }); - $updater->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($eventSource, $l) { + $updater->listen(\OC\Updater::class, 'startCheckCodeIntegrity', function () use ($eventSource, $l) { $eventSource->send('success', $l->t('Starting code integrity check')); }); - $updater->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($eventSource, $l) { + $updater->listen(\OC\Updater::class, 'finishedCheckCodeIntegrity', function () use ($eventSource, $l) { $eventSource->send('success', $l->t('Finished code integrity check')); }); diff --git a/lib/autoloader.php b/lib/autoloader.php index 41b272a457cc0..333718ef4d260 100644 --- a/lib/autoloader.php +++ b/lib/autoloader.php @@ -97,7 +97,7 @@ public function findClass(string $class): array { } catch (AppPathNotFoundException) { // App not found, ignore } - } elseif ($class === 'Test\\TestCase') { + } elseif ($class === \Test\TestCase::class) { // This File is considered public API, so we make sure that the class // can still be loaded, although the PSR-4 paths have not been loaded. $paths[] = \OC::$SERVERROOT . '/tests/lib/TestCase.php'; diff --git a/lib/base.php b/lib/base.php index 1f9caf473e266..5958f0b714acf 100644 --- a/lib/base.php +++ b/lib/base.php @@ -725,7 +725,7 @@ public static function init(): void { \OCP\Util::connectHook( '\OCA\Files_Sharing\API\Server2Server', 'preLoginNameUsedAsUserName', - '\OC\User\Database', + \OC\User\Database::class, 'preLoginNameUsedAsUserName' ); @@ -866,7 +866,7 @@ private static function registerEncryptionWrapperAndHooks(): void { \OCP\Util::connectHook(Share::class, 'post_shared', HookManager::class, 'postShared'); \OCP\Util::connectHook(Share::class, 'post_unshare', HookManager::class, 'postUnshared'); \OCP\Util::connectHook('OC_Filesystem', 'post_rename', HookManager::class, 'postRename'); - \OCP\Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', HookManager::class, 'postRestore'); + \OCP\Util::connectHook(\OCA\Files_Trashbin\Trashbin::class, 'post_restore', HookManager::class, 'postRestore'); } } diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index a96e050c0e643..cff8b5fe438d4 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -389,7 +389,7 @@ private function getUserId() { * @param string $serviceName e.g. 'OCA\Files\Capabilities' */ public function registerCapability($serviceName) { - $this->query('OC\CapabilitiesManager')->registerCapability(function () use ($serviceName) { + $this->query(\OC\CapabilitiesManager::class)->registerCapability(function () use ($serviceName) { return $this->query($serviceName); }); } diff --git a/lib/private/Encryption/DecryptAll.php b/lib/private/Encryption/DecryptAll.php index 0007467298ce7..d72cfa6c925ad 100644 --- a/lib/private/Encryption/DecryptAll.php +++ b/lib/private/Encryption/DecryptAll.php @@ -173,7 +173,7 @@ protected function decryptUsersFiles($uid, ProgressBar $progress, $userCount) { $content = $this->rootView->getDirectoryContent($root); foreach ($content as $file) { // only decrypt files owned by the user - if ($file->getStorage()->instanceOfStorage('OCA\Files_Sharing\SharedStorage')) { + if ($file->getStorage()->instanceOfStorage(\OCA\Files_Sharing\SharedStorage::class)) { continue; } $path = $root . '/' . $file['name']; diff --git a/lib/private/Encryption/Util.php b/lib/private/Encryption/Util.php index 1fb08b15696ec..0e65d4c2238dd 100644 --- a/lib/private/Encryption/Util.php +++ b/lib/private/Encryption/Util.php @@ -92,7 +92,7 @@ public function getEncryptionModuleId(?array $header = null) { if (isset($header[$encryptionModuleKey])) { $id = $header[$encryptionModuleKey]; } elseif (isset($header['cipher'])) { - if (class_exists('\OCA\Encryption\Crypto\Encryption')) { + if (class_exists(\OCA\Encryption\Crypto\Encryption::class)) { // fall back to default encryption if the user migrated from // ownCloud <= 8.0 with the old encryption $id = \OCA\Encryption\Crypto\Encryption::ID; diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php index c85104ac4b99e..92ea035124c60 100644 --- a/lib/private/Files/Cache/Scanner.php +++ b/lib/private/Files/Cache/Scanner.php @@ -125,7 +125,7 @@ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = if (!self::isPartialFile($file)) { // acquire a lock if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(\OCP\Files\Storage\ILockingStorage::class)) { $this->storage->acquireLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } @@ -134,7 +134,7 @@ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = $data = $data ?? $this->getData($file); } catch (ForbiddenException $e) { if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(\OCP\Files\Storage\ILockingStorage::class)) { $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } @@ -146,8 +146,8 @@ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = if ($data) { // pre-emit only if it was a file. By that we avoid counting/treating folders as files if ($data['mimetype'] !== 'httpd/unix-directory') { - $this->emit('\OC\Files\Cache\Scanner', 'scanFile', [$file, $this->storageId]); - \OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', ['path' => $file, 'storage' => $this->storageId]); + $this->emit(\OC\Files\Cache\Scanner::class, 'scanFile', [$file, $this->storageId]); + \OC_Hook::emit(\OC\Files\Cache\Scanner::class, 'scan_file', ['path' => $file, 'storage' => $this->storageId]); } $parent = dirname($file); @@ -225,15 +225,15 @@ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = // post-emit only if it was a file. By that we avoid counting/treating folders as files if ($data['mimetype'] !== 'httpd/unix-directory') { - $this->emit('\OC\Files\Cache\Scanner', 'postScanFile', [$file, $this->storageId]); - \OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', ['path' => $file, 'storage' => $this->storageId]); + $this->emit(\OC\Files\Cache\Scanner::class, 'postScanFile', [$file, $this->storageId]); + \OC_Hook::emit(\OC\Files\Cache\Scanner::class, 'post_scan_file', ['path' => $file, 'storage' => $this->storageId]); } } else { $this->removeFromCache($file); } } catch (\Exception $e) { if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(\OCP\Files\Storage\ILockingStorage::class)) { $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } @@ -242,7 +242,7 @@ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = // release the acquired lock if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(\OCP\Files\Storage\ILockingStorage::class)) { $this->storage->releaseLock($file, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } } @@ -258,7 +258,7 @@ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = protected function removeFromCache($path) { \OC_Hook::emit('Scanner', 'removeFromCache', ['file' => $path]); - $this->emit('\OC\Files\Cache\Scanner', 'removeFromCache', [$path]); + $this->emit(\OC\Files\Cache\Scanner::class, 'removeFromCache', [$path]); if ($this->cacheActive) { $this->cache->remove($path); } @@ -275,7 +275,7 @@ protected function addToCache($path, $data, $fileId = -1) { $data['permissions'] = $data['scan_permissions']; } \OC_Hook::emit('Scanner', 'addToCache', ['file' => $path, 'data' => $data]); - $this->emit('\OC\Files\Cache\Scanner', 'addToCache', [$path, $this->storageId, $data, $fileId]); + $this->emit(\OC\Files\Cache\Scanner::class, 'addToCache', [$path, $this->storageId, $data, $fileId]); if ($this->cacheActive) { if ($fileId !== -1) { $this->cache->update($fileId, $data); @@ -295,7 +295,7 @@ protected function addToCache($path, $data, $fileId = -1) { */ protected function updateCache($path, $data, $fileId = -1) { \OC_Hook::emit('Scanner', 'addToCache', ['file' => $path, 'data' => $data]); - $this->emit('\OC\Files\Cache\Scanner', 'updateCache', [$path, $this->storageId, $data]); + $this->emit(\OC\Files\Cache\Scanner::class, 'updateCache', [$path, $this->storageId, $data]); if ($this->cacheActive) { if ($fileId !== -1) { $this->cache->update($fileId, $data); @@ -319,7 +319,7 @@ public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $loc $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG; } if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(\OCP\Files\Storage\ILockingStorage::class)) { $this->storage->acquireLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); $this->storage->acquireLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); } @@ -337,7 +337,7 @@ public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $loc } } finally { if ($lock) { - if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->storage->instanceOfStorage(\OCP\Files\Storage\ILockingStorage::class)) { $this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); $this->storage->releaseLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); } @@ -420,7 +420,7 @@ protected function scanChildren(string $path, $recursive, int $reuse, int $folde if ($reuse === -1) { $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG; } - $this->emit('\OC\Files\Cache\Scanner', 'scanFolder', [$path, $this->storageId]); + $this->emit(\OC\Files\Cache\Scanner::class, 'scanFolder', [$path, $this->storageId]); $size = 0; $childQueue = $this->handleChildren($path, $recursive, $reuse, $folderId, $lock, $size, $etagChanged); @@ -455,7 +455,7 @@ protected function scanChildren(string $path, $recursive, int $reuse, int $folde } } } - $this->emit('\OC\Files\Cache\Scanner', 'postScanFolder', [$path, $this->storageId]); + $this->emit(\OC\Files\Cache\Scanner::class, 'postScanFolder', [$path, $this->storageId]); return $size; } @@ -489,7 +489,7 @@ private function handleChildren(string $path, $recursive, int $reuse, int $folde if (trim($originalFile, '/') !== $file) { // encoding mismatch, might require compatibility wrapper \OC::$server->get(LoggerInterface::class)->debug('Scanner: Skipping non-normalized file name "'. $originalFile . '" in path "' . $path . '".', ['app' => 'core']); - $this->emit('\OC\Files\Cache\Scanner', 'normalizedNameMismatch', [$path ? $path . '/' . $originalFile : $originalFile]); + $this->emit(\OC\Files\Cache\Scanner::class, 'normalizedNameMismatch', [$path ? $path . '/' . $originalFile : $originalFile]); // skip this entry continue; } diff --git a/lib/private/Files/Config/MountProviderCollection.php b/lib/private/Files/Config/MountProviderCollection.php index 1dbc469c8c3b1..d54be1996aa22 100644 --- a/lib/private/Files/Config/MountProviderCollection.php +++ b/lib/private/Files/Config/MountProviderCollection.php @@ -112,10 +112,10 @@ public function addMountForUser(IUser $user, IMountManager $mountManager, ?calla $providers = $this->providers; } $firstProviders = array_filter($providers, function (IMountProvider $provider) { - return (get_class($provider) !== 'OCA\Files_Sharing\MountProvider'); + return (get_class($provider) !== \OCA\Files_Sharing\MountProvider::class); }); $lastProviders = array_filter($providers, function (IMountProvider $provider) { - return (get_class($provider) === 'OCA\Files_Sharing\MountProvider'); + return (get_class($provider) === \OCA\Files_Sharing\MountProvider::class); }); foreach ($firstProviders as $provider) { $mounts = $this->getMountsFromProvider($provider, $user, $this->loader); diff --git a/lib/private/Files/Mount/CacheMountProvider.php b/lib/private/Files/Mount/CacheMountProvider.php index 27c7eec9da34f..a3bbc6f903562 100644 --- a/lib/private/Files/Mount/CacheMountProvider.php +++ b/lib/private/Files/Mount/CacheMountProvider.php @@ -47,8 +47,8 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) { } return [ - new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class), - new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads'], $loader, null, null, self::class) + new MountPoint(\OC\Files\Storage\Local::class, '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class), + new MountPoint(\OC\Files\Storage\Local::class, '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads'], $loader, null, null, self::class) ]; } else { return []; diff --git a/lib/private/Files/Mount/LocalHomeMountProvider.php b/lib/private/Files/Mount/LocalHomeMountProvider.php index a2b3d3b2a991f..857542988a9e5 100644 --- a/lib/private/Files/Mount/LocalHomeMountProvider.php +++ b/lib/private/Files/Mount/LocalHomeMountProvider.php @@ -24,6 +24,6 @@ class LocalHomeMountProvider implements IHomeMountProvider { */ public function getHomeMountForUser(IUser $user, IStorageFactory $loader) { $arguments = ['user' => $user]; - return new HomeMountPoint($user, '\OC\Files\Storage\Home', '/' . $user->getUID(), $arguments, $loader, null, null, self::class); + return new HomeMountPoint($user, \OC\Files\Storage\Home::class, '/' . $user->getUID(), $arguments, $loader, null, null, self::class); } } diff --git a/lib/private/Files/Mount/ObjectHomeMountProvider.php b/lib/private/Files/Mount/ObjectHomeMountProvider.php index 99c52108fa88a..cd069c73f4c86 100644 --- a/lib/private/Files/Mount/ObjectHomeMountProvider.php +++ b/lib/private/Files/Mount/ObjectHomeMountProvider.php @@ -48,7 +48,7 @@ public function getHomeMountForUser(IUser $user, IStorageFactory $loader) { return null; } - return new HomeMountPoint($user, '\OC\Files\ObjectStore\HomeObjectStoreStorage', '/' . $user->getUID(), $config['arguments'], $loader, null, null, self::class); + return new HomeMountPoint($user, \OC\Files\ObjectStore\HomeObjectStoreStorage::class, '/' . $user->getUID(), $config['arguments'], $loader, null, null, self::class); } /** diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index cefba66683bce..e3e1b7b0bee6e 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -470,7 +470,7 @@ public function isLocal() { public function instanceOfStorage($class) { if (ltrim($class, '\\') === 'OC\Files\Storage\Shared') { // FIXME Temporary fix to keep existing checks working - $class = '\OCA\Files_Sharing\SharedStorage'; + $class = \OCA\Files_Sharing\SharedStorage::class; } return is_a($this, $class); } diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php index f8aa9d963dcc0..6cb371a78761a 100644 --- a/lib/private/Files/Storage/Wrapper/Wrapper.php +++ b/lib/private/Files/Storage/Wrapper/Wrapper.php @@ -474,7 +474,7 @@ public function isLocal() { public function instanceOfStorage($class) { if (ltrim($class, '\\') === 'OC\Files\Storage\Shared') { // FIXME Temporary fix to keep existing checks working - $class = '\OCA\Files_Sharing\SharedStorage'; + $class = \OCA\Files_Sharing\SharedStorage::class; } return is_a($this, $class) or $this->getWrapperStorage()->instanceOfStorage($class); } @@ -588,7 +588,7 @@ public function getMetaData($path) { * @throws \OCP\Lock\LockedException */ public function acquireLock($path, $type, ILockingProvider $provider) { - if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->getWrapperStorage()->instanceOfStorage(\OCP\Files\Storage\ILockingStorage::class)) { $this->getWrapperStorage()->acquireLock($path, $type, $provider); } } @@ -599,7 +599,7 @@ public function acquireLock($path, $type, ILockingProvider $provider) { * @param \OCP\Lock\ILockingProvider $provider */ public function releaseLock($path, $type, ILockingProvider $provider) { - if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->getWrapperStorage()->instanceOfStorage(\OCP\Files\Storage\ILockingStorage::class)) { $this->getWrapperStorage()->releaseLock($path, $type, $provider); } } @@ -610,7 +610,7 @@ public function releaseLock($path, $type, ILockingProvider $provider) { * @param \OCP\Lock\ILockingProvider $provider */ public function changeLock($path, $type, ILockingProvider $provider) { - if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($this->getWrapperStorage()->instanceOfStorage(\OCP\Files\Storage\ILockingStorage::class)) { $this->getWrapperStorage()->changeLock($path, $type, $provider); } } diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index bcc54dea0dcb1..9f6bcbde84d7b 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -107,24 +107,24 @@ protected function getMounts($dir) { */ protected function attachListener($mount) { $scanner = $mount->getStorage()->getScanner(); - $scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($mount) { - $this->emit('\OC\Files\Utils\Scanner', 'scanFile', [$mount->getMountPoint() . $path]); + $scanner->listen(\OC\Files\Cache\Scanner::class, 'scanFile', function ($path) use ($mount) { + $this->emit(\OC\Files\Utils\Scanner::class, 'scanFile', [$mount->getMountPoint() . $path]); $this->dispatcher->dispatchTyped(new BeforeFileScannedEvent($mount->getMountPoint() . $path)); }); - $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($mount) { - $this->emit('\OC\Files\Utils\Scanner', 'scanFolder', [$mount->getMountPoint() . $path]); + $scanner->listen(\OC\Files\Cache\Scanner::class, 'scanFolder', function ($path) use ($mount) { + $this->emit(\OC\Files\Utils\Scanner::class, 'scanFolder', [$mount->getMountPoint() . $path]); $this->dispatcher->dispatchTyped(new BeforeFolderScannedEvent($mount->getMountPoint() . $path)); }); - $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function ($path) use ($mount) { - $this->emit('\OC\Files\Utils\Scanner', 'postScanFile', [$mount->getMountPoint() . $path]); + $scanner->listen(\OC\Files\Cache\Scanner::class, 'postScanFile', function ($path) use ($mount) { + $this->emit(\OC\Files\Utils\Scanner::class, 'postScanFile', [$mount->getMountPoint() . $path]); $this->dispatcher->dispatchTyped(new FileScannedEvent($mount->getMountPoint() . $path)); }); - $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function ($path) use ($mount) { - $this->emit('\OC\Files\Utils\Scanner', 'postScanFolder', [$mount->getMountPoint() . $path]); + $scanner->listen(\OC\Files\Cache\Scanner::class, 'postScanFolder', function ($path) use ($mount) { + $this->emit(\OC\Files\Utils\Scanner::class, 'postScanFolder', [$mount->getMountPoint() . $path]); $this->dispatcher->dispatchTyped(new FolderScannedEvent($mount->getMountPoint() . $path)); }); - $scanner->listen('\OC\Files\Cache\Scanner', 'normalizedNameMismatch', function ($path) use ($mount) { - $this->emit('\OC\Files\Utils\Scanner', 'normalizedNameMismatch', [$path]); + $scanner->listen(\OC\Files\Cache\Scanner::class, 'normalizedNameMismatch', function ($path) use ($mount) { + $this->emit(\OC\Files\Utils\Scanner::class, 'normalizedNameMismatch', [$path]); }); } @@ -148,13 +148,13 @@ public function backgroundScan($dir) { $scanner = $storage->getScanner(); $this->attachListener($mount); - $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) { + $scanner->listen(\OC\Files\Cache\Scanner::class, 'removeFromCache', function ($path) use ($storage) { $this->triggerPropagator($storage, $path); }); - $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) { + $scanner->listen(\OC\Files\Cache\Scanner::class, 'updateCache', function ($path) use ($storage) { $this->triggerPropagator($storage, $path); }); - $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) { + $scanner->listen(\OC\Files\Cache\Scanner::class, 'addToCache', function ($path) use ($storage) { $this->triggerPropagator($storage, $path); }); @@ -225,15 +225,15 @@ public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECUR $scanner->setUseTransactions(false); $this->attachListener($mount); - $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) { + $scanner->listen(\OC\Files\Cache\Scanner::class, 'removeFromCache', function ($path) use ($storage) { $this->postProcessEntry($storage, $path); $this->dispatcher->dispatchTyped(new NodeRemovedFromCache($storage, $path)); }); - $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) { + $scanner->listen(\OC\Files\Cache\Scanner::class, 'updateCache', function ($path) use ($storage) { $this->postProcessEntry($storage, $path); $this->dispatcher->dispatchTyped(new FileCacheUpdated($storage, $path)); }); - $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path, $storageId, $data, $fileId) use ($storage) { + $scanner->listen(\OC\Files\Cache\Scanner::class, 'addToCache', function ($path, $storageId, $data, $fileId) use ($storage) { $this->postProcessEntry($storage, $path); if ($fileId) { $this->dispatcher->dispatchTyped(new FileCacheUpdated($storage, $path)); @@ -261,7 +261,7 @@ public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECUR $propagator->commitBatch(); } catch (StorageNotAvailableException $e) { $this->logger->error('Storage ' . $storage->getId() . ' not available', ['exception' => $e]); - $this->emit('\OC\Files\Utils\Scanner', 'StorageNotAvailable', [$e]); + $this->emit(\OC\Files\Utils\Scanner::class, 'StorageNotAvailable', [$e]); } if ($this->useTransaction) { $this->db->commit(); diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 336349c680bab..e8fabf759d55e 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1948,7 +1948,7 @@ private function lockPath($path, $type, $lockMountPoint = false) { $mount = $this->getMountForLock($absolutePath, $lockMountPoint); try { $storage = $mount->getStorage(); - if ($storage && $storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($storage && $storage->instanceOfStorage(\OCP\Files\Storage\ILockingStorage::class)) { $storage->acquireLock( $mount->getInternalPath($absolutePath), $type, @@ -1988,7 +1988,7 @@ public function changeLock($path, $type, $lockMountPoint = false) { $mount = $this->getMountForLock($absolutePath, $lockMountPoint); try { $storage = $mount->getStorage(); - if ($storage && $storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($storage && $storage->instanceOfStorage(\OCP\Files\Storage\ILockingStorage::class)) { $storage->changeLock( $mount->getInternalPath($absolutePath), $type, @@ -2034,7 +2034,7 @@ private function unlockPath($path, $type, $lockMountPoint = false) { $mount = $this->getMountForLock($absolutePath, $lockMountPoint); $storage = $mount->getStorage(); - if ($storage && $storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { + if ($storage && $storage->instanceOfStorage(\OCP\Files\Storage\ILockingStorage::class)) { $storage->releaseLock( $mount->getInternalPath($absolutePath), $type, diff --git a/lib/private/Server.php b/lib/private/Server.php index c514a4b93ff0a..3288b0cc87e35 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -1143,7 +1143,7 @@ public function __construct($webRoot, \OC\Config $config) { $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults'); $this->registerService('ThemingDefaults', function (Server $c) { try { - $classExists = class_exists('OCA\Theming\ThemingDefaults'); + $classExists = class_exists(\OCA\Theming\ThemingDefaults::class); } catch (\OCP\AutoloadNotAllowedException $e) { // App disabled or in maintenance mode $classExists = false; diff --git a/lib/private/Share/Share.php b/lib/private/Share/Share.php index 0af264fb96858..684cd7d4b0681 100644 --- a/lib/private/Share/Share.php +++ b/lib/private/Share/Share.php @@ -80,20 +80,20 @@ public static function getBackend($itemType) { if (!(self::$backends[$itemType] instanceof \OCP\Share_Backend)) { $message = 'Sharing backend %s must implement the interface OCP\Share_Backend'; $message_t = $l->t('Sharing backend %s must implement the interface OCP\Share_Backend', [$class]); - $logger->error(sprintf($message, $class), ['app' => 'OCP\Share']); + $logger->error(sprintf($message, $class), ['app' => \OCP\Share::class]); throw new \Exception($message_t); } return self::$backends[$itemType]; } else { $message = 'Sharing backend %s not found'; $message_t = $l->t('Sharing backend %s not found', [$class]); - $logger->error(sprintf($message, $class), ['app' => 'OCP\Share']); + $logger->error(sprintf($message, $class), ['app' => \OCP\Share::class]); throw new \Exception($message_t); } } $message = 'Sharing backend for %s not found'; $message_t = $l->t('Sharing backend for %s not found', [$itemType]); - $logger->error(sprintf($message, $itemType), ['app' => 'OCP\Share']); + $logger->error(sprintf($message, $itemType), ['app' => \OCP\Share::class]); throw new \Exception($message_t); } diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 5457e8024a41a..5dcfcb1050f65 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -578,7 +578,7 @@ protected function pathCreateChecks($path) { if ($path instanceof \OCP\Files\Folder) { $mounts = $this->mountManager->findIn($path->getPath()); foreach ($mounts as $mount) { - if ($mount->getStorage()->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) { + if ($mount->getStorage()->instanceOfStorage(\OCA\Files_Sharing\ISharedStorage::class)) { throw new \InvalidArgumentException($this->l->t('Path contains files shared with you')); } } @@ -623,9 +623,9 @@ public function createShare(IShare $share) { * Except for mounted federated shares. */ $storage = $share->getNode()->getStorage(); - if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) { + if ($storage->instanceOfStorage(\OCA\Files_Sharing\External\Storage::class)) { $parent = $share->getNode()->getParent(); - while ($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) { + while ($parent->getStorage()->instanceOfStorage(\OCA\Files_Sharing\External\Storage::class)) { $parent = $parent->getParent(); } $share->setShareOwner($parent->getOwner()->getUID()); diff --git a/lib/private/SubAdmin.php b/lib/private/SubAdmin.php index c025ab7b01246..6dad75545e6d8 100644 --- a/lib/private/SubAdmin.php +++ b/lib/private/SubAdmin.php @@ -69,7 +69,7 @@ public function createSubAdmin(IUser $user, IGroup $group): void { ->execute(); /** @deprecated 21.0.0 - use type SubAdminAddedEvent instead */ - $this->emit('\OC\SubAdmin', 'postCreateSubAdmin', [$user, $group]); + $this->emit(\OC\SubAdmin::class, 'postCreateSubAdmin', [$user, $group]); $event = new SubAdminAddedEvent($group, $user); $this->eventDispatcher->dispatchTyped($event); } @@ -88,7 +88,7 @@ public function deleteSubAdmin(IUser $user, IGroup $group): void { ->execute(); /** @deprecated 21.0.0 - use type SubAdminRemovedEvent instead */ - $this->emit('\OC\SubAdmin', 'postDeleteSubAdmin', [$user, $group]); + $this->emit(\OC\SubAdmin::class, 'postDeleteSubAdmin', [$user, $group]); $event = new SubAdminRemovedEvent($group, $user); $this->eventDispatcher->dispatchTyped($event); } diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 0ef4ec197cf67..b93695ab500a7 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -89,7 +89,7 @@ public function __construct($renderAs, $appId = '') { } // Set body data-theme $this->assign('enabledThemes', []); - if (\OC::$server->getAppManager()->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) { + if (\OC::$server->getAppManager()->isEnabledForUser('theming') && class_exists(\OCA\Theming\Service\ThemesService::class)) { /** @var \OCA\Theming\Service\ThemesService */ $themesService = \OC::$server->get(\OCA\Theming\Service\ThemesService::class); $this->assign('enabledThemes', $themesService->getEnabledThemes()); diff --git a/lib/private/Updater.php b/lib/private/Updater.php index 2722c172f1a40..fca88e22774de 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -71,14 +71,14 @@ public function upgrade(): bool { $this->logAllEvents(); $logLevel = $this->config->getSystemValue('loglevel', ILogger::WARN); - $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); + $this->emit(\OC\Updater::class, 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); $this->config->setSystemValue('loglevel', ILogger::DEBUG); $wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance'); if (!$wasMaintenanceModeEnabled) { $this->config->setSystemValue('maintenance', true); - $this->emit('\OC\Updater', 'maintenanceEnabled'); + $this->emit(\OC\Updater::class, 'maintenanceEnabled'); } // Clear CAN_INSTALL file if not on git @@ -100,26 +100,26 @@ public function upgrade(): bool { $this->log->error($exception->getMessage(), [ 'exception' => $exception, ]); - $this->emit('\OC\Updater', 'failure', [$exception->getMessage() . ': ' .$exception->getHint()]); + $this->emit(\OC\Updater::class, 'failure', [$exception->getMessage() . ': ' .$exception->getHint()]); $success = false; } catch (\Exception $exception) { $this->log->error($exception->getMessage(), [ 'exception' => $exception, ]); - $this->emit('\OC\Updater', 'failure', [get_class($exception) . ': ' .$exception->getMessage()]); + $this->emit(\OC\Updater::class, 'failure', [get_class($exception) . ': ' .$exception->getMessage()]); $success = false; } - $this->emit('\OC\Updater', 'updateEnd', [$success]); + $this->emit(\OC\Updater::class, 'updateEnd', [$success]); if (!$wasMaintenanceModeEnabled && $success) { $this->config->setSystemValue('maintenance', false); - $this->emit('\OC\Updater', 'maintenanceDisabled'); + $this->emit(\OC\Updater::class, 'maintenanceDisabled'); } else { - $this->emit('\OC\Updater', 'maintenanceActive'); + $this->emit(\OC\Updater::class, 'maintenanceActive'); } - $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); + $this->emit(\OC\Updater::class, 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); $this->config->setSystemValue('loglevel', $logLevel); $this->config->setSystemValue('installed', true); @@ -254,7 +254,7 @@ private function doUpgrade(string $currentVersion, string $installedVersion): vo 'exception' => $exception, 'app' => $appId, ]); - $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]); + $this->emit(\OC\Updater::class, 'failure', [$appId . ': ' . $exception->getMessage()]); } // post-upgrade repairs @@ -267,9 +267,9 @@ private function doUpgrade(string $currentVersion, string $installedVersion): vo // Check for code integrity if not disabled if (\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) { - $this->emit('\OC\Updater', 'startCheckCodeIntegrity'); + $this->emit(\OC\Updater::class, 'startCheckCodeIntegrity'); $this->checker->runInstanceVerification(); - $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity'); + $this->emit(\OC\Updater::class, 'finishedCheckCodeIntegrity'); } // only set the final version if everything went well @@ -278,13 +278,13 @@ private function doUpgrade(string $currentVersion, string $installedVersion): vo } protected function doCoreUpgrade(): void { - $this->emit('\OC\Updater', 'dbUpgradeBefore'); + $this->emit(\OC\Updater::class, 'dbUpgradeBefore'); // execute core migrations $ms = new MigrationService('core', \OC::$server->get(Connection::class)); $ms->migrate(); - $this->emit('\OC\Updater', 'dbUpgrade'); + $this->emit(\OC\Updater::class, 'dbUpgrade'); } /** @@ -319,9 +319,9 @@ protected function doAppUpgrade(): void { $stack = $stacks[$type]; foreach ($stack as $appId) { if (\OC_App::shouldUpgrade($appId)) { - $this->emit('\OC\Updater', 'appUpgradeStarted', [$appId, \OCP\Server::get(IAppManager::class)->getAppVersion($appId)]); + $this->emit(\OC\Updater::class, 'appUpgradeStarted', [$appId, \OCP\Server::get(IAppManager::class)->getAppVersion($appId)]); \OC_App::updateApp($appId); - $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OCP\Server::get(IAppManager::class)->getAppVersion($appId)]); + $this->emit(\OC\Updater::class, 'appUpgrade', [$appId, \OCP\Server::get(IAppManager::class)->getAppVersion($appId)]); } if ($type !== $pseudoOtherType) { // load authentication, filesystem and logging apps after @@ -354,7 +354,7 @@ private function checkAppsRequirements(): void { throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update'); } $appManager->disableApp($app, true); - $this->emit('\OC\Updater', 'incompatibleAppDisabled', [$app]); + $this->emit(\OC\Updater::class, 'incompatibleAppDisabled', [$app]); } } } @@ -379,12 +379,12 @@ private function isCodeUpgrade(): bool { private function upgradeAppStoreApps(array $apps, array $previousEnableStates = []): void { foreach ($apps as $app) { try { - $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]); + $this->emit(\OC\Updater::class, 'checkAppStoreAppBefore', [$app]); if ($this->installer->isUpdateAvailable($app)) { - $this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]); + $this->emit(\OC\Updater::class, 'upgradeAppStoreApp', [$app]); $this->installer->updateAppstoreApp($app); } - $this->emit('\OC\Updater', 'checkAppStoreApp', [$app]); + $this->emit(\OC\Updater::class, 'checkAppStoreApp', [$app]); if (!empty($previousEnableStates)) { $ocApp = new \OC_App(); @@ -445,62 +445,62 @@ function (MigratorExecuteSqlEvent $event) use ($log): void { $dispatcher->addListener(RepairErrorEvent::class, $repairListener); - $this->listen('\OC\Updater', 'maintenanceEnabled', function () use ($log) { + $this->listen(\OC\Updater::class, 'maintenanceEnabled', function () use ($log) { $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'maintenanceDisabled', function () use ($log) { + $this->listen(\OC\Updater::class, 'maintenanceDisabled', function () use ($log) { $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'maintenanceActive', function () use ($log) { + $this->listen(\OC\Updater::class, 'maintenanceActive', function () use ($log) { $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'updateEnd', function ($success) use ($log) { + $this->listen(\OC\Updater::class, 'updateEnd', function ($success) use ($log) { if ($success) { $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']); } else { $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']); } }); - $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($log) { + $this->listen(\OC\Updater::class, 'dbUpgradeBefore', function () use ($log) { $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'dbUpgrade', function () use ($log) { + $this->listen(\OC\Updater::class, 'dbUpgrade', function () use ($log) { $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($log) { + $this->listen(\OC\Updater::class, 'incompatibleAppDisabled', function ($app) use ($log) { $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($log) { + $this->listen(\OC\Updater::class, 'checkAppStoreAppBefore', function ($app) use ($log) { $log->debug('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($log) { + $this->listen(\OC\Updater::class, 'upgradeAppStoreApp', function ($app) use ($log) { $log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($log) { + $this->listen(\OC\Updater::class, 'checkAppStoreApp', function ($app) use ($log) { $log->debug('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) { + $this->listen(\OC\Updater::class, 'appSimulateUpdate', function ($app) use ($log) { $log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <' . $app . '> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) { + $this->listen(\OC\Updater::class, 'appUpgradeStarted', function ($app) use ($log) { $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) { + $this->listen(\OC\Updater::class, 'appUpgrade', function ($app, $version) use ($log) { $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'failure', function ($message) use ($log) { + $this->listen(\OC\Updater::class, 'failure', function ($message) use ($log) { $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'setDebugLogLevel', function () use ($log) { + $this->listen(\OC\Updater::class, 'setDebugLogLevel', function () use ($log) { $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($log) { + $this->listen(\OC\Updater::class, 'resetLogLevel', function ($logLevel, $logLevelName) use ($log) { $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($log) { + $this->listen(\OC\Updater::class, 'startCheckCodeIntegrity', function () use ($log) { $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']); }); - $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($log) { + $this->listen(\OC\Updater::class, 'finishedCheckCodeIntegrity', function () use ($log) { $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']); }); } diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index ef84d35d7bca3..c07aca015c191 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -790,7 +790,7 @@ public static function setupBackgroundJobs(array $jobs) { private static function setupLiveMigrations(string $appId, array $steps) { $queue = \OC::$server->getJobList(); foreach ($steps as $step) { - $queue->add('OC\Migration\BackgroundRepair', [ + $queue->add(\OC\Migration\BackgroundRepair::class, [ 'app' => $appId, 'step' => $step]); } diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index 33cc966da2a6e..d05f1e108c23b 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -486,12 +486,12 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin $mount = $rootInfo->getMountPoint(); $storage = $mount->getStorage(); $sourceStorage = $storage; - if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { + if ($storage->instanceOfStorage(\OCA\Files_Sharing\SharedStorage::class)) { self::$quotaIncludeExternalStorage = false; } if (self::$quotaIncludeExternalStorage) { - if ($storage->instanceOfStorage('\OC\Files\Storage\Home') - || $storage->instanceOfStorage('\OC\Files\ObjectStore\HomeObjectStoreStorage') + if ($storage->instanceOfStorage(\OC\Files\Storage\Home::class) + || $storage->instanceOfStorage(\OC\Files\ObjectStore\HomeObjectStoreStorage::class) ) { /** @var \OC\Files\Storage\Home $storage */ $user = $storage->getUser(); @@ -506,7 +506,7 @@ public static function getStorageInfo($path, $rootInfo = null, $includeMountPoin } // TODO: need a better way to get total space from storage - if ($sourceStorage->instanceOfStorage('\OC\Files\Storage\Wrapper\Quota')) { + if ($sourceStorage->instanceOfStorage(\OC\Files\Storage\Wrapper\Quota::class)) { /** @var \OC\Files\Storage\Wrapper\Quota $storage */ $quota = $sourceStorage->getQuota(); } diff --git a/tests/Core/Command/Config/ListConfigsTest.php b/tests/Core/Command/Config/ListConfigsTest.php index 8b6fdf39192b6..115296ed654aa 100644 --- a/tests/Core/Command/Config/ListConfigsTest.php +++ b/tests/Core/Command/Config/ListConfigsTest.php @@ -131,7 +131,7 @@ public function listData() { [ ['secret', 'N;', IConfig::SENSITIVE_VALUE], ['objectstore', 'N;', [ - 'class' => 'OC\\Files\\ObjectStore\\Swift', + 'class' => \OC\Files\ObjectStore\Swift::class, 'arguments' => [ 'username' => 'facebook100000123456789', 'password' => IConfig::SENSITIVE_VALUE, @@ -153,7 +153,7 @@ public function listData() { 'system' => [ 'secret' => IConfig::SENSITIVE_VALUE, 'objectstore' => [ - 'class' => 'OC\\Files\\ObjectStore\\Swift', + 'class' => \OC\Files\ObjectStore\Swift::class, 'arguments' => [ 'username' => 'facebook100000123456789', 'password' => IConfig::SENSITIVE_VALUE, diff --git a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php index 852715651923d..4aed3e0b5bdf4 100644 --- a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php +++ b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php @@ -53,7 +53,7 @@ protected function setUp(): void { $this->view = $this->getMockBuilder(View::class)->getMock(); $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); $this->config = $this->getMockBuilder(IConfig::class)->getMock(); - $this->util = $this->getMockBuilder('OC\Encryption\Util')->disableOriginalConstructor()->getMock(); + $this->util = $this->getMockBuilder(\OC\Encryption\Util::class)->disableOriginalConstructor()->getMock(); $this->questionHelper = $this->getMockBuilder(QuestionHelper::class)->getMock(); $this->inputInterface = $this->getMockBuilder(InputInterface::class)->getMock(); $this->outputInterface = $this->getMockBuilder(OutputInterface::class)->getMock(); @@ -80,7 +80,7 @@ protected function setUp(): void { * @dataProvider dataTestExecute */ public function testExecute($newRoot, $answer, $successMoveKey) { - $changeKeyStorageRoot = $this->getMockBuilder('OC\Core\Command\Encryption\ChangeKeyStorageRoot') + $changeKeyStorageRoot = $this->getMockBuilder(\OC\Core\Command\Encryption\ChangeKeyStorageRoot::class) ->setConstructorArgs( [ $this->view, @@ -134,7 +134,7 @@ public function dataTestExecute() { public function testMoveAllKeys() { /** @var \OC\Core\Command\Encryption\ChangeKeyStorageRoot $changeKeyStorageRoot */ - $changeKeyStorageRoot = $this->getMockBuilder('OC\Core\Command\Encryption\ChangeKeyStorageRoot') + $changeKeyStorageRoot = $this->getMockBuilder(\OC\Core\Command\Encryption\ChangeKeyStorageRoot::class) ->setConstructorArgs( [ $this->view, @@ -195,7 +195,7 @@ public function dataTestPrepareNewRootException() { * @param bool $executeRename */ public function testMoveSystemKeys($dirExists, $targetExists, $executeRename) { - $changeKeyStorageRoot = $this->getMockBuilder('OC\Core\Command\Encryption\ChangeKeyStorageRoot') + $changeKeyStorageRoot = $this->getMockBuilder(\OC\Core\Command\Encryption\ChangeKeyStorageRoot::class) ->setConstructorArgs( [ $this->view, @@ -232,7 +232,7 @@ public function dataTestMoveSystemKeys() { public function testMoveUserKeys() { - $changeKeyStorageRoot = $this->getMockBuilder('OC\Core\Command\Encryption\ChangeKeyStorageRoot') + $changeKeyStorageRoot = $this->getMockBuilder(\OC\Core\Command\Encryption\ChangeKeyStorageRoot::class) ->setConstructorArgs( [ $this->view, @@ -262,7 +262,7 @@ public function testMoveUserKeys() { * @param bool $shouldRename */ public function testMoveUserEncryptionFolder($userExists, $isDir, $targetExists, $shouldRename) { - $changeKeyStorageRoot = $this->getMockBuilder('OC\Core\Command\Encryption\ChangeKeyStorageRoot') + $changeKeyStorageRoot = $this->getMockBuilder(\OC\Core\Command\Encryption\ChangeKeyStorageRoot::class) ->setConstructorArgs( [ $this->view, diff --git a/tests/Core/Command/User/SettingTest.php b/tests/Core/Command/User/SettingTest.php index 7be9bd27ecb44..818b23af713a9 100644 --- a/tests/Core/Command/User/SettingTest.php +++ b/tests/Core/Command/User/SettingTest.php @@ -51,7 +51,7 @@ public function getCommand(array $methods = []) { if (empty($methods)) { return new Setting($this->userManager, $this->config, $this->connection); } else { - $mock = $this->getMockBuilder('OC\Core\Command\User\Setting') + $mock = $this->getMockBuilder(\OC\Core\Command\User\Setting::class) ->setConstructorArgs([ $this->userManager, $this->config, diff --git a/tests/Core/Controller/AvatarControllerTest.php b/tests/Core/Controller/AvatarControllerTest.php index 41c16bc4c3f08..a1b0168dcd286 100644 --- a/tests/Core/Controller/AvatarControllerTest.php +++ b/tests/Core/Controller/AvatarControllerTest.php @@ -72,18 +72,18 @@ class AvatarControllerTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->avatarManager = $this->getMockBuilder('OCP\IAvatarManager')->getMock(); - $this->cache = $this->getMockBuilder('OCP\ICache') + $this->avatarManager = $this->getMockBuilder(\OCP\IAvatarManager::class)->getMock(); + $this->cache = $this->getMockBuilder(\OCP\ICache::class) ->disableOriginalConstructor()->getMock(); $this->l = $this->getMockBuilder(IL10N::class)->getMock(); $this->l->method('t')->willReturnArgument(0); $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); $this->request = $this->getMockBuilder(IRequest::class)->getMock(); - $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock(); + $this->rootFolder = $this->getMockBuilder(\OCP\Files\IRootFolder::class)->getMock(); $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); - $this->timeFactory = $this->getMockBuilder('OC\AppFramework\Utility\TimeFactory')->getMock(); + $this->timeFactory = $this->getMockBuilder(\OC\AppFramework\Utility\TimeFactory::class)->getMock(); - $this->avatarMock = $this->getMockBuilder('OCP\IAvatar')->getMock(); + $this->avatarMock = $this->getMockBuilder(\OCP\IAvatar::class)->getMock(); $this->userMock = $this->getMockBuilder(IUser::class)->getMock(); $this->guestAvatarController = new GuestAvatarController( @@ -392,7 +392,7 @@ public function testPostAvatarFileGif() { */ public function testPostAvatarFromFile() { //Mock node API call - $file = $this->getMockBuilder('OCP\Files\File') + $file = $this->getMockBuilder(\OCP\Files\File::class) ->disableOriginalConstructor()->getMock(); $file->expects($this->once()) ->method('getContent') @@ -400,7 +400,7 @@ public function testPostAvatarFromFile() { $file->expects($this->once()) ->method('getMimeType') ->willReturn('image/jpeg'); - $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(\OCP\Files\Folder::class)->getMock(); $this->rootFolder->method('getUserFolder')->with('userid')->willReturn($userFolder); $userFolder->method('get')->willReturn($file); @@ -415,8 +415,8 @@ public function testPostAvatarFromFile() { * Test posting avatar from existing folder */ public function testPostAvatarFromNoFile() { - $file = $this->getMockBuilder('OCP\Files\Node')->getMock(); - $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock(); + $file = $this->getMockBuilder(\OCP\Files\Node::class)->getMock(); + $userFolder = $this->getMockBuilder(\OCP\Files\Folder::class)->getMock(); $this->rootFolder->method('getUserFolder')->with('userid')->willReturn($userFolder); $userFolder ->method('get') @@ -431,14 +431,14 @@ public function testPostAvatarFromNoFile() { } public function testPostAvatarInvalidType() { - $file = $this->getMockBuilder('OCP\Files\File') + $file = $this->getMockBuilder(\OCP\Files\File::class) ->disableOriginalConstructor()->getMock(); $file->expects($this->never()) ->method('getContent'); $file->expects($this->exactly(2)) ->method('getMimeType') ->willReturn('text/plain'); - $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(\OCP\Files\Folder::class)->getMock(); $this->rootFolder->method('getUserFolder')->with('userid')->willReturn($userFolder); $userFolder->method('get')->willReturn($file); @@ -447,7 +447,7 @@ public function testPostAvatarInvalidType() { } public function testPostAvatarNotPermittedException() { - $file = $this->getMockBuilder('OCP\Files\File') + $file = $this->getMockBuilder(\OCP\Files\File::class) ->disableOriginalConstructor()->getMock(); $file->expects($this->once()) ->method('getContent') @@ -455,7 +455,7 @@ public function testPostAvatarNotPermittedException() { $file->expects($this->once()) ->method('getMimeType') ->willReturn('image/jpeg'); - $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(\OCP\Files\Folder::class)->getMock(); $this->rootFolder->method('getUserFolder')->with('userid')->willReturn($userFolder); $userFolder->method('get')->willReturn($file); @@ -470,7 +470,7 @@ public function testPostAvatarException() { $this->cache->expects($this->once()) ->method('set') ->will($this->throwException(new \Exception('foo'))); - $file = $this->getMockBuilder('OCP\Files\File') + $file = $this->getMockBuilder(\OCP\Files\File::class) ->disableOriginalConstructor()->getMock(); $file->expects($this->once()) ->method('getContent') @@ -478,7 +478,7 @@ public function testPostAvatarException() { $file->expects($this->once()) ->method('getMimeType') ->willReturn('image/jpeg'); - $userFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(\OCP\Files\Folder::class)->getMock(); $this->rootFolder->method('getUserFolder')->with('userid')->willReturn($userFolder); $userFolder->method('get')->willReturn($file); diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php index 7e9d085a291c0..d6729a98caf72 100644 --- a/tests/Core/Controller/LostControllerTest.php +++ b/tests/Core/Controller/LostControllerTest.php @@ -244,7 +244,7 @@ public function testEmailSuccessful() { ->method('linkToRouteAbsolute') ->with('core.lost.resetform', ['userId' => 'ExistingUser', 'token' => 'ThisIsMaybeANotSoSecretToken!']) ->willReturn('https://example.tld/index.php/lostpassword/'); - $message = $this->getMockBuilder('\OC\Mail\Message') + $message = $this->getMockBuilder(\OC\Mail\Message::class) ->disableOriginalConstructor()->getMock(); $message ->expects($this->once()) @@ -306,7 +306,7 @@ public function testEmailWithMailSuccessful() { ->method('linkToRouteAbsolute') ->with('core.lost.resetform', ['userId' => 'ExistingUser', 'token' => 'ThisIsMaybeANotSoSecretToken!']) ->willReturn('https://example.tld/index.php/lostpassword/'); - $message = $this->getMockBuilder('\OC\Mail\Message') + $message = $this->getMockBuilder(\OC\Mail\Message::class) ->disableOriginalConstructor()->getMock(); $message ->expects($this->once()) diff --git a/tests/lib/Activity/ManagerTest.php b/tests/lib/Activity/ManagerTest.php index 223021fa66a3a..931ea7e974e7f 100644 --- a/tests/lib/Activity/ManagerTest.php +++ b/tests/lib/Activity/ManagerTest.php @@ -221,7 +221,7 @@ public function testPublish($author, $expected) { ->setAffectedUser('test_affected') ->setObject('file', 123); - $consumer = $this->getMockBuilder('OCP\Activity\IConsumer') + $consumer = $this->getMockBuilder(\OCP\Activity\IConsumer::class) ->disableOriginalConstructor() ->getMock(); $consumer->expects($this->once()) @@ -252,7 +252,7 @@ public function testPublishAllManually() { ->setLink('test_link') ; - $consumer = $this->getMockBuilder('OCP\Activity\IConsumer') + $consumer = $this->getMockBuilder(\OCP\Activity\IConsumer::class) ->disableOriginalConstructor() ->getMock(); $consumer->expects($this->once()) diff --git a/tests/lib/AllConfigTest.php b/tests/lib/AllConfigTest.php index 73a62c6b8f21b..11d4ff4ded57e 100644 --- a/tests/lib/AllConfigTest.php +++ b/tests/lib/AllConfigTest.php @@ -30,7 +30,7 @@ protected function getConfig($systemConfig = null, $connection = null) { $connection = $this->connection; } if ($systemConfig === null) { - $systemConfig = $this->getMockBuilder('\OC\SystemConfig') + $systemConfig = $this->getMockBuilder(\OC\SystemConfig::class) ->disableOriginalConstructor() ->getMock(); } @@ -465,7 +465,7 @@ public function testDeleteAppFromAllUsers() { public function testGetUsersForUserValue() { // mock the check for the database to run the correct SQL statements for each database type - $systemConfig = $this->getMockBuilder('\OC\SystemConfig') + $systemConfig = $this->getMockBuilder(\OC\SystemConfig::class) ->disableOriginalConstructor() ->getMock(); $config = $this->getConfig($systemConfig); diff --git a/tests/lib/AppFramework/AppTest.php b/tests/lib/AppFramework/AppTest.php index 48f95564a221e..9b29389b6750e 100644 --- a/tests/lib/AppFramework/AppTest.php +++ b/tests/lib/AppFramework/AppTest.php @@ -55,7 +55,7 @@ protected function setUp(): void { $this->container[$this->controllerName] = $this->controller; $this->container['Dispatcher'] = $this->dispatcher; - $this->container['OCP\\AppFramework\\Http\\IOutput'] = $this->io; + $this->container[\OCP\AppFramework\Http\IOutput::class] = $this->io; $this->container['urlParams'] = ['_route' => 'not-profiler']; $this->appPath = __DIR__ . '/../../../apps/namespacetestapp'; @@ -151,7 +151,7 @@ public function testNoOutput(string $statusCode) { public function testCallbackIsCalled() { - $mock = $this->getMockBuilder('OCP\AppFramework\Http\ICallbackResponse') + $mock = $this->getMockBuilder(\OCP\AppFramework\Http\ICallbackResponse::class) ->getMock(); $return = ['HTTP/2.0 200 OK', [], [], $this->output, $mock]; diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php index ef37a0b8942a3..818c8041cdbbc 100644 --- a/tests/lib/AppFramework/Http/DispatcherTest.php +++ b/tests/lib/AppFramework/Http/DispatcherTest.php @@ -105,11 +105,11 @@ protected function setUp(): void { $this->eventLogger = $this->createMock(IEventLogger::class); $this->container = $this->createMock(ContainerInterface::class); $app = $this->getMockBuilder( - 'OC\AppFramework\DependencyInjection\DIContainer') + \OC\AppFramework\DependencyInjection\DIContainer::class) ->disableOriginalConstructor() ->getMock(); $request = $this->getMockBuilder( - '\OC\AppFramework\Http\Request') + \OC\AppFramework\Http\Request::class) ->disableOriginalConstructor() ->getMock(); $this->http = $this->getMockBuilder( @@ -118,17 +118,17 @@ protected function setUp(): void { ->getMock(); $this->middlewareDispatcher = $this->getMockBuilder( - '\OC\AppFramework\Middleware\MiddlewareDispatcher') + \OC\AppFramework\Middleware\MiddlewareDispatcher::class) ->disableOriginalConstructor() ->getMock(); $this->controller = $this->getMockBuilder( - '\OCP\AppFramework\Controller') + \OCP\AppFramework\Controller::class) ->setMethods([$this->controllerMethod]) ->setConstructorArgs([$app, $request]) ->getMock(); $this->request = $this->getMockBuilder( - '\OC\AppFramework\Http\Request') + \OC\AppFramework\Http\Request::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/AppFramework/Http/FileDisplayResponseTest.php b/tests/lib/AppFramework/Http/FileDisplayResponseTest.php index a75c6fdd59161..bb8c93237942e 100644 --- a/tests/lib/AppFramework/Http/FileDisplayResponseTest.php +++ b/tests/lib/AppFramework/Http/FileDisplayResponseTest.php @@ -18,7 +18,7 @@ class FileDisplayResponseTest extends \Test\TestCase { private $response; protected function setUp(): void { - $this->file = $this->getMockBuilder('OCP\Files\File') + $this->file = $this->getMockBuilder(\OCP\Files\File::class) ->getMock(); $this->file->expects($this->once()) @@ -51,7 +51,7 @@ public function testLastModified() { } public function test304() { - $output = $this->getMockBuilder('OCP\AppFramework\Http\IOutput') + $output = $this->getMockBuilder(\OCP\AppFramework\Http\IOutput::class) ->disableOriginalConstructor() ->getMock(); @@ -68,7 +68,7 @@ public function test304() { public function testNon304() { - $output = $this->getMockBuilder('OCP\AppFramework\Http\IOutput') + $output = $this->getMockBuilder(\OCP\AppFramework\Http\IOutput::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php index f97341cb265ef..1d448780feb66 100644 --- a/tests/lib/AppFramework/Http/RequestTest.php +++ b/tests/lib/AppFramework/Http/RequestTest.php @@ -33,7 +33,7 @@ protected function setUp(): void { if (in_array('fakeinput', stream_get_wrappers())) { stream_wrapper_unregister('fakeinput'); } - stream_wrapper_register('fakeinput', 'Test\AppFramework\Http\RequestStream'); + stream_wrapper_register('fakeinput', \Test\AppFramework\Http\RequestStream::class); $this->requestId = $this->createMock(IRequestId::class); $this->config = $this->createMock(IConfig::class); @@ -1690,7 +1690,7 @@ public function testGetRequestUriWithOverwrite($expectedUri, $overwriteWebRoot, public function testPassesCSRFCheckWithGet() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -1720,7 +1720,7 @@ public function testPassesCSRFCheckWithGet() { public function testPassesCSRFCheckWithPost() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -1750,7 +1750,7 @@ public function testPassesCSRFCheckWithPost() { public function testPassesCSRFCheckWithHeader() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -1780,7 +1780,7 @@ public function testPassesCSRFCheckWithHeader() { public function testPassesCSRFCheckWithGetAndWithoutCookies() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -1804,7 +1804,7 @@ public function testPassesCSRFCheckWithGetAndWithoutCookies() { public function testPassesCSRFCheckWithPostAndWithoutCookies() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -1828,7 +1828,7 @@ public function testPassesCSRFCheckWithPostAndWithoutCookies() { public function testPassesCSRFCheckWithHeaderAndWithoutCookies() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -1852,7 +1852,7 @@ public function testPassesCSRFCheckWithHeaderAndWithoutCookies() { public function testFailsCSRFCheckWithHeaderAndNotAllChecksPassing() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -1879,7 +1879,7 @@ public function testFailsCSRFCheckWithHeaderAndNotAllChecksPassing() { public function testPassesStrictCookieCheckWithAllCookiesAndStrict() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName', 'getCookieParams']) ->setConstructorArgs([ [ @@ -1911,7 +1911,7 @@ public function testPassesStrictCookieCheckWithAllCookiesAndStrict() { public function testFailsStrictCookieCheckWithAllCookiesAndMissingStrict() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName', 'getCookieParams']) ->setConstructorArgs([ [ @@ -1959,7 +1959,7 @@ public function testGetCookieParams() { public function testPassesStrictCookieCheckWithAllCookies() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -1984,7 +1984,7 @@ public function testPassesStrictCookieCheckWithAllCookies() { public function testPassesStrictCookieCheckWithRandomCookies() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -2007,7 +2007,7 @@ public function testPassesStrictCookieCheckWithRandomCookies() { public function testFailsStrictCookieCheckWithSessionCookie() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -2030,7 +2030,7 @@ public function testFailsStrictCookieCheckWithSessionCookie() { public function testFailsStrictCookieCheckWithRememberMeCookie() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -2053,7 +2053,7 @@ public function testFailsStrictCookieCheckWithRememberMeCookie() { public function testFailsCSRFCheckWithPostAndWithCookies() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -2080,7 +2080,7 @@ public function testFailsCSRFCheckWithPostAndWithCookies() { public function testFailStrictCookieCheckWithOnlyLaxCookie() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -2104,7 +2104,7 @@ public function testFailStrictCookieCheckWithOnlyLaxCookie() { public function testFailStrictCookieCheckWithOnlyStrictCookie() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -2128,7 +2128,7 @@ public function testFailStrictCookieCheckWithOnlyStrictCookie() { public function testPassesLaxCookieCheck() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -2152,7 +2152,7 @@ public function testPassesLaxCookieCheck() { public function testFailsLaxCookieCheckWithOnlyStrictCookie() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -2176,7 +2176,7 @@ public function testFailsLaxCookieCheckWithOnlyStrictCookie() { public function testSkipCookieCheckForOCSRequests() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -2216,7 +2216,7 @@ public function invalidTokenDataProvider() { */ public function testPassesCSRFCheckWithInvalidToken($invalidToken) { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ @@ -2243,7 +2243,7 @@ public function testPassesCSRFCheckWithInvalidToken($invalidToken) { public function testPassesCSRFCheckWithoutTokenFail() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [], @@ -2259,7 +2259,7 @@ public function testPassesCSRFCheckWithoutTokenFail() { public function testPassesCSRFCheckWithOCSAPIRequestHeader() { /** @var Request $request */ - $request = $this->getMockBuilder('\OC\AppFramework\Http\Request') + $request = $this->getMockBuilder(\OC\AppFramework\Http\Request::class) ->setMethods(['getScriptName']) ->setConstructorArgs([ [ diff --git a/tests/lib/AppFramework/Http/StreamResponseTest.php b/tests/lib/AppFramework/Http/StreamResponseTest.php index 637fb0251421c..67e7cc2f161f1 100644 --- a/tests/lib/AppFramework/Http/StreamResponseTest.php +++ b/tests/lib/AppFramework/Http/StreamResponseTest.php @@ -18,7 +18,7 @@ class StreamResponseTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->output = $this->getMockBuilder('OCP\\AppFramework\\Http\\IOutput') + $this->output = $this->getMockBuilder(\OCP\AppFramework\Http\IOutput::class) ->disableOriginalConstructor() ->getMock(); } diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php index cddec9bf256ea..f4921ba751907 100644 --- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php +++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php @@ -110,7 +110,7 @@ protected function setUp(): void { private function getControllerMock() { - return $this->getMockBuilder('OCP\AppFramework\Controller') + return $this->getMockBuilder(\OCP\AppFramework\Controller::class) ->setMethods(['method']) ->setConstructorArgs(['app', new Request( @@ -131,13 +131,13 @@ private function getMiddleware($beforeControllerThrowsEx = false) { public function testAfterExceptionShouldReturnResponseOfMiddleware() { $response = new Response(); - $m1 = $this->getMockBuilder('\OCP\AppFramework\Middleware') + $m1 = $this->getMockBuilder(\OCP\AppFramework\Middleware::class) ->setMethods(['afterException', 'beforeController']) ->getMock(); $m1->expects($this->never()) ->method('afterException'); - $m2 = $this->getMockBuilder('OCP\AppFramework\Middleware') + $m2 = $this->getMockBuilder(\OCP\AppFramework\Middleware::class) ->setMethods(['afterException', 'beforeController']) ->getMock(); $m2->expects($this->once()) diff --git a/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php b/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php index b7d14cb6cbafe..db58416859dae 100644 --- a/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php +++ b/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php @@ -59,7 +59,7 @@ class ControllerMethodReflectorTest extends \Test\TestCase { public function testReadAnnotation() { $reader = new ControllerMethodReflector(); $reader->reflect( - '\Test\AppFramework\Utility\ControllerMethodReflectorTest', + \Test\AppFramework\Utility\ControllerMethodReflectorTest::class, 'testReadAnnotation' ); @@ -101,7 +101,7 @@ public function testGetAnnotationParameterMultiple() { public function testReadAnnotationNoLowercase() { $reader = new ControllerMethodReflector(); $reader->reflect( - '\Test\AppFramework\Utility\ControllerMethodReflectorTest', + \Test\AppFramework\Utility\ControllerMethodReflectorTest::class, 'testReadAnnotationNoLowercase' ); @@ -117,7 +117,7 @@ public function testReadAnnotationNoLowercase() { public function testReadTypeIntAnnotations() { $reader = new ControllerMethodReflector(); $reader->reflect( - '\Test\AppFramework\Utility\ControllerMethodReflectorTest', + \Test\AppFramework\Utility\ControllerMethodReflectorTest::class, 'testReadTypeIntAnnotations' ); @@ -138,7 +138,7 @@ public function arguments3($a, float $b, int $c, $d) { public function testReadTypeIntAnnotationsScalarTypes() { $reader = new ControllerMethodReflector(); $reader->reflect( - '\Test\AppFramework\Utility\ControllerMethodReflectorTest', + \Test\AppFramework\Utility\ControllerMethodReflectorTest::class, 'arguments3' ); @@ -156,7 +156,7 @@ public function testReadTypeIntAnnotationsScalarTypes() { public function testReadTypeDoubleAnnotations() { $reader = new ControllerMethodReflector(); $reader->reflect( - '\Test\AppFramework\Utility\ControllerMethodReflectorTest', + \Test\AppFramework\Utility\ControllerMethodReflectorTest::class, 'testReadTypeDoubleAnnotations' ); @@ -170,7 +170,7 @@ public function testReadTypeDoubleAnnotations() { public function testReadTypeWhitespaceAnnotations() { $reader = new ControllerMethodReflector(); $reader->reflect( - '\Test\AppFramework\Utility\ControllerMethodReflectorTest', + \Test\AppFramework\Utility\ControllerMethodReflectorTest::class, 'testReadTypeWhitespaceAnnotations' ); @@ -183,7 +183,7 @@ public function arguments($arg, $arg2 = 'hi') { public function testReflectParameters() { $reader = new ControllerMethodReflector(); $reader->reflect( - '\Test\AppFramework\Utility\ControllerMethodReflectorTest', + \Test\AppFramework\Utility\ControllerMethodReflectorTest::class, 'arguments' ); @@ -196,7 +196,7 @@ public function arguments2($arg) { public function testReflectParameters2() { $reader = new ControllerMethodReflector(); $reader->reflect( - '\Test\AppFramework\Utility\ControllerMethodReflectorTest', + \Test\AppFramework\Utility\ControllerMethodReflectorTest::class, 'arguments2' ); @@ -206,7 +206,7 @@ public function testReflectParameters2() { public function testInheritance() { $reader = new ControllerMethodReflector(); - $reader->reflect('Test\AppFramework\Utility\EndController', 'test'); + $reader->reflect(\Test\AppFramework\Utility\EndController::class, 'test'); $this->assertTrue($reader->hasAnnotation('Annotation')); } @@ -214,7 +214,7 @@ public function testInheritance() { public function testInheritanceOverride() { $reader = new ControllerMethodReflector(); - $reader->reflect('Test\AppFramework\Utility\EndController', 'test2'); + $reader->reflect(\Test\AppFramework\Utility\EndController::class, 'test2'); $this->assertTrue($reader->hasAnnotation('NoAnnotation')); $this->assertFalse($reader->hasAnnotation('Annotation')); @@ -223,14 +223,14 @@ public function testInheritanceOverride() { public function testInheritanceOverrideNoDocblock() { $reader = new ControllerMethodReflector(); - $reader->reflect('Test\AppFramework\Utility\EndController', 'test3'); + $reader->reflect(\Test\AppFramework\Utility\EndController::class, 'test3'); $this->assertFalse($reader->hasAnnotation('Annotation')); } public function testRangeDetection() { $reader = new ControllerMethodReflector(); - $reader->reflect('Test\AppFramework\Utility\EndController', 'test4'); + $reader->reflect(\Test\AppFramework\Utility\EndController::class, 'test4'); $rangeInfo1 = $reader->getRange('rangedOne'); $this->assertSame(-4, $rangeInfo1['min']); diff --git a/tests/lib/AppFramework/Utility/SimpleContainerTest.php b/tests/lib/AppFramework/Utility/SimpleContainerTest.php index d27d29db95169..b389282e660f4 100644 --- a/tests/lib/AppFramework/Utility/SimpleContainerTest.php +++ b/tests/lib/AppFramework/Utility/SimpleContainerTest.php @@ -105,26 +105,26 @@ public function testNothingRegistered_autoload() { public function testNotAClass() { $this->expectException(\OCP\AppFramework\QueryException::class); - $this->container->query('Test\AppFramework\Utility\TestInterface'); + $this->container->query(\Test\AppFramework\Utility\TestInterface::class); } public function testNoConstructorClass() { - $object = $this->container->query('Test\AppFramework\Utility\ClassEmptyConstructor'); + $object = $this->container->query(\Test\AppFramework\Utility\ClassEmptyConstructor::class); $this->assertTrue($object instanceof ClassEmptyConstructor); } public function testInstancesOnlyOnce() { - $object = $this->container->query('Test\AppFramework\Utility\ClassEmptyConstructor'); - $object2 = $this->container->query('Test\AppFramework\Utility\ClassEmptyConstructor'); + $object = $this->container->query(\Test\AppFramework\Utility\ClassEmptyConstructor::class); + $object2 = $this->container->query(\Test\AppFramework\Utility\ClassEmptyConstructor::class); $this->assertSame($object, $object2); } public function testConstructorSimple() { $this->container->registerParameter('test', 'abc'); $object = $this->container->query( - 'Test\AppFramework\Utility\ClassSimpleConstructor' + \Test\AppFramework\Utility\ClassSimpleConstructor::class ); $this->assertTrue($object instanceof ClassSimpleConstructor); $this->assertEquals('abc', $object->test); @@ -134,7 +134,7 @@ public function testConstructorSimple() { public function testConstructorComplex() { $this->container->registerParameter('test', 'abc'); $object = $this->container->query( - 'Test\AppFramework\Utility\ClassComplexConstructor' + \Test\AppFramework\Utility\ClassComplexConstructor::class ); $this->assertTrue($object instanceof ClassComplexConstructor); $this->assertEquals('abc', $object->class->test); @@ -145,11 +145,11 @@ public function testConstructorComplex() { public function testConstructorComplexInterface() { $this->container->registerParameter('test', 'abc'); $this->container->registerService( - 'Test\AppFramework\Utility\IInterfaceConstructor', function ($c) { - return $c->query('Test\AppFramework\Utility\ClassSimpleConstructor'); + \Test\AppFramework\Utility\IInterfaceConstructor::class, function ($c) { + return $c->query(\Test\AppFramework\Utility\ClassSimpleConstructor::class); }); $object = $this->container->query( - 'Test\AppFramework\Utility\ClassInterfaceConstructor' + \Test\AppFramework\Utility\ClassInterfaceConstructor::class ); $this->assertTrue($object instanceof ClassInterfaceConstructor); $this->assertEquals('abc', $object->class->test); @@ -159,15 +159,15 @@ public function testConstructorComplexInterface() { public function testOverrideService() { $this->container->registerService( - 'Test\AppFramework\Utility\IInterfaceConstructor', function ($c) { - return $c->query('Test\AppFramework\Utility\ClassSimpleConstructor'); + \Test\AppFramework\Utility\IInterfaceConstructor::class, function ($c) { + return $c->query(\Test\AppFramework\Utility\ClassSimpleConstructor::class); }); $this->container->registerService( - 'Test\AppFramework\Utility\IInterfaceConstructor', function ($c) { - return $c->query('Test\AppFramework\Utility\ClassEmptyConstructor'); + \Test\AppFramework\Utility\IInterfaceConstructor::class, function ($c) { + return $c->query(\Test\AppFramework\Utility\ClassEmptyConstructor::class); }); $object = $this->container->query( - 'Test\AppFramework\Utility\IInterfaceConstructor' + \Test\AppFramework\Utility\IInterfaceConstructor::class ); $this->assertTrue($object instanceof ClassEmptyConstructor); } @@ -215,7 +215,7 @@ public function testConstructorComplexNoTestParameterFound() { $this->expectException(\OCP\AppFramework\QueryException::class); $object = $this->container->query( - 'Test\AppFramework\Utility\ClassComplexConstructor' + \Test\AppFramework\Utility\ClassComplexConstructor::class ); } diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php index a89b07f7716e1..6e5e4e1eea109 100644 --- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php @@ -102,7 +102,7 @@ protected function setUp(): void { $this->fakeProvider = $this->createMock(IProvider::class); $this->fakeProvider->method('getId')->willReturn('email'); - $this->backupProvider = $this->getMockBuilder('\OCP\Authentication\TwoFactorAuth\IProvider')->getMock(); + $this->backupProvider = $this->getMockBuilder(\OCP\Authentication\TwoFactorAuth\IProvider::class)->getMock(); $this->backupProvider->method('getId')->willReturn('backup_codes'); $this->backupProvider->method('isTwoFactorAuthEnabledForUser')->willReturn(true); } diff --git a/tests/lib/AutoLoaderTest.php b/tests/lib/AutoLoaderTest.php index 22d66c6c4aa3a..6992afd19d3e3 100644 --- a/tests/lib/AutoLoaderTest.php +++ b/tests/lib/AutoLoaderTest.php @@ -27,7 +27,7 @@ public function testLegacyPath() { public function testLoadTestTestCase() { $this->assertEquals([ \OC::$SERVERROOT . '/tests/lib/TestCase.php' - ], $this->loader->findClass('Test\TestCase')); + ], $this->loader->findClass(\Test\TestCase::class)); } public function testLoadCore() { diff --git a/tests/lib/BackgroundJob/JobListTest.php b/tests/lib/BackgroundJob/JobListTest.php index 510d307eda8e4..7dfaf158f8558 100644 --- a/tests/lib/BackgroundJob/JobListTest.php +++ b/tests/lib/BackgroundJob/JobListTest.php @@ -96,7 +96,7 @@ public function testAddRemove($argument) { $this->assertCount(count($existingJobs) + 1, $jobs); $addedJob = $jobs[count($jobs) - 1]; - $this->assertInstanceOf('\Test\BackgroundJob\TestJob', $addedJob); + $this->assertInstanceOf(\Test\BackgroundJob\TestJob::class, $addedJob); $this->assertEquals($argument, $addedJob->getArgument()); $this->instance->remove($job, $argument); diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php index b21e6f1ba4dab..251b9905904e2 100644 --- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php @@ -594,7 +594,7 @@ function ($appName, $key, $default) { $this->instantiatePlugin(); /** @var \OCP\IUser | \PHPUnit\Framework\MockObject\MockObject */ - $currentUser = $this->createMock('\OCP\IUser'); + $currentUser = $this->createMock(\OCP\IUser::class); $currentUser->expects($this->any()) ->method('getUID') diff --git a/tests/lib/Command/AsyncBusTest.php b/tests/lib/Command/AsyncBusTest.php index 7492a4912d771..12d6a3ddecc22 100644 --- a/tests/lib/Command/AsyncBusTest.php +++ b/tests/lib/Command/AsyncBusTest.php @@ -107,7 +107,7 @@ public function testStateFullCommand() { } public function testStaticCallable() { - $this->getBus()->push(['\Test\Command\AsyncBusTest', 'DummyCommand']); + $this->getBus()->push([\Test\Command\AsyncBusTest::class, 'DummyCommand']); $this->runJobs(); $this->assertEquals('static', self::$lastCommand); } @@ -167,7 +167,7 @@ public function testFileFileAccessCommand() { } public function testFileFileAccessCommandSync() { - $this->getBus()->requireSync('\OC\Command\FileAccess'); + $this->getBus()->requireSync(\OC\Command\FileAccess::class); $this->getBus()->push(new FilesystemCommand()); $this->assertEquals('FileAccess', self::$lastCommand); self::$lastCommand = ''; diff --git a/tests/lib/ContactsManagerTest.php b/tests/lib/ContactsManagerTest.php index 91053cd0b52fa..8219c5899d650 100644 --- a/tests/lib/ContactsManagerTest.php +++ b/tests/lib/ContactsManagerTest.php @@ -67,7 +67,7 @@ public function searchProvider() { */ public function testSearch($search1, $search2, $expectedResult) { /** @var \PHPUnit\Framework\MockObject\MockObject|IAddressBook $addressbook */ - $addressbook1 = $this->getMockBuilder('\OCP\IAddressBook') + $addressbook1 = $this->getMockBuilder(\OCP\IAddressBook::class) ->disableOriginalConstructor() ->getMock(); @@ -79,7 +79,7 @@ public function testSearch($search1, $search2, $expectedResult) { ->method('getKey') ->willReturn('simple:1'); - $addressbook2 = $this->getMockBuilder('\OCP\IAddressBook') + $addressbook2 = $this->getMockBuilder(\OCP\IAddressBook::class) ->disableOriginalConstructor() ->getMock(); @@ -101,7 +101,7 @@ public function testSearch($search1, $search2, $expectedResult) { public function testDeleteHavePermission() { /** @var \PHPUnit\Framework\MockObject\MockObject|IAddressBook $addressbook */ - $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + $addressbook = $this->getMockBuilder(\OCP\IAddressBook::class) ->disableOriginalConstructor() ->getMock(); @@ -124,7 +124,7 @@ public function testDeleteHavePermission() { public function testDeleteNoPermission() { /** @var \PHPUnit\Framework\MockObject\MockObject|IAddressBook $addressbook */ - $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + $addressbook = $this->getMockBuilder(\OCP\IAddressBook::class) ->disableOriginalConstructor() ->getMock(); @@ -146,7 +146,7 @@ public function testDeleteNoPermission() { public function testDeleteNoAddressbook() { /** @var \PHPUnit\Framework\MockObject\MockObject|IAddressBook $addressbook */ - $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + $addressbook = $this->getMockBuilder(\OCP\IAddressBook::class) ->disableOriginalConstructor() ->getMock(); @@ -164,7 +164,7 @@ public function testDeleteNoAddressbook() { public function testCreateOrUpdateHavePermission() { /** @var \PHPUnit\Framework\MockObject\MockObject|IAddressBook $addressbook */ - $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + $addressbook = $this->getMockBuilder(\OCP\IAddressBook::class) ->disableOriginalConstructor() ->getMock(); @@ -187,7 +187,7 @@ public function testCreateOrUpdateHavePermission() { public function testCreateOrUpdateNoPermission() { /** @var \PHPUnit\Framework\MockObject\MockObject|IAddressBook $addressbook */ - $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + $addressbook = $this->getMockBuilder(\OCP\IAddressBook::class) ->disableOriginalConstructor() ->getMock(); @@ -209,7 +209,7 @@ public function testCreateOrUpdateNoPermission() { public function testCreateOrUpdateNOAdressbook() { /** @var \PHPUnit\Framework\MockObject\MockObject|IAddressBook $addressbook */ - $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + $addressbook = $this->getMockBuilder(\OCP\IAddressBook::class) ->disableOriginalConstructor() ->getMock(); @@ -232,7 +232,7 @@ public function testIsEnabledIfNot() { public function testIsEnabledIfSo() { /** @var \PHPUnit\Framework\MockObject\MockObject|IAddressBook $addressbook */ - $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + $addressbook = $this->getMockBuilder(\OCP\IAddressBook::class) ->disableOriginalConstructor() ->getMock(); @@ -248,7 +248,7 @@ public function testIsEnabledIfSo() { public function testAddressBookEnumeration() { // create mock for the addressbook /** @var \PHPUnit\Framework\MockObject\MockObject|IAddressBook $addressbook */ - $addressbook = $this->getMockBuilder('\OCP\IAddressBook') + $addressbook = $this->getMockBuilder(\OCP\IAddressBook::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php index a088ca1baf0d0..eff7b764958a2 100644 --- a/tests/lib/DB/MigrationsTest.php +++ b/tests/lib/DB/MigrationsTest.php @@ -823,14 +823,14 @@ private function getMigrationMetadata(): array { return [ '30000Date20240102030405' => [ [ - 'class' => 'OCP\\Migration\\Attributes\\DropTable', + 'class' => \OCP\Migration\Attributes\DropTable::class, 'table' => 'old_table', 'description' => '', 'notes' => [], 'columns' => [] ], [ - 'class' => 'OCP\\Migration\\Attributes\\CreateTable', + 'class' => \OCP\Migration\Attributes\CreateTable::class, 'table' => 'new_table', 'description' => 'Table is used to store things, but also to get more things', 'notes' => @@ -841,7 +841,7 @@ private function getMigrationMetadata(): array { 'columns' => [] ], [ - 'class' => 'OCP\\Migration\\Attributes\\AddColumn', + 'class' => \OCP\Migration\Attributes\AddColumn::class, 'table' => 'my_table', 'description' => '', 'notes' => [], @@ -849,7 +849,7 @@ private function getMigrationMetadata(): array { 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\AddColumn', + 'class' => \OCP\Migration\Attributes\AddColumn::class, 'table' => 'my_table', 'description' => '', 'notes' => [], @@ -857,7 +857,7 @@ private function getMigrationMetadata(): array { 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\AddColumn', + 'class' => \OCP\Migration\Attributes\AddColumn::class, 'table' => 'other_table', 'description' => '', 'notes' => [], @@ -865,21 +865,21 @@ private function getMigrationMetadata(): array { 'type' => 'date' ], [ - 'class' => 'OCP\\Migration\\Attributes\\AddIndex', + 'class' => \OCP\Migration\Attributes\AddIndex::class, 'table' => 'my_table', 'description' => '', 'notes' => [], 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\AddIndex', + 'class' => \OCP\Migration\Attributes\AddIndex::class, 'table' => 'my_table', 'description' => '', 'notes' => [], 'type' => 'primary' ], [ - 'class' => 'OCP\\Migration\\Attributes\\DropColumn', + 'class' => \OCP\Migration\Attributes\DropColumn::class, 'table' => 'other_table', 'description' => '', 'notes' => [], @@ -887,7 +887,7 @@ private function getMigrationMetadata(): array { 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\DropColumn', + 'class' => \OCP\Migration\Attributes\DropColumn::class, 'table' => 'other_table', 'description' => 'field is not used anymore and replaced by \'last_one\'', 'notes' => [], @@ -895,14 +895,14 @@ private function getMigrationMetadata(): array { 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\DropIndex', + 'class' => \OCP\Migration\Attributes\DropIndex::class, 'table' => 'other_table', 'description' => '', 'notes' => [], 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\ModifyColumn', + 'class' => \OCP\Migration\Attributes\ModifyColumn::class, 'table' => 'other_table', 'description' => '', 'notes' => [], @@ -910,7 +910,7 @@ private function getMigrationMetadata(): array { 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\ModifyColumn', + 'class' => \OCP\Migration\Attributes\ModifyColumn::class, 'table' => 'other_table', 'description' => '', 'notes' => [], @@ -918,7 +918,7 @@ private function getMigrationMetadata(): array { 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\ModifyColumn', + 'class' => \OCP\Migration\Attributes\ModifyColumn::class, 'table' => 'other_table', 'description' => '', 'notes' => [], diff --git a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php index 4ac5cbc8292db..33a047e106b03 100644 --- a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php +++ b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php @@ -338,7 +338,7 @@ public function testLiteral($input, $type) { /** @var \OC\DB\QueryBuilder\Literal $actual */ $actual = $this->expressionBuilder->literal($input, $type); - $this->assertInstanceOf('\OC\DB\QueryBuilder\Literal', $actual); + $this->assertInstanceOf(\OC\DB\QueryBuilder\Literal::class, $actual); $this->assertEquals( $this->doctrineExpressionBuilder->literal($input, $type), $actual->__toString() diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php index a74c030898636..52f120fde82b6 100644 --- a/tests/lib/Encryption/DecryptAllTest.php +++ b/tests/lib/Encryption/DecryptAllTest.php @@ -55,7 +55,7 @@ protected function setUp(): void { $this->userManager = $this->getMockBuilder(IUserManager::class) ->disableOriginalConstructor()->getMock(); - $this->encryptionManager = $this->getMockBuilder('OC\Encryption\Manager') + $this->encryptionManager = $this->getMockBuilder(\OC\Encryption\Manager::class) ->disableOriginalConstructor()->getMock(); $this->view = $this->getMockBuilder(View::class) ->disableOriginalConstructor()->getMock(); @@ -105,7 +105,7 @@ public function testDecryptAll($prepareResult, $user, $userExistsChecked) { $this->userManager->expects($this->never())->method('userExists'); } /** @var DecryptAll | \PHPUnit\Framework\MockObject\MockObject | $instance */ - $instance = $this->getMockBuilder('OC\Encryption\DecryptAll') + $instance = $this->getMockBuilder(\OC\Encryption\DecryptAll::class) ->setConstructorArgs( [ $this->encryptionManager, @@ -159,7 +159,7 @@ public function dataTrueFalse() { public function testPrepareEncryptionModules($success) { $user = 'user1'; - $dummyEncryptionModule = $this->getMockBuilder('OCP\Encryption\IEncryptionModule') + $dummyEncryptionModule = $this->getMockBuilder(\OCP\Encryption\IEncryptionModule::class) ->disableOriginalConstructor()->getMock(); $dummyEncryptionModule->expects($this->once()) @@ -190,7 +190,7 @@ public function testPrepareEncryptionModules($success) { */ public function testDecryptAllUsersFiles($user) { /** @var DecryptAll | \PHPUnit\Framework\MockObject\MockObject | $instance */ - $instance = $this->getMockBuilder('OC\Encryption\DecryptAll') + $instance = $this->getMockBuilder(\OC\Encryption\DecryptAll::class) ->setConstructorArgs( [ $this->encryptionManager, @@ -235,7 +235,7 @@ public function dataTestDecryptAllUsersFiles() { public function testDecryptUsersFiles() { /** @var DecryptAll | \PHPUnit\Framework\MockObject\MockObject $instance */ - $instance = $this->getMockBuilder('OC\Encryption\DecryptAll') + $instance = $this->getMockBuilder(\OC\Encryption\DecryptAll::class) ->setConstructorArgs( [ $this->encryptionManager, @@ -254,7 +254,7 @@ public function testDecryptUsersFiles() { ->disableOriginalConstructor()->getMock(); $sharedStorage->expects($this->once())->method('instanceOfStorage') - ->with('OCA\Files_Sharing\SharedStorage')->willReturn(true); + ->with(\OCA\Files_Sharing\SharedStorage::class)->willReturn(true); $this->view->expects($this->exactly(2)) ->method('getDirectoryContent') @@ -312,7 +312,7 @@ public function testDecryptFile($isEncrypted) { $path = 'test.txt'; /** @var DecryptAll | \PHPUnit\Framework\MockObject\MockObject $instance */ - $instance = $this->getMockBuilder('OC\Encryption\DecryptAll') + $instance = $this->getMockBuilder(\OC\Encryption\DecryptAll::class) ->setConstructorArgs( [ $this->encryptionManager, @@ -352,7 +352,7 @@ public function testDecryptFileFailure() { $path = 'test.txt'; /** @var DecryptAll | \PHPUnit\Framework\MockObject\MockObject $instance */ - $instance = $this->getMockBuilder('OC\Encryption\DecryptAll') + $instance = $this->getMockBuilder(\OC\Encryption\DecryptAll::class) ->setConstructorArgs( [ $this->encryptionManager, diff --git a/tests/lib/Encryption/EncryptionWrapperTest.php b/tests/lib/Encryption/EncryptionWrapperTest.php index a5985c6c30de6..00460e34ecb56 100644 --- a/tests/lib/Encryption/EncryptionWrapperTest.php +++ b/tests/lib/Encryption/EncryptionWrapperTest.php @@ -54,7 +54,7 @@ public function testWrapStorage($expectedWrapped, $wrappedStorages) { ]); } - $mount = $this->getMockBuilder('OCP\Files\Mount\IMountPoint') + $mount = $this->getMockBuilder(\OCP\Files\Mount\IMountPoint::class) ->disableOriginalConstructor() ->getMock(); @@ -62,7 +62,7 @@ public function testWrapStorage($expectedWrapped, $wrappedStorages) { $this->assertEquals( $expectedWrapped, - $returnedStorage->instanceOfStorage('OC\Files\Storage\Wrapper\Encryption'), + $returnedStorage->instanceOfStorage(\OC\Files\Storage\Wrapper\Encryption::class), 'Asserted that the storage is (not) wrapped with encryption' ); } @@ -71,7 +71,7 @@ public function provideWrapStorage() { return [ // Wrap when not wrapped or not wrapped with storage [true, []], - [true, ['OCA\Files_Trashbin\Storage']], + [true, [\OCA\Files_Trashbin\Storage::class]], // Do not wrap shared storages [false, [Storage\IDisableEncryptionStorage::class]], diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php index 1f6773b1663cb..2fcdd8abc1674 100644 --- a/tests/lib/Encryption/Keys/StorageTest.php +++ b/tests/lib/Encryption/Keys/StorageTest.php @@ -36,7 +36,7 @@ class StorageTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->util = $this->getMockBuilder('OC\Encryption\Util') + $this->util = $this->getMockBuilder(\OC\Encryption\Util::class) ->disableOriginalConstructor() ->setMethodsExcept(['getFileKeyDir']) ->getMock(); @@ -575,7 +575,7 @@ public function mkdirCallback() { * @param bool $createBackupDir */ public function testBackupUserKeys($createBackupDir) { - $storage = $this->getMockBuilder('OC\Encryption\Keys\Storage') + $storage = $this->getMockBuilder(\OC\Encryption\Keys\Storage::class) ->setConstructorArgs([$this->view, $this->util, $this->crypto, $this->config]) ->setMethods(['getTimestamp']) ->getMock(); diff --git a/tests/lib/Encryption/UpdateTest.php b/tests/lib/Encryption/UpdateTest.php index a87a39fdf86cc..1f20ac9ba51bd 100644 --- a/tests/lib/Encryption/UpdateTest.php +++ b/tests/lib/Encryption/UpdateTest.php @@ -203,7 +203,7 @@ public function dataTestPostRestore() { * @return \OC\Encryption\Update | \PHPUnit\Framework\MockObject\MockObject */ protected function getUpdateMock($methods) { - return $this->getMockBuilder('\OC\Encryption\Update') + return $this->getMockBuilder(\OC\Encryption\Update::class) ->setConstructorArgs( [ $this->view, diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php index b90b67a6589ef..eca3531a7be1a 100644 --- a/tests/lib/Files/Cache/CacheTest.php +++ b/tests/lib/Files/Cache/CacheTest.php @@ -638,7 +638,7 @@ public function testWithNormalizer() { $this->assertEquals($folderWith00F6, $unNormalizedFolderName['name']); // put normalized folder - $this->assertInstanceOf('\OCP\Files\Cache\ICacheEntry', $this->cache->get('folder/' . $folderWith00F6)); + $this->assertInstanceOf(\OCP\Files\Cache\ICacheEntry::class, $this->cache->get('folder/' . $folderWith00F6)); $this->assertGreaterThan(0, $this->cache->put('folder/' . $folderWith00F6, $data)); // at this point we should have only one folder named "Schön" diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php index d84f4469e8b0c..8da2f380955d4 100644 --- a/tests/lib/Files/Config/UserMountCacheTest.php +++ b/tests/lib/Files/Config/UserMountCacheTest.php @@ -88,21 +88,21 @@ protected function tearDown(): void { private function getStorage($storageId, $rootInternalPath = '') { $rootId = $this->createCacheEntry($rootInternalPath, $storageId); - $storageCache = $this->getMockBuilder('\OC\Files\Cache\Storage') + $storageCache = $this->getMockBuilder(\OC\Files\Cache\Storage::class) ->disableOriginalConstructor() ->getMock(); $storageCache->expects($this->any()) ->method('getNumericId') ->willReturn($storageId); - $cache = $this->getMockBuilder('\OC\Files\Cache\Cache') + $cache = $this->getMockBuilder(\OC\Files\Cache\Cache::class) ->disableOriginalConstructor() ->getMock(); $cache->expects($this->any()) ->method('getId') ->willReturn($rootId); - $storage = $this->getMockBuilder('\OC\Files\Storage\Storage') + $storage = $this->getMockBuilder(\OC\Files\Storage\Storage::class) ->disableOriginalConstructor() ->getMock(); $storage->expects($this->any()) @@ -425,7 +425,7 @@ public function testGetMountsForFileIdSubFolderMount() { $fileId = $this->createCacheEntry('/foo/bar', 2); - $mount1 = $this->getMockBuilder('\OC\Files\Mount\MountPoint') + $mount1 = $this->getMockBuilder(\OC\Files\Mount\MountPoint::class) ->setConstructorArgs([$storage1, '/']) ->setMethods(['getStorageRootId']) ->getMock(); @@ -458,7 +458,7 @@ public function testGetMountsForFileIdSubFolderMountOutside() { $folderId = $this->createCacheEntry('/foo', 2); $fileId = $this->createCacheEntry('/bar/asd', 2); - $mount1 = $this->getMockBuilder('\OC\Files\Mount\MountPoint') + $mount1 = $this->getMockBuilder(\OC\Files\Mount\MountPoint::class) ->setConstructorArgs([$storage1, '/foo/']) ->setMethods(['getStorageRootId']) ->getMock(); diff --git a/tests/lib/Files/EtagTest.php b/tests/lib/Files/EtagTest.php index a109a17d2509b..b70785b192e84 100644 --- a/tests/lib/Files/EtagTest.php +++ b/tests/lib/Files/EtagTest.php @@ -36,8 +36,8 @@ protected function setUp(): void { // init files sharing new Application(); - \OC\Share\Share::registerBackend('file', 'OCA\Files_Sharing\ShareBackend\File'); - \OC\Share\Share::registerBackend('folder', 'OCA\Files_Sharing\ShareBackend\Folder', 'file'); + \OC\Share\Share::registerBackend('file', \OCA\Files_Sharing\ShareBackend\File::class); + \OC\Share\Share::registerBackend('folder', \OCA\Files_Sharing\ShareBackend\Folder::class, 'file'); $config = \OC::$server->getConfig(); $this->datadir = $config->getSystemValueString('datadirectory'); diff --git a/tests/lib/Files/FilesystemTest.php b/tests/lib/Files/FilesystemTest.php index f7964feeae8ab..1045c9684170c 100644 --- a/tests/lib/Files/FilesystemTest.php +++ b/tests/lib/Files/FilesystemTest.php @@ -76,12 +76,12 @@ protected function tearDown(): void { } $this->logout(); - $this->invokePrivate('\OC\Files\Filesystem', 'normalizedPathCache', [null]); + $this->invokePrivate(\OC\Files\Filesystem::class, 'normalizedPathCache', [null]); parent::tearDown(); } public function testMount() { - \OC\Files\Filesystem::mount('\OC\Files\Storage\Local', self::getStorageData(), '/'); + \OC\Files\Filesystem::mount(\OC\Files\Storage\Local::class, self::getStorageData(), '/'); $this->assertEquals('/', \OC\Files\Filesystem::getMountPoint('/')); $this->assertEquals('/', \OC\Files\Filesystem::getMountPoint('/some/folder')); [, $internalPath] = \OC\Files\Filesystem::resolvePath('/'); @@ -89,7 +89,7 @@ public function testMount() { [, $internalPath] = \OC\Files\Filesystem::resolvePath('/some/folder'); $this->assertEquals('some/folder', $internalPath); - \OC\Files\Filesystem::mount('\OC\Files\Storage\Local', self::getStorageData(), '/some'); + \OC\Files\Filesystem::mount(\OC\Files\Storage\Local::class, self::getStorageData(), '/some'); $this->assertEquals('/', \OC\Files\Filesystem::getMountPoint('/')); $this->assertEquals('/some/', \OC\Files\Filesystem::getMountPoint('/some/folder')); $this->assertEquals('/some/', \OC\Files\Filesystem::getMountPoint('/some/')); @@ -304,7 +304,7 @@ public function testHooks() { \OC_Hook::clear('OC_Filesystem'); \OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook'); - \OC\Files\Filesystem::mount('OC\Files\Storage\Temporary', [], '/'); + \OC\Files\Filesystem::mount(\OC\Files\Storage\Temporary::class, [], '/'); $rootView = new \OC\Files\View(''); $rootView->mkdir('/' . $user); @@ -388,10 +388,10 @@ public function testHomeMount() { $homeMount = \OC\Files\Filesystem::getStorage('/' . $userId . '/'); - $this->assertTrue($homeMount->instanceOfStorage('\OCP\Files\IHomeStorage')); - if ($homeMount->instanceOfStorage('\OC\Files\ObjectStore\HomeObjectStoreStorage')) { + $this->assertTrue($homeMount->instanceOfStorage(\OCP\Files\IHomeStorage::class)); + if ($homeMount->instanceOfStorage(\OC\Files\ObjectStore\HomeObjectStoreStorage::class)) { $this->assertEquals('object::user:' . $userId, $homeMount->getId()); - } elseif ($homeMount->instanceOfStorage('\OC\Files\Storage\Home')) { + } elseif ($homeMount->instanceOfStorage(\OC\Files\Storage\Home::class)) { $this->assertEquals('home::' . $userId, $homeMount->getId()); } @@ -424,7 +424,7 @@ public function testMountDefaultCacheDir() { \OC\Files\Filesystem::getMountPoint('/' . $userId . '/cache') ); [$storage, $internalPath] = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache'); - $this->assertTrue($storage->instanceOfStorage('\OCP\Files\IHomeStorage')); + $this->assertTrue($storage->instanceOfStorage(\OCP\Files\IHomeStorage::class)); $this->assertEquals('cache', $internalPath); $user = \OC::$server->getUserManager()->get($userId); if ($user !== null) { @@ -455,7 +455,7 @@ public function testMountExternalCacheDir() { \OC\Files\Filesystem::getMountPoint('/' . $userId . '/cache') ); [$storage, $internalPath] = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache'); - $this->assertTrue($storage->instanceOfStorage('\OC\Files\Storage\Local')); + $this->assertTrue($storage->instanceOfStorage(\OC\Files\Storage\Local::class)); $this->assertEquals('', $internalPath); $user = \OC::$server->getUserManager()->get($userId); if ($user !== null) { diff --git a/tests/lib/Files/Mount/MountPointTest.php b/tests/lib/Files/Mount/MountPointTest.php index 189667df276da..b5ba7e0155855 100644 --- a/tests/lib/Files/Mount/MountPointTest.php +++ b/tests/lib/Files/Mount/MountPointTest.php @@ -27,7 +27,7 @@ public function testGetStorage() { $mountPoint = new \OC\Files\Mount\MountPoint( // just use this because a real class is needed - '\Test\Files\Mount\DummyStorage', + \Test\Files\Mount\DummyStorage::class, '/mountpoint', null, $loader @@ -54,7 +54,7 @@ public function testInvalidStorage() { $mountPoint = new \OC\Files\Mount\MountPoint( // just use this because a real class is needed - '\Test\Files\Mount\DummyStorage', + \Test\Files\Mount\DummyStorage::class, '/mountpoint', null, $loader diff --git a/tests/lib/Files/Mount/MountTest.php b/tests/lib/Files/Mount/MountTest.php index 0b4c6a214f3c0..e33fb9505a298 100644 --- a/tests/lib/Files/Mount/MountTest.php +++ b/tests/lib/Files/Mount/MountTest.php @@ -12,33 +12,33 @@ class MountTest extends \Test\TestCase { public function testFromStorageObject() { - $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary') + $storage = $this->getMockBuilder(\OC\Files\Storage\Temporary::class) ->disableOriginalConstructor() ->getMock(); $mount = new \OC\Files\Mount\MountPoint($storage, '/foo'); - $this->assertInstanceOf('\OC\Files\Storage\Temporary', $mount->getStorage()); + $this->assertInstanceOf(\OC\Files\Storage\Temporary::class, $mount->getStorage()); } public function testFromStorageClassname() { - $mount = new \OC\Files\Mount\MountPoint('\OC\Files\Storage\Temporary', '/foo'); - $this->assertInstanceOf('\OC\Files\Storage\Temporary', $mount->getStorage()); + $mount = new \OC\Files\Mount\MountPoint(\OC\Files\Storage\Temporary::class, '/foo'); + $this->assertInstanceOf(\OC\Files\Storage\Temporary::class, $mount->getStorage()); } public function testWrapper() { $test = $this; $wrapper = function ($mountPoint, $storage) use (&$test) { $test->assertEquals('/foo/', $mountPoint); - $test->assertInstanceOf('\OC\Files\Storage\Storage', $storage); + $test->assertInstanceOf(\OC\Files\Storage\Storage::class, $storage); return new Wrapper(['storage' => $storage]); }; $loader = new StorageFactory(); $loader->addStorageWrapper('test_wrapper', $wrapper); - $storage = $this->getMockBuilder('\OC\Files\Storage\Temporary') + $storage = $this->getMockBuilder(\OC\Files\Storage\Temporary::class) ->disableOriginalConstructor() ->getMock(); $mount = new \OC\Files\Mount\MountPoint($storage, '/foo', [], $loader); - $this->assertInstanceOf('\OC\Files\Storage\Wrapper\Wrapper', $mount->getStorage()); + $this->assertInstanceOf(\OC\Files\Storage\Wrapper\Wrapper::class, $mount->getStorage()); } } diff --git a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php index 9b6aaeccfeb7b..d77809b53e422 100644 --- a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php +++ b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php @@ -39,7 +39,7 @@ public function testSingleBucket() { ->method('getSystemValue') ->with($this->equalTo('objectstore'), '') ->willReturn([ - 'class' => 'Test\Files\Mount\FakeObjectStore', + 'class' => \Test\Files\Mount\FakeObjectStore::class, ]); $this->user->expects($this->never())->method($this->anything()); @@ -48,12 +48,12 @@ public function testSingleBucket() { $config = $this->invokePrivate($this->provider, 'getSingleBucketObjectStoreConfig', [$this->user, $this->loader]); $this->assertArrayHasKey('class', $config); - $this->assertEquals($config['class'], 'Test\Files\Mount\FakeObjectStore'); + $this->assertEquals($config['class'], \Test\Files\Mount\FakeObjectStore::class); $this->assertArrayHasKey('arguments', $config); $this->assertArrayHasKey('user', $config['arguments']); $this->assertSame($this->user, $config['arguments']['user']); $this->assertArrayHasKey('objectstore', $config['arguments']); - $this->assertInstanceOf('Test\Files\Mount\FakeObjectStore', $config['arguments']['objectstore']); + $this->assertInstanceOf(\Test\Files\Mount\FakeObjectStore::class, $config['arguments']['objectstore']); } public function testMultiBucket() { @@ -61,7 +61,7 @@ public function testMultiBucket() { ->method('getSystemValue') ->with($this->equalTo('objectstore_multibucket'), '') ->willReturn([ - 'class' => 'Test\Files\Mount\FakeObjectStore', + 'class' => \Test\Files\Mount\FakeObjectStore::class, ]); $this->user->method('getUID') @@ -90,12 +90,12 @@ public function testMultiBucket() { $config = $this->invokePrivate($this->provider, 'getMultiBucketObjectStoreConfig', [$this->user, $this->loader]); $this->assertArrayHasKey('class', $config); - $this->assertEquals($config['class'], 'Test\Files\Mount\FakeObjectStore'); + $this->assertEquals($config['class'], \Test\Files\Mount\FakeObjectStore::class); $this->assertArrayHasKey('arguments', $config); $this->assertArrayHasKey('user', $config['arguments']); $this->assertSame($this->user, $config['arguments']['user']); $this->assertArrayHasKey('objectstore', $config['arguments']); - $this->assertInstanceOf('Test\Files\Mount\FakeObjectStore', $config['arguments']['objectstore']); + $this->assertInstanceOf(\Test\Files\Mount\FakeObjectStore::class, $config['arguments']['objectstore']); $this->assertArrayHasKey('bucket', $config['arguments']); $this->assertEquals('49', $config['arguments']['bucket']); } @@ -105,7 +105,7 @@ public function testMultiBucketWithPrefix() { ->method('getSystemValue') ->with('objectstore_multibucket') ->willReturn([ - 'class' => 'Test\Files\Mount\FakeObjectStore', + 'class' => \Test\Files\Mount\FakeObjectStore::class, 'arguments' => [ 'bucket' => 'myBucketPrefix', ], @@ -137,12 +137,12 @@ public function testMultiBucketWithPrefix() { $config = $this->invokePrivate($this->provider, 'getMultiBucketObjectStoreConfig', [$this->user, $this->loader]); $this->assertArrayHasKey('class', $config); - $this->assertEquals($config['class'], 'Test\Files\Mount\FakeObjectStore'); + $this->assertEquals($config['class'], \Test\Files\Mount\FakeObjectStore::class); $this->assertArrayHasKey('arguments', $config); $this->assertArrayHasKey('user', $config['arguments']); $this->assertSame($this->user, $config['arguments']['user']); $this->assertArrayHasKey('objectstore', $config['arguments']); - $this->assertInstanceOf('Test\Files\Mount\FakeObjectStore', $config['arguments']['objectstore']); + $this->assertInstanceOf(\Test\Files\Mount\FakeObjectStore::class, $config['arguments']['objectstore']); $this->assertArrayHasKey('bucket', $config['arguments']); $this->assertEquals('myBucketPrefix49', $config['arguments']['bucket']); } @@ -152,7 +152,7 @@ public function testMultiBucketBucketAlreadySet() { ->method('getSystemValue') ->with('objectstore_multibucket') ->willReturn([ - 'class' => 'Test\Files\Mount\FakeObjectStore', + 'class' => \Test\Files\Mount\FakeObjectStore::class, 'arguments' => [ 'bucket' => 'myBucketPrefix', ], @@ -177,12 +177,12 @@ public function testMultiBucketBucketAlreadySet() { $config = $this->invokePrivate($this->provider, 'getMultiBucketObjectStoreConfig', [$this->user, $this->loader]); $this->assertArrayHasKey('class', $config); - $this->assertEquals($config['class'], 'Test\Files\Mount\FakeObjectStore'); + $this->assertEquals($config['class'], \Test\Files\Mount\FakeObjectStore::class); $this->assertArrayHasKey('arguments', $config); $this->assertArrayHasKey('user', $config['arguments']); $this->assertSame($this->user, $config['arguments']['user']); $this->assertArrayHasKey('objectstore', $config['arguments']); - $this->assertInstanceOf('Test\Files\Mount\FakeObjectStore', $config['arguments']['objectstore']); + $this->assertInstanceOf(\Test\Files\Mount\FakeObjectStore::class, $config['arguments']['objectstore']); $this->assertArrayHasKey('bucket', $config['arguments']); $this->assertEquals('awesomeBucket1', $config['arguments']['bucket']); } @@ -192,7 +192,7 @@ public function testMultiBucketConfigFirst() { ->method('getSystemValue') ->with('objectstore_multibucket') ->willReturn([ - 'class' => 'Test\Files\Mount\FakeObjectStore', + 'class' => \Test\Files\Mount\FakeObjectStore::class, ]); $this->user->method('getUID') @@ -200,7 +200,7 @@ public function testMultiBucketConfigFirst() { $this->loader->expects($this->never())->method($this->anything()); $mount = $this->provider->getHomeMountForUser($this->user, $this->loader); - $this->assertInstanceOf('OC\Files\Mount\MountPoint', $mount); + $this->assertInstanceOf(\OC\Files\Mount\MountPoint::class, $mount); } public function testMultiBucketConfigFirstFallBackSingle() { @@ -212,7 +212,7 @@ public function testMultiBucketConfigFirstFallBackSingle() { )->willReturnOnConsecutiveCalls( '', [ - 'class' => 'Test\Files\Mount\FakeObjectStore', + 'class' => \Test\Files\Mount\FakeObjectStore::class, ], ); @@ -221,7 +221,7 @@ public function testMultiBucketConfigFirstFallBackSingle() { $this->loader->expects($this->never())->method($this->anything()); $mount = $this->provider->getHomeMountForUser($this->user, $this->loader); - $this->assertInstanceOf('OC\Files\Mount\MountPoint', $mount); + $this->assertInstanceOf(\OC\Files\Mount\MountPoint::class, $mount); } public function testNoObjectStore() { diff --git a/tests/lib/Files/Mount/RootMountProviderTest.php b/tests/lib/Files/Mount/RootMountProviderTest.php index f3f43a8457cbe..5a33ddf479e81 100644 --- a/tests/lib/Files/Mount/RootMountProviderTest.php +++ b/tests/lib/Files/Mount/RootMountProviderTest.php @@ -61,7 +61,7 @@ public function testLocal() { public function testObjectStore() { $provider = $this->getProvider([ 'objectstore' => [ - 'class' => "OC\Files\ObjectStore\S3", + 'class' => \OC\Files\ObjectStore\S3::class, 'arguments' => [ 'bucket' => 'nextcloud', 'autocreate' => true, @@ -94,7 +94,7 @@ public function testObjectStore() { public function testObjectStoreMultiBucket() { $provider = $this->getProvider([ 'objectstore_multibucket' => [ - 'class' => "OC\Files\ObjectStore\S3", + 'class' => \OC\Files\ObjectStore\S3::class, 'arguments' => [ 'bucket' => 'nextcloud', 'autocreate' => true, diff --git a/tests/lib/Files/Node/FileTest.php b/tests/lib/Files/Node/FileTest.php index 35c2443aeff5a..a5d455b33b7bf 100644 --- a/tests/lib/Files/Node/FileTest.php +++ b/tests/lib/Files/Node/FileTest.php @@ -24,11 +24,11 @@ protected function createTestNode($root, $view, $path, array $data = [], $intern } protected function getNodeClass() { - return '\OC\Files\Node\File'; + return \OC\Files\Node\File::class; } protected function getNonExistingNodeClass() { - return '\OC\Files\Node\NonExistingFile'; + return \OC\Files\Node\NonExistingFile::class; } protected function getViewDeleteMethod() { @@ -37,7 +37,7 @@ protected function getViewDeleteMethod() { public function testGetContent() { /** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */ - $root = $this->getMockBuilder('\OC\Files\Node\Root') + $root = $this->getMockBuilder(\OC\Files\Node\Root::class) ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory]) ->getMock(); @@ -67,7 +67,7 @@ public function testGetContentNotPermitted() { $this->expectException(\OCP\Files\NotPermittedException::class); /** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */ - $root = $this->getMockBuilder('\OC\Files\Node\Root') + $root = $this->getMockBuilder(\OC\Files\Node\Root::class) ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory]) ->getMock(); @@ -86,7 +86,7 @@ public function testGetContentNotPermitted() { public function testPutContent() { /** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */ - $root = $this->getMockBuilder('\OC\Files\Node\Root') + $root = $this->getMockBuilder(\OC\Files\Node\Root::class) ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory]) ->getMock(); @@ -113,7 +113,7 @@ public function testPutContentNotPermitted() { $this->expectException(\OCP\Files\NotPermittedException::class); /** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */ - $root = $this->getMockBuilder('\OC\Files\Node\Root') + $root = $this->getMockBuilder(\OC\Files\Node\Root::class) ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory]) ->getMock(); @@ -128,7 +128,7 @@ public function testPutContentNotPermitted() { public function testGetMimeType() { /** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */ - $root = $this->getMockBuilder('\OC\Files\Node\Root') + $root = $this->getMockBuilder(\OC\Files\Node\Root::class) ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory]) ->getMock(); diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php index 46fda6c3a7665..4b194746d4da4 100644 --- a/tests/lib/Files/Node/FolderTest.php +++ b/tests/lib/Files/Node/FolderTest.php @@ -51,11 +51,11 @@ protected function createTestNode($root, $view, $path, array $data = [], $intern } protected function getNodeClass() { - return '\OC\Files\Node\Folder'; + return \OC\Files\Node\Folder::class; } protected function getNonExistingNodeClass() { - return '\OC\Files\Node\NonExistingFolder'; + return \OC\Files\Node\NonExistingFolder::class; } protected function getViewDeleteMethod() { @@ -89,8 +89,8 @@ public function testGetDirectoryContent() { $node = new Folder($root, $this->view, '/bar/foo'); $children = $node->getDirectoryListing(); $this->assertEquals(2, count($children)); - $this->assertInstanceOf('\OC\Files\Node\File', $children[0]); - $this->assertInstanceOf('\OC\Files\Node\Folder', $children[1]); + $this->assertInstanceOf(\OC\Files\Node\File::class, $children[0]); + $this->assertInstanceOf(\OC\Files\Node\Folder::class, $children[1]); $this->assertEquals('asd', $children[0]->getName()); $this->assertEquals('qwerty', $children[1]->getName()); $this->assertEquals(2, $children[0]->getId()); diff --git a/tests/lib/Files/Node/IntegrationTest.php b/tests/lib/Files/Node/IntegrationTest.php index fe6fe779ad00d..965cab32ac2a3 100644 --- a/tests/lib/Files/Node/IntegrationTest.php +++ b/tests/lib/Files/Node/IntegrationTest.php @@ -93,7 +93,7 @@ public function testBasicFile() { $this->assertCount(2, $this->root->getDirectoryListing()); $this->assertTrue($this->root->nodeExists('/foo.txt')); $id = $file->getId(); - $this->assertInstanceOf('\OC\Files\Node\File', $file); + $this->assertInstanceOf(\OC\Files\Node\File::class, $file); $file->putContent('qwerty'); $this->assertEquals('text/plain', $file->getMimeType()); $this->assertEquals('qwerty', $file->getContent()); @@ -132,7 +132,7 @@ public function testBasicFolder() { * @var \OC\Files\Node\File $file */ $file = $folder->get('/bar'); - $this->assertInstanceOf('\OC\Files\Node\File', $file); + $this->assertInstanceOf(\OC\Files\Node\File::class, $file); $this->assertFalse($this->root->nodeExists('/foo/bar')); $this->assertTrue($this->root->nodeExists('/asd/bar')); $this->assertEquals('qwerty', $file->getContent()); @@ -141,7 +141,7 @@ public function testBasicFolder() { * @var \OC\Files\Node\File $file */ $file = $folder->get('/bar'); - $this->assertInstanceOf('\OC\Files\Node\File', $file); + $this->assertInstanceOf(\OC\Files\Node\File::class, $file); $this->assertTrue($this->root->nodeExists('/substorage/foo/bar')); $this->assertEquals('qwerty', $file->getContent()); } diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php index b00d9e1b4de6a..bbea14daf0467 100644 --- a/tests/lib/Files/Node/NodeTest.php +++ b/tests/lib/Files/Node/NodeTest.php @@ -60,7 +60,7 @@ protected function setUp(): void { $this->view->expects($this->any()) ->method('getRoot') ->willReturn(''); - $this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache') + $this->userMountCache = $this->getMockBuilder(\OCP\Files\Config\IUserMountCache::class) ->disableOriginalConstructor() ->getMock(); $this->logger = $this->createMock(LoggerInterface::class); @@ -71,7 +71,7 @@ protected function setUp(): void { ->willReturnCallback(function () { return new ArrayCache(); }); - $this->root = $this->getMockBuilder('\OC\Files\Node\Root') + $this->root = $this->getMockBuilder(\OC\Files\Node\Root::class) ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory]) ->getMock(); } @@ -336,7 +336,7 @@ public function testGetStorage() { /** * @var \OC\Files\Storage\Storage | \PHPUnit\Framework\MockObject\MockObject $storage */ - $storage = $this->getMockBuilder('\OC\Files\Storage\Storage') + $storage = $this->getMockBuilder(\OC\Files\Storage\Storage::class) ->disableOriginalConstructor() ->getMock(); @@ -360,7 +360,7 @@ public function testGetInternalPath() { /** * @var \OC\Files\Storage\Storage | \PHPUnit\Framework\MockObject\MockObject $storage */ - $storage = $this->getMockBuilder('\OC\Files\Storage\Storage') + $storage = $this->getMockBuilder(\OC\Files\Storage\Storage::class) ->disableOriginalConstructor() ->getMock(); @@ -509,7 +509,7 @@ public function testCopyNotPermitted() { /** * @var \OC\Files\Storage\Storage | \PHPUnit\Framework\MockObject\MockObject $storage */ - $storage = $this->createMock('\OC\Files\Storage\Storage'); + $storage = $this->createMock(\OC\Files\Storage\Storage::class); $this->root->expects($this->never()) ->method('getMount'); @@ -608,7 +608,7 @@ public function moveOrCopyProvider() { */ public function testMoveCopyHooks($operationMethod, $viewMethod, $preHookName, $postHookName) { /** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject $root */ - $root = $this->getMockBuilder('\OC\Files\Node\Root') + $root = $this->getMockBuilder(\OC\Files\Node\Root::class) ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory]) ->setMethods(['get']) ->getMock(); @@ -702,7 +702,7 @@ public function testMoveNoParent() { /** * @var \OC\Files\Storage\Storage | \PHPUnit\Framework\MockObject\MockObject $storage */ - $storage = $this->createMock('\OC\Files\Storage\Storage'); + $storage = $this->createMock(\OC\Files\Storage\Storage::class); $storage->expects($this->never()) ->method('rename'); diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php index 9b3139cf78b27..00d6a3283351f 100644 --- a/tests/lib/Files/Node/RootTest.php +++ b/tests/lib/Files/Node/RootTest.php @@ -47,7 +47,7 @@ protected function setUp(): void { $this->manager = $this->getMockBuilder(Manager::class) ->disableOriginalConstructor() ->getMock(); - $this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache') + $this->userMountCache = $this->getMockBuilder(\OCP\Files\Config\IUserMountCache::class) ->disableOriginalConstructor() ->getMock(); $this->logger = $this->createMock(LoggerInterface::class); @@ -79,7 +79,7 @@ public function testGet() { /** * @var \OC\Files\Storage\Storage $storage */ - $storage = $this->getMockBuilder('\OC\Files\Storage\Storage') + $storage = $this->getMockBuilder(\OC\Files\Storage\Storage::class) ->disableOriginalConstructor() ->getMock(); $view = $this->getRootViewMock(); @@ -102,7 +102,7 @@ public function testGet() { $root->mount($storage, ''); $node = $root->get('/bar/foo'); $this->assertEquals(10, $node->getId()); - $this->assertInstanceOf('\OC\Files\Node\File', $node); + $this->assertInstanceOf(\OC\Files\Node\File::class, $node); } @@ -112,7 +112,7 @@ public function testGetNotFound() { /** * @var \OC\Files\Storage\Storage $storage */ - $storage = $this->getMockBuilder('\OC\Files\Storage\Storage') + $storage = $this->getMockBuilder(\OC\Files\Storage\Storage::class) ->disableOriginalConstructor() ->getMock(); $view = $this->getRootViewMock(); diff --git a/tests/lib/Files/ObjectStore/AzureTest.php b/tests/lib/Files/ObjectStore/AzureTest.php index 5d4234532a66a..9c7b48d7ca79e 100644 --- a/tests/lib/Files/ObjectStore/AzureTest.php +++ b/tests/lib/Files/ObjectStore/AzureTest.php @@ -14,7 +14,7 @@ class AzureTest extends ObjectStoreTest { protected function getInstance() { $config = \OC::$server->getConfig()->getSystemValue('objectstore'); - if (!is_array($config) || $config['class'] !== 'OC\\Files\\ObjectStore\\Azure') { + if (!is_array($config) || $config['class'] !== \OC\Files\ObjectStore\Azure::class) { $this->markTestSkipped('objectstore not configured for azure'); } diff --git a/tests/lib/Files/ObjectStore/SwiftTest.php b/tests/lib/Files/ObjectStore/SwiftTest.php index 8c9a0d524ed9f..735bebc44a0e3 100644 --- a/tests/lib/Files/ObjectStore/SwiftTest.php +++ b/tests/lib/Files/ObjectStore/SwiftTest.php @@ -18,7 +18,7 @@ class SwiftTest extends ObjectStoreTest { */ protected function getInstance() { $config = \OC::$server->getConfig()->getSystemValue('objectstore'); - if (!is_array($config) || $config['class'] !== 'OC\\Files\\ObjectStore\\Swift') { + if (!is_array($config) || $config['class'] !== \OC\Files\ObjectStore\Swift::class) { $this->markTestSkipped('objectstore not configured for swift'); } diff --git a/tests/lib/Files/Storage/HomeTest.php b/tests/lib/Files/Storage/HomeTest.php index c3111e7425932..ca2c1a797af51 100644 --- a/tests/lib/Files/Storage/HomeTest.php +++ b/tests/lib/Files/Storage/HomeTest.php @@ -77,7 +77,7 @@ public function testId() { * Tests that getCache() returns an instance of HomeCache */ public function testGetCacheReturnsHomeCache() { - $this->assertInstanceOf('\OC\Files\Cache\HomeCache', $this->instance->getCache()); + $this->assertInstanceOf(\OC\Files\Cache\HomeCache::class, $this->instance->getCache()); } public function testGetOwner() { diff --git a/tests/lib/Files/Storage/Storage.php b/tests/lib/Files/Storage/Storage.php index 747cb4b6f4392..584be1d4e963e 100644 --- a/tests/lib/Files/Storage/Storage.php +++ b/tests/lib/Files/Storage/Storage.php @@ -572,7 +572,7 @@ public function testCopyOverWriteDirectoryOverFile() { } public function testInstanceOfStorage() { - $this->assertTrue($this->instance->instanceOfStorage('\OCP\Files\Storage')); + $this->assertTrue($this->instance->instanceOfStorage(\OCP\Files\Storage::class)); $this->assertTrue($this->instance->instanceOfStorage(get_class($this->instance))); $this->assertFalse($this->instance->instanceOfStorage('\OC')); } diff --git a/tests/lib/Files/Storage/StorageFactoryTest.php b/tests/lib/Files/Storage/StorageFactoryTest.php index ee23f6199c988..1114a48b80ff4 100644 --- a/tests/lib/Files/Storage/StorageFactoryTest.php +++ b/tests/lib/Files/Storage/StorageFactoryTest.php @@ -27,31 +27,31 @@ public function __construct($arguments) { class StorageFactoryTest extends TestCase { public function testSimpleWrapper() { $instance = new \OC\Files\Storage\StorageFactory(); - $mount = new MountPoint('\OC\Files\Storage\Temporary', '/foo', [[]], $instance); + $mount = new MountPoint(\OC\Files\Storage\Temporary::class, '/foo', [[]], $instance); $instance->addStorageWrapper('dummy', function ($mountPoint, IStorage $storage, IMountPoint $mount) { - $this->assertInstanceOf('\OC\Files\Storage\Temporary', $storage); + $this->assertInstanceOf(\OC\Files\Storage\Temporary::class, $storage); $this->assertEquals('/foo/', $mount->getMountPoint()); $this->assertEquals('/foo/', $mountPoint); return new DummyWrapper(['storage' => $storage]); }); $wrapped = $mount->getStorage(); - $this->assertInstanceOf('\Test\Files\Storage\DummyWrapper', $wrapped); + $this->assertInstanceOf(\Test\Files\Storage\DummyWrapper::class, $wrapped); } public function testRemoveWrapper() { $instance = new \OC\Files\Storage\StorageFactory(); - $mount = new MountPoint('\OC\Files\Storage\Temporary', '/foo', [[]], $instance); + $mount = new MountPoint(\OC\Files\Storage\Temporary::class, '/foo', [[]], $instance); $instance->addStorageWrapper('dummy', function ($mountPoint, IStorage $storage) { return new DummyWrapper(['storage' => $storage]); }); $instance->removeStorageWrapper('dummy'); $wrapped = $mount->getStorage(); - $this->assertInstanceOf('\OC\Files\Storage\Temporary', $wrapped); + $this->assertInstanceOf(\OC\Files\Storage\Temporary::class, $wrapped); } public function testWrapperPriority() { $instance = new \OC\Files\Storage\StorageFactory(); - $mount = new MountPoint('\OC\Files\Storage\Temporary', '/foo', [[]], $instance); + $mount = new MountPoint(\OC\Files\Storage\Temporary::class, '/foo', [[]], $instance); $instance->addStorageWrapper('dummy1', function ($mountPoint, IStorage $storage) { return new DummyWrapper(['storage' => $storage, 'data' => 1]); }, 1); @@ -63,7 +63,7 @@ public function testWrapperPriority() { }, 50); /** @var \Test\Files\Storage\DummyWrapper $wrapped */ $wrapped = $mount->getStorage(); - $this->assertInstanceOf('\Test\Files\Storage\DummyWrapper', $wrapped); + $this->assertInstanceOf(\Test\Files\Storage\DummyWrapper::class, $wrapped); $this->assertEquals(1, $wrapped->data);// lowest priority is applied last, called first $this->assertEquals(50, $wrapped->getWrapperStorage()->data); $this->assertEquals(100, $wrapped->getWrapperStorage()->getWrapperStorage()->data); diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php index 74b91216c378b..8bc8196fea3ee 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -116,7 +116,7 @@ protected function setUp(): void { parent::setUp(); $mockModule = $this->buildMockModule(); - $this->encryptionManager = $this->getMockBuilder('\OC\Encryption\Manager') + $this->encryptionManager = $this->getMockBuilder(\OC\Encryption\Manager::class) ->disableOriginalConstructor() ->setMethods(['getEncryptionModule', 'isEnabled']) ->getMock(); @@ -128,11 +128,11 @@ protected function setUp(): void { $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); - $this->groupManager = $this->getMockBuilder('\OC\Group\Manager') + $this->groupManager = $this->getMockBuilder(\OC\Group\Manager::class) ->disableOriginalConstructor() ->getMock(); - $this->util = $this->getMockBuilder('\OC\Encryption\Util') + $this->util = $this->getMockBuilder(\OC\Encryption\Util::class) ->setMethods(['getUidAndFilename', 'isFile', 'isExcluded']) ->setConstructorArgs([new View(), new Manager( $this->config, @@ -146,7 +146,7 @@ protected function setUp(): void { return ['user1', $path]; }); - $this->file = $this->getMockBuilder('\OC\Encryption\File') + $this->file = $this->getMockBuilder(\OC\Encryption\File::class) ->disableOriginalConstructor() ->setMethods(['getAccessList']) ->getMock(); @@ -156,13 +156,13 @@ protected function setUp(): void { $this->sourceStorage = new Temporary([]); - $this->keyStore = $this->getMockBuilder('\OC\Encryption\Keys\Storage') + $this->keyStore = $this->getMockBuilder(\OC\Encryption\Keys\Storage::class) ->disableOriginalConstructor()->getMock(); - $this->update = $this->getMockBuilder('\OC\Encryption\Update') + $this->update = $this->getMockBuilder(\OC\Encryption\Update::class) ->disableOriginalConstructor()->getMock(); - $this->mount = $this->getMockBuilder('\OC\Files\Mount\MountPoint') + $this->mount = $this->getMockBuilder(\OC\Files\Mount\MountPoint::class) ->disableOriginalConstructor() ->setMethods(['getOption']) ->getMock(); @@ -176,7 +176,7 @@ protected function setUp(): void { return true; }); - $this->cache = $this->getMockBuilder('\OC\Files\Cache\Cache') + $this->cache = $this->getMockBuilder(\OC\Files\Cache\Cache::class) ->disableOriginalConstructor()->getMock(); $this->cache->expects($this->any()) ->method('get') @@ -188,7 +188,7 @@ protected function setUp(): void { $this->mountManager->method('findByStorageId') ->willReturn([]); - $this->instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') + $this->instance = $this->getMockBuilder(\OC\Files\Storage\Wrapper\Encryption::class) ->setConstructorArgs( [ [ @@ -222,7 +222,7 @@ protected function setUp(): void { * @return \PHPUnit\Framework\MockObject\MockObject */ protected function buildMockModule() { - $this->encryptionModule = $this->getMockBuilder('\OCP\Encryption\IEncryptionModule') + $this->encryptionModule = $this->getMockBuilder(\OCP\Encryption\IEncryptionModule::class) ->disableOriginalConstructor() ->setMethods(['getId', 'getDisplayName', 'begin', 'end', 'encrypt', 'decrypt', 'update', 'shouldEncrypt', 'getUnencryptedBlockSize', 'isReadable', 'encryptAll', 'prepareDecryptAll', 'isReadyForUser', 'needDetailedAccessList']) ->getMock(); @@ -252,10 +252,10 @@ protected function buildMockModule() { * @param array $expected */ public function testGetMetaData($path, $metaData, $encrypted, $unencryptedSizeSet, $storedUnencryptedSize, $expected) { - $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') + $sourceStorage = $this->getMockBuilder(\OC\Files\Storage\Storage::class) ->disableOriginalConstructor()->getMock(); - $cache = $this->getMockBuilder('\OC\Files\Cache\Cache') + $cache = $this->getMockBuilder(\OC\Files\Cache\Cache::class) ->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('get') @@ -265,7 +265,7 @@ function ($path) use ($encrypted) { } ); - $this->instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') + $this->instance = $this->getMockBuilder(\OC\Files\Storage\Wrapper\Encryption::class) ->setConstructorArgs( [ [ @@ -284,7 +284,7 @@ function ($path) use ($encrypted) { $this->invokePrivate($this->instance, 'unencryptedSize', [[$path => $storedUnencryptedSize]]); } - $fileEntry = $this->getMockBuilder('\OC\Files\Cache\Cache') + $fileEntry = $this->getMockBuilder(\OC\Files\Cache\Cache::class) ->disableOriginalConstructor()->getMock(); $sourceStorage->expects($this->once())->method('getMetaData')->with($path) ->willReturn($metaData); @@ -330,13 +330,13 @@ public function dataTestGetMetaData() { } public function testFilesize() { - $cache = $this->getMockBuilder('\OC\Files\Cache\Cache') + $cache = $this->getMockBuilder(\OC\Files\Cache\Cache::class) ->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('get') ->willReturn(new CacheEntry(['encrypted' => true, 'path' => '/test.txt', 'size' => 0, 'fileid' => 1])); - $this->instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') + $this->instance = $this->getMockBuilder(\OC\Files\Storage\Wrapper\Encryption::class) ->setConstructorArgs( [ [ @@ -370,10 +370,10 @@ public function testFilesize() { * @param int $expected */ public function testVerifyUnencryptedSize($encryptedSize, $unencryptedSize, $failure, $expected) { - $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') + $sourceStorage = $this->getMockBuilder(\OC\Files\Storage\Storage::class) ->disableOriginalConstructor()->getMock(); - $this->instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') + $this->instance = $this->getMockBuilder(\OC\Files\Storage\Wrapper\Encryption::class) ->setConstructorArgs( [ [ @@ -488,10 +488,10 @@ public function testIsLocal() { * @param boolean $encryptionEnabled */ public function testRmdir($path, $rmdirResult, $isExcluded, $encryptionEnabled) { - $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') + $sourceStorage = $this->getMockBuilder(\OC\Files\Storage\Storage::class) ->disableOriginalConstructor()->getMock(); - $util = $this->getMockBuilder('\OC\Encryption\Util')->disableOriginalConstructor()->getMock(); + $util = $this->getMockBuilder(\OC\Encryption\Util::class)->disableOriginalConstructor()->getMock(); $sourceStorage->expects($this->once())->method('rmdir')->willReturn($rmdirResult); $util->expects($this->any())->method('isExcluded')-> willReturn($isExcluded); @@ -567,10 +567,10 @@ public function dataTestCopyKeys() { * @param string $strippedPath */ public function testGetHeader($path, $strippedPathExists, $strippedPath) { - $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') + $sourceStorage = $this->getMockBuilder(\OC\Files\Storage\Storage::class) ->disableOriginalConstructor()->getMock(); - $util = $this->getMockBuilder('\OC\Encryption\Util') + $util = $this->getMockBuilder(\OC\Encryption\Util::class) ->setConstructorArgs( [ new View(), @@ -585,7 +585,7 @@ public function testGetHeader($path, $strippedPathExists, $strippedPath) { ] )->getMock(); - $cache = $this->getMockBuilder('\OC\Files\Cache\Cache') + $cache = $this->getMockBuilder(\OC\Files\Cache\Cache::class) ->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('get') @@ -593,7 +593,7 @@ public function testGetHeader($path, $strippedPathExists, $strippedPath) { return ['encrypted' => true, 'path' => $path]; }); - $instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') + $instance = $this->getMockBuilder(\OC\Files\Storage\Wrapper\Encryption::class) ->setConstructorArgs( [ [ @@ -648,14 +648,14 @@ public function dataTestGetHeader() { * @dataProvider dataTestGetHeaderAddLegacyModule */ public function testGetHeaderAddLegacyModule($header, $isEncrypted, $exists, $expected) { - $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage') + $sourceStorage = $this->getMockBuilder(\OC\Files\Storage\Storage::class) ->disableOriginalConstructor()->getMock(); $sourceStorage->expects($this->once()) ->method('is_file') ->willReturn($exists); - $util = $this->getMockBuilder('\OC\Encryption\Util') + $util = $this->getMockBuilder(\OC\Encryption\Util::class) ->setConstructorArgs([new View(), new Manager( $this->config, $this->createMock(ICacheFactory::class), @@ -663,7 +663,7 @@ public function testGetHeaderAddLegacyModule($header, $isEncrypted, $exists, $ex ), $this->groupManager, $this->config, $this->arrayCache]) ->getMock(); - $cache = $this->getMockBuilder('\OC\Files\Cache\Cache') + $cache = $this->getMockBuilder(\OC\Files\Cache\Cache::class) ->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) ->method('get') @@ -671,7 +671,7 @@ public function testGetHeaderAddLegacyModule($header, $isEncrypted, $exists, $ex return ['encrypted' => $isEncrypted, 'path' => $path]; }); - $instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') + $instance = $this->getMockBuilder(\OC\Files\Storage\Wrapper\Encryption::class) ->setConstructorArgs( [ [ @@ -832,13 +832,13 @@ public function testCopyBetweenStorageVersions($sourceInternalPath, $targetInter $targetStorage = $this->createMock(\OC\Files\Storage\Storage::class); - $cache = $this->getMockBuilder('\OC\Files\Cache\Cache') + $cache = $this->getMockBuilder(\OC\Files\Cache\Cache::class) ->disableOriginalConstructor()->getMock(); $mountPoint = '/mountPoint'; /** @var \OC\Files\Storage\Wrapper\Encryption |\PHPUnit\Framework\MockObject\MockObject $instance */ - $instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') + $instance = $this->getMockBuilder(\OC\Files\Storage\Wrapper\Encryption::class) ->setConstructorArgs( [ [ diff --git a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php index 0b2d444700a06..4e5324651a014 100644 --- a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php +++ b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php @@ -149,7 +149,7 @@ public function testScanUnchanged() { $storage = $this->getMaskedStorage(Constants::PERMISSION_READ); $scanner = $storage->getScanner(); $called = false; - $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function () use (&$called) { + $scanner->listen(\OC\Files\Cache\Scanner::class, 'addToCache', function () use (&$called) { $called = true; }); $scanner->scan('foo', IScanner::SCAN_RECURSIVE, IScanner::REUSE_ETAG | IScanner::REUSE_SIZE); @@ -167,7 +167,7 @@ public function testScanUnchangedWrapped() { $wrappedStorage = new Wrapper(['storage' => $storage]); $scanner = $wrappedStorage->getScanner(); $called = false; - $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function () use (&$called) { + $scanner->listen(\OC\Files\Cache\Scanner::class, 'addToCache', function () use (&$called) { $called = true; }); $scanner->scan('foo', IScanner::SCAN_RECURSIVE, IScanner::REUSE_ETAG | IScanner::REUSE_SIZE); diff --git a/tests/lib/Files/Storage/Wrapper/QuotaTest.php b/tests/lib/Files/Storage/Wrapper/QuotaTest.php index b24b44c6a5682..ff606855510c6 100644 --- a/tests/lib/Files/Storage/Wrapper/QuotaTest.php +++ b/tests/lib/Files/Storage/Wrapper/QuotaTest.php @@ -11,7 +11,7 @@ use OC\Files\Cache\CacheEntry; use OC\Files\Storage\Local; -\OC::$loader->load('\OC\Files\Filesystem'); +\OC::$loader->load(\OC\Files\Filesystem::class); /** * Class QuotaTest @@ -185,7 +185,7 @@ public function testReturnQuotaStreamOnWrite() { public function testSpaceRoot() { $storage = $this->getMockBuilder(Local::class)->disableOriginalConstructor()->getMock(); - $cache = $this->getMockBuilder('\OC\Files\Cache\Cache')->disableOriginalConstructor()->getMock(); + $cache = $this->getMockBuilder(\OC\Files\Cache\Cache::class)->disableOriginalConstructor()->getMock(); $storage->expects($this->once()) ->method('getCache') ->willReturn($cache); @@ -203,9 +203,9 @@ public function testSpaceRoot() { } public function testInstanceOfStorageWrapper() { - $this->assertTrue($this->instance->instanceOfStorage('\OC\Files\Storage\Local')); - $this->assertTrue($this->instance->instanceOfStorage('\OC\Files\Storage\Wrapper\Wrapper')); - $this->assertTrue($this->instance->instanceOfStorage('\OC\Files\Storage\Wrapper\Quota')); + $this->assertTrue($this->instance->instanceOfStorage(\OC\Files\Storage\Local::class)); + $this->assertTrue($this->instance->instanceOfStorage(\OC\Files\Storage\Wrapper\Wrapper::class)); + $this->assertTrue($this->instance->instanceOfStorage(\OC\Files\Storage\Wrapper\Quota::class)); } public function testNoMkdirQuotaZero() { diff --git a/tests/lib/Files/Storage/Wrapper/WrapperTest.php b/tests/lib/Files/Storage/Wrapper/WrapperTest.php index 0244c78da8ba8..ef84c35abc09d 100644 --- a/tests/lib/Files/Storage/Wrapper/WrapperTest.php +++ b/tests/lib/Files/Storage/Wrapper/WrapperTest.php @@ -27,7 +27,7 @@ protected function tearDown(): void { } public function testInstanceOfStorageWrapper() { - $this->assertTrue($this->instance->instanceOfStorage('\OC\Files\Storage\Local')); - $this->assertTrue($this->instance->instanceOfStorage('\OC\Files\Storage\Wrapper\Wrapper')); + $this->assertTrue($this->instance->instanceOfStorage(\OC\Files\Storage\Local::class)); + $this->assertTrue($this->instance->instanceOfStorage(\OC\Files\Storage\Wrapper\Wrapper::class)); } } diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php index 4f8d0b88de231..5482f365358b8 100644 --- a/tests/lib/Files/Stream/EncryptionTest.php +++ b/tests/lib/Files/Stream/EncryptionTest.php @@ -36,23 +36,23 @@ protected function getStream($fileName, $mode, $unencryptedSize, $wrapper = self $uid = ''; $this->encryptionModule = $this->buildMockModule(); $cache = $this->createMock(ICache::class); - $storage = $this->getMockBuilder('\OC\Files\Storage\Storage') + $storage = $this->getMockBuilder(\OC\Files\Storage\Storage::class) ->disableOriginalConstructor()->getMock(); - $encStorage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') + $encStorage = $this->getMockBuilder(\OC\Files\Storage\Wrapper\Encryption::class) ->disableOriginalConstructor()->getMock(); $config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); $arrayCache = $this->createMock(ArrayCache::class); - $groupManager = $this->getMockBuilder('\OC\Group\Manager') + $groupManager = $this->getMockBuilder(\OC\Group\Manager::class) ->disableOriginalConstructor() ->getMock(); - $file = $this->getMockBuilder('\OC\Encryption\File') + $file = $this->getMockBuilder(\OC\Encryption\File::class) ->disableOriginalConstructor() ->setMethods(['getAccessList']) ->getMock(); $file->expects($this->any())->method('getAccessList')->willReturn([]); - $util = $this->getMockBuilder('\OC\Encryption\Util') + $util = $this->getMockBuilder(\OC\Encryption\Util::class) ->setMethods(['getUidAndFilename']) ->setConstructorArgs([new View(), new \OC\User\Manager( $config, @@ -90,7 +90,7 @@ public function testStreamOpen($isMasterKeyUsed, $expectedUnencryptedSize, $expectedReadOnly) { // build mocks - $encryptionModuleMock = $this->getMockBuilder('\OCP\Encryption\IEncryptionModule') + $encryptionModuleMock = $this->getMockBuilder(\OCP\Encryption\IEncryptionModule::class) ->disableOriginalConstructor()->getMock(); $encryptionModuleMock->expects($this->any())->method('needDetailedAccessList')->willReturn(!$isMasterKeyUsed); $encryptionModuleMock->expects($this->once()) @@ -98,11 +98,11 @@ public function testStreamOpen($isMasterKeyUsed, $encryptionModuleMock->expects($this->once()) ->method('begin')->willReturn(true); - $storageMock = $this->getMockBuilder('\OC\Files\Storage\Storage') + $storageMock = $this->getMockBuilder(\OC\Files\Storage\Storage::class) ->disableOriginalConstructor()->getMock(); $storageMock->expects($this->once())->method('file_exists')->willReturn($fileExists); - $fileMock = $this->getMockBuilder('\OC\Encryption\File') + $fileMock = $this->getMockBuilder(\OC\Encryption\File::class) ->disableOriginalConstructor()->getMock(); if ($isMasterKeyUsed) { $fileMock->expects($this->never())->method('getAccessList'); @@ -113,18 +113,18 @@ public function testStreamOpen($isMasterKeyUsed, return []; }); } - $utilMock = $this->getMockBuilder('\OC\Encryption\Util') + $utilMock = $this->getMockBuilder(\OC\Encryption\Util::class) ->disableOriginalConstructor()->getMock(); $utilMock->expects($this->any()) ->method('getHeaderSize') ->willReturn(8192); // get a instance of the stream wrapper - $streamWrapper = $this->getMockBuilder('\OC\Files\Stream\Encryption') + $streamWrapper = $this->getMockBuilder(\OC\Files\Stream\Encryption::class) ->setMethods(['loadContext', 'writeHeader', 'skipHeader'])->disableOriginalConstructor()->getMock(); // set internal properties of the stream wrapper - $stream = new \ReflectionClass('\OC\Files\Stream\Encryption'); + $stream = new \ReflectionClass(\OC\Files\Stream\Encryption::class); $encryptionModule = $stream->getProperty('encryptionModule'); $encryptionModule->setAccessible(true); $encryptionModule->setValue($streamWrapper, $encryptionModuleMock); @@ -298,14 +298,14 @@ public function testWriteReadBigFile($testFile) { * @dataProvider dataFilesProvider */ public function testWriteToNonSeekableStorage($testFile) { - $wrapper = $this->getMockBuilder('\OC\Files\Stream\Encryption') + $wrapper = $this->getMockBuilder(\OC\Files\Stream\Encryption::class) ->setMethods(['parentSeekStream'])->getMock(); $wrapper->expects($this->any())->method('parentSeekStream')->willReturn(false); $expectedData = file_get_contents(\OC::$SERVERROOT . '/tests/data/' . $testFile); // write it $fileName = tempnam('/tmp', 'FOO'); - $stream = $this->getStream($fileName, 'w+', 0, '\Test\Files\Stream\DummyEncryptionWrapper', strlen($expectedData)); + $stream = $this->getStream($fileName, 'w+', 0, \Test\Files\Stream\DummyEncryptionWrapper::class, strlen($expectedData)); // while writing the file from the beginning to the end we should never try // to read parts of the file. This should only happen for write operations // in the middle of a file @@ -314,7 +314,7 @@ public function testWriteToNonSeekableStorage($testFile) { fclose($stream); // read it all - $stream = $this->getStream($fileName, 'r', strlen($expectedData), '\Test\Files\Stream\DummyEncryptionWrapper', strlen($expectedData)); + $stream = $this->getStream($fileName, 'r', strlen($expectedData), \Test\Files\Stream\DummyEncryptionWrapper::class, strlen($expectedData)); $data = stream_get_contents($stream); fclose($stream); @@ -337,7 +337,7 @@ public function testWriteToNonSeekableStorage($testFile) { * @return \PHPUnit\Framework\MockObject\MockObject */ protected function buildMockModule() { - $encryptionModule = $this->getMockBuilder('\OCP\Encryption\IEncryptionModule') + $encryptionModule = $this->getMockBuilder(\OCP\Encryption\IEncryptionModule::class) ->disableOriginalConstructor() ->setMethods(['getId', 'getDisplayName', 'begin', 'end', 'encrypt', 'decrypt', 'update', 'shouldEncrypt', 'getUnencryptedBlockSize', 'isReadable', 'encryptAll', 'prepareDecryptAll', 'isReadyForUser', 'needDetailedAccessList']) ->getMock(); diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index e9e4d0e7573e0..7a70266d5d5e4 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -51,7 +51,7 @@ public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $t class TemporaryNoLocal extends Temporary { public function instanceOfStorage($className) { - if ($className === '\OC\Files\Storage\Local') { + if ($className === \OC\Files\Storage\Local::class) { return false; } else { return parent::instanceOfStorage($className); @@ -930,7 +930,7 @@ public function testPartFileInfo() { $view = new View('/test'); $info = $view->getFileInfo('test.part'); - $this->assertInstanceOf('\OCP\Files\FileInfo', $info); + $this->assertInstanceOf(\OCP\Files\FileInfo::class, $info); $this->assertNull($info->getId()); $this->assertEquals(6, $info->getSize()); } diff --git a/tests/lib/Group/GroupTest.php b/tests/lib/Group/GroupTest.php index 9ca178d4a4122..14cdaf1f2cb6c 100644 --- a/tests/lib/Group/GroupTest.php +++ b/tests/lib/Group/GroupTest.php @@ -41,10 +41,10 @@ private function newUser($uid, \OC\User\Backend $backend) { * @return \OC\User\Manager */ protected function getUserManager() { - $userManager = $this->getMockBuilder('\OC\User\Manager') + $userManager = $this->getMockBuilder(\OC\User\Manager::class) ->disableOriginalConstructor() ->getMock(); - $backend = $this->getMockBuilder('\OC\User\Backend') + $backend = $this->getMockBuilder(\OC\User\Backend::class) ->disableOriginalConstructor() ->getMock(); $user1 = $this->newUser('user1', $backend); @@ -61,7 +61,7 @@ protected function getUserManager() { } public function testGetUsersSingleBackend() { - $backend = $this->getMockBuilder('OC\Group\Database') + $backend = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); @@ -82,10 +82,10 @@ public function testGetUsersSingleBackend() { } public function testGetUsersMultipleBackends() { - $backend1 = $this->getMockBuilder('OC\Group\Database') + $backend1 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); - $backend2 = $this->getMockBuilder('OC\Group\Database') + $backend2 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); @@ -113,11 +113,11 @@ public function testGetUsersMultipleBackends() { } public function testInGroupSingleBackend() { - $backend = $this->getMockBuilder('OC\Group\Database') + $backend = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $userBackend = $this->getMockBuilder('\OC\User\Backend') + $userBackend = $this->getMockBuilder(\OC\User\Backend::class) ->disableOriginalConstructor() ->getMock(); $group = new \OC\Group\Group('group1', [$backend], $this->dispatcher, $userManager); @@ -131,10 +131,10 @@ public function testInGroupSingleBackend() { } public function testInGroupMultipleBackends() { - $backend1 = $this->getMockBuilder('OC\Group\Database') + $backend1 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); - $backend2 = $this->getMockBuilder('OC\Group\Database') + $backend2 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); @@ -157,11 +157,11 @@ public function testInGroupMultipleBackends() { } public function testAddUser() { - $backend = $this->getMockBuilder('OC\Group\Database') + $backend = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $userBackend = $this->getMockBuilder('\OC\User\Backend') + $userBackend = $this->getMockBuilder(\OC\User\Backend::class) ->disableOriginalConstructor() ->getMock(); $group = new \OC\Group\Group('group1', [$backend], $this->dispatcher, $userManager); @@ -182,11 +182,11 @@ public function testAddUser() { } public function testAddUserAlreadyInGroup() { - $backend = $this->getMockBuilder('OC\Group\Database') + $backend = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $userBackend = $this->getMockBuilder('\OC\User\Backend') + $userBackend = $this->getMockBuilder(\OC\User\Backend::class) ->disableOriginalConstructor() ->getMock(); $group = new \OC\Group\Group('group1', [$backend], $this->dispatcher, $userManager); @@ -206,11 +206,11 @@ public function testAddUserAlreadyInGroup() { } public function testRemoveUser() { - $backend = $this->getMockBuilder('OC\Group\Database') + $backend = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $userBackend = $this->getMockBuilder('\OC\User\Backend') + $userBackend = $this->getMockBuilder(\OC\User\Backend::class) ->disableOriginalConstructor() ->getMock(); $group = new \OC\Group\Group('group1', [$backend], $this->dispatcher, $userManager); @@ -231,7 +231,7 @@ public function testRemoveUser() { } public function testRemoveUserNotInGroup() { - $backend = $this->getMockBuilder('OC\Group\Database') + $backend = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); @@ -255,14 +255,14 @@ public function testRemoveUserNotInGroup() { } public function testRemoveUserMultipleBackends() { - $backend1 = $this->getMockBuilder('OC\Group\Database') + $backend1 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); - $backend2 = $this->getMockBuilder('OC\Group\Database') + $backend2 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); - $userBackend = $this->getMockBuilder('\OC\User\Backend') + $userBackend = $this->getMockBuilder(\OC\User\Backend::class) ->disableOriginalConstructor() ->getMock(); $group = new \OC\Group\Group('group1', [$backend1, $backend2], $this->dispatcher, $userManager); @@ -295,7 +295,7 @@ public function testRemoveUserMultipleBackends() { } public function testSearchUsers() { - $backend = $this->getMockBuilder('OC\Group\Database') + $backend = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); @@ -314,10 +314,10 @@ public function testSearchUsers() { } public function testSearchUsersMultipleBackends() { - $backend1 = $this->getMockBuilder('OC\Group\Database') + $backend1 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); - $backend2 = $this->getMockBuilder('OC\Group\Database') + $backend2 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); @@ -340,7 +340,7 @@ public function testSearchUsersMultipleBackends() { } public function testSearchUsersLimitAndOffset() { - $backend = $this->getMockBuilder('OC\Group\Database') + $backend = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); @@ -359,10 +359,10 @@ public function testSearchUsersLimitAndOffset() { } public function testSearchUsersMultipleBackendsLimitAndOffset() { - $backend1 = $this->getMockBuilder('OC\Group\Database') + $backend1 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); - $backend2 = $this->getMockBuilder('OC\Group\Database') + $backend2 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); @@ -387,7 +387,7 @@ public function testSearchUsersMultipleBackendsLimitAndOffset() { } public function testCountUsers() { - $backend1 = $this->getMockBuilder('OC\Group\Database') + $backend1 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); @@ -408,10 +408,10 @@ public function testCountUsers() { } public function testCountUsersMultipleBackends() { - $backend1 = $this->getMockBuilder('OC\Group\Database') + $backend1 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); - $backend2 = $this->getMockBuilder('OC\Group\Database') + $backend2 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); @@ -439,7 +439,7 @@ public function testCountUsersMultipleBackends() { } public function testCountUsersNoMethod() { - $backend1 = $this->getMockBuilder('OC\Group\Database') + $backend1 = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); @@ -457,7 +457,7 @@ public function testCountUsersNoMethod() { } public function testDelete() { - $backend = $this->getMockBuilder('OC\Group\Database') + $backend = $this->getMockBuilder(\OC\Group\Database::class) ->disableOriginalConstructor() ->getMock(); $userManager = $this->getUserManager(); diff --git a/tests/lib/Group/MetaDataTest.php b/tests/lib/Group/MetaDataTest.php index 0c9029aaf5676..bd91203a8080a 100644 --- a/tests/lib/Group/MetaDataTest.php +++ b/tests/lib/Group/MetaDataTest.php @@ -18,7 +18,7 @@ class MetaDataTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->groupManager = $this->getMockBuilder('\OC\Group\Manager') + $this->groupManager = $this->getMockBuilder(\OC\Group\Manager::class) ->disableOriginalConstructor() ->getMock(); $this->userSession = $this->createMock(IUserSession::class); @@ -32,7 +32,7 @@ protected function setUp(): void { } private function getGroupMock($countCallCount = 0) { - $group = $this->getMockBuilder('\OC\Group\Group') + $group = $this->getMockBuilder(\OC\Group\Group::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/HookHelper.php b/tests/lib/HookHelper.php index 8b7d17a67668e..dcf5df771e3e7 100644 --- a/tests/lib/HookHelper.php +++ b/tests/lib/HookHelper.php @@ -20,38 +20,38 @@ public static function setUpHooks() { \OCP\Util::connectHook( Filesystem::CLASSNAME, Filesystem::signal_create, - '\Test\HookHelper', + \Test\HookHelper::class, 'createCallback' ); \OCP\Util::connectHook( Filesystem::CLASSNAME, Filesystem::signal_update, - '\Test\HookHelper', + \Test\HookHelper::class, 'updateCallback' ); \OCP\Util::connectHook( Filesystem::CLASSNAME, Filesystem::signal_write, - '\Test\HookHelper', + \Test\HookHelper::class, 'writeCallback' ); \OCP\Util::connectHook( Filesystem::CLASSNAME, Filesystem::signal_post_create, - '\Test\HookHelper', + \Test\HookHelper::class, 'postCreateCallback' ); \OCP\Util::connectHook( Filesystem::CLASSNAME, Filesystem::signal_post_update, - '\Test\HookHelper', + \Test\HookHelper::class, 'postUpdateCallback' ); \OCP\Util::connectHook( Filesystem::CLASSNAME, Filesystem::signal_post_write, - '\Test\HookHelper', + \Test\HookHelper::class, 'postWriteCallback' ); } diff --git a/tests/lib/Hooks/BasicEmitterTest.php b/tests/lib/Hooks/BasicEmitterTest.php index 82e5a64ecae1a..262d9bfb0fdd9 100644 --- a/tests/lib/Hooks/BasicEmitterTest.php +++ b/tests/lib/Hooks/BasicEmitterTest.php @@ -63,7 +63,7 @@ public function testAnonymousFunction() { public function testStaticCallback() { $this->expectException(\Test\Hooks\EmittedException::class); - $this->emitter->listen('Test', 'test', ['\Test\Hooks\BasicEmitterTest', 'staticCallBack']); + $this->emitter->listen('Test', 'test', [\Test\Hooks\BasicEmitterTest::class, 'staticCallBack']); $this->emitter->emitEvent('Test', 'test'); } diff --git a/tests/lib/ImageTest.php b/tests/lib/ImageTest.php index 80cf22a9442aa..5cdfbdb36cfac 100644 --- a/tests/lib/ImageTest.php +++ b/tests/lib/ImageTest.php @@ -23,27 +23,27 @@ public static function tearDownAfterClass(): void { public function testConstructDestruct() { $img = new Image(); $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); - $this->assertInstanceOf('\OC\Image', $img); - $this->assertInstanceOf('\OCP\IImage', $img); + $this->assertInstanceOf(\OC\Image::class, $img); + $this->assertInstanceOf(\OCP\IImage::class, $img); unset($img); $imgcreate = imagecreatefromjpeg(OC::$SERVERROOT.'/tests/data/testimage.jpg'); $img = new Image(); $img->setResource($imgcreate); - $this->assertInstanceOf('\OC\Image', $img); - $this->assertInstanceOf('\OCP\IImage', $img); + $this->assertInstanceOf(\OC\Image::class, $img); + $this->assertInstanceOf(\OCP\IImage::class, $img); unset($img); $base64 = base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif')); $img = new Image(); $img->loadFromBase64($base64); - $this->assertInstanceOf('\OC\Image', $img); - $this->assertInstanceOf('\OCP\IImage', $img); + $this->assertInstanceOf(\OC\Image::class, $img); + $this->assertInstanceOf(\OCP\IImage::class, $img); unset($img); $img = new Image(); - $this->assertInstanceOf('\OC\Image', $img); - $this->assertInstanceOf('\OCP\IImage', $img); + $this->assertInstanceOf(\OC\Image::class, $img); + $this->assertInstanceOf(\OCP\IImage::class, $img); unset($img); } diff --git a/tests/lib/IntegrityCheck/CheckerTest.php b/tests/lib/IntegrityCheck/CheckerTest.php index 05607f8113ce4..a9e99a4c81dfa 100644 --- a/tests/lib/IntegrityCheck/CheckerTest.php +++ b/tests/lib/IntegrityCheck/CheckerTest.php @@ -161,7 +161,7 @@ public function testVerifyAppSignatureWithoutSignatureData() { $expected = [ 'EXCEPTION' => [ - 'class' => 'OC\IntegrityCheck\Exceptions\InvalidSignatureException', + 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ]; @@ -245,7 +245,7 @@ public function testVerifyAppSignatureWithTamperedSignatureData() { $expected = [ 'EXCEPTION' => [ - 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', + 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature could not get verified.', ], ]; @@ -410,7 +410,7 @@ public function testVerifyAppWithDifferentScope() { $expected = [ 'EXCEPTION' => [ - 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', + 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Certificate is not valid for required scope. (Requested: SomeApp, current: CN=AnotherScope)', ], ]; @@ -651,7 +651,7 @@ public function testVerifyCoreSignatureWithoutSignatureData() { $expected = [ 'EXCEPTION' => [ - 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', + 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature data not found.', ], ]; @@ -858,7 +858,7 @@ public function testVerifyCoreSignatureWithTamperedSignatureData() { $expected = [ 'EXCEPTION' => [ - 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', + 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Signature could not get verified.', ] ]; @@ -959,7 +959,7 @@ public function testVerifyCoreWithInvalidCertificate() { $expected = [ 'EXCEPTION' => [ - 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', + 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Certificate is not valid.', ] ]; @@ -1002,7 +1002,7 @@ public function testVerifyCoreWithDifferentScope() { $expected = [ 'EXCEPTION' => [ - 'class' => 'OC\\IntegrityCheck\\Exceptions\\InvalidSignatureException', + 'class' => \OC\IntegrityCheck\Exceptions\InvalidSignatureException::class, 'message' => 'Certificate is not valid for required scope. (Requested: core, current: CN=SomeApp)', ] ]; @@ -1010,7 +1010,7 @@ public function testVerifyCoreWithDifferentScope() { } public function testRunInstanceVerification() { - $this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker') + $this->checker = $this->getMockBuilder(\OC\IntegrityCheck\Checker::class) ->setConstructorArgs([ $this->environmentHelper, $this->fileAccessHelper, diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php index be95307da6d2e..4d146cb72bbb2 100644 --- a/tests/lib/Mail/MailerTest.php +++ b/tests/lib/Mail/MailerTest.php @@ -179,7 +179,7 @@ public function testCreateMessage() { ->method('getSystemValueBool') ->with('mail_send_plaintext_only', false) ->willReturn(false); - $this->assertInstanceOf('\OC\Mail\Message', $this->mailer->createMessage()); + $this->assertInstanceOf(\OC\Mail\Message::class, $this->mailer->createMessage()); } @@ -194,7 +194,7 @@ public function testSendInvalidMailException() { $this->expectException(\Exception::class); /** @var Message&MockObject */ - $message = $this->getMockBuilder('\OC\Mail\Message') + $message = $this->getMockBuilder(\OC\Mail\Message::class) ->disableOriginalConstructor()->getMock(); $message->expects($this->once()) ->method('getSymfonyEmail') diff --git a/tests/lib/Memcache/CasTraitTest.php b/tests/lib/Memcache/CasTraitTest.php index 1c09a0e08f816..1502366e6473d 100644 --- a/tests/lib/Memcache/CasTraitTest.php +++ b/tests/lib/Memcache/CasTraitTest.php @@ -18,7 +18,7 @@ class CasTraitTest extends TestCase { */ private function getCache() { $sourceCache = new \OC\Memcache\ArrayCache(); - $mock = $this->getMockForTrait('\OC\Memcache\CasTrait'); + $mock = $this->getMockForTrait(\OC\Memcache\CasTrait::class); $mock->expects($this->any()) ->method('set') diff --git a/tests/lib/Migration/BackgroundRepairTest.php b/tests/lib/Migration/BackgroundRepairTest.php index 2744ac5cefb64..0c4fe69fc8992 100644 --- a/tests/lib/Migration/BackgroundRepairTest.php +++ b/tests/lib/Migration/BackgroundRepairTest.php @@ -106,7 +106,7 @@ public function testWorkingStep() { $this->job->setArgument([ 'app' => 'test', - 'step' => '\Test\Migration\TestRepairStep' + 'step' => \Test\Migration\TestRepairStep::class ]); $this->job->start($this->jobList); } diff --git a/tests/lib/OCS/ProviderTest.php b/tests/lib/OCS/ProviderTest.php index c1efa7d873e53..c4a319db09bda 100644 --- a/tests/lib/OCS/ProviderTest.php +++ b/tests/lib/OCS/ProviderTest.php @@ -20,8 +20,8 @@ class ProviderTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->request = $this->getMockBuilder('\\OCP\\IRequest')->getMock(); - $this->appManager = $this->getMockBuilder('\\OCP\\App\\IAppManager')->getMock(); + $this->request = $this->getMockBuilder(\OCP\IRequest::class)->getMock(); + $this->appManager = $this->getMockBuilder(\OCP\App\IAppManager::class)->getMock(); $this->ocsProvider = new Provider('ocs_provider', $this->request, $this->appManager); } diff --git a/tests/lib/Repair/CleanTagsTest.php b/tests/lib/Repair/CleanTagsTest.php index 11430cc121550..6c25248df774a 100644 --- a/tests/lib/Repair/CleanTagsTest.php +++ b/tests/lib/Repair/CleanTagsTest.php @@ -37,7 +37,7 @@ class CleanTagsTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->outputMock = $this->getMockBuilder('\OCP\Migration\IOutput') + $this->outputMock = $this->getMockBuilder(\OCP\Migration\IOutput::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Repair/OldGroupMembershipSharesTest.php b/tests/lib/Repair/OldGroupMembershipSharesTest.php index 4678bd174eb3d..c734f0a9e1322 100644 --- a/tests/lib/Repair/OldGroupMembershipSharesTest.php +++ b/tests/lib/Repair/OldGroupMembershipSharesTest.php @@ -32,7 +32,7 @@ protected function setUp(): void { parent::setUp(); /** \OCP\IGroupManager|\PHPUnit\Framework\MockObject\MockObject */ - $this->groupManager = $this->getMockBuilder('OCP\IGroupManager') + $this->groupManager = $this->getMockBuilder(\OCP\IGroupManager::class) ->disableOriginalConstructor() ->getMock(); $this->connection = \OC::$server->getDatabaseConnection(); @@ -82,7 +82,7 @@ public function testRun() { $result->closeCursor(); /** @var IOutput | \PHPUnit\Framework\MockObject\MockObject $outputMock */ - $outputMock = $this->getMockBuilder('\OCP\Migration\IOutput') + $outputMock = $this->getMockBuilder(\OCP\Migration\IOutput::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Repair/RepairCollationTest.php b/tests/lib/Repair/RepairCollationTest.php index 234f68892b3ba..bfeae9e769e70 100644 --- a/tests/lib/Repair/RepairCollationTest.php +++ b/tests/lib/Repair/RepairCollationTest.php @@ -81,7 +81,7 @@ public function testCollationConvert() { $this->assertGreaterThanOrEqual(1, count($tables)); /** @var IOutput | \PHPUnit\Framework\MockObject\MockObject $outputMock */ - $outputMock = $this->getMockBuilder('\OCP\Migration\IOutput') + $outputMock = $this->getMockBuilder(\OCP\Migration\IOutput::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php index eb0e46c61db39..d43b3969a294e 100644 --- a/tests/lib/Repair/RepairInvalidSharesTest.php +++ b/tests/lib/Repair/RepairInvalidSharesTest.php @@ -109,7 +109,7 @@ public function testSharesNonExistingParent() { $result->closeCursor(); /** @var IOutput | \PHPUnit\Framework\MockObject\MockObject $outputMock */ - $outputMock = $this->getMockBuilder('\OCP\Migration\IOutput') + $outputMock = $this->getMockBuilder(\OCP\Migration\IOutput::class) ->disableOriginalConstructor() ->getMock(); @@ -172,7 +172,7 @@ public function testFileSharePermissions($itemType, $testPerms, $expectedPerms) $shareId = $this->getLastShareId(); /** @var IOutput | \PHPUnit\Framework\MockObject\MockObject $outputMock */ - $outputMock = $this->getMockBuilder('\OCP\Migration\IOutput') + $outputMock = $this->getMockBuilder(\OCP\Migration\IOutput::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Repair/RepairMimeTypesTest.php b/tests/lib/Repair/RepairMimeTypesTest.php index fbccd393fd0a4..393187b9ab993 100644 --- a/tests/lib/Repair/RepairMimeTypesTest.php +++ b/tests/lib/Repair/RepairMimeTypesTest.php @@ -98,7 +98,7 @@ private function renameMimeTypes($currentMimeTypes, $fixedMimeTypes) { $this->addEntries($currentMimeTypes); /** @var IOutput | \PHPUnit\Framework\MockObject\MockObject $outputMock */ - $outputMock = $this->getMockBuilder('\OCP\Migration\IOutput') + $outputMock = $this->getMockBuilder(\OCP\Migration\IOutput::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php b/tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php index 82bffb74e0159..e566f4f4e5a7a 100644 --- a/tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php +++ b/tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php @@ -36,7 +36,7 @@ protected function setUp(): void { $this->cacheFactory ->expects($this->once()) ->method('createDistributed') - ->with('OC\Security\Bruteforce\Backend\MemoryCacheBackend') + ->with(\OC\Security\Bruteforce\Backend\MemoryCacheBackend::class) ->willReturn($this->cache); $this->backend = new MemoryCacheBackend( diff --git a/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php b/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php index 8b92848341c98..449a7956756ee 100644 --- a/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php +++ b/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php @@ -18,7 +18,7 @@ class CsrfTokenGeneratorTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->random = $this->getMockBuilder('\OCP\Security\ISecureRandom') + $this->random = $this->getMockBuilder(\OCP\Security\ISecureRandom::class) ->disableOriginalConstructor()->getMock(); $this->csrfTokenGenerator = new \OC\Security\CSRF\CsrfTokenGenerator($this->random); } diff --git a/tests/lib/Security/CSRF/CsrfTokenManagerTest.php b/tests/lib/Security/CSRF/CsrfTokenManagerTest.php index 8c19bc6e82d7d..5c4ad6346e794 100644 --- a/tests/lib/Security/CSRF/CsrfTokenManagerTest.php +++ b/tests/lib/Security/CSRF/CsrfTokenManagerTest.php @@ -20,9 +20,9 @@ class CsrfTokenManagerTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->tokenGenerator = $this->getMockBuilder('\OC\Security\CSRF\CsrfTokenGenerator') + $this->tokenGenerator = $this->getMockBuilder(\OC\Security\CSRF\CsrfTokenGenerator::class) ->disableOriginalConstructor()->getMock(); - $this->storageInterface = $this->getMockBuilder('\OC\Security\CSRF\TokenStorage\SessionStorage') + $this->storageInterface = $this->getMockBuilder(\OC\Security\CSRF\TokenStorage\SessionStorage::class) ->disableOriginalConstructor()->getMock(); $this->csrfTokenManager = new \OC\Security\CSRF\CsrfTokenManager( diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php index e123ebeda25df..1e2d5fb601ea7 100644 --- a/tests/lib/Security/CertificateManagerTest.php +++ b/tests/lib/Security/CertificateManagerTest.php @@ -151,7 +151,7 @@ public function testNeedRebundling($CaBundleMtime, $config = $this->createMock(IConfig::class); /** @var CertificateManager | \PHPUnit\Framework\MockObject\MockObject $certificateManager */ - $certificateManager = $this->getMockBuilder('OC\Security\CertificateManager') + $certificateManager = $this->getMockBuilder(\OC\Security\CertificateManager::class) ->setConstructorArgs([$view, $config, $this->createMock(LoggerInterface::class), $this->random]) ->setMethods(['getFilemtimeOfCaBundle', 'getCertificateBundle']) ->getMock(); diff --git a/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php b/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php index 27799ce4af5fc..62325461ef136 100644 --- a/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php +++ b/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php @@ -39,7 +39,7 @@ protected function setUp(): void { $this->cacheFactory ->expects($this->once()) ->method('createDistributed') - ->with('OC\Security\RateLimiting\Backend\MemoryCacheBackend') + ->with(\OC\Security\RateLimiting\Backend\MemoryCacheBackend::class) ->willReturn($this->cache); $this->config->method('getSystemValueBool') diff --git a/tests/lib/ServerTest.php b/tests/lib/ServerTest.php index e43c10b9cde6d..3ccda8fce7cc8 100644 --- a/tests/lib/ServerTest.php +++ b/tests/lib/ServerTest.php @@ -31,118 +31,118 @@ protected function setUp(): void { public function dataTestQuery() { return [ - ['ActivityManager', '\OC\Activity\Manager'], - ['ActivityManager', '\OCP\Activity\IManager'], - ['AllConfig', '\OC\AllConfig'], - ['AllConfig', '\OCP\IConfig'], - ['AppConfig', '\OC\AppConfig'], - ['AppConfig', '\OCP\IAppConfig'], + ['ActivityManager', \OC\Activity\Manager::class], + ['ActivityManager', \OCP\Activity\IManager::class], + ['AllConfig', \OC\AllConfig::class], + ['AllConfig', \OCP\IConfig::class], + ['AppConfig', \OC\AppConfig::class], + ['AppConfig', \OCP\IAppConfig::class], ['AppFetcher', AppFetcher::class], - ['AppManager', '\OC\App\AppManager'], - ['AppManager', '\OCP\App\IAppManager'], - ['AsyncCommandBus', '\OC\Command\AsyncBus'], - ['AsyncCommandBus', '\OCP\Command\IBus'], - ['AvatarManager', '\OC\Avatar\AvatarManager'], - ['AvatarManager', '\OCP\IAvatarManager'], + ['AppManager', \OC\App\AppManager::class], + ['AppManager', \OCP\App\IAppManager::class], + ['AsyncCommandBus', \OC\Command\AsyncBus::class], + ['AsyncCommandBus', \OCP\Command\IBus::class], + ['AvatarManager', \OC\Avatar\AvatarManager::class], + ['AvatarManager', \OCP\IAvatarManager::class], ['CategoryFetcher', CategoryFetcher::class], - ['CapabilitiesManager', '\OC\CapabilitiesManager'], - ['ContactsManager', '\OC\ContactsManager'], - ['ContactsManager', '\OCP\Contacts\IManager'], - ['ContentSecurityPolicyManager', '\OC\Security\CSP\ContentSecurityPolicyManager'], - ['CommentsManager', '\OCP\Comments\ICommentsManager'], - ['Crypto', '\OC\Security\Crypto'], - ['Crypto', '\OCP\Security\ICrypto'], - ['CryptoWrapper', '\OC\Session\CryptoWrapper'], - ['CsrfTokenManager', '\OC\Security\CSRF\CsrfTokenManager'], - - ['DatabaseConnection', '\OC\DB\ConnectionAdapter'], - ['DatabaseConnection', '\OCP\IDBConnection'], - ['DateTimeFormatter', '\OC\DateTimeFormatter'], - ['DateTimeFormatter', '\OCP\IDateTimeFormatter'], - ['DateTimeZone', '\OC\DateTimeZone'], - ['DateTimeZone', '\OCP\IDateTimeZone'], - - ['EncryptionFileHelper', '\OC\Encryption\File'], - ['EncryptionFileHelper', '\OCP\Encryption\IFile'], - ['EncryptionKeyStorage', '\OC\Encryption\Keys\Storage'], - ['EncryptionKeyStorage', '\OCP\Encryption\Keys\IStorage'], - ['EncryptionManager', '\OC\Encryption\Manager'], - ['EncryptionManager', '\OCP\Encryption\IManager'], - ['EventLogger', '\OCP\Diagnostics\IEventLogger'], - - ['GroupManager', '\OC\Group\Manager'], - ['GroupManager', '\OCP\IGroupManager'], - - ['Hasher', '\OC\Security\Hasher'], - ['Hasher', '\OCP\Security\IHasher'], - ['HttpClientService', '\OC\Http\Client\ClientService'], - ['HttpClientService', '\OCP\Http\Client\IClientService'], + ['CapabilitiesManager', \OC\CapabilitiesManager::class], + ['ContactsManager', \OC\ContactsManager::class], + ['ContactsManager', \OCP\Contacts\IManager::class], + ['ContentSecurityPolicyManager', \OC\Security\CSP\ContentSecurityPolicyManager::class], + ['CommentsManager', \OCP\Comments\ICommentsManager::class], + ['Crypto', \OC\Security\Crypto::class], + ['Crypto', \OCP\Security\ICrypto::class], + ['CryptoWrapper', \OC\Session\CryptoWrapper::class], + ['CsrfTokenManager', \OC\Security\CSRF\CsrfTokenManager::class], + + ['DatabaseConnection', \OC\DB\ConnectionAdapter::class], + ['DatabaseConnection', \OCP\IDBConnection::class], + ['DateTimeFormatter', \OC\DateTimeFormatter::class], + ['DateTimeFormatter', \OCP\IDateTimeFormatter::class], + ['DateTimeZone', \OC\DateTimeZone::class], + ['DateTimeZone', \OCP\IDateTimeZone::class], + + ['EncryptionFileHelper', \OC\Encryption\File::class], + ['EncryptionFileHelper', \OCP\Encryption\IFile::class], + ['EncryptionKeyStorage', \OC\Encryption\Keys\Storage::class], + ['EncryptionKeyStorage', \OCP\Encryption\Keys\IStorage::class], + ['EncryptionManager', \OC\Encryption\Manager::class], + ['EncryptionManager', \OCP\Encryption\IManager::class], + ['EventLogger', \OCP\Diagnostics\IEventLogger::class], + + ['GroupManager', \OC\Group\Manager::class], + ['GroupManager', \OCP\IGroupManager::class], + + ['Hasher', \OC\Security\Hasher::class], + ['Hasher', \OCP\Security\IHasher::class], + ['HttpClientService', \OC\Http\Client\ClientService::class], + ['HttpClientService', \OCP\Http\Client\IClientService::class], ['IniWrapper', '\bantu\IniGetWrapper\IniGetWrapper'], - ['MimeTypeDetector', '\OCP\Files\IMimeTypeDetector'], - ['MimeTypeDetector', '\OC\Files\Type\Detection'], - - ['JobList', '\OC\BackgroundJob\JobList'], - ['JobList', '\OCP\BackgroundJob\IJobList'], - - ['L10NFactory', '\OC\L10N\Factory'], - ['L10NFactory', '\OCP\L10N\IFactory'], - ['LockingProvider', '\OCP\Lock\ILockingProvider'], - ['Logger', '\OC\Log'], - ['Logger', '\OCP\ILogger'], - - ['Mailer', '\OC\Mail\Mailer'], - ['Mailer', '\OCP\Mail\IMailer'], - ['MemCacheFactory', '\OC\Memcache\Factory'], - ['MemCacheFactory', '\OCP\ICacheFactory'], - ['MountConfigManager', '\OC\Files\Config\MountProviderCollection'], - ['MountConfigManager', '\OCP\Files\Config\IMountProviderCollection'], - - ['NavigationManager', '\OC\NavigationManager'], - ['NavigationManager', '\OCP\INavigationManager'], - ['NotificationManager', '\OC\Notification\Manager'], - ['NotificationManager', '\OCP\Notification\IManager'], - ['UserCache', '\OC\Cache\File'], - ['UserCache', '\OCP\ICache'], - - ['PreviewManager', '\OC\PreviewManager'], - ['PreviewManager', '\OCP\IPreview'], - - ['QueryLogger', '\OCP\Diagnostics\IQueryLogger'], - - ['Request', '\OC\AppFramework\Http\Request'], - ['Request', '\OCP\IRequest'], - ['RootFolder', '\OC\Files\Node\Root'], - ['RootFolder', '\OC\Files\Node\Folder'], - ['RootFolder', '\OCP\Files\IRootFolder'], - ['RootFolder', '\OCP\Files\Folder'], - ['Router', '\OCP\Route\IRouter'], - - ['SecureRandom', '\OC\Security\SecureRandom'], - ['SecureRandom', '\OCP\Security\ISecureRandom'], - ['ShareManager', '\OC\Share20\Manager'], - ['ShareManager', '\OCP\Share\IManager'], - ['SystemConfig', '\OC\SystemConfig'], - - ['URLGenerator', '\OC\URLGenerator'], - ['URLGenerator', '\OCP\IURLGenerator'], - ['UserManager', '\OC\User\Manager'], - ['UserManager', '\OCP\IUserManager'], - ['UserSession', '\OC\User\Session'], - ['UserSession', '\OCP\IUserSession'], - - ['TagMapper', '\OC\Tagging\TagMapper'], - ['TagMapper', '\OCP\AppFramework\Db\QBMapper'], - ['TagManager', '\OC\TagManager'], - ['TagManager', '\OCP\ITagManager'], - ['TempManager', '\OC\TempManager'], - ['TempManager', '\OCP\ITempManager'], - ['ThemingDefaults', '\OCA\Theming\ThemingDefaults'], - ['TrustedDomainHelper', '\OC\Security\TrustedDomainHelper'], - - ['SystemTagManager', '\OCP\SystemTag\ISystemTagManager'], - ['SystemTagObjectMapper', '\OCP\SystemTag\ISystemTagObjectMapper'], + ['MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class], + ['MimeTypeDetector', \OC\Files\Type\Detection::class], + + ['JobList', \OC\BackgroundJob\JobList::class], + ['JobList', \OCP\BackgroundJob\IJobList::class], + + ['L10NFactory', \OC\L10N\Factory::class], + ['L10NFactory', \OCP\L10N\IFactory::class], + ['LockingProvider', \OCP\Lock\ILockingProvider::class], + ['Logger', \OC\Log::class], + ['Logger', \OCP\ILogger::class], + + ['Mailer', \OC\Mail\Mailer::class], + ['Mailer', \OCP\Mail\IMailer::class], + ['MemCacheFactory', \OC\Memcache\Factory::class], + ['MemCacheFactory', \OCP\ICacheFactory::class], + ['MountConfigManager', \OC\Files\Config\MountProviderCollection::class], + ['MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class], + + ['NavigationManager', \OC\NavigationManager::class], + ['NavigationManager', \OCP\INavigationManager::class], + ['NotificationManager', \OC\Notification\Manager::class], + ['NotificationManager', \OCP\Notification\IManager::class], + ['UserCache', \OC\Cache\File::class], + ['UserCache', \OCP\ICache::class], + + ['PreviewManager', \OC\PreviewManager::class], + ['PreviewManager', \OCP\IPreview::class], + + ['QueryLogger', \OCP\Diagnostics\IQueryLogger::class], + + ['Request', \OC\AppFramework\Http\Request::class], + ['Request', \OCP\IRequest::class], + ['RootFolder', \OC\Files\Node\Root::class], + ['RootFolder', \OC\Files\Node\Folder::class], + ['RootFolder', \OCP\Files\IRootFolder::class], + ['RootFolder', \OCP\Files\Folder::class], + ['Router', \OCP\Route\IRouter::class], + + ['SecureRandom', \OC\Security\SecureRandom::class], + ['SecureRandom', \OCP\Security\ISecureRandom::class], + ['ShareManager', \OC\Share20\Manager::class], + ['ShareManager', \OCP\Share\IManager::class], + ['SystemConfig', \OC\SystemConfig::class], + + ['URLGenerator', \OC\URLGenerator::class], + ['URLGenerator', \OCP\IURLGenerator::class], + ['UserManager', \OC\User\Manager::class], + ['UserManager', \OCP\IUserManager::class], + ['UserSession', \OC\User\Session::class], + ['UserSession', \OCP\IUserSession::class], + + ['TagMapper', \OC\Tagging\TagMapper::class], + ['TagMapper', \OCP\AppFramework\Db\QBMapper::class], + ['TagManager', \OC\TagManager::class], + ['TagManager', \OCP\ITagManager::class], + ['TempManager', \OC\TempManager::class], + ['TempManager', \OCP\ITempManager::class], + ['ThemingDefaults', \OCA\Theming\ThemingDefaults::class], + ['TrustedDomainHelper', \OC\Security\TrustedDomainHelper::class], + + ['SystemTagManager', \OCP\SystemTag\ISystemTagManager::class], + ['SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class], ]; } @@ -157,18 +157,18 @@ public function testQuery($serviceName, $instanceOf) { } public function testGetCertificateManager() { - $this->assertInstanceOf('\OC\Security\CertificateManager', $this->server->getCertificateManager(), 'service returned by "getCertificateManager" did not return the right class'); - $this->assertInstanceOf('\OCP\ICertificateManager', $this->server->getCertificateManager(), 'service returned by "getCertificateManager" did not return the right class'); + $this->assertInstanceOf(\OC\Security\CertificateManager::class, $this->server->getCertificateManager(), 'service returned by "getCertificateManager" did not return the right class'); + $this->assertInstanceOf(\OCP\ICertificateManager::class, $this->server->getCertificateManager(), 'service returned by "getCertificateManager" did not return the right class'); } public function testOverwriteDefaultCommentsManager() { $config = $this->server->getConfig(); - $defaultManagerFactory = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); + $defaultManagerFactory = $config->getSystemValue('comments.managerFactory', \OC\Comments\ManagerFactory::class); - $config->setSystemValue('comments.managerFactory', '\Test\Comments\FakeFactory'); + $config->setSystemValue('comments.managerFactory', \Test\Comments\FakeFactory::class); $manager = $this->server->get(ICommentsManager::class); - $this->assertInstanceOf('\OCP\Comments\ICommentsManager', $manager); + $this->assertInstanceOf(\OCP\Comments\ICommentsManager::class, $manager); $config->setSystemValue('comments.managerFactory', $defaultManagerFactory); } diff --git a/tests/lib/Session/CryptoWrappingTest.php b/tests/lib/Session/CryptoWrappingTest.php index 093f2214929ee..da29f7470e6ef 100644 --- a/tests/lib/Session/CryptoWrappingTest.php +++ b/tests/lib/Session/CryptoWrappingTest.php @@ -27,7 +27,7 @@ protected function setUp(): void { $this->wrappedSession = $this->getMockBuilder(ISession::class) ->disableOriginalConstructor() ->getMock(); - $this->crypto = $this->getMockBuilder('OCP\Security\ICrypto') + $this->crypto = $this->getMockBuilder(\OCP\Security\ICrypto::class) ->disableOriginalConstructor() ->getMock(); $this->crypto->expects($this->any()) diff --git a/tests/lib/Share/ShareTest.php b/tests/lib/Share/ShareTest.php index d6ed54f06da3c..9938048450d0d 100644 --- a/tests/lib/Share/ShareTest.php +++ b/tests/lib/Share/ShareTest.php @@ -76,8 +76,8 @@ protected function setUp(): void { $this->groupAndUser_group->addUser($this->user2); $this->groupAndUser_group->addUser($this->user3); - Share::registerBackend('test', 'Test\Share\Backend'); - \OC_Hook::clear('OCP\\Share'); + Share::registerBackend('test', \Test\Share\Backend::class); + \OC_Hook::clear(\OCP\Share::class); \OC::registerShareHooks(\OC::$server->getSystemConfig()); $this->resharing = \OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_resharing', 'yes'); \OC::$server->getConfig()->setAppValue('core', 'shareapi_allow_resharing', 'yes'); diff --git a/tests/lib/Share20/LegacyHooksTest.php b/tests/lib/Share20/LegacyHooksTest.php index 87643614f7442..115bfa077979a 100644 --- a/tests/lib/Share20/LegacyHooksTest.php +++ b/tests/lib/Share20/LegacyHooksTest.php @@ -61,7 +61,7 @@ public function testPreUnshare() { ->setNodeCacheEntry($info); $hookListner = $this->getMockBuilder('Dummy')->setMethods(['pre'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'pre_unshare', $hookListner, 'pre'); + \OCP\Util::connectHook(\OCP\Share::class, 'pre_unshare', $hookListner, 'pre'); $hookListnerExpectsPre = [ 'id' => 42, @@ -102,7 +102,7 @@ public function testPostUnshare() { ->setNodeCacheEntry($info); $hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_unshare', $hookListner, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_unshare', $hookListner, 'post'); $hookListnerExpectsPost = [ 'id' => 42, @@ -156,7 +156,7 @@ public function testPostUnshareFromSelf() { ->setNodeCacheEntry($info); $hookListner = $this->getMockBuilder('Dummy')->setMethods(['postFromSelf'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_unshareFromSelf', $hookListner, 'postFromSelf'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_unshareFromSelf', $hookListner, 'postFromSelf'); $hookListnerExpectsPostFromSelf = [ 'id' => 42, @@ -213,7 +213,7 @@ public function testPreShare() { $hookListner = $this->getMockBuilder('Dummy')->setMethods(['preShare'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'pre_shared', $hookListner, 'preShare'); + \OCP\Util::connectHook(\OCP\Share::class, 'pre_shared', $hookListner, 'preShare'); $run = true; $error = ''; @@ -261,7 +261,7 @@ public function testPreShareError() { $hookListner = $this->getMockBuilder('Dummy')->setMethods(['preShare'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'pre_shared', $hookListner, 'preShare'); + \OCP\Util::connectHook(\OCP\Share::class, 'pre_shared', $hookListner, 'preShare'); $run = true; $error = ''; @@ -317,7 +317,7 @@ public function testPostShare() { $hookListner = $this->getMockBuilder('Dummy')->setMethods(['postShare'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_shared', $hookListner, 'postShare'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_shared', $hookListner, 'postShare'); $expected = [ 'id' => 42, diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index f7b8f1458b3f0..527164ea33464 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -633,7 +633,7 @@ public function dataGeneralChecks() { $node = $this->createMock(Node::class); $storage = $this->createMock(Storage\IStorage::class); $storage->method('instanceOfStorage') - ->with('\OCA\Files_Sharing\External\Storage') + ->with(\OCA\Files_Sharing\External\Storage::class) ->willReturn(false); $file->method('getStorage') ->willReturn($storage); @@ -708,7 +708,7 @@ public function dataGeneralChecks() { $nonMovableStorage = $this->createMock(Storage\IStorage::class); $nonMovableStorage->method('instanceOfStorage') - ->with('\OCA\Files_Sharing\External\Storage') + ->with(\OCA\Files_Sharing\External\Storage::class) ->willReturn(false); $nonMovableStorage->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_ALL); $nonMoveableMountPermssions = $this->createMock(Folder::class); @@ -754,7 +754,7 @@ public function dataGeneralChecks() { $remoteStorage = $this->createMock(Storage\IStorage::class); $remoteStorage->method('instanceOfStorage') - ->with('\OCA\Files_Sharing\External\Storage') + ->with(\OCA\Files_Sharing\External\Storage::class) ->willReturn(true); $remoteFile = $this->createMock(Folder::class); $remoteFile->method('isShareable')->willReturn(true); @@ -2061,7 +2061,7 @@ public function testPathCreateChecksContainsSharedMount() { $mount = $this->createMock(IMountPoint::class); $storage = $this->createMock(Storage::class); $mount->method('getStorage')->willReturn($storage); - $storage->method('instanceOfStorage')->with('\OCA\Files_Sharing\ISharedStorage')->willReturn(true); + $storage->method('instanceOfStorage')->with(\OCA\Files_Sharing\ISharedStorage::class)->willReturn(true); $this->mountManager->method('findIn')->with('path')->willReturn([$mount]); @@ -2075,7 +2075,7 @@ public function testPathCreateChecksContainsNoSharedMount() { $mount = $this->createMock(IMountPoint::class); $storage = $this->createMock(Storage::class); $mount->method('getStorage')->willReturn($storage); - $storage->method('instanceOfStorage')->with('\OCA\Files_Sharing\ISharedStorage')->willReturn(false); + $storage->method('instanceOfStorage')->with(\OCA\Files_Sharing\ISharedStorage::class)->willReturn(false); $this->mountManager->method('findIn')->with('path')->willReturn([$mount]); @@ -2625,12 +2625,12 @@ public function testCreateShareOfIncomingFederatedShare() { $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') - ->with('OCA\Files_Sharing\External\Storage') + ->with(\OCA\Files_Sharing\External\Storage::class) ->willReturn(true); $storage2 = $this->createMock(Storage::class); $storage2->method('instanceOfStorage') - ->with('OCA\Files_Sharing\External\Storage') + ->with(\OCA\Files_Sharing\External\Storage::class) ->willReturn(false); $path = $this->createMock(File::class); @@ -3232,14 +3232,14 @@ public function testUpdateShareUser() { ->willReturn($share); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_set_expiration_date', $hookListener, 'post'); $hookListener->expects($this->never())->method('post'); $this->rootFolder->method('getUserFolder')->with('newUser')->willReturnSelf(); $this->rootFolder->method('getRelativePath')->with('/newUser/files/myPath')->willReturn('/myPath'); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener2, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_permissions', $hookListener2, 'post'); $hookListener2->expects($this->once())->method('post')->with([ 'itemType' => 'file', 'itemSource' => 100, @@ -3290,11 +3290,11 @@ public function testUpdateShareGroup() { ->willReturn($share); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_set_expiration_date', $hookListener, 'post'); $hookListener->expects($this->never())->method('post'); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener2, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_permissions', $hookListener2, 'post'); $hookListener2->expects($this->never())->method('post'); $manager->updateShare($share); @@ -3352,7 +3352,7 @@ public function testUpdateShareLink() { ->willReturn($share); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_set_expiration_date', $hookListener, 'post'); $hookListener->expects($this->once())->method('post')->with([ 'itemType' => 'file', 'itemSource' => 100, @@ -3361,7 +3361,7 @@ public function testUpdateShareLink() { ]); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_password', $hookListener2, 'post'); $hookListener2->expects($this->once())->method('post')->with([ 'itemType' => 'file', 'itemSource' => 100, @@ -3371,7 +3371,7 @@ public function testUpdateShareLink() { ]); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_permissions', $hookListener3, 'post'); $hookListener3->expects($this->never())->method('post'); @@ -3433,15 +3433,15 @@ public function testUpdateShareLinkEnableSendPasswordByTalkWithNoPassword() { ->method('update'); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_set_expiration_date', $hookListener, 'post'); $hookListener->expects($this->never())->method('post'); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_password', $hookListener2, 'post'); $hookListener2->expects($this->never())->method('post'); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_permissions', $hookListener3, 'post'); $hookListener3->expects($this->never())->method('post'); $manager->updateShare($share); @@ -3502,7 +3502,7 @@ public function testUpdateShareMail() { ->willReturn($share); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_set_expiration_date', $hookListener, 'post'); $hookListener->expects($this->once())->method('post')->with([ 'itemType' => 'file', 'itemSource' => 100, @@ -3511,7 +3511,7 @@ public function testUpdateShareMail() { ]); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_password', $hookListener2, 'post'); $hookListener2->expects($this->once())->method('post')->with([ 'itemType' => 'file', 'itemSource' => 100, @@ -3521,7 +3521,7 @@ public function testUpdateShareMail() { ]); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_permissions', $hookListener3, 'post'); $hookListener3->expects($this->never())->method('post'); $manager->updateShare($share); @@ -3585,7 +3585,7 @@ public function testUpdateShareMailEnableSendPasswordByTalk() { ->willReturn($share); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_set_expiration_date', $hookListener, 'post'); $hookListener->expects($this->once())->method('post')->with([ 'itemType' => 'file', 'itemSource' => 100, @@ -3594,7 +3594,7 @@ public function testUpdateShareMailEnableSendPasswordByTalk() { ]); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_password', $hookListener2, 'post'); $hookListener2->expects($this->once())->method('post')->with([ 'itemType' => 'file', 'itemSource' => 100, @@ -3604,7 +3604,7 @@ public function testUpdateShareMailEnableSendPasswordByTalk() { ]); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_permissions', $hookListener3, 'post'); $hookListener3->expects($this->never())->method('post'); $manager->updateShare($share); @@ -3673,7 +3673,7 @@ public function testUpdateShareMailEnableSendPasswordByTalkWithDifferentPassword ->willReturn($share); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_set_expiration_date', $hookListener, 'post'); $hookListener->expects($this->once())->method('post')->with([ 'itemType' => 'file', 'itemSource' => 100, @@ -3682,7 +3682,7 @@ public function testUpdateShareMailEnableSendPasswordByTalkWithDifferentPassword ]); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_password', $hookListener2, 'post'); $hookListener2->expects($this->once())->method('post')->with([ 'itemType' => 'file', 'itemSource' => 100, @@ -3692,7 +3692,7 @@ public function testUpdateShareMailEnableSendPasswordByTalkWithDifferentPassword ]); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_permissions', $hookListener3, 'post'); $hookListener3->expects($this->never())->method('post'); $manager->updateShare($share); @@ -3756,15 +3756,15 @@ public function testUpdateShareMailEnableSendPasswordByTalkWithNoPassword() { ->method('update'); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_set_expiration_date', $hookListener, 'post'); $hookListener->expects($this->never())->method('post'); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_password', $hookListener2, 'post'); $hookListener2->expects($this->never())->method('post'); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_permissions', $hookListener3, 'post'); $hookListener3->expects($this->never())->method('post'); $manager->updateShare($share); @@ -3829,15 +3829,15 @@ public function testUpdateShareMailEnableSendPasswordByTalkRemovingPassword() { ->method('update'); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_set_expiration_date', $hookListener, 'post'); $hookListener->expects($this->never())->method('post'); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_password', $hookListener2, 'post'); $hookListener2->expects($this->never())->method('post'); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_permissions', $hookListener3, 'post'); $hookListener3->expects($this->never())->method('post'); $manager->updateShare($share); @@ -3902,15 +3902,15 @@ public function testUpdateShareMailEnableSendPasswordByTalkRemovingPasswordWithE ->method('update'); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_set_expiration_date', $hookListener, 'post'); $hookListener->expects($this->never())->method('post'); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_password', $hookListener2, 'post'); $hookListener2->expects($this->never())->method('post'); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_permissions', $hookListener3, 'post'); $hookListener3->expects($this->never())->method('post'); $manager->updateShare($share); @@ -3977,15 +3977,15 @@ public function testUpdateShareMailEnableSendPasswordByTalkWithPreviousPassword( ->method('update'); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_set_expiration_date', $hookListener, 'post'); $hookListener->expects($this->never())->method('post'); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_password', $hookListener2, 'post'); $hookListener2->expects($this->never())->method('post'); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_permissions', $hookListener3, 'post'); $hookListener3->expects($this->never())->method('post'); $manager->updateShare($share); @@ -4051,15 +4051,15 @@ public function testUpdateShareMailDisableSendPasswordByTalkWithPreviousPassword ->method('update'); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_set_expiration_date', $hookListener, 'post'); $hookListener->expects($this->never())->method('post'); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_password', $hookListener2, 'post'); $hookListener2->expects($this->never())->method('post'); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_permissions', $hookListener3, 'post'); $hookListener3->expects($this->never())->method('post'); $manager->updateShare($share); @@ -4125,15 +4125,15 @@ public function testUpdateShareMailDisableSendPasswordByTalkWithoutChangingPassw ->method('update'); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_set_expiration_date', $hookListener, 'post'); $hookListener->expects($this->never())->method('post'); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_password', $hookListener2, 'post'); $hookListener2->expects($this->never())->method('post'); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); - \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post'); + \OCP\Util::connectHook(\OCP\Share::class, 'post_update_permissions', $hookListener3, 'post'); $hookListener3->expects($this->never())->method('post'); $manager->updateShare($share); @@ -4240,7 +4240,7 @@ public function testMoveShareGroup() { * @dataProvider dataTestShareProviderExists */ public function testShareProviderExists($shareType, $expected) { - $factory = $this->getMockBuilder('OCP\Share\IProviderFactory')->getMock(); + $factory = $this->getMockBuilder(\OCP\Share\IProviderFactory::class)->getMock(); $factory->expects($this->any())->method('getProviderForType') ->willReturnCallback(function ($id) { if ($id === IShare::TYPE_USER) { diff --git a/tests/lib/Template/ResourceLocatorTest.php b/tests/lib/Template/ResourceLocatorTest.php index e74e72014c5d5..6841efc185f0a 100644 --- a/tests/lib/Template/ResourceLocatorTest.php +++ b/tests/lib/Template/ResourceLocatorTest.php @@ -32,7 +32,7 @@ public function getResourceLocator($theme) { ->with('theme', '') ->willReturn($theme); $this->overwriteService(SystemConfig::class, $systemConfig); - return $this->getMockForAbstractClass('OC\Template\ResourceLocator', + return $this->getMockForAbstractClass(\OC\Template\ResourceLocator::class, [$this->logger], '', true, true, true, []); } diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php index 9369a20eb8112..460e695f7dca5 100644 --- a/tests/lib/TestCase.php +++ b/tests/lib/TestCase.php @@ -534,7 +534,7 @@ protected function assertTemplate($expectedHtml, $template, $vars = []) { $requestToken = 12345; /** @var Defaults|\PHPUnit\Framework\MockObject\MockObject $l10n */ - $theme = $this->getMockBuilder('\OCP\Defaults') + $theme = $this->getMockBuilder(\OCP\Defaults::class) ->disableOriginalConstructor()->getMock(); $theme->expects($this->any()) ->method('getName') diff --git a/tests/lib/Traits/MountProviderTrait.php b/tests/lib/Traits/MountProviderTrait.php index 6d947d645dd63..c957379aa3cd8 100644 --- a/tests/lib/Traits/MountProviderTrait.php +++ b/tests/lib/Traits/MountProviderTrait.php @@ -46,7 +46,7 @@ protected function registerStorageWrapper($name, $wrapper) { protected function setUpMountProviderTrait() { $this->storageFactory = new StorageFactory(); - $this->mountProvider = $this->getMockBuilder('\OCP\Files\Config\IMountProvider')->getMock(); + $this->mountProvider = $this->getMockBuilder(\OCP\Files\Config\IMountProvider::class)->getMock(); $this->mountProvider->expects($this->any()) ->method('getMountsForUser') ->will($this->returnCallback(function (IUser $user) { diff --git a/tests/lib/Updater/ReleaseMetadataTest.php b/tests/lib/Updater/ReleaseMetadataTest.php index 5191d1f6c3c22..66b31f4da6991 100644 --- a/tests/lib/Updater/ReleaseMetadataTest.php +++ b/tests/lib/Updater/ReleaseMetadataTest.php @@ -100,14 +100,14 @@ private function resultRequestArray(): array { 'apps' => [ 'testing' => [ '30000Date20240102030405' => [ - 'class' => 'OCP\\Migration\\Attributes\\DropTable', + 'class' => \OCP\Migration\Attributes\DropTable::class, 'table' => 'old_table', 'description' => '', 'notes' => [], 'columns' => [] ], [ - 'class' => 'OCP\\Migration\\Attributes\\CreateTable', + 'class' => \OCP\Migration\Attributes\CreateTable::class, 'table' => 'new_table', 'description' => 'Table is used to store things, but also to get more things', 'notes' => [ @@ -117,7 +117,7 @@ private function resultRequestArray(): array { 'columns' => [] ], [ - 'class' => 'OCP\\Migration\\Attributes\\AddColumn', + 'class' => \OCP\Migration\Attributes\AddColumn::class, 'table' => 'my_table', 'description' => '', 'notes' => [], @@ -125,7 +125,7 @@ private function resultRequestArray(): array { 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\AddColumn', + 'class' => \OCP\Migration\Attributes\AddColumn::class, 'table' => 'my_table', 'description' => '', 'notes' => [], @@ -133,7 +133,7 @@ private function resultRequestArray(): array { 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\AddColumn', + 'class' => \OCP\Migration\Attributes\AddColumn::class, 'table' => 'other_table', 'description' => '', 'notes' => [], @@ -141,21 +141,21 @@ private function resultRequestArray(): array { 'type' => 'date' ], [ - 'class' => 'OCP\\Migration\\Attributes\\AddIndex', + 'class' => \OCP\Migration\Attributes\AddIndex::class, 'table' => 'my_table', 'description' => '', 'notes' => [], 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\AddIndex', + 'class' => \OCP\Migration\Attributes\AddIndex::class, 'table' => 'my_table', 'description' => '', 'notes' => [], 'type' => 'primary' ], [ - 'class' => 'OCP\\Migration\\Attributes\\DropColumn', + 'class' => \OCP\Migration\Attributes\DropColumn::class, 'table' => 'other_table', 'description' => '', 'notes' => [], @@ -163,7 +163,7 @@ private function resultRequestArray(): array { 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\DropColumn', + 'class' => \OCP\Migration\Attributes\DropColumn::class, 'table' => 'other_table', 'description' => 'field is not used anymore and replaced by \'last_one\'', 'notes' => [], @@ -171,14 +171,14 @@ private function resultRequestArray(): array { 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\DropIndex', + 'class' => \OCP\Migration\Attributes\DropIndex::class, 'table' => 'other_table', 'description' => '', 'notes' => [], 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\ModifyColumn', + 'class' => \OCP\Migration\Attributes\ModifyColumn::class, 'table' => 'other_table', 'description' => '', 'notes' => [], @@ -186,7 +186,7 @@ private function resultRequestArray(): array { 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\ModifyColumn', + 'class' => \OCP\Migration\Attributes\ModifyColumn::class, 'table' => 'other_table', 'description' => '', 'notes' => [], @@ -194,7 +194,7 @@ private function resultRequestArray(): array { 'type' => '' ], [ - 'class' => 'OCP\\Migration\\Attributes\\ModifyColumn', + 'class' => \OCP\Migration\Attributes\ModifyColumn::class, 'table' => 'other_table', 'description' => '', 'notes' => [], diff --git a/tests/lib/UtilCheckServerTest.php b/tests/lib/UtilCheckServerTest.php index 23da44b6e848e..a182db894759b 100644 --- a/tests/lib/UtilCheckServerTest.php +++ b/tests/lib/UtilCheckServerTest.php @@ -22,7 +22,7 @@ class UtilCheckServerTest extends \Test\TestCase { protected function getConfig($systemOptions) { $systemOptions['datadirectory'] = $this->datadir; $systemOptions['appstoreenabled'] = false; //it's likely that there is no app folder we can write in - $config = $this->getMockBuilder('\OC\SystemConfig') + $config = $this->getMockBuilder(\OC\SystemConfig::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/preseed-config.php b/tests/preseed-config.php index f9c1593946946..6a0d17f5bcb36 100644 --- a/tests/preseed-config.php +++ b/tests/preseed-config.php @@ -25,7 +25,7 @@ if (getenv('OBJECT_STORE') === 's3') { $CONFIG['objectstore'] = [ - 'class' => 'OC\\Files\\ObjectStore\\S3', + 'class' => \OC\Files\ObjectStore\S3::class, 'arguments' => [ 'bucket' => 'nextcloud', 'autocreate' => true, @@ -40,7 +40,7 @@ ]; } elseif (getenv('OBJECT_STORE') === 'azure') { $CONFIG['objectstore'] = [ - 'class' => 'OC\\Files\\ObjectStore\\Azure', + 'class' => \OC\Files\ObjectStore\Azure::class, 'arguments' => [ 'container' => 'test', 'account_name' => getenv('OBJECT_STORE_KEY') ?: 'devstoreaccount1', @@ -53,7 +53,7 @@ $swiftHost = getenv('OBJECT_STORE_HOST') ?: 'localhost:5000'; $CONFIG['objectstore'] = [ - 'class' => 'OC\\Files\\ObjectStore\\Swift', + 'class' => \OC\Files\ObjectStore\Swift::class, 'arguments' => [ 'autocreate' => true, 'user' => [ diff --git a/tests/redis-cluster.config.php b/tests/redis-cluster.config.php index d9951218384b6..c8226ddcbc7e6 100644 --- a/tests/redis-cluster.config.php +++ b/tests/redis-cluster.config.php @@ -4,9 +4,9 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ $CONFIG = [ - 'memcache.local' => '\\OC\\Memcache\\Redis', - 'memcache.distributed' => '\\OC\\Memcache\\Redis', - 'memcache.locking' => '\\OC\\Memcache\\Redis', + 'memcache.local' => \OC\Memcache\Redis::class, + 'memcache.distributed' => \OC\Memcache\Redis::class, + 'memcache.locking' => \OC\Memcache\Redis::class, 'redis.cluster' => [ 'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required 'cache-cluster:7000', diff --git a/tests/redis.config.php b/tests/redis.config.php index 9068d1ad3d522..5d3219cab4baf 100644 --- a/tests/redis.config.php +++ b/tests/redis.config.php @@ -4,9 +4,9 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ $CONFIG = [ - 'memcache.local' => '\\OC\\Memcache\\Redis', - 'memcache.distributed' => '\\OC\\Memcache\\Redis', - 'memcache.locking' => '\\OC\\Memcache\\Redis', + 'memcache.local' => \OC\Memcache\Redis::class, + 'memcache.distributed' => \OC\Memcache\Redis::class, + 'memcache.locking' => \OC\Memcache\Redis::class, 'redis' => [ 'host' => 'localhost', 'port' => 6379, From 20798012dcdb02fb18128a78d4670bd3924121b9 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Sun, 15 Sep 2024 22:38:43 +0200 Subject: [PATCH 2/2] chore: Update git blame ignore Signed-off-by: Christoph Wurst --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 9f7bdba22d6cf..f8b3ad05ee871 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -11,3 +11,5 @@ aa5f037af71c915424c6dcfd5ad2dc82797dc0d6 af6de04e9e141466dc229e444ff3f146f4a34765 0bd284cb81b6866338aaaa67aa1d81ef9bfbb2ab 8af7ecb2576071f170ecbb0aa2311b26581e40e2 +# Automated refactorings +275a8ce1dc69e3ae6e27a34d3c8501c1e3078f09