Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-11-28 10:36:10 +0300
committerGitHub <noreply@github.com>2019-11-28 10:36:10 +0300
commit669302e570024c83140ff5c4f4b1489c5a1c66ed (patch)
tree010182798f5c83193554031753e063a8a0b35ca1 /tests
parent125be68311a319f2b839e5aa4ea29cd642cd1e00 (diff)
parente3e782b63df4f1d65c86cb3b204b4bdecf93a6cd (diff)
Merge pull request #18064 from nextcloud/feature/php74
Add php7.4 support
Diffstat (limited to 'tests')
-rw-r--r--tests/Core/Command/Apps/AppsDisableTest.php2
-rw-r--r--tests/Core/Command/Apps/AppsEnableTest.php2
-rw-r--r--tests/Core/Command/Config/App/DeleteConfigTest.php2
-rw-r--r--tests/Core/Command/Config/App/GetConfigTest.php2
-rw-r--r--tests/Core/Command/Config/App/SetConfigTest.php2
-rw-r--r--tests/Core/Command/Config/ImportTest.php2
-rw-r--r--tests/Core/Command/Config/ListConfigsTest.php2
-rw-r--r--tests/Core/Command/Config/System/DeleteConfigTest.php2
-rw-r--r--tests/Core/Command/Config/System/GetConfigTest.php2
-rw-r--r--tests/Core/Command/Config/System/SetConfigTest.php8
-rw-r--r--tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php11
-rw-r--r--tests/Core/Command/Encryption/DecryptAllTest.php8
-rw-r--r--tests/Core/Command/Encryption/DisableTest.php2
-rw-r--r--tests/Core/Command/Encryption/EnableTest.php2
-rw-r--r--tests/Core/Command/Encryption/EncryptAllTest.php8
-rw-r--r--tests/Core/Command/Encryption/SetDefaultModuleTest.php2
-rw-r--r--tests/Core/Command/Group/AddTest.php2
-rw-r--r--tests/Core/Command/Group/AddUserTest.php2
-rw-r--r--tests/Core/Command/Group/DeleteTest.php2
-rw-r--r--tests/Core/Command/Group/ListCommandTest.php2
-rw-r--r--tests/Core/Command/Group/RemoveUserTest.php2
-rw-r--r--tests/Core/Command/Log/FileTest.php2
-rw-r--r--tests/Core/Command/Log/ManageTest.php26
-rw-r--r--tests/Core/Command/Maintenance/DataFingerprintTest.php2
-rw-r--r--tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php2
-rw-r--r--tests/Core/Command/Maintenance/ModeTest.php2
-rw-r--r--tests/Core/Command/Maintenance/UpdateTheme.php2
-rw-r--r--tests/Core/Command/TwoFactorAuth/CleanupTest.php2
-rw-r--r--tests/Core/Command/TwoFactorAuth/DisableTest.php2
-rw-r--r--tests/Core/Command/TwoFactorAuth/EnableTest.php2
-rw-r--r--tests/Core/Command/TwoFactorAuth/EnforceTest.php2
-rw-r--r--tests/Core/Command/TwoFactorAuth/StateTest.php2
-rw-r--r--tests/Core/Command/User/DeleteTest.php2
-rw-r--r--tests/Core/Command/User/DisableTest.php2
-rw-r--r--tests/Core/Command/User/EnableTest.php2
-rw-r--r--tests/Core/Command/User/LastSeenTest.php2
-rw-r--r--tests/Core/Command/User/SettingTest.php2
-rw-r--r--tests/Core/Controller/AppPasswordControllerTest.php2
-rw-r--r--tests/Core/Controller/AutoCompleteControllerTest.php2
-rw-r--r--tests/Core/Controller/AvatarControllerTest.php6
-rw-r--r--tests/Core/Controller/CSRFTokenControllerTest.php2
-rw-r--r--tests/Core/Controller/ChangePasswordControllerTest.php2
-rw-r--r--tests/Core/Controller/ClientFlowLoginControllerTest.php2
-rw-r--r--tests/Core/Controller/ClientFlowLoginV2ControllerTest.php2
-rw-r--r--tests/Core/Controller/ContactsMenuControllerTest.php2
-rw-r--r--tests/Core/Controller/CssControllerTest.php2
-rw-r--r--tests/Core/Controller/GuestAvatarControllerTest.php2
-rw-r--r--tests/Core/Controller/JsControllerTest.php2
-rw-r--r--tests/Core/Controller/LoginControllerTest.php2
-rw-r--r--tests/Core/Controller/LostControllerTest.php2
-rw-r--r--tests/Core/Controller/NavigationControllerTest.php2
-rw-r--r--tests/Core/Controller/OCSControllerTest.php2
-rw-r--r--tests/Core/Controller/PreviewControllerTest.php2
-rw-r--r--tests/Core/Controller/TwoFactorChallengeControllerTest.php2
-rw-r--r--tests/Core/Controller/UserControllerTest.php2
-rw-r--r--tests/Core/Controller/WipeControllerTest.php2
-rw-r--r--tests/Core/Middleware/TwoFactorMiddlewareTest.php14
-rw-r--r--tests/acceptance/features/core/NextcloudTestServerLocalApacheHelper.php2
-rw-r--r--tests/acceptance/features/core/NextcloudTestServerLocalBuiltInHelper.php2
-rw-r--r--tests/lib/Accounts/AccountsManagerTest.php4
-rw-r--r--tests/lib/Accounts/HooksTest.php2
-rw-r--r--tests/lib/Activity/ManagerTest.php35
-rw-r--r--tests/lib/AllConfigTest.php9
-rw-r--r--tests/lib/App/AppManagerTest.php7
-rw-r--r--tests/lib/App/AppStore/Bundles/BundleBase.php2
-rw-r--r--tests/lib/App/AppStore/Bundles/BundleFetcherTest.php10
-rw-r--r--tests/lib/App/AppStore/Bundles/CoreBundleTest.php2
-rw-r--r--tests/lib/App/AppStore/Bundles/EducationBundleTest.php2
-rw-r--r--tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php2
-rw-r--r--tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php2
-rw-r--r--tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php2
-rw-r--r--tests/lib/App/AppStore/Fetcher/AppFetcherTest.php2
-rw-r--r--tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php2
-rw-r--r--tests/lib/App/AppStore/Fetcher/FetcherBase.php2
-rw-r--r--tests/lib/App/AppStore/Version/VersionParserTest.php18
-rw-r--r--tests/lib/App/CodeChecker/InfoCheckerTest.php6
-rw-r--r--tests/lib/App/CompareVersionTest.php2
-rw-r--r--tests/lib/App/DependencyAnalyzerTest.php2
-rw-r--r--tests/lib/App/InfoParserTest.php2
-rw-r--r--tests/lib/AppConfigTest.php4
-rw-r--r--tests/lib/AppFramework/AppTest.php4
-rw-r--r--tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php2
-rw-r--r--tests/lib/AppFramework/Controller/ControllerTest.php8
-rw-r--r--tests/lib/AppFramework/Controller/PublicShareControllerTest.php2
-rw-r--r--tests/lib/AppFramework/Db/EntityTest.php26
-rw-r--r--tests/lib/AppFramework/Db/MapperTest.php2
-rw-r--r--tests/lib/AppFramework/Db/MapperTestUtility.php2
-rw-r--r--tests/lib/AppFramework/Db/QBMapperTest.php14
-rw-r--r--tests/lib/AppFramework/DependencyInjection/DIContainerTest.php2
-rw-r--r--tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php2
-rw-r--r--tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php2
-rw-r--r--tests/lib/AppFramework/Http/DataResponseTest.php2
-rw-r--r--tests/lib/AppFramework/Http/DispatcherTest.php2
-rw-r--r--tests/lib/AppFramework/Http/DownloadResponseTest.php2
-rw-r--r--tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php2
-rw-r--r--tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php2
-rw-r--r--tests/lib/AppFramework/Http/FeaturePolicyTest.php2
-rw-r--r--tests/lib/AppFramework/Http/FileDisplayResponseTest.php2
-rw-r--r--tests/lib/AppFramework/Http/HttpTest.php2
-rw-r--r--tests/lib/AppFramework/Http/JSONResponseTest.php10
-rw-r--r--tests/lib/AppFramework/Http/RedirectResponseTest.php2
-rw-r--r--tests/lib/AppFramework/Http/RequestTest.php38
-rw-r--r--tests/lib/AppFramework/Http/ResponseTest.php2
-rw-r--r--tests/lib/AppFramework/Http/StreamResponseTest.php2
-rw-r--r--tests/lib/AppFramework/Http/TemplateResponseTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php19
-rw-r--r--tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php10
-rw-r--r--tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php11
-rw-r--r--tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Routing/RoutingTest.php12
-rw-r--r--tests/lib/AppFramework/Utility/SimpleContainerTest.php20
-rw-r--r--tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php2
-rw-r--r--tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php2
-rw-r--r--tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php2
-rw-r--r--tests/lib/Authentication/Login/ALoginCommandTest.php2
-rw-r--r--tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php2
-rw-r--r--tests/lib/Authentication/Login/CompleteLoginCommandTest.php2
-rw-r--r--tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php2
-rw-r--r--tests/lib/Authentication/Login/EmailLoginCommandTest.php2
-rw-r--r--tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php2
-rw-r--r--tests/lib/Authentication/Login/LoggedInCheckCommandTest.php2
-rw-r--r--tests/lib/Authentication/Login/PreLoginHookCommandTest.php2
-rw-r--r--tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php2
-rw-r--r--tests/lib/Authentication/Login/TwoFactorCommandTest.php2
-rw-r--r--tests/lib/Authentication/Login/UidLoginCommandTest.php2
-rw-r--r--tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php2
-rw-r--r--tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php2
-rw-r--r--tests/lib/Authentication/LoginCredentials/CredentialsTest.php2
-rw-r--r--tests/lib/Authentication/LoginCredentials/StoreTest.php2
-rw-r--r--tests/lib/Authentication/Token/DefaultTokenCleanupJobTest.php2
-rw-r--r--tests/lib/Authentication/Token/DefaultTokenMapperTest.php20
-rw-r--r--tests/lib/Authentication/Token/DefaultTokenProviderTest.php20
-rw-r--r--tests/lib/Authentication/Token/ManagerTest.php2
-rw-r--r--tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php20
-rw-r--r--tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php20
-rw-r--r--tests/lib/Authentication/Token/RemoteWipeTest.php2
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php2
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/ManagerTest.php2
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php2
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php10
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php14
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/RegistryTest.php2
-rw-r--r--tests/lib/AutoLoaderTest.php2
-rw-r--r--tests/lib/Avatar/AvatarManagerTest.php10
-rw-r--r--tests/lib/Avatar/UserAvatarTest.php2
-rw-r--r--tests/lib/BackgroundJob/JobListTest.php2
-rw-r--r--tests/lib/BackgroundJob/JobTest.php2
-rw-r--r--tests/lib/BackgroundJob/QueuedJobTest.php2
-rw-r--r--tests/lib/BackgroundJob/TimedJobTest.php2
-rw-r--r--tests/lib/Cache/CappedMemoryCacheTest.php2
-rw-r--r--tests/lib/Cache/FileCacheTest.php4
-rw-r--r--tests/lib/Cache/TestCache.php2
-rw-r--r--tests/lib/Calendar/ManagerTest.php2
-rw-r--r--tests/lib/Calendar/Resource/ManagerTest.php2
-rw-r--r--tests/lib/Calendar/Room/ManagerTest.php2
-rw-r--r--tests/lib/CapabilitiesManagerTest.php7
-rw-r--r--tests/lib/Collaboration/Collaborators/GroupPluginTest.php2
-rw-r--r--tests/lib/Collaboration/Collaborators/LookupPluginTest.php2
-rw-r--r--tests/lib/Collaboration/Collaborators/MailPluginTest.php2
-rw-r--r--tests/lib/Collaboration/Collaborators/RemotePluginTest.php5
-rw-r--r--tests/lib/Collaboration/Collaborators/SearchResultTest.php2
-rw-r--r--tests/lib/Collaboration/Collaborators/SearchTest.php2
-rw-r--r--tests/lib/Collaboration/Collaborators/UserPluginTest.php6
-rw-r--r--tests/lib/Command/AsyncBusTest.php2
-rw-r--r--tests/lib/Command/CronBusTest.php2
-rw-r--r--tests/lib/Command/Integrity/SignAppTest.php10
-rw-r--r--tests/lib/Command/Integrity/SignCoreTest.php12
-rw-r--r--tests/lib/Comments/CommentTest.php18
-rw-r--r--tests/lib/Comments/ManagerTest.php77
-rw-r--r--tests/lib/ConfigTest.php4
-rw-r--r--tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php2
-rw-r--r--tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php8
-rw-r--r--tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php2
-rw-r--r--tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php2
-rw-r--r--tests/lib/Contacts/ContactsMenu/EntryTest.php2
-rw-r--r--tests/lib/Contacts/ContactsMenu/ManagerTest.php2
-rw-r--r--tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php2
-rw-r--r--tests/lib/ContactsManagerTest.php2
-rw-r--r--tests/lib/DB/ConnectionTest.php20
-rw-r--r--tests/lib/DB/DBSchemaTest.php4
-rw-r--r--tests/lib/DB/LegacyDBTest.php12
-rw-r--r--tests/lib/DB/MDB2SchemaManagerTest.php2
-rw-r--r--tests/lib/DB/MigrationsTest.php68
-rw-r--r--tests/lib/DB/MigratorTest.php10
-rw-r--r--tests/lib/DB/MySqlMigrationTest.php4
-rw-r--r--tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php2
-rw-r--r--tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php2
-rw-r--r--tests/lib/DB/QueryBuilder/FunctionBuilderTest.php2
-rw-r--r--tests/lib/DB/QueryBuilder/QueryBuilderTest.php4
-rw-r--r--tests/lib/DB/QueryBuilder/QuoteHelperTest.php2
-rw-r--r--tests/lib/DB/SchemaDiffTest.php4
-rw-r--r--tests/lib/DB/SqliteMigrationTest.php4
-rw-r--r--tests/lib/DateTimeFormatterTest.php12
-rw-r--r--tests/lib/Diagnostics/EventLoggerTest.php2
-rw-r--r--tests/lib/Diagnostics/QueryLoggerTest.php2
-rw-r--r--tests/lib/Encryption/DecryptAllTest.php2
-rw-r--r--tests/lib/Encryption/EncryptionWrapperTest.php2
-rw-r--r--tests/lib/Encryption/Keys/StorageTest.php2
-rw-r--r--tests/lib/Encryption/ManagerTest.php15
-rw-r--r--tests/lib/Encryption/UpdateTest.php2
-rw-r--r--tests/lib/Encryption/UtilTest.php8
-rw-r--r--tests/lib/Federation/CloudIdManagerTest.php5
-rw-r--r--tests/lib/Files/AppData/AppDataTest.php2
-rw-r--r--tests/lib/Files/AppData/FactoryTest.php2
-rw-r--r--tests/lib/Files/Cache/CacheTest.php4
-rw-r--r--tests/lib/Files/Cache/HomeCacheTest.php2
-rw-r--r--tests/lib/Files/Cache/MoveFromCacheTraitTest.php2
-rw-r--r--tests/lib/Files/Cache/PropagatorTest.php2
-rw-r--r--tests/lib/Files/Cache/QuerySearchHelperTest.php4
-rw-r--r--tests/lib/Files/Cache/ScannerTest.php16
-rw-r--r--tests/lib/Files/Cache/UpdaterLegacyTest.php76
-rw-r--r--tests/lib/Files/Cache/UpdaterTest.php4
-rw-r--r--tests/lib/Files/Cache/WatcherTest.php4
-rw-r--r--tests/lib/Files/Cache/Wrapper/CacheJailTest.php2
-rw-r--r--tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php2
-rw-r--r--tests/lib/Files/Config/UserMountCacheTest.php4
-rw-r--r--tests/lib/Files/EtagTest.php4
-rw-r--r--tests/lib/Files/FileInfoTest.php2
-rw-r--r--tests/lib/Files/FilesystemTest.php13
-rw-r--r--tests/lib/Files/Mount/ManagerTest.php2
-rw-r--r--tests/lib/Files/Mount/MountPointTest.php8
-rw-r--r--tests/lib/Files/Mount/ObjectHomeMountProviderTest.php2
-rw-r--r--tests/lib/Files/Node/FileTest.php30
-rw-r--r--tests/lib/Files/Node/FolderTest.php12
-rw-r--r--tests/lib/Files/Node/HookConnectorTest.php4
-rw-r--r--tests/lib/Files/Node/IntegrationTest.php4
-rw-r--r--tests/lib/Files/Node/NodeTest.php68
-rw-r--r--tests/lib/Files/Node/RootTest.php28
-rw-r--r--tests/lib/Files/ObjectStore/NoopScannerTest.php2
-rw-r--r--tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php4
-rw-r--r--tests/lib/Files/PathVerificationTest.php23
-rw-r--r--tests/lib/Files/SimpleFS/SimpleFileTest.php2
-rw-r--r--tests/lib/Files/SimpleFS/SimpleFolderTest.php2
-rw-r--r--tests/lib/Files/Storage/CommonTest.php4
-rw-r--r--tests/lib/Files/Storage/CopyDirectoryTest.php2
-rw-r--r--tests/lib/Files/Storage/HomeTest.php4
-rw-r--r--tests/lib/Files/Storage/LocalTest.php22
-rw-r--r--tests/lib/Files/Storage/Wrapper/AvailabilityTest.php11
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncodingTest.php4
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php23
-rw-r--r--tests/lib/Files/Storage/Wrapper/JailTest.php4
-rw-r--r--tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php4
-rw-r--r--tests/lib/Files/Storage/Wrapper/QuotaTest.php4
-rw-r--r--tests/lib/Files/Storage/Wrapper/WrapperTest.php4
-rw-r--r--tests/lib/Files/Type/DetectionTest.php2
-rw-r--r--tests/lib/Files/Type/LoaderTest.php4
-rw-r--r--tests/lib/Files/Utils/ScannerTest.php9
-rw-r--r--tests/lib/Files/ViewTest.php36
-rw-r--r--tests/lib/GlobalScale/ConfigTest.php2
-rw-r--r--tests/lib/Group/DatabaseTest.php4
-rw-r--r--tests/lib/Group/Dummy.php2
-rw-r--r--tests/lib/Group/GroupTest.php2
-rw-r--r--tests/lib/Group/ManagerTest.php4
-rw-r--r--tests/lib/Group/MetaDataTest.php2
-rw-r--r--tests/lib/HelperStorageTest.php4
-rw-r--r--tests/lib/Hooks/BasicEmitterTest.php56
-rw-r--r--tests/lib/Hooks/LegacyEmitterTest.php2
-rw-r--r--tests/lib/Http/Client/ClientTest.php2
-rw-r--r--tests/lib/Http/Client/ResponseTest.php2
-rw-r--r--tests/lib/ImageTest.php2
-rw-r--r--tests/lib/InitialStateServiceTest.php2
-rw-r--r--tests/lib/InstallerTest.php60
-rw-r--r--tests/lib/IntegrityCheck/CheckerTest.php34
-rw-r--r--tests/lib/IntegrityCheck/Helpers/AppLocatorTest.php10
-rw-r--r--tests/lib/IntegrityCheck/Helpers/EnvironmentHelperTest.php4
-rw-r--r--tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php18
-rw-r--r--tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php2
-rw-r--r--tests/lib/L10N/FactoryTest.php2
-rw-r--r--tests/lib/L10N/LanguageIteratorTest.php2
-rw-r--r--tests/lib/LargeFileHelperGetFileSizeTest.php4
-rw-r--r--tests/lib/LargeFileHelperTest.php8
-rw-r--r--tests/lib/LegacyHelperTest.php4
-rw-r--r--tests/lib/Lock/DBLockingProviderTest.php4
-rw-r--r--tests/lib/Lock/LockingProvider.php60
-rw-r--r--tests/lib/Lock/MemcacheLockingProviderTest.php2
-rw-r--r--tests/lib/Lockdown/Filesystem/NoFSTest.php6
-rw-r--r--tests/lib/Lockdown/Filesystem/NullCacheTest.php2
-rw-r--r--tests/lib/Lockdown/Filesystem/NullStorageTest.php2
-rw-r--r--tests/lib/Lockdown/LockdownManagerTest.php2
-rw-r--r--tests/lib/Log/FileTest.php4
-rw-r--r--tests/lib/Log/LogFactoryTest.php2
-rw-r--r--tests/lib/LoggerTest.php3
-rw-r--r--tests/lib/Mail/EMailTemplateTest.php2
-rw-r--r--tests/lib/Mail/MailerTest.php8
-rw-r--r--tests/lib/Mail/MessageTest.php2
-rw-r--r--tests/lib/Memcache/APCuTest.php2
-rw-r--r--tests/lib/Memcache/ArrayCacheTest.php2
-rw-r--r--tests/lib/Memcache/Cache.php2
-rw-r--r--tests/lib/Memcache/FactoryTest.php3
-rw-r--r--tests/lib/Memcache/MemcachedTest.php4
-rw-r--r--tests/lib/Memcache/RedisTest.php8
-rw-r--r--tests/lib/Migration/BackgroundRepairTest.php2
-rw-r--r--tests/lib/NavigationManagerTest.php2
-rw-r--r--tests/lib/Notification/ActionTest.php11
-rw-r--r--tests/lib/Notification/ManagerTest.php8
-rw-r--r--tests/lib/Notification/NotificationTest.php44
-rw-r--r--tests/lib/OCS/DiscoveryServiceTest.php2
-rw-r--r--tests/lib/OCS/ProviderTest.php2
-rw-r--r--tests/lib/Preview/BackgroundCleanupJobTest.php6
-rw-r--r--tests/lib/Preview/BitmapTest.php2
-rw-r--r--tests/lib/Preview/GeneratorTest.php2
-rw-r--r--tests/lib/Preview/HEICTest.php2
-rw-r--r--tests/lib/Preview/ImageTest.php2
-rw-r--r--tests/lib/Preview/MP3Test.php2
-rw-r--r--tests/lib/Preview/MovieTest.php2
-rw-r--r--tests/lib/Preview/OfficeTest.php2
-rw-r--r--tests/lib/Preview/Provider.php4
-rw-r--r--tests/lib/Preview/SVGTest.php2
-rw-r--r--tests/lib/Preview/TXTTest.php2
-rw-r--r--tests/lib/Remote/Api/OCSTest.php16
-rw-r--r--tests/lib/Remote/InstanceTest.php10
-rw-r--r--tests/lib/Repair/CleanTagsTest.php4
-rw-r--r--tests/lib/Repair/ClearFrontendCachesTest.php2
-rw-r--r--tests/lib/Repair/ClearGeneratedAvatarCacheTest.php2
-rw-r--r--tests/lib/Repair/NC11/FixMountStoragesTest.php2
-rw-r--r--tests/lib/Repair/OldGroupMembershipSharesTest.php4
-rw-r--r--tests/lib/Repair/RepairCollationTest.php4
-rw-r--r--tests/lib/Repair/RepairInvalidSharesTest.php4
-rw-r--r--tests/lib/Repair/RepairMimeTypesTest.php4
-rw-r--r--tests/lib/Repair/RepairSqliteAutoincrementTest.php4
-rw-r--r--tests/lib/RepairStepTest.php2
-rw-r--r--tests/lib/RichObjectStrings/DefinitionsTest.php8
-rw-r--r--tests/lib/Security/Bruteforce/CapabilitiesTest.php2
-rw-r--r--tests/lib/Security/Bruteforce/ThrottlerTest.php2
-rw-r--r--tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php2
-rw-r--r--tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php2
-rw-r--r--tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php2
-rw-r--r--tests/lib/Security/CSRF/CsrfTokenManagerTest.php2
-rw-r--r--tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php7
-rw-r--r--tests/lib/Security/CertificateManagerTest.php17
-rw-r--r--tests/lib/Security/CertificateTest.php18
-rw-r--r--tests/lib/Security/CredentialsManagerTest.php2
-rw-r--r--tests/lib/Security/CryptoTest.php26
-rw-r--r--tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php2
-rw-r--r--tests/lib/Security/HasherTest.php2
-rw-r--r--tests/lib/Security/IdentityProof/KeyTest.php2
-rw-r--r--tests/lib/Security/IdentityProof/ManagerTest.php8
-rw-r--r--tests/lib/Security/IdentityProof/SignerTest.php2
-rw-r--r--tests/lib/Security/RateLimiting/Backend/MemoryCacheTest.php2
-rw-r--r--tests/lib/Security/RateLimiting/LimiterTest.php18
-rw-r--r--tests/lib/Security/SecureRandomTest.php2
-rw-r--r--tests/lib/Security/TrustedDomainHelperTest.php2
-rw-r--r--tests/lib/ServerTest.php2
-rw-r--r--tests/lib/Session/CryptoSessionDataTest.php10
-rw-r--r--tests/lib/Session/CryptoWrappingTest.php5
-rw-r--r--tests/lib/Session/MemoryTest.php8
-rw-r--r--tests/lib/Session/Session.php2
-rw-r--r--tests/lib/Settings/ManagerTest.php2
-rw-r--r--tests/lib/SetupTest.php10
-rw-r--r--tests/lib/Share/HelperTest.php3
-rw-r--r--tests/lib/Share/ShareTest.php4
-rw-r--r--tests/lib/Share20/DefaultShareProviderTest.php48
-rw-r--r--tests/lib/Share20/LegacyHooksTest.php2
-rw-r--r--tests/lib/Share20/ManagerTest.php264
-rw-r--r--tests/lib/Share20/ShareHelperTest.php2
-rw-r--r--tests/lib/Share20/ShareTest.php34
-rw-r--r--tests/lib/SubAdminTest.php4
-rw-r--r--tests/lib/Support/CrashReport/RegistryTest.php2
-rw-r--r--tests/lib/Support/Subscription/RegistryTest.php8
-rw-r--r--tests/lib/SystemTag/SystemTagManagerTest.php34
-rw-r--r--tests/lib/SystemTag/SystemTagObjectMapperTest.php34
-rw-r--r--tests/lib/TagsTest.php4
-rw-r--r--tests/lib/TempManagerTest.php4
-rw-r--r--tests/lib/Template/CSSResourceLocatorTest.php2
-rw-r--r--tests/lib/Template/IconsCacherTest.php2
-rw-r--r--tests/lib/Template/JSCombinerTest.php2
-rw-r--r--tests/lib/Template/JSResourceLocatorTest.php2
-rw-r--r--tests/lib/Template/ResourceLocatorTest.php2
-rw-r--r--tests/lib/Template/SCSSCacherTest.php2
-rw-r--r--tests/lib/TemplateFunctionsTest.php2
-rw-r--r--tests/lib/TestCase.php8
-rw-r--r--tests/lib/Traits/EncryptionTrait.php4
-rw-r--r--tests/lib/Updater/ChangesCheckTest.php2
-rw-r--r--tests/lib/Updater/VersionCheckTest.php2
-rw-r--r--tests/lib/UpdaterTest.php2
-rw-r--r--tests/lib/UrlGeneratorTest.php4
-rw-r--r--tests/lib/User/DatabaseTest.php12
-rw-r--r--tests/lib/User/Dummy.php2
-rw-r--r--tests/lib/User/ManagerTest.php22
-rw-r--r--tests/lib/User/SessionTest.php26
-rw-r--r--tests/lib/User/UserTest.php2
-rw-r--r--tests/lib/UtilCheckServerTest.php4
-rw-r--r--tests/lib/UtilTest.php4
-rw-r--r--tests/phpunit-autotest.xml1
-rw-r--r--tests/startsessionlistener.php2
395 files changed, 1439 insertions, 1365 deletions
diff --git a/tests/Core/Command/Apps/AppsDisableTest.php b/tests/Core/Command/Apps/AppsDisableTest.php
index d9c43a79c26..cbe6a816cd6 100644
--- a/tests/Core/Command/Apps/AppsDisableTest.php
+++ b/tests/Core/Command/Apps/AppsDisableTest.php
@@ -36,7 +36,7 @@ class AppsDisableTest extends TestCase {
/** @var CommandTester */
private $commandTester;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$command = new Disable(
diff --git a/tests/Core/Command/Apps/AppsEnableTest.php b/tests/Core/Command/Apps/AppsEnableTest.php
index d2bda141303..6c137dca44b 100644
--- a/tests/Core/Command/Apps/AppsEnableTest.php
+++ b/tests/Core/Command/Apps/AppsEnableTest.php
@@ -36,7 +36,7 @@ class AppsEnableTest extends TestCase {
/** @var CommandTester */
private $commandTester;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$command = new Enable(
diff --git a/tests/Core/Command/Config/App/DeleteConfigTest.php b/tests/Core/Command/Config/App/DeleteConfigTest.php
index f74fd73d697..251de227d67 100644
--- a/tests/Core/Command/Config/App/DeleteConfigTest.php
+++ b/tests/Core/Command/Config/App/DeleteConfigTest.php
@@ -40,7 +40,7 @@ class DeleteConfigTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)
diff --git a/tests/Core/Command/Config/App/GetConfigTest.php b/tests/Core/Command/Config/App/GetConfigTest.php
index 7ea3fbb587c..7ecb09b8f82 100644
--- a/tests/Core/Command/Config/App/GetConfigTest.php
+++ b/tests/Core/Command/Config/App/GetConfigTest.php
@@ -40,7 +40,7 @@ class GetConfigTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$config = $this->config = $this->getMockBuilder(IConfig::class)
diff --git a/tests/Core/Command/Config/App/SetConfigTest.php b/tests/Core/Command/Config/App/SetConfigTest.php
index f66390871de..988e965d317 100644
--- a/tests/Core/Command/Config/App/SetConfigTest.php
+++ b/tests/Core/Command/Config/App/SetConfigTest.php
@@ -40,7 +40,7 @@ class SetConfigTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$config = $this->config = $this->getMockBuilder(IConfig::class)
diff --git a/tests/Core/Command/Config/ImportTest.php b/tests/Core/Command/Config/ImportTest.php
index 7afa47d3536..fa1ed151678 100644
--- a/tests/Core/Command/Config/ImportTest.php
+++ b/tests/Core/Command/Config/ImportTest.php
@@ -40,7 +40,7 @@ class ImportTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$config = $this->config = $this->getMockBuilder(IConfig::class)
diff --git a/tests/Core/Command/Config/ListConfigsTest.php b/tests/Core/Command/Config/ListConfigsTest.php
index 861c1f59d5e..203feaacbf1 100644
--- a/tests/Core/Command/Config/ListConfigsTest.php
+++ b/tests/Core/Command/Config/ListConfigsTest.php
@@ -44,7 +44,7 @@ class ListConfigsTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$systemConfig = $this->systemConfig = $this->getMockBuilder(SystemConfig::class)
diff --git a/tests/Core/Command/Config/System/DeleteConfigTest.php b/tests/Core/Command/Config/System/DeleteConfigTest.php
index 5ac4c853df3..21ef3e33981 100644
--- a/tests/Core/Command/Config/System/DeleteConfigTest.php
+++ b/tests/Core/Command/Config/System/DeleteConfigTest.php
@@ -40,7 +40,7 @@ class DeleteConfigTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$systemConfig = $this->systemConfig = $this->getMockBuilder(SystemConfig::class)
diff --git a/tests/Core/Command/Config/System/GetConfigTest.php b/tests/Core/Command/Config/System/GetConfigTest.php
index fd5db69fec9..1d8975f7f7f 100644
--- a/tests/Core/Command/Config/System/GetConfigTest.php
+++ b/tests/Core/Command/Config/System/GetConfigTest.php
@@ -40,7 +40,7 @@ class GetConfigTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$systemConfig = $this->systemConfig = $this->getMockBuilder(SystemConfig::class)
diff --git a/tests/Core/Command/Config/System/SetConfigTest.php b/tests/Core/Command/Config/System/SetConfigTest.php
index bb8d2c4b962..9b34afed691 100644
--- a/tests/Core/Command/Config/System/SetConfigTest.php
+++ b/tests/Core/Command/Config/System/SetConfigTest.php
@@ -40,7 +40,7 @@ class SetConfigTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$systemConfig = $this->systemConfig = $this->getMockBuilder(SystemConfig::class)
@@ -102,9 +102,10 @@ class SetConfigTest extends TestCase {
/**
* @dataProvider setUpdateOnlyProvider
- * @expectedException \UnexpectedValueException
*/
public function testSetUpdateOnly($configNames, $existingData) {
+ $this->expectException(\UnexpectedValueException::class);
+
$this->systemConfig->expects($this->never())
->method('setValue');
$this->systemConfig->method('getValue')
@@ -169,9 +170,10 @@ class SetConfigTest extends TestCase {
/**
* @dataProvider castValueInvalidProvider
- * @expectedException \InvalidArgumentException
*/
public function testCastValueInvalid($value, $type) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->invokePrivate($this->command, 'castValue', [$value, $type]);
}
diff --git a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
index 811b64029c6..d17050e7245 100644
--- a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
+++ b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
@@ -63,7 +63,7 @@ class ChangeKeyStorageRootTest extends TestCase {
/** @var \OCP\UserInterface | \PHPUnit_Framework_MockObject_MockObject */
protected $userInterface;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->view = $this->getMockBuilder(View::class)->getMock();
@@ -181,12 +181,13 @@ class ChangeKeyStorageRootTest extends TestCase {
/**
* @dataProvider dataTestPrepareNewRootException
- * @expectedException \Exception
*
* @param bool $dirExists
* @param bool $couldCreateFile
*/
public function testPrepareNewRootException($dirExists, $couldCreateFile) {
+ $this->expectException(\Exception::class);
+
$this->view->expects($this->once())->method('is_dir')->with('newRoot')
->willReturn($dirExists);
$this->view->expects($this->any())->method('file_put_contents')->willReturn($couldCreateFile);
@@ -370,10 +371,10 @@ class ChangeKeyStorageRootTest extends TestCase {
);
}
- /**
- * @expectedException \Exception
- */
+
public function testTargetExistsException() {
+ $this->expectException(\Exception::class);
+
$this->view->expects($this->once())->method('file_exists')->with('path')
->willReturn(true);
diff --git a/tests/Core/Command/Encryption/DecryptAllTest.php b/tests/Core/Command/Encryption/DecryptAllTest.php
index 508d5da95f7..acdaff4bbab 100644
--- a/tests/Core/Command/Encryption/DecryptAllTest.php
+++ b/tests/Core/Command/Encryption/DecryptAllTest.php
@@ -54,7 +54,7 @@ class DecryptAllTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject | \OC\Encryption\DecryptAll */
protected $decryptAll;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)
@@ -181,10 +181,10 @@ class DecryptAllTest extends TestCase {
];
}
- /**
- * @expectedException \Exception
- */
+
public function testExecuteFailure() {
+ $this->expectException(\Exception::class);
+
$instance = new DecryptAll(
$this->encryptionManager,
$this->appManager,
diff --git a/tests/Core/Command/Encryption/DisableTest.php b/tests/Core/Command/Encryption/DisableTest.php
index 77a690fe264..f9035a84788 100644
--- a/tests/Core/Command/Encryption/DisableTest.php
+++ b/tests/Core/Command/Encryption/DisableTest.php
@@ -39,7 +39,7 @@ class DisableTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$config = $this->config = $this->getMockBuilder(IConfig::class)
diff --git a/tests/Core/Command/Encryption/EnableTest.php b/tests/Core/Command/Encryption/EnableTest.php
index eb1b7842385..5c8fc826af1 100644
--- a/tests/Core/Command/Encryption/EnableTest.php
+++ b/tests/Core/Command/Encryption/EnableTest.php
@@ -42,7 +42,7 @@ class EnableTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$config = $this->config = $this->getMockBuilder(IConfig::class)
diff --git a/tests/Core/Command/Encryption/EncryptAllTest.php b/tests/Core/Command/Encryption/EncryptAllTest.php
index 7fa4b5e5bbe..778d51fd8b8 100644
--- a/tests/Core/Command/Encryption/EncryptAllTest.php
+++ b/tests/Core/Command/Encryption/EncryptAllTest.php
@@ -58,7 +58,7 @@ class EncryptAllTest extends TestCase {
/** @var EncryptAll */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)
@@ -128,10 +128,10 @@ class EncryptAllTest extends TestCase {
];
}
- /**
- * @expectedException \Exception
- */
+
public function testExecuteException() {
+ $this->expectException(\Exception::class);
+
$command = new EncryptAll($this->encryptionManager, $this->appManager, $this->config, $this->questionHelper);
$this->encryptionManager->expects($this->once())->method('isEnabled')->willReturn(false);
$this->encryptionManager->expects($this->never())->method('getEncryptionModule');
diff --git a/tests/Core/Command/Encryption/SetDefaultModuleTest.php b/tests/Core/Command/Encryption/SetDefaultModuleTest.php
index 2dc62d42bfa..0776ef42b48 100644
--- a/tests/Core/Command/Encryption/SetDefaultModuleTest.php
+++ b/tests/Core/Command/Encryption/SetDefaultModuleTest.php
@@ -42,7 +42,7 @@ class SetDefaultModuleTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->manager = $this->getMockBuilder(IManager::class)
diff --git a/tests/Core/Command/Group/AddTest.php b/tests/Core/Command/Group/AddTest.php
index c7010e53e58..d4ba34246af 100644
--- a/tests/Core/Command/Group/AddTest.php
+++ b/tests/Core/Command/Group/AddTest.php
@@ -44,7 +44,7 @@ class AddTest extends TestCase {
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
private $output;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->groupManager = $this->createMock(IGroupManager::class);
diff --git a/tests/Core/Command/Group/AddUserTest.php b/tests/Core/Command/Group/AddUserTest.php
index 7660aad1192..1ee2d2d3377 100644
--- a/tests/Core/Command/Group/AddUserTest.php
+++ b/tests/Core/Command/Group/AddUserTest.php
@@ -49,7 +49,7 @@ class AddUserTest extends TestCase {
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
private $output;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->groupManager = $this->createMock(IGroupManager::class);
diff --git a/tests/Core/Command/Group/DeleteTest.php b/tests/Core/Command/Group/DeleteTest.php
index f9b1cbbe3a8..69bdae99d63 100644
--- a/tests/Core/Command/Group/DeleteTest.php
+++ b/tests/Core/Command/Group/DeleteTest.php
@@ -44,7 +44,7 @@ class DeleteTest extends TestCase {
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
private $output;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->groupManager = $this->createMock(IGroupManager::class);
diff --git a/tests/Core/Command/Group/ListCommandTest.php b/tests/Core/Command/Group/ListCommandTest.php
index ab089c93422..21adb29924a 100644
--- a/tests/Core/Command/Group/ListCommandTest.php
+++ b/tests/Core/Command/Group/ListCommandTest.php
@@ -45,7 +45,7 @@ class ListCommandTest extends TestCase {
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
private $output;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->groupManager = $this->createMock(IGroupManager::class);
diff --git a/tests/Core/Command/Group/RemoveUserTest.php b/tests/Core/Command/Group/RemoveUserTest.php
index 8a75571e3cb..eda4886da3b 100644
--- a/tests/Core/Command/Group/RemoveUserTest.php
+++ b/tests/Core/Command/Group/RemoveUserTest.php
@@ -49,7 +49,7 @@ class RemoveUserTest extends TestCase {
/** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
private $output;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->groupManager = $this->createMock(IGroupManager::class);
diff --git a/tests/Core/Command/Log/FileTest.php b/tests/Core/Command/Log/FileTest.php
index 4b8845277da..524a193d86f 100644
--- a/tests/Core/Command/Log/FileTest.php
+++ b/tests/Core/Command/Log/FileTest.php
@@ -39,7 +39,7 @@ class FileTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$config = $this->config = $this->getMockBuilder(IConfig::class)
diff --git a/tests/Core/Command/Log/ManageTest.php b/tests/Core/Command/Log/ManageTest.php
index 2044fc4de90..d73bc7ed9c2 100644
--- a/tests/Core/Command/Log/ManageTest.php
+++ b/tests/Core/Command/Log/ManageTest.php
@@ -39,7 +39,7 @@ class ManageTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$config = $this->config = $this->getMockBuilder(IConfig::class)
@@ -87,17 +87,17 @@ class ManageTest extends TestCase {
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testValidateBackend() {
+ $this->expectException(\InvalidArgumentException::class);
+
self::invokePrivate($this->command, 'validateBackend', ['notabackend']);
}
- /**
- * @expectedException \Exception
- */
+
public function testValidateTimezone() {
+ $this->expectException(\Exception::class);
+
// this might need to be changed when humanity colonises Mars
self::invokePrivate($this->command, 'validateTimezone', ['Mars/OlympusMons']);
}
@@ -123,10 +123,10 @@ class ManageTest extends TestCase {
);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testConvertLevelStringInvalid() {
+ $this->expectException(\InvalidArgumentException::class);
+
self::invokePrivate($this->command, 'convertLevelString', ['abc']);
}
@@ -149,10 +149,10 @@ class ManageTest extends TestCase {
);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testConvertLevelNumberInvalid() {
+ $this->expectException(\InvalidArgumentException::class);
+
self::invokePrivate($this->command, 'convertLevelNumber', [11]);
}
diff --git a/tests/Core/Command/Maintenance/DataFingerprintTest.php b/tests/Core/Command/Maintenance/DataFingerprintTest.php
index 90ffa50c012..5cc816627e6 100644
--- a/tests/Core/Command/Maintenance/DataFingerprintTest.php
+++ b/tests/Core/Command/Maintenance/DataFingerprintTest.php
@@ -41,7 +41,7 @@ class DataFingerprintTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
diff --git a/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php b/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php
index 77757008633..32608796864 100644
--- a/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php
+++ b/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php
@@ -44,7 +44,7 @@ class UpdateDBTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->detector = $this->getMockBuilder(Detection::class)
diff --git a/tests/Core/Command/Maintenance/ModeTest.php b/tests/Core/Command/Maintenance/ModeTest.php
index 895a06bbec1..1e8af354d50 100644
--- a/tests/Core/Command/Maintenance/ModeTest.php
+++ b/tests/Core/Command/Maintenance/ModeTest.php
@@ -48,7 +48,7 @@ class ModeTest extends TestCase {
*
* @return void
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)
->getMock();
diff --git a/tests/Core/Command/Maintenance/UpdateTheme.php b/tests/Core/Command/Maintenance/UpdateTheme.php
index 73141cefcbd..ace756b2647 100644
--- a/tests/Core/Command/Maintenance/UpdateTheme.php
+++ b/tests/Core/Command/Maintenance/UpdateTheme.php
@@ -50,7 +50,7 @@ class UpdateThemeTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->detector = $this->createMock(Detection::class);
diff --git a/tests/Core/Command/TwoFactorAuth/CleanupTest.php b/tests/Core/Command/TwoFactorAuth/CleanupTest.php
index 227283decf6..24aaa9abce2 100644
--- a/tests/Core/Command/TwoFactorAuth/CleanupTest.php
+++ b/tests/Core/Command/TwoFactorAuth/CleanupTest.php
@@ -40,7 +40,7 @@ class CleanupTest extends TestCase {
/** @var CommandTester */
private $cmd;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->registry = $this->createMock(IRegistry::class);
diff --git a/tests/Core/Command/TwoFactorAuth/DisableTest.php b/tests/Core/Command/TwoFactorAuth/DisableTest.php
index 30ebc007dc1..fc0def50b90 100644
--- a/tests/Core/Command/TwoFactorAuth/DisableTest.php
+++ b/tests/Core/Command/TwoFactorAuth/DisableTest.php
@@ -45,7 +45,7 @@ class DisableTest extends TestCase {
/** @var CommandTester */
private $command;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->providerManager = $this->createMock(ProviderManager::class);
diff --git a/tests/Core/Command/TwoFactorAuth/EnableTest.php b/tests/Core/Command/TwoFactorAuth/EnableTest.php
index f31f92da4a5..faf00ed1ded 100644
--- a/tests/Core/Command/TwoFactorAuth/EnableTest.php
+++ b/tests/Core/Command/TwoFactorAuth/EnableTest.php
@@ -45,7 +45,7 @@ class EnableTest extends TestCase {
/** @var CommandTester */
private $command;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->providerManager = $this->createMock(ProviderManager::class);
diff --git a/tests/Core/Command/TwoFactorAuth/EnforceTest.php b/tests/Core/Command/TwoFactorAuth/EnforceTest.php
index 2d9b77e18c2..aa2cbc10620 100644
--- a/tests/Core/Command/TwoFactorAuth/EnforceTest.php
+++ b/tests/Core/Command/TwoFactorAuth/EnforceTest.php
@@ -41,7 +41,7 @@ class EnforceTest extends TestCase {
/** @var CommandTester */
private $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->mandatoryTwoFactor = $this->createMock(MandatoryTwoFactor::class);
diff --git a/tests/Core/Command/TwoFactorAuth/StateTest.php b/tests/Core/Command/TwoFactorAuth/StateTest.php
index 580e137fe32..8d1b28862d3 100644
--- a/tests/Core/Command/TwoFactorAuth/StateTest.php
+++ b/tests/Core/Command/TwoFactorAuth/StateTest.php
@@ -45,7 +45,7 @@ class StateTest extends TestCase {
/** @var CommandTester|MockObject */
private $cmd;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->registry = $this->createMock(IRegistry::class);
diff --git a/tests/Core/Command/User/DeleteTest.php b/tests/Core/Command/User/DeleteTest.php
index 1b94d37cfc4..9dc920894d7 100644
--- a/tests/Core/Command/User/DeleteTest.php
+++ b/tests/Core/Command/User/DeleteTest.php
@@ -40,7 +40,7 @@ class DeleteTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$userManager = $this->userManager = $this->getMockBuilder(IUserManager::class)
diff --git a/tests/Core/Command/User/DisableTest.php b/tests/Core/Command/User/DisableTest.php
index 019fedc1da9..5456118f67c 100644
--- a/tests/Core/Command/User/DisableTest.php
+++ b/tests/Core/Command/User/DisableTest.php
@@ -42,7 +42,7 @@ class DisableTest extends TestCase {
/** @var Disable */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
diff --git a/tests/Core/Command/User/EnableTest.php b/tests/Core/Command/User/EnableTest.php
index 9a3df13efe0..4a723ca1167 100644
--- a/tests/Core/Command/User/EnableTest.php
+++ b/tests/Core/Command/User/EnableTest.php
@@ -42,7 +42,7 @@ class EnableTest extends TestCase {
/** @var Disable */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
diff --git a/tests/Core/Command/User/LastSeenTest.php b/tests/Core/Command/User/LastSeenTest.php
index cceefb98810..f6ee4796454 100644
--- a/tests/Core/Command/User/LastSeenTest.php
+++ b/tests/Core/Command/User/LastSeenTest.php
@@ -40,7 +40,7 @@ class LastSeenTest extends TestCase {
/** @var \Symfony\Component\Console\Command\Command */
protected $command;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$userManager = $this->userManager = $this->getMockBuilder(IUserManager::class)
diff --git a/tests/Core/Command/User/SettingTest.php b/tests/Core/Command/User/SettingTest.php
index 784183c72c3..7d717343348 100644
--- a/tests/Core/Command/User/SettingTest.php
+++ b/tests/Core/Command/User/SettingTest.php
@@ -42,7 +42,7 @@ class SettingTest extends TestCase {
/** @var \Symfony\Component\Console\Output\OutputInterface|\PHPUnit_Framework_MockObject_MockObject */
protected $consoleOutput;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->getMockBuilder(IUserManager::class)
diff --git a/tests/Core/Controller/AppPasswordControllerTest.php b/tests/Core/Controller/AppPasswordControllerTest.php
index a7be7a90b09..ceccf912285 100644
--- a/tests/Core/Controller/AppPasswordControllerTest.php
+++ b/tests/Core/Controller/AppPasswordControllerTest.php
@@ -64,7 +64,7 @@ class AppPasswordControllerTest extends TestCase {
/** @var AppPasswordController */
private $controller;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->session = $this->createMock(ISession::class);
diff --git a/tests/Core/Controller/AutoCompleteControllerTest.php b/tests/Core/Controller/AutoCompleteControllerTest.php
index 8ff0542cb0b..ea62b502196 100644
--- a/tests/Core/Controller/AutoCompleteControllerTest.php
+++ b/tests/Core/Controller/AutoCompleteControllerTest.php
@@ -41,7 +41,7 @@ class AutoCompleteControllerTest extends TestCase {
/** @var AutoCompleteController */
protected $controller;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
/** @var IRequest $request */
diff --git a/tests/Core/Controller/AvatarControllerTest.php b/tests/Core/Controller/AvatarControllerTest.php
index 6f82607dc02..9135a6bc92f 100644
--- a/tests/Core/Controller/AvatarControllerTest.php
+++ b/tests/Core/Controller/AvatarControllerTest.php
@@ -79,7 +79,7 @@ class AvatarControllerTest extends \Test\TestCase {
/** @var TimeFactory|\PHPUnit_Framework_MockObject_MockObject */
private $timeFactory;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->avatarManager = $this->getMockBuilder('OCP\IAvatarManager')->getMock();
@@ -121,7 +121,7 @@ class AvatarControllerTest extends \Test\TestCase {
$this->avatarFile->method('getEtag')->willReturn('my etag');
}
- public function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
}
@@ -332,7 +332,7 @@ class AvatarControllerTest extends \Test\TestCase {
$this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT.'/tests/data/testimage.gif'));
//Create request return
- $reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => filesize(\OC::$SERVERROOT.'/tests/data/testimage.gif')];
+ $reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => [filesize(\OC::$SERVERROOT.'/tests/data/testimage.gif')]];
$this->request->method('getUploadedFile')->willReturn($reqRet);
$response = $this->avatarController->postAvatar(null);
diff --git a/tests/Core/Controller/CSRFTokenControllerTest.php b/tests/Core/Controller/CSRFTokenControllerTest.php
index a97f2eabc27..74eebf61749 100644
--- a/tests/Core/Controller/CSRFTokenControllerTest.php
+++ b/tests/Core/Controller/CSRFTokenControllerTest.php
@@ -44,7 +44,7 @@ class CSRFTokenControllerTest extends TestCase {
/** @var CsrfTokenManager|PHPUnit_Framework_MockObject_MockObject */
private $tokenManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/tests/Core/Controller/ChangePasswordControllerTest.php b/tests/Core/Controller/ChangePasswordControllerTest.php
index 55f05c975ed..a55b0bc232e 100644
--- a/tests/Core/Controller/ChangePasswordControllerTest.php
+++ b/tests/Core/Controller/ChangePasswordControllerTest.php
@@ -49,7 +49,7 @@ class ChangePasswordControllerTest extends \Test\TestCase {
/** @var ChangePasswordController */
private $controller;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(\OC\User\Manager::class);
diff --git a/tests/Core/Controller/ClientFlowLoginControllerTest.php b/tests/Core/Controller/ClientFlowLoginControllerTest.php
index 1401eac67d8..3932cb9e144 100644
--- a/tests/Core/Controller/ClientFlowLoginControllerTest.php
+++ b/tests/Core/Controller/ClientFlowLoginControllerTest.php
@@ -74,7 +74,7 @@ class ClientFlowLoginControllerTest extends TestCase {
/** @var ClientFlowLoginController */
private $clientFlowLoginController;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php b/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php
index c3ed740432c..3c39a402f55 100644
--- a/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php
+++ b/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php
@@ -58,7 +58,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase {
/** @var ClientFlowLoginV2Controller */
private $controller;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/tests/Core/Controller/ContactsMenuControllerTest.php b/tests/Core/Controller/ContactsMenuControllerTest.php
index 92a185cf2ad..24f1adb10f2 100644
--- a/tests/Core/Controller/ContactsMenuControllerTest.php
+++ b/tests/Core/Controller/ContactsMenuControllerTest.php
@@ -47,7 +47,7 @@ class ContactsMenuControllerTest extends TestCase {
/** @var ContactsMenuController */
private $controller;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/tests/Core/Controller/CssControllerTest.php b/tests/Core/Controller/CssControllerTest.php
index faab89db40c..c0d1ea42f41 100644
--- a/tests/Core/Controller/CssControllerTest.php
+++ b/tests/Core/Controller/CssControllerTest.php
@@ -48,7 +48,7 @@ class CssControllerTest extends TestCase {
/** @var CssController */
private $controller;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
/** @var Factory|\PHPUnit_Framework_MockObject_MockObject $factory */
diff --git a/tests/Core/Controller/GuestAvatarControllerTest.php b/tests/Core/Controller/GuestAvatarControllerTest.php
index f720478e499..dd8188b002f 100644
--- a/tests/Core/Controller/GuestAvatarControllerTest.php
+++ b/tests/Core/Controller/GuestAvatarControllerTest.php
@@ -48,7 +48,7 @@ class GuestAvatarControllerTest extends \Test\TestCase {
/**
* Sets up the test environment.
*/
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->logger = $this->getMockBuilder(ILogger::class)->getMock();
diff --git a/tests/Core/Controller/JsControllerTest.php b/tests/Core/Controller/JsControllerTest.php
index e05f5bf5ded..26df6d181ef 100644
--- a/tests/Core/Controller/JsControllerTest.php
+++ b/tests/Core/Controller/JsControllerTest.php
@@ -48,7 +48,7 @@ class JsControllerTest extends TestCase {
/** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */
private $request;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
/** @var Factory|\PHPUnit_Framework_MockObject_MockObject $factory */
diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php
index df1b12b9709..b4f3663c0ba 100644
--- a/tests/Core/Controller/LoginControllerTest.php
+++ b/tests/Core/Controller/LoginControllerTest.php
@@ -83,7 +83,7 @@ class LoginControllerTest extends TestCase {
/** @var IInitialStateService|MockObject */
private $initialStateService;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
$this->userManager = $this->createMock(\OC\User\Manager::class);
diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php
index 60b96a39081..27344102f0a 100644
--- a/tests/Core/Controller/LostControllerTest.php
+++ b/tests/Core/Controller/LostControllerTest.php
@@ -84,7 +84,7 @@ class LostControllerTest extends \Test\TestCase {
/** @var IInitialStateService|\PHPUnit_Framework_MockObject_MockObject */
private $initialStateService;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->existingUser = $this->createMock(IUser::class);
diff --git a/tests/Core/Controller/NavigationControllerTest.php b/tests/Core/Controller/NavigationControllerTest.php
index 71730a8f8b9..4a4ad4b49e3 100644
--- a/tests/Core/Controller/NavigationControllerTest.php
+++ b/tests/Core/Controller/NavigationControllerTest.php
@@ -45,7 +45,7 @@ class NavigationControllerTest extends TestCase {
/** @var NavigationController */
private $controller;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/tests/Core/Controller/OCSControllerTest.php b/tests/Core/Controller/OCSControllerTest.php
index 241c3b12477..f0fbce86b8c 100644
--- a/tests/Core/Controller/OCSControllerTest.php
+++ b/tests/Core/Controller/OCSControllerTest.php
@@ -48,7 +48,7 @@ class OCSControllerTest extends TestCase {
/** @var OCSController */
private $controller;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/tests/Core/Controller/PreviewControllerTest.php b/tests/Core/Controller/PreviewControllerTest.php
index 7b66d32f61e..65252561796 100644
--- a/tests/Core/Controller/PreviewControllerTest.php
+++ b/tests/Core/Controller/PreviewControllerTest.php
@@ -49,7 +49,7 @@ class PreviewControllerTest extends \Test\TestCase {
/** @var PreviewController|\PHPUnit_Framework_MockObject_MockObject */
private $controller;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->rootFolder = $this->createMock(IRootFolder::class);
diff --git a/tests/Core/Controller/TwoFactorChallengeControllerTest.php b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
index 73b035a408c..40453db5729 100644
--- a/tests/Core/Controller/TwoFactorChallengeControllerTest.php
+++ b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
@@ -61,7 +61,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
/** @var TwoFactorChallengeController|PHPUnit_Framework_MockObject_MockObject */
private $controller;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/tests/Core/Controller/UserControllerTest.php b/tests/Core/Controller/UserControllerTest.php
index 7a089d5e57e..b5e43b2999d 100644
--- a/tests/Core/Controller/UserControllerTest.php
+++ b/tests/Core/Controller/UserControllerTest.php
@@ -38,7 +38,7 @@ class UserControllerTest extends TestCase {
/** @var UserController */
private $controller;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
diff --git a/tests/Core/Controller/WipeControllerTest.php b/tests/Core/Controller/WipeControllerTest.php
index cc084890e70..73d16a63a6e 100644
--- a/tests/Core/Controller/WipeControllerTest.php
+++ b/tests/Core/Controller/WipeControllerTest.php
@@ -40,7 +40,7 @@ class WipeControllerTest extends TestCase {
/** @var WipeController */
private $controller;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->remoteWipe = $this->createMock(RemoteWipe::class);
diff --git a/tests/Core/Middleware/TwoFactorMiddlewareTest.php b/tests/Core/Middleware/TwoFactorMiddlewareTest.php
index 994599212f9..2198cc7d5b4 100644
--- a/tests/Core/Middleware/TwoFactorMiddlewareTest.php
+++ b/tests/Core/Middleware/TwoFactorMiddlewareTest.php
@@ -70,7 +70,7 @@ class TwoFactorMiddlewareTest extends TestCase {
/** @var Controller */
private $controller;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->twoFactorManager = $this->getMockBuilder(Manager::class)
@@ -162,10 +162,10 @@ class TwoFactorMiddlewareTest extends TestCase {
$this->middleware->beforeController($this->controller, 'index');
}
- /**
- * @expectedException \OC\Authentication\Exceptions\TwoFactorAuthRequiredException
- */
+
public function testBeforeControllerTwoFactorAuthRequired() {
+ $this->expectException(\OC\Authentication\Exceptions\TwoFactorAuthRequiredException::class);
+
$user = $this->createMock(IUser::class);
$this->reflector->expects($this->once())
@@ -190,10 +190,10 @@ class TwoFactorMiddlewareTest extends TestCase {
$this->middleware->beforeController($this->controller, 'index');
}
- /**
- * @expectedException \OC\Authentication\Exceptions\UserAlreadyLoggedInException
- */
+
public function testBeforeControllerUserAlreadyLoggedIn() {
+ $this->expectException(\OC\Authentication\Exceptions\UserAlreadyLoggedInException::class);
+
$user = $this->createMock(IUser::class);
$this->reflector
diff --git a/tests/acceptance/features/core/NextcloudTestServerLocalApacheHelper.php b/tests/acceptance/features/core/NextcloudTestServerLocalApacheHelper.php
index b552a86d250..a2dd6664c6f 100644
--- a/tests/acceptance/features/core/NextcloudTestServerLocalApacheHelper.php
+++ b/tests/acceptance/features/core/NextcloudTestServerLocalApacheHelper.php
@@ -72,7 +72,7 @@ class NextcloudTestServerLocalApacheHelper implements NextcloudTestServerHelper
* @throws \Exception if the Nextcloud test server can not be reset or
* started again.
*/
- public function setUp() {
+ public function setUp(): void {
// Ensure that previous Apache server is not running (as cleanUp may not
// have been called).
$this->stopApacheServer();
diff --git a/tests/acceptance/features/core/NextcloudTestServerLocalBuiltInHelper.php b/tests/acceptance/features/core/NextcloudTestServerLocalBuiltInHelper.php
index 722f580171a..1e74f5c66d1 100644
--- a/tests/acceptance/features/core/NextcloudTestServerLocalBuiltInHelper.php
+++ b/tests/acceptance/features/core/NextcloudTestServerLocalBuiltInHelper.php
@@ -76,7 +76,7 @@ class NextcloudTestServerLocalBuiltInHelper implements NextcloudTestServerHelper
* @throws \Exception if the Nextcloud test server can not be reset or
* started again.
*/
- public function setUp() {
+ public function setUp(): void {
// Ensure that previous PHP server is not running (as cleanUp may not
// have been called).
$this->killPhpServer();
diff --git a/tests/lib/Accounts/AccountsManagerTest.php b/tests/lib/Accounts/AccountsManagerTest.php
index 9d9a0e01583..d727f05d1ef 100644
--- a/tests/lib/Accounts/AccountsManagerTest.php
+++ b/tests/lib/Accounts/AccountsManagerTest.php
@@ -51,7 +51,7 @@ class AccountsManagerTest extends TestCase {
/** @var string accounts table name */
private $table = 'accounts';
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->eventDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')
->disableOriginalConstructor()->getMock();
@@ -59,7 +59,7 @@ class AccountsManagerTest extends TestCase {
$this->jobList = $this->getMockBuilder(IJobList::class)->getMock();
}
- public function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
$query = $this->connection->getQueryBuilder();
$query->delete($this->table)->execute();
diff --git a/tests/lib/Accounts/HooksTest.php b/tests/lib/Accounts/HooksTest.php
index 0534f2dba6b..0d6ce3241d6 100644
--- a/tests/lib/Accounts/HooksTest.php
+++ b/tests/lib/Accounts/HooksTest.php
@@ -45,7 +45,7 @@ class HooksTest extends TestCase {
/** @var Hooks | \PHPUnit_Framework_MockObject_MockObject */
private $hooks;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->logger = $this->createMock(ILogger::class);
diff --git a/tests/lib/Activity/ManagerTest.php b/tests/lib/Activity/ManagerTest.php
index ba6b87ca9aa..b52b12a7e8c 100644
--- a/tests/lib/Activity/ManagerTest.php
+++ b/tests/lib/Activity/ManagerTest.php
@@ -44,7 +44,7 @@ class ManagerTest extends TestCase {
/** @var IValidator|\PHPUnit_Framework_MockObject_MockObject */
protected $validator;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
@@ -75,10 +75,10 @@ class ManagerTest extends TestCase {
$this->assertNotEmpty($consumers);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testGetConsumersInvalidConsumer() {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->activityManager->registerConsumer(function() {
return new \stdClass();
});
@@ -98,13 +98,14 @@ class ManagerTest extends TestCase {
}
/**
- * @expectedException \UnexpectedValueException
* @dataProvider getUserFromTokenThrowInvalidTokenData
*
* @param string $token
* @param array $users
*/
public function testGetUserFromTokenThrowInvalidToken($token, $users) {
+ $this->expectException(\UnexpectedValueException::class);
+
$this->mockRSSToken($token, $token, $users);
self::invokePrivate($this->activityManager, 'getUserFromToken');
}
@@ -163,37 +164,37 @@ class ManagerTest extends TestCase {
->willReturn($mockUser);
}
- /**
- * @expectedException \BadMethodCallException
- */
+
public function testPublishExceptionNoApp() {
+ $this->expectException(\BadMethodCallException::class);
+
$event = $this->activityManager->generateEvent();
$this->activityManager->publish($event);
}
- /**
- * @expectedException \BadMethodCallException
- */
+
public function testPublishExceptionNoType() {
+ $this->expectException(\BadMethodCallException::class);
+
$event = $this->activityManager->generateEvent();
$event->setApp('test');
$this->activityManager->publish($event);
}
- /**
- * @expectedException \BadMethodCallException
- */
+
public function testPublishExceptionNoAffectedUser() {
+ $this->expectException(\BadMethodCallException::class);
+
$event = $this->activityManager->generateEvent();
$event->setApp('test')
->setType('test_type');
$this->activityManager->publish($event);
}
- /**
- * @expectedException \BadMethodCallException
- */
+
public function testPublishExceptionNoSubject() {
+ $this->expectException(\BadMethodCallException::class);
+
$event = $this->activityManager->generateEvent();
$event->setApp('test')
->setType('test_type')
diff --git a/tests/lib/AllConfigTest.php b/tests/lib/AllConfigTest.php
index f3d43ff4396..80ddcbbd354 100644
--- a/tests/lib/AllConfigTest.php
+++ b/tests/lib/AllConfigTest.php
@@ -137,17 +137,18 @@ class AllConfigTest extends \Test\TestCase {
/**
* @dataProvider dataSetUserValueUnexpectedValue
* @param mixed $value
- * @expectedException \UnexpectedValueException
*/
public function testSetUserValueUnexpectedValue($value) {
+ $this->expectException(\UnexpectedValueException::class);
+
$config = $this->getConfig();
$config->setUserValue('userSetBool', 'appSetBool', 'keySetBool', $value);
}
- /**
- * @expectedException \OCP\PreConditionNotMetException
- */
+
public function testSetUserValueWithPreConditionFailure() {
+ $this->expectException(\OCP\PreConditionNotMetException::class);
+
$config = $this->getConfig();
$selectAllSQL = 'SELECT `userid`, `appid`, `configkey`, `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ?';
diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php
index 66b210c4c13..b3437ad290c 100644
--- a/tests/lib/App/AppManagerTest.php
+++ b/tests/lib/App/AppManagerTest.php
@@ -97,7 +97,7 @@ class AppManagerTest extends TestCase {
/** @var IAppManager */
protected $manager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userSession = $this->createMock(IUserSession::class);
@@ -248,10 +248,11 @@ class AppManagerTest extends TestCase {
*
* @param string $type
*
- * @expectedException \Exception
- * @expectedExceptionMessage test can't be enabled for groups.
*/
public function testEnableAppForGroupsForbiddenTypes($type) {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('test can\'t be enabled for groups.');
+
$group1 = $this->createMock(IGroup::class);
$group1->method('getGID')
->willReturn('group1');
diff --git a/tests/lib/App/AppStore/Bundles/BundleBase.php b/tests/lib/App/AppStore/Bundles/BundleBase.php
index 23af1cda927..2c566b0ea0a 100644
--- a/tests/lib/App/AppStore/Bundles/BundleBase.php
+++ b/tests/lib/App/AppStore/Bundles/BundleBase.php
@@ -37,7 +37,7 @@ abstract class BundleBase extends TestCase {
/** @var array */
protected $bundleAppIds;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->l10n = $this->createMock(IL10N::class);
$this->l10n->method('t')
diff --git a/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php b/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php
index 350f6654e08..f453fbcb59a 100644
--- a/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php
+++ b/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php
@@ -36,7 +36,7 @@ class BundleFetcherTest extends TestCase {
/** @var BundleFetcher */
private $bundleFetcher;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->l10n = $this->createMock(IL10N::class);
@@ -69,11 +69,11 @@ class BundleFetcherTest extends TestCase {
$this->assertEquals(new GroupwareBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('GroupwareBundle'));
}
- /**
- * @expectedException \BadMethodCallException
- * @expectedExceptionMessage Bundle with specified identifier does not exist
- */
+
public function testGetBundleByIdentifierWithException() {
+ $this->expectException(\BadMethodCallException::class);
+ $this->expectExceptionMessage('Bundle with specified identifier does not exist');
+
$this->bundleFetcher->getBundleByIdentifier('NotExistingBundle');
}
diff --git a/tests/lib/App/AppStore/Bundles/CoreBundleTest.php b/tests/lib/App/AppStore/Bundles/CoreBundleTest.php
index 235e2ec84fe..2ace537b938 100644
--- a/tests/lib/App/AppStore/Bundles/CoreBundleTest.php
+++ b/tests/lib/App/AppStore/Bundles/CoreBundleTest.php
@@ -24,7 +24,7 @@ namespace Test\App\AppStore\Bundles;
use OC\App\AppStore\Bundles\CoreBundle;
class CoreBundleTest extends BundleBase {
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->bundle = new CoreBundle($this->l10n);
$this->bundleIdentifier = 'CoreBundle';
diff --git a/tests/lib/App/AppStore/Bundles/EducationBundleTest.php b/tests/lib/App/AppStore/Bundles/EducationBundleTest.php
index 589f35db215..1c5d2a480e9 100644
--- a/tests/lib/App/AppStore/Bundles/EducationBundleTest.php
+++ b/tests/lib/App/AppStore/Bundles/EducationBundleTest.php
@@ -24,7 +24,7 @@ namespace Test\App\AppStore\Bundles;
use OC\App\AppStore\Bundles\EducationBundle;
class EducationBundleTest extends BundleBase {
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->bundle = new EducationBundle($this->l10n);
$this->bundleIdentifier = 'EducationBundle';
diff --git a/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php b/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php
index b3182ff00c8..d24e8846f56 100644
--- a/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php
+++ b/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php
@@ -24,7 +24,7 @@ namespace Test\App\AppStore\Bundles;
use OC\App\AppStore\Bundles\EnterpriseBundle;
class EnterpriseBundleTest extends BundleBase {
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->bundle = new EnterpriseBundle($this->l10n);
$this->bundleIdentifier = 'EnterpriseBundle';
diff --git a/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php b/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php
index ccff5dcbd34..88391a6382f 100644
--- a/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php
+++ b/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php
@@ -24,7 +24,7 @@ namespace Test\App\AppStore\Bundles;
use OC\App\AppStore\Bundles\GroupwareBundle;
class GroupwareBundleTest extends BundleBase {
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->bundle = new GroupwareBundle($this->l10n);
$this->bundleIdentifier = 'GroupwareBundle';
diff --git a/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php b/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php
index 3d8bccf1935..17b2974b7c7 100644
--- a/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php
+++ b/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php
@@ -24,7 +24,7 @@ namespace Test\App\AppStore\Bundles;
use OC\App\AppStore\Bundles\SocialSharingBundle;
class SocialSharingBundleTest extends BundleBase {
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->bundle = new SocialSharingBundle($this->l10n);
$this->bundleIdentifier = 'SocialSharingBundle';
diff --git a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
index 214f652742b..9a118234049 100644
--- a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
+++ b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
@@ -59,7 +59,7 @@ class AppFetcherTest extends TestCase {
EOD;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
/** @var Factory|PHPUnit_Framework_MockObject_MockObject $factory */
diff --git a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php
index f4b8c320c51..8a82322b61c 100644
--- a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php
+++ b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php
@@ -24,7 +24,7 @@ namespace Test\App\AppStore\Fetcher;
use OC\App\AppStore\Fetcher\CategoryFetcher;
class CategoryFetcherTest extends FetcherBase {
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->fileName = 'categories.json';
$this->endpoint = 'https://apps.nextcloud.com/api/v1/categories.json';
diff --git a/tests/lib/App/AppStore/Fetcher/FetcherBase.php b/tests/lib/App/AppStore/Fetcher/FetcherBase.php
index 851773a6506..84584e5432f 100644
--- a/tests/lib/App/AppStore/Fetcher/FetcherBase.php
+++ b/tests/lib/App/AppStore/Fetcher/FetcherBase.php
@@ -56,7 +56,7 @@ abstract class FetcherBase extends TestCase {
/** @var string */
protected $endpoint;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->appDataFactory = $this->createMock(Factory::class);
$this->appData = $this->createMock(AppData::class);
diff --git a/tests/lib/App/AppStore/Version/VersionParserTest.php b/tests/lib/App/AppStore/Version/VersionParserTest.php
index ebfa98ade39..327c8cac779 100644
--- a/tests/lib/App/AppStore/Version/VersionParserTest.php
+++ b/tests/lib/App/AppStore/Version/VersionParserTest.php
@@ -29,7 +29,7 @@ class VersionParserTest extends TestCase {
/** @var VersionParser */
private $versionParser;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->versionParser = new VersionParser();
}
@@ -81,19 +81,19 @@ class VersionParserTest extends TestCase {
$this->assertEquals($expected, $this->versionParser->getVersion($input));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Version cannot be parsed: BogusVersion
- */
+
public function testGetVersionException() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Version cannot be parsed: BogusVersion');
+
$this->versionParser->getVersion('BogusVersion');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Version cannot be parsed: >=8.2 <=9.1a
- */
+
public function testGetVersionExceptionWithMultiple() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Version cannot be parsed: >=8.2 <=9.1a');
+
$this->versionParser->getVersion('>=8.2 <=9.1a');
}
}
diff --git a/tests/lib/App/CodeChecker/InfoCheckerTest.php b/tests/lib/App/CodeChecker/InfoCheckerTest.php
index 3128f902f47..531066a54c6 100644
--- a/tests/lib/App/CodeChecker/InfoCheckerTest.php
+++ b/tests/lib/App/CodeChecker/InfoCheckerTest.php
@@ -29,7 +29,7 @@ class InfoCheckerTest extends TestCase {
/** @var InfoChecker */
protected $infoChecker;
- public static function setUpBeforeClass() {
+ public static function setUpBeforeClass(): void {
\OC::$APPSROOTS[] = [
'path' => \OC::$SERVERROOT . '/tests/apps',
'url' => '/apps-test',
@@ -37,12 +37,12 @@ class InfoCheckerTest extends TestCase {
];
}
- public static function tearDownAfterClass() {
+ public static function tearDownAfterClass(): void {
// remove last element
array_pop(\OC::$APPSROOTS);
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->infoChecker = new InfoChecker();
}
diff --git a/tests/lib/App/CompareVersionTest.php b/tests/lib/App/CompareVersionTest.php
index 60309fdeae4..af04691f276 100644
--- a/tests/lib/App/CompareVersionTest.php
+++ b/tests/lib/App/CompareVersionTest.php
@@ -33,7 +33,7 @@ class CompareVersionTest extends TestCase {
/** @var CompareVersion */
private $compare;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->compare = new CompareVersion();
diff --git a/tests/lib/App/DependencyAnalyzerTest.php b/tests/lib/App/DependencyAnalyzerTest.php
index 081f6d767db..943b53eee64 100644
--- a/tests/lib/App/DependencyAnalyzerTest.php
+++ b/tests/lib/App/DependencyAnalyzerTest.php
@@ -26,7 +26,7 @@ class DependencyAnalyzerTest extends TestCase {
/** @var DependencyAnalyzer */
private $analyser;
- public function setUp() {
+ protected function setUp(): void {
$this->platformMock = $this->getMockBuilder(Platform::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/App/InfoParserTest.php b/tests/lib/App/InfoParserTest.php
index b72a869e02c..8de0f4cfd4f 100644
--- a/tests/lib/App/InfoParserTest.php
+++ b/tests/lib/App/InfoParserTest.php
@@ -16,7 +16,7 @@ class InfoParserTest extends TestCase {
/** @var OC\Cache\CappedMemoryCache */
private static $cache;
- public static function setUpBeforeClass() {
+ public static function setUpBeforeClass(): void {
self::$cache = new OC\Cache\CappedMemoryCache();
}
diff --git a/tests/lib/AppConfigTest.php b/tests/lib/AppConfigTest.php
index 9456fe4c232..14114e8fad7 100644
--- a/tests/lib/AppConfigTest.php
+++ b/tests/lib/AppConfigTest.php
@@ -26,7 +26,7 @@ class AppConfigTest extends TestCase {
protected $originalConfig;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -111,7 +111,7 @@ class AppConfigTest extends TestCase {
])->execute();
}
- public function tearDown() {
+ protected function tearDown(): void {
$sql = $this->connection->getQueryBuilder();
$sql->delete('appconfig');
$sql->execute();
diff --git a/tests/lib/AppFramework/AppTest.php b/tests/lib/AppFramework/AppTest.php
index cd3e7c47ad6..ccc694942a1 100644
--- a/tests/lib/AppFramework/AppTest.php
+++ b/tests/lib/AppFramework/AppTest.php
@@ -56,7 +56,7 @@ class AppTest extends \Test\TestCase {
private $controllerMethod;
private $appPath;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->container = new \OC\AppFramework\DependencyInjection\DIContainer('test', array());
@@ -121,7 +121,7 @@ class AppTest extends \Test\TestCase {
}
- protected function tearDown() {
+ protected function tearDown(): void {
rrmdir($this->appPath);
parent::tearDown();
}
diff --git a/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php b/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php
index 30da40d36b4..8eb76d3cb27 100644
--- a/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php
+++ b/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php
@@ -50,7 +50,7 @@ class AuthPublicShareControllerTest extends \Test\TestCase {
private $controller;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/tests/lib/AppFramework/Controller/ControllerTest.php b/tests/lib/AppFramework/Controller/ControllerTest.php
index 7831b44b632..b1cb1ceab6f 100644
--- a/tests/lib/AppFramework/Controller/ControllerTest.php
+++ b/tests/lib/AppFramework/Controller/ControllerTest.php
@@ -62,7 +62,7 @@ class ControllerTest extends \Test\TestCase {
private $controller;
private $app;
- protected function setUp(){
+ protected function setUp(): void {
parent::setUp();
$request = new Request(
@@ -94,10 +94,10 @@ class ControllerTest extends \Test\TestCase {
$this->controller = new ChildController($this->app, $request);
}
- /**
- * @expectedException \DomainException
- */
+
public function testFormatResonseInvalidFormat() {
+ $this->expectException(\DomainException::class);
+
$this->controller->buildResponse(null, 'test');
}
diff --git a/tests/lib/AppFramework/Controller/PublicShareControllerTest.php b/tests/lib/AppFramework/Controller/PublicShareControllerTest.php
index f20f996d5a3..318647ca844 100644
--- a/tests/lib/AppFramework/Controller/PublicShareControllerTest.php
+++ b/tests/lib/AppFramework/Controller/PublicShareControllerTest.php
@@ -47,7 +47,7 @@ class PublicShareControllerTest extends \Test\TestCase {
private $controller;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/tests/lib/AppFramework/Db/EntityTest.php b/tests/lib/AppFramework/Db/EntityTest.php
index a49440949e3..c8ebda55a86 100644
--- a/tests/lib/AppFramework/Db/EntityTest.php
+++ b/tests/lib/AppFramework/Db/EntityTest.php
@@ -66,7 +66,7 @@ class EntityTest extends \Test\TestCase {
private $entity;
- protected function setUp(){
+ protected function setUp(): void {
parent::setUp();
$this->entity = new TestEntity();
}
@@ -129,25 +129,25 @@ class EntityTest extends \Test\TestCase {
}
- /**
- * @expectedException \BadFunctionCallException
- */
+
public function testCallShouldOnlyWorkForGetterSetter(){
+ $this->expectException(\BadFunctionCallException::class);
+
$this->entity->something();
}
- /**
- * @expectedException \BadFunctionCallException
- */
+
public function testGetterShouldFailIfAttributeNotDefined(){
+ $this->expectException(\BadFunctionCallException::class);
+
$this->entity->getTest();
}
- /**
- * @expectedException \BadFunctionCallException
- */
+
public function testSetterShouldFailIfAttributeNotDefined(){
+ $this->expectException(\BadFunctionCallException::class);
+
$this->entity->setTest();
}
@@ -245,10 +245,10 @@ class EntityTest extends \Test\TestCase {
$this->assertThat($entity->isAnotherBool(), new IsType(IsType::TYPE_BOOL));
}
- /**
- * @expectedException BadFunctionCallException
- */
+
public function testIsGetterShoudFailForOtherType() {
+ $this->expectException(\BadFunctionCallException::class);
+
$entity = new TestEntity();
$entity->setName('hello');
$this->assertThat($entity->isName(), new IsType(IsType::TYPE_BOOL));
diff --git a/tests/lib/AppFramework/Db/MapperTest.php b/tests/lib/AppFramework/Db/MapperTest.php
index 8ca80fe11ca..a69980fbb26 100644
--- a/tests/lib/AppFramework/Db/MapperTest.php
+++ b/tests/lib/AppFramework/Db/MapperTest.php
@@ -60,7 +60,7 @@ class MapperTest extends MapperTestUtility {
*/
private $mapper;
- protected function setUp(){
+ protected function setUp(): void {
parent::setUp();
$this->mapper = new ExampleMapper($this->db);
}
diff --git a/tests/lib/AppFramework/Db/MapperTestUtility.php b/tests/lib/AppFramework/Db/MapperTestUtility.php
index 71c21a06632..83156a3932b 100644
--- a/tests/lib/AppFramework/Db/MapperTestUtility.php
+++ b/tests/lib/AppFramework/Db/MapperTestUtility.php
@@ -40,7 +40,7 @@ abstract class MapperTestUtility extends \Test\TestCase {
* Run this function before the actual test to either set or initialize the
* db. After this the db can be accessed by using $this->db
*/
- protected function setUp(){
+ protected function setUp(): void {
parent::setUp();
$this->db = $this->getMockBuilder(
diff --git a/tests/lib/AppFramework/Db/QBMapperTest.php b/tests/lib/AppFramework/Db/QBMapperTest.php
index 279c95afaeb..6fa0fe10d88 100644
--- a/tests/lib/AppFramework/Db/QBMapperTest.php
+++ b/tests/lib/AppFramework/Db/QBMapperTest.php
@@ -105,7 +105,7 @@ class QBMapperTest extends \Test\TestCase {
/**
* @throws \ReflectionException
*/
- protected function setUp() {
+ protected function setUp(): void {
$this->db = $this->getMockBuilder(IDBConnection::class)
->disableOriginalConstructor()
@@ -127,9 +127,7 @@ class QBMapperTest extends \Test\TestCase {
$this->mapper = new QBTestMapper($this->db);
}
- /**
- *
- */
+
public function testInsertEntityParameterTypeMapping() {
$entity = new QBTestEntity();
$entity->setIntProp(123);
@@ -166,9 +164,7 @@ class QBMapperTest extends \Test\TestCase {
$this->mapper->insert($entity);
}
- /**
- *
- */
+
public function testUpdateEntityParameterTypeMapping() {
$entity = new QBTestEntity();
$entity->setId(789);
@@ -214,9 +210,7 @@ class QBMapperTest extends \Test\TestCase {
$this->mapper->update($entity);
}
- /**
- *
- */
+
public function testGetParameterTypeForProperty() {
$entity = new QBTestEntity();
diff --git a/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php b/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php
index 03c8265f2c9..95d368a448e 100644
--- a/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php
+++ b/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php
@@ -41,7 +41,7 @@ class DIContainerTest extends \Test\TestCase {
/** @var DIContainer|\PHPUnit_Framework_MockObject_MockObject */
private $container;
- protected function setUp(){
+ protected function setUp(): void {
parent::setUp();
$this->container = $this->getMockBuilder(DIContainer::class)
->setMethods(['isAdminUser'])
diff --git a/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php b/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php
index d3d3f73e872..669063f4d18 100644
--- a/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php
+++ b/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php
@@ -56,7 +56,7 @@ class DIIntergrationTests extends TestCase {
/** @var ServerContainer */
private $server;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->server = new ServerContainer();
diff --git a/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php b/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php
index b6163e90386..6acc21550d1 100644
--- a/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php
+++ b/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php
@@ -21,7 +21,7 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
/** @var ContentSecurityPolicy */
private $contentSecurityPolicy;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->contentSecurityPolicy = new ContentSecurityPolicy();
}
diff --git a/tests/lib/AppFramework/Http/DataResponseTest.php b/tests/lib/AppFramework/Http/DataResponseTest.php
index 6f81e0d56b4..b629c6d385e 100644
--- a/tests/lib/AppFramework/Http/DataResponseTest.php
+++ b/tests/lib/AppFramework/Http/DataResponseTest.php
@@ -34,7 +34,7 @@ class DataResponseTest extends \Test\TestCase {
*/
private $response;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->response = new DataResponse();
}
diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php
index 404c94abdbd..1c4dc067b5d 100644
--- a/tests/lib/AppFramework/Http/DispatcherTest.php
+++ b/tests/lib/AppFramework/Http/DispatcherTest.php
@@ -87,7 +87,7 @@ class DispatcherTest extends \Test\TestCase {
private $http;
private $reflector;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->controllerMethod = 'test';
diff --git a/tests/lib/AppFramework/Http/DownloadResponseTest.php b/tests/lib/AppFramework/Http/DownloadResponseTest.php
index 97c7ab75ed9..5f816eaeb76 100644
--- a/tests/lib/AppFramework/Http/DownloadResponseTest.php
+++ b/tests/lib/AppFramework/Http/DownloadResponseTest.php
@@ -38,7 +38,7 @@ class DownloadResponseTest extends \Test\TestCase {
*/
protected $response;
- protected function setUp(){
+ protected function setUp(): void {
parent::setUp();
$this->response = new ChildDownloadResponse('file', 'content');
}
diff --git a/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php b/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php
index d9bdfccf60b..c19caad23c7 100644
--- a/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php
+++ b/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php
@@ -21,7 +21,7 @@ class EmptyContentSecurityPolicyTest extends \Test\TestCase {
/** @var EmptyContentSecurityPolicy */
private $contentSecurityPolicy;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->contentSecurityPolicy = new EmptyContentSecurityPolicy();
}
diff --git a/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php b/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php
index 9150503c632..1cebc9ef0f2 100644
--- a/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php
+++ b/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php
@@ -31,7 +31,7 @@ class EmptyFeaturePolicyTest extends \Test\TestCase {
/** @var EmptyFeaturePolicy */
private $policy;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->policy = new EmptyFeaturePolicy();
}
diff --git a/tests/lib/AppFramework/Http/FeaturePolicyTest.php b/tests/lib/AppFramework/Http/FeaturePolicyTest.php
index 7c2cc3fa6d5..af21457bf0a 100644
--- a/tests/lib/AppFramework/Http/FeaturePolicyTest.php
+++ b/tests/lib/AppFramework/Http/FeaturePolicyTest.php
@@ -31,7 +31,7 @@ class FeaturePolicyTest extends \Test\TestCase {
/** @var EmptyFeaturePolicy */
private $policy;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->policy = new FeaturePolicy();
}
diff --git a/tests/lib/AppFramework/Http/FileDisplayResponseTest.php b/tests/lib/AppFramework/Http/FileDisplayResponseTest.php
index 2c91289a5c9..5ca7635614c 100644
--- a/tests/lib/AppFramework/Http/FileDisplayResponseTest.php
+++ b/tests/lib/AppFramework/Http/FileDisplayResponseTest.php
@@ -34,7 +34,7 @@ class FileDisplayResponseTest extends \Test\TestCase {
/** @var FileDisplayResponse */
private $response;
- public function setup() {
+ protected function setUp(): void {
$this->file = $this->getMockBuilder('OCP\Files\File')
->getMock();
diff --git a/tests/lib/AppFramework/Http/HttpTest.php b/tests/lib/AppFramework/Http/HttpTest.php
index 0a13e1e11e5..79c03ce1ab0 100644
--- a/tests/lib/AppFramework/Http/HttpTest.php
+++ b/tests/lib/AppFramework/Http/HttpTest.php
@@ -34,7 +34,7 @@ class HttpTest extends \Test\TestCase {
*/
private $http;
- protected function setUp(){
+ protected function setUp(): void {
parent::setUp();
$this->server = array();
diff --git a/tests/lib/AppFramework/Http/JSONResponseTest.php b/tests/lib/AppFramework/Http/JSONResponseTest.php
index a74bd67d1f0..95d2e2a0a4c 100644
--- a/tests/lib/AppFramework/Http/JSONResponseTest.php
+++ b/tests/lib/AppFramework/Http/JSONResponseTest.php
@@ -36,7 +36,7 @@ class JSONResponseTest extends \Test\TestCase {
*/
private $json;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->json = new JSONResponse();
}
@@ -89,11 +89,11 @@ class JSONResponseTest extends \Test\TestCase {
$this->assertEquals($expected, $this->json->render());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Could not json_encode due to invalid non UTF-8 characters in the array: array (
- */
+
public function testRenderWithNonUtf8Encoding() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Could not json_encode due to invalid non UTF-8 characters in the array: array (');
+
$params = ['test' => hex2bin('e9')];
$this->json->setData($params);
$this->json->render();
diff --git a/tests/lib/AppFramework/Http/RedirectResponseTest.php b/tests/lib/AppFramework/Http/RedirectResponseTest.php
index 218f748a88b..fc24f323c6a 100644
--- a/tests/lib/AppFramework/Http/RedirectResponseTest.php
+++ b/tests/lib/AppFramework/Http/RedirectResponseTest.php
@@ -33,7 +33,7 @@ class RedirectResponseTest extends \Test\TestCase {
*/
protected $response;
- protected function setUp(){
+ protected function setUp(): void {
parent::setUp();
$this->response = new RedirectResponse('/url');
}
diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php
index 2ad660405f3..000a05f7913 100644
--- a/tests/lib/AppFramework/Http/RequestTest.php
+++ b/tests/lib/AppFramework/Http/RequestTest.php
@@ -31,7 +31,7 @@ class RequestTest extends \Test\TestCase {
/** @var CsrfTokenManager */
protected $csrfTokenManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
if (in_array('fakeinput', stream_get_wrappers())) {
@@ -45,7 +45,7 @@ class RequestTest extends \Test\TestCase {
->disableOriginalConstructor()->getMock();
}
- protected function tearDown() {
+ protected function tearDown(): void {
stream_wrapper_unregister('fakeinput');
parent::tearDown();
}
@@ -103,10 +103,10 @@ class RequestTest extends \Test\TestCase {
}
- /**
- * @expectedException \RuntimeException
- */
+
public function testImmutableArrayAccess() {
+ $this->expectException(\RuntimeException::class);
+
$vars = array(
'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
'method' => 'GET'
@@ -123,10 +123,10 @@ class RequestTest extends \Test\TestCase {
$request['nickname'] = 'Janey';
}
- /**
- * @expectedException \RuntimeException
- */
+
public function testImmutableMagicAccess() {
+ $this->expectException(\RuntimeException::class);
+
$vars = array(
'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
'method' => 'GET'
@@ -143,10 +143,10 @@ class RequestTest extends \Test\TestCase {
$request->{'nickname'} = 'Janey';
}
- /**
- * @expectedException \LogicException
- */
+
public function testGetTheMethodRight() {
+ $this->expectException(\LogicException::class);
+
$vars = array(
'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
'method' => 'GET',
@@ -1246,11 +1246,11 @@ class RequestTest extends \Test\TestCase {
$this->assertSame('www.owncloud.org', self::invokePrivate($request, 'getOverwriteHost'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The requested uri(/foo.php) cannot be processed by the script '/var/www/index.php')
- */
+
public function testGetPathInfoNotProcessible() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The requested uri(/foo.php) cannot be processed by the script \'/var/www/index.php\')');
+
$request = new Request(
[
'server' => [
@@ -1267,11 +1267,11 @@ class RequestTest extends \Test\TestCase {
$request->getPathInfo();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage The requested uri(/foo.php) cannot be processed by the script '/var/www/index.php')
- */
+
public function testGetRawPathInfoNotProcessible() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('The requested uri(/foo.php) cannot be processed by the script \'/var/www/index.php\')');
+
$request = new Request(
[
'server' => [
diff --git a/tests/lib/AppFramework/Http/ResponseTest.php b/tests/lib/AppFramework/Http/ResponseTest.php
index 64b9566f8e6..3d76d24496d 100644
--- a/tests/lib/AppFramework/Http/ResponseTest.php
+++ b/tests/lib/AppFramework/Http/ResponseTest.php
@@ -35,7 +35,7 @@ class ResponseTest extends \Test\TestCase {
*/
private $childResponse;
- protected function setUp(){
+ protected function setUp(): void {
parent::setUp();
$this->childResponse = new Response();
}
diff --git a/tests/lib/AppFramework/Http/StreamResponseTest.php b/tests/lib/AppFramework/Http/StreamResponseTest.php
index ef9a37aa81b..ef7132013b6 100644
--- a/tests/lib/AppFramework/Http/StreamResponseTest.php
+++ b/tests/lib/AppFramework/Http/StreamResponseTest.php
@@ -33,7 +33,7 @@ class StreamResponseTest extends \Test\TestCase {
/** @var IOutput */
private $output;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->output = $this->getMockBuilder('OCP\\AppFramework\\Http\\IOutput')
->disableOriginalConstructor()
diff --git a/tests/lib/AppFramework/Http/TemplateResponseTest.php b/tests/lib/AppFramework/Http/TemplateResponseTest.php
index b5586222257..6672b4d0c1e 100644
--- a/tests/lib/AppFramework/Http/TemplateResponseTest.php
+++ b/tests/lib/AppFramework/Http/TemplateResponseTest.php
@@ -33,7 +33,7 @@ class TemplateResponseTest extends \Test\TestCase {
*/
private $tpl;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->tpl = new TemplateResponse('app', 'home');
diff --git a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
index 7f817e03c1e..8971fe4df06 100644
--- a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
@@ -47,7 +47,7 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase {
/** @var AdditionalScriptsMiddleware */
private $middleWare;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
index e38aa4525e3..965637cb4c4 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
@@ -113,7 +113,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
*/
private $dispatcher;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->dispatcher = new MiddlewareDispatcher();
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareTest.php b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
index 8f9c60b65ff..4ac6fa647f7 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
@@ -43,7 +43,7 @@ class MiddlewareTest extends \Test\TestCase {
/** @var Response */
private $response;
- protected function setUp(){
+ protected function setUp(): void {
parent::setUp();
$this->middleware = new ChildMiddleware();
diff --git a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
index cca3b4aecca..e001e48acd2 100644
--- a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
@@ -42,7 +42,7 @@ class OCSMiddlewareTest extends \Test\TestCase {
*/
private $request;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->getMockBuilder(IRequest::class)
diff --git a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
index 4ad90b6e874..82f354d127d 100644
--- a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
@@ -49,7 +49,7 @@ class PublicShareMiddlewareTest extends \Test\TestCase {
private $middleware;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php
index ae2345764ff..f6ce5c27b22 100644
--- a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php
@@ -40,7 +40,7 @@ class BruteForceMiddlewareTest extends TestCase {
/** @var BruteForceMiddleware */
private $bruteForceMiddleware;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->reflector = $this->createMock(ControllerMethodReflector::class);
diff --git a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
index 0fab8803073..1c12a4aa153 100644
--- a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
@@ -34,7 +34,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
/** @var Controller */
private $controller;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->reflector = new ControllerMethodReflector();
$this->session = $this->createMock(Session::class);
@@ -102,9 +102,10 @@ class CORSMiddlewareTest extends \Test\TestCase {
/**
* @CORS
- * @expectedException \OC\AppFramework\Middleware\Security\Exceptions\SecurityException
*/
public function testCorsIgnoredIfWithCredentialsHeaderPresent() {
+ $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\SecurityException::class);
+
$request = new Request(
[
'server' => [
@@ -171,9 +172,10 @@ class CORSMiddlewareTest extends \Test\TestCase {
/**
* @CORS
- * @expectedException \OC\AppFramework\Middleware\Security\Exceptions\SecurityException
*/
public function testCORSShouldFailIfPasswordLoginIsForbidden() {
+ $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\SecurityException::class);
+
$request = new Request(
['server' => [
'PHP_AUTH_USER' => 'user',
@@ -196,9 +198,10 @@ class CORSMiddlewareTest extends \Test\TestCase {
/**
* @CORS
- * @expectedException \OC\AppFramework\Middleware\Security\Exceptions\SecurityException
*/
public function testCORSShouldNotAllowCookieAuth() {
+ $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\SecurityException::class);
+
$request = new Request(
['server' => [
'PHP_AUTH_USER' => 'user',
@@ -251,11 +254,11 @@ class CORSMiddlewareTest extends \Test\TestCase {
$this->assertEquals($expected, $response);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage A regular exception
- */
+
public function testAfterExceptionWithRegularException() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('A regular exception');
+
$request = new Request(
['server' => [
'PHP_AUTH_USER' => 'user',
diff --git a/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php
index 9f2b4e399fb..6d089e3880d 100644
--- a/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php
@@ -48,7 +48,7 @@ class CSPMiddlewareTest extends \Test\TestCase {
/** @var ContentSecurityPolicyNonceManager|MockObject */
private $cspNonceManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->controller = $this->createMock(Controller::class);
diff --git a/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php
index d2ab8d05919..e136d783616 100644
--- a/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php
@@ -44,7 +44,7 @@ class FeaturePolicyMiddlewareTest extends \Test\TestCase {
/** @var FeaturePolicyManager|MockObject */
private $manager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->controller = $this->createMock(Controller::class);
diff --git a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
index c981e840d70..7a64b6cbcad 100644
--- a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
@@ -49,7 +49,7 @@ class PasswordConfirmationMiddlewareTest extends TestCase {
/** @var ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */
private $timeFactory;
- protected function setUp() {
+ protected function setUp(): void {
$this->reflector = new ControllerMethodReflector();
$this->session = $this->createMock(ISession::class);
$this->userSession = $this->createMock(IUserSession::class);
diff --git a/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php
index 1317a07447d..3a06531eefd 100644
--- a/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php
@@ -45,7 +45,7 @@ class RateLimitingMiddlewareTest extends TestCase {
/** @var RateLimitingMiddleware */
private $rateLimitingMiddleware;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
@@ -229,11 +229,11 @@ class RateLimitingMiddlewareTest extends TestCase {
$this->rateLimitingMiddleware->beforeController($controller, 'testMethod');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage My test exception
- */
+
public function testAfterExceptionWithOtherException() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('My test exception');
+
/** @var Controller|\PHPUnit_Framework_MockObject_MockObject $controller */
$controller = $this->createMock(Controller::class);
diff --git a/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php
index c92c131780e..6f3c3f32adc 100644
--- a/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php
@@ -43,7 +43,7 @@ class SameSiteCookieMiddlewareTest extends TestCase {
/** @var ControllerMethodReflector|\PHPUnit_Framework_MockObject_MockObject */
private $reflector;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(Request::class);
diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
index 00bb1a0bb3c..ae0e6ff484d 100644
--- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
@@ -77,7 +77,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
private $l10n;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->controller = $this->createMock(Controller::class);
@@ -256,9 +256,10 @@ class SecurityMiddlewareTest extends \Test\TestCase {
/**
* @PublicPage
- * @expectedException \OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException
*/
public function testCsrfCheck(){
+ $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException::class);
+
$this->request->expects($this->once())
->method('passesCSRFCheck')
->will($this->returnValue(false));
@@ -300,9 +301,10 @@ class SecurityMiddlewareTest extends \Test\TestCase {
/**
* @PublicPage
- * @expectedException \OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException
*/
public function testFailCsrfCheck(){
+ $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException::class);
+
$this->request->expects($this->once())
->method('passesCSRFCheck')
->will($this->returnValue(false));
@@ -317,9 +319,10 @@ class SecurityMiddlewareTest extends \Test\TestCase {
/**
* @PublicPage
* @StrictCookieRequired
- * @expectedException \OC\Appframework\Middleware\Security\Exceptions\StrictCookieMissingException
*/
public function testStrictCookieRequiredCheck() {
+ $this->expectException(\OC\Appframework\Middleware\Security\Exceptions\StrictCookieMissingException::class);
+
$this->request->expects($this->never())
->method('passesCSRFCheck');
$this->request->expects($this->once())
diff --git a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
index 2cd61c73c71..db2a9d5b625 100644
--- a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
@@ -26,7 +26,7 @@ class SessionMiddlewareTest extends \Test\TestCase {
/** @var Controller */
private $controller;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->reflector = new ControllerMethodReflector();
diff --git a/tests/lib/AppFramework/Routing/RoutingTest.php b/tests/lib/AppFramework/Routing/RoutingTest.php
index 559561a8ccd..1b7ab054a0f 100644
--- a/tests/lib/AppFramework/Routing/RoutingTest.php
+++ b/tests/lib/AppFramework/Routing/RoutingTest.php
@@ -122,11 +122,11 @@ class RoutingTest extends \Test\TestCase
$this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], [], '_something');
}
- /**
- * @expectedException \UnexpectedValueException
- */
+
public function testSimpleRouteWithBrokenName()
{
+ $this->expectException(\UnexpectedValueException::class);
+
$routes = array('routes' => array(
array('name' => 'folders_open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete')
));
@@ -144,10 +144,10 @@ class RoutingTest extends \Test\TestCase
$config->register();
}
- /**
- * @expectedException \UnexpectedValueException
- */
+
public function testSimpleOCSRouteWithBrokenName() {
+ $this->expectException(\UnexpectedValueException::class);
+
$routes = ['ocs' => [
['name' => 'folders_open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete']
]];
diff --git a/tests/lib/AppFramework/Utility/SimpleContainerTest.php b/tests/lib/AppFramework/Utility/SimpleContainerTest.php
index b2f6c6ad8d0..0341be14af9 100644
--- a/tests/lib/AppFramework/Utility/SimpleContainerTest.php
+++ b/tests/lib/AppFramework/Utility/SimpleContainerTest.php
@@ -61,7 +61,7 @@ class SimpleContainerTest extends \Test\TestCase {
private $container;
- public function setUp() {
+ protected function setUp(): void {
$this->container = new SimpleContainer();
}
@@ -72,18 +72,18 @@ class SimpleContainerTest extends \Test\TestCase {
}
- /**
- * @expectedException \OCP\AppFramework\QueryException
- */
+
public function testNothingRegistered() {
+ $this->expectException(\OCP\AppFramework\QueryException::class);
+
$this->container->query('something really hard');
}
- /**
- * @expectedException \OCP\AppFramework\QueryException
- */
+
public function testNotAClass() {
+ $this->expectException(\OCP\AppFramework\QueryException::class);
+
$this->container->query('Test\AppFramework\Utility\TestInterface');
}
@@ -189,10 +189,10 @@ class SimpleContainerTest extends \Test\TestCase {
$this->assertEquals('abc', $this->container->query($query));
}
- /**
- * @expectedException \OCP\AppFramework\QueryException
- */
+
public function testConstructorComplexNoTestParameterFound() {
+ $this->expectException(\OCP\AppFramework\QueryException::class);
+
$object = $this->container->query(
'Test\AppFramework\Utility\ClassComplexConstructor'
);
diff --git a/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php
index 87a7b030273..47d1d53a74c 100644
--- a/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php
+++ b/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php
@@ -47,7 +47,7 @@ class RemoteWipeActivityListenerTests extends TestCase {
/** @var IEventListener */
private $listener;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->activityManager = $this->createMock(IActivityManager::class);
diff --git a/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php
index ea7740057ba..3d47b8d4a03 100644
--- a/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php
+++ b/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php
@@ -60,7 +60,7 @@ class RemoteWipeEmailListenerTest extends TestCase {
/** @var IEventListener */
private $listener;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->mailer = $this->createMock(IMailer::class);
diff --git a/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php
index e3e526e401b..79d362410ae 100644
--- a/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php
+++ b/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php
@@ -47,7 +47,7 @@ class RemoteWipeNotificationListenerTests extends TestCase {
/** @var IEventListener */
private $listener;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->notificationManager = $this->createMock(INotificationManager::class);
diff --git a/tests/lib/Authentication/Login/ALoginCommandTest.php b/tests/lib/Authentication/Login/ALoginCommandTest.php
index ec3b324b2ce..f09b649ffcb 100644
--- a/tests/lib/Authentication/Login/ALoginCommandTest.php
+++ b/tests/lib/Authentication/Login/ALoginCommandTest.php
@@ -56,7 +56,7 @@ abstract class ALoginCommandTest extends TestCase {
/** @var ALoginCommand */
protected $cmd;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php b/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php
index 05078cde930..0d3b7acfa2d 100644
--- a/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php
+++ b/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php
@@ -36,7 +36,7 @@ class ClearLostPasswordTokensCommandTest extends ALoginCommandTest {
/** @var IConfig|MockObject */
private $config;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/tests/lib/Authentication/Login/CompleteLoginCommandTest.php b/tests/lib/Authentication/Login/CompleteLoginCommandTest.php
index bf312e7f4e3..e611611dd7c 100644
--- a/tests/lib/Authentication/Login/CompleteLoginCommandTest.php
+++ b/tests/lib/Authentication/Login/CompleteLoginCommandTest.php
@@ -34,7 +34,7 @@ class CompleteLoginCommandTest extends ALoginCommandTest {
/** @var Session|MockObject */
private $session;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->session = $this->createMock(Session::class);
diff --git a/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php b/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php
index 11d2ea36b27..82ae90015a4 100644
--- a/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php
+++ b/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php
@@ -39,7 +39,7 @@ class CreateSessionTokenCommandTest extends ALoginCommandTest {
/** @var Session|MockObject */
private $userSession;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/tests/lib/Authentication/Login/EmailLoginCommandTest.php b/tests/lib/Authentication/Login/EmailLoginCommandTest.php
index c72048d8877..5217a4d0080 100644
--- a/tests/lib/Authentication/Login/EmailLoginCommandTest.php
+++ b/tests/lib/Authentication/Login/EmailLoginCommandTest.php
@@ -35,7 +35,7 @@ class EmailLoginCommandTest extends ALoginCommandTest {
/** @var IUserManager|MockObject */
private $userManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
diff --git a/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php b/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php
index 33926aeea0e..9cb3734922e 100644
--- a/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php
+++ b/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php
@@ -34,7 +34,7 @@ class FinishRememberedLoginCommandTest extends ALoginCommandTest {
/** @var Session|MockObject */
private $userSession;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userSession = $this->createMock(Session::class);
diff --git a/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php b/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php
index 16938307338..3b18c97a612 100644
--- a/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php
+++ b/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php
@@ -35,7 +35,7 @@ class LoggedInCheckCommandTest extends ALoginCommandTest {
/** @var ILogger|MockObject */
private $logger;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->logger = $this->createMock(ILogger::class);
diff --git a/tests/lib/Authentication/Login/PreLoginHookCommandTest.php b/tests/lib/Authentication/Login/PreLoginHookCommandTest.php
index 3329f3ad82f..c067899ffc2 100644
--- a/tests/lib/Authentication/Login/PreLoginHookCommandTest.php
+++ b/tests/lib/Authentication/Login/PreLoginHookCommandTest.php
@@ -35,7 +35,7 @@ class PreLoginHookCommandTest extends ALoginCommandTest {
/** @var IUserManager|MockObject */
private $userManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(Manager::class);
diff --git a/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php b/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php
index a2ce656a14b..14da73b93fa 100644
--- a/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php
+++ b/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php
@@ -38,7 +38,7 @@ class SetUserTimezoneCommandTest extends ALoginCommandTest {
/** @var ISession|MockObject */
private $session;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/tests/lib/Authentication/Login/TwoFactorCommandTest.php b/tests/lib/Authentication/Login/TwoFactorCommandTest.php
index 5f91d812525..3e8ad142cc1 100644
--- a/tests/lib/Authentication/Login/TwoFactorCommandTest.php
+++ b/tests/lib/Authentication/Login/TwoFactorCommandTest.php
@@ -45,7 +45,7 @@ class TwoFactorCommandTest extends ALoginCommandTest {
/** @var IURLGenerator|MockObject */
private $urlGenerator;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->twoFactorManager = $this->createMock(Manager::class);
diff --git a/tests/lib/Authentication/Login/UidLoginCommandTest.php b/tests/lib/Authentication/Login/UidLoginCommandTest.php
index 0a7889c227c..c4dd3f10381 100644
--- a/tests/lib/Authentication/Login/UidLoginCommandTest.php
+++ b/tests/lib/Authentication/Login/UidLoginCommandTest.php
@@ -35,7 +35,7 @@ class UidLoginCommandTest extends ALoginCommandTest {
/** @var Manager|MockObject */
private $userManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(Manager::class);
diff --git a/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php b/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php
index 5f5bd3032a8..b66ecdde3c4 100644
--- a/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php
+++ b/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php
@@ -34,7 +34,7 @@ class UpdateLastPasswordConfirmCommandTest extends ALoginCommandTest {
/** @var ISession|MockObject */
private $session;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->session = $this->createMock(ISession::class);
diff --git a/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php b/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php
index 35d8ac63de6..2a2f23162bf 100644
--- a/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php
+++ b/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php
@@ -39,7 +39,7 @@ class UserDisabledCheckCommandTest extends ALoginCommandTest {
/** @var ILogger|MockObject */
private $logger;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
diff --git a/tests/lib/Authentication/LoginCredentials/CredentialsTest.php b/tests/lib/Authentication/LoginCredentials/CredentialsTest.php
index 308ccafb151..263db1bbb5b 100644
--- a/tests/lib/Authentication/LoginCredentials/CredentialsTest.php
+++ b/tests/lib/Authentication/LoginCredentials/CredentialsTest.php
@@ -41,7 +41,7 @@ class CredentialsTest extends TestCase {
/** @var Credentials */
private $credentials;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->uid = 'user123';
diff --git a/tests/lib/Authentication/LoginCredentials/StoreTest.php b/tests/lib/Authentication/LoginCredentials/StoreTest.php
index 4588eae35f0..b75e1498889 100644
--- a/tests/lib/Authentication/LoginCredentials/StoreTest.php
+++ b/tests/lib/Authentication/LoginCredentials/StoreTest.php
@@ -51,7 +51,7 @@ class StoreTest extends TestCase {
/** @var Store */
private $store;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->session = $this->createMock(ISession::class);
diff --git a/tests/lib/Authentication/Token/DefaultTokenCleanupJobTest.php b/tests/lib/Authentication/Token/DefaultTokenCleanupJobTest.php
index b8074d75b30..e4bc13fe5fb 100644
--- a/tests/lib/Authentication/Token/DefaultTokenCleanupJobTest.php
+++ b/tests/lib/Authentication/Token/DefaultTokenCleanupJobTest.php
@@ -33,7 +33,7 @@ class DefaultTokenCleanupJobTest extends TestCase {
private $job;
private $tokenProvider;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->tokenProvider = $this->getMockBuilder(Manager::class)
diff --git a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php
index a40db4461d2..7060dc2a770 100644
--- a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php
+++ b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php
@@ -46,7 +46,7 @@ class DefaultTokenMapperTest extends TestCase {
private $dbConnection;
private $time;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->dbConnection = OC::$server->getDatabaseConnection();
@@ -145,10 +145,10 @@ class DefaultTokenMapperTest extends TestCase {
$this->assertEquals($token, $dbToken);
}
- /**
- * @expectedException \OCP\AppFramework\Db\DoesNotExistException
- */
+
public function testGetInvalidToken() {
+ $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class);
+
$token = 'thisisaninvalidtokenthatisnotinthedatabase';
$this->mapper->getToken($token);
@@ -175,17 +175,17 @@ class DefaultTokenMapperTest extends TestCase {
$this->assertEquals($token, $dbToken);
}
- /**
- * @expectedException \OCP\AppFramework\Db\DoesNotExistException
- */
+
public function testGetTokenByIdNotFound() {
+ $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class);
+
$this->mapper->getTokenById(-1);
}
- /**
- * @expectedException \OCP\AppFramework\Db\DoesNotExistException
- */
+
public function testGetInvalidTokenById() {
+ $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class);
+
$id = 42;
$this->mapper->getToken($id);
diff --git a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
index 57144d0f00d..b4e5e097847 100644
--- a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
+++ b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php
@@ -53,7 +53,7 @@ class DefaultTokenProviderTest extends TestCase {
/** @var int */
private $time;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->mapper = $this->createMock(DefaultTokenMapper::class);
@@ -159,10 +159,10 @@ class DefaultTokenProviderTest extends TestCase {
$this->assertEquals('passme', $actual);
}
- /**
- * @expectedException \OC\Authentication\Exceptions\PasswordlessTokenException
- */
+
public function testGetPasswordPasswordLessToken() {
+ $this->expectException(\OC\Authentication\Exceptions\PasswordlessTokenException::class);
+
$token = 'token1234';
$tk = new DefaultToken();
$tk->setPassword(null);
@@ -170,10 +170,10 @@ class DefaultTokenProviderTest extends TestCase {
$this->tokenProvider->getPassword($tk, $token);
}
- /**
- * @expectedException \OC\Authentication\Exceptions\InvalidTokenException
- */
+
public function testGetPasswordDeletesInvalidToken() {
+ $this->expectException(\OC\Authentication\Exceptions\InvalidTokenException::class);
+
$token = 'token1234';
$tk = new DefaultToken();
$tk->setPassword('someencryptedvalue');
@@ -222,10 +222,10 @@ class DefaultTokenProviderTest extends TestCase {
$this->assertEquals('encryptedpassword', $token->getPassword());
}
- /**
- * @expectedException \OC\Authentication\Exceptions\InvalidTokenException
- */
+
public function testSetPasswordInvalidToken() {
+ $this->expectException(\OC\Authentication\Exceptions\InvalidTokenException::class);
+
$token = $this->createMock(IToken::class);
$tokenId = 'token123';
$password = '123456';
diff --git a/tests/lib/Authentication/Token/ManagerTest.php b/tests/lib/Authentication/Token/ManagerTest.php
index 1f3fda1b15d..6f64424364e 100644
--- a/tests/lib/Authentication/Token/ManagerTest.php
+++ b/tests/lib/Authentication/Token/ManagerTest.php
@@ -46,7 +46,7 @@ class ManagerTest extends TestCase {
/** @var Manager */
private $manager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->publicKeyTokenProvider = $this->createMock(PublicKeyTokenProvider::class);
diff --git a/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php b/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php
index b8c399b81f8..58340b905c0 100644
--- a/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php
+++ b/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php
@@ -47,7 +47,7 @@ class PublicKeyTokenMapperTest extends TestCase {
/** @var int */
private $time;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->dbConnection = OC::$server->getDatabaseConnection();
@@ -171,10 +171,10 @@ class PublicKeyTokenMapperTest extends TestCase {
$this->assertEquals($token, $dbToken);
}
- /**
- * @expectedException \OCP\AppFramework\Db\DoesNotExistException
- */
+
public function testGetInvalidToken() {
+ $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class);
+
$token = 'thisisaninvalidtokenthatisnotinthedatabase';
$this->mapper->getToken($token);
@@ -203,17 +203,17 @@ class PublicKeyTokenMapperTest extends TestCase {
$this->assertEquals($token, $dbToken);
}
- /**
- * @expectedException \OCP\AppFramework\Db\DoesNotExistException
- */
+
public function testGetTokenByIdNotFound() {
+ $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class);
+
$this->mapper->getTokenById(-1);
}
- /**
- * @expectedException \OCP\AppFramework\Db\DoesNotExistException
- */
+
public function testGetInvalidTokenById() {
+ $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class);
+
$id = '42';
$this->mapper->getToken($id);
diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
index 1b468839cb7..3fa7a92bb9b 100644
--- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
+++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
@@ -54,7 +54,7 @@ class PublicKeyTokenProviderTest extends TestCase {
/** @var int */
private $time;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->mapper = $this->createMock(PublicKeyTokenMapper::class);
@@ -145,10 +145,10 @@ class PublicKeyTokenProviderTest extends TestCase {
$this->assertSame($password, $this->tokenProvider->getPassword($actual, $token));
}
- /**
- * @expectedException \OC\Authentication\Exceptions\PasswordlessTokenException
- */
+
public function testGetPasswordPasswordLessToken() {
+ $this->expectException(\OC\Authentication\Exceptions\PasswordlessTokenException::class);
+
$token = 'token1234';
$tk = new PublicKeyToken();
$tk->setPassword(null);
@@ -156,10 +156,10 @@ class PublicKeyTokenProviderTest extends TestCase {
$this->tokenProvider->getPassword($tk, $token);
}
- /**
- * @expectedException \OC\Authentication\Exceptions\InvalidTokenException
- */
+
public function testGetPasswordInvalidToken() {
+ $this->expectException(\OC\Authentication\Exceptions\InvalidTokenException::class);
+
$token = 'token';
$uid = 'user';
$user = 'User';
@@ -205,10 +205,10 @@ class PublicKeyTokenProviderTest extends TestCase {
$this->assertSame($newpass, $this->tokenProvider->getPassword($actual, 'token'));
}
- /**
- * @expectedException \OC\Authentication\Exceptions\InvalidTokenException
- */
+
public function testSetPasswordInvalidToken() {
+ $this->expectException(\OC\Authentication\Exceptions\InvalidTokenException::class);
+
$token = $this->createMock(IToken::class);
$tokenId = 'token123';
$password = '123456';
diff --git a/tests/lib/Authentication/Token/RemoteWipeTest.php b/tests/lib/Authentication/Token/RemoteWipeTest.php
index 5773bb596a5..2ca49d36159 100644
--- a/tests/lib/Authentication/Token/RemoteWipeTest.php
+++ b/tests/lib/Authentication/Token/RemoteWipeTest.php
@@ -51,7 +51,7 @@ class RemoteWipeTest extends TestCase {
/** @var RemoteWipe */
private $remoteWipe;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->tokenProvider = $this->createMock(IProvider::class);
diff --git a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
index 2402fcf9f7b..67eb27cfdee 100644
--- a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
@@ -41,7 +41,7 @@ class ProviderUserAssignmentDaoTest extends TestCase {
/** @var ProviderUserAssignmentDao */
private $dao;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->dbConn = OC::$server->getDatabaseConnection();
diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
index e836e8d316b..63d0e993f3b 100644
--- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
@@ -87,7 +87,7 @@ class ManagerTest extends TestCase {
/** @var EventDispatcherInterface|MockObject */
private $eventDispatcher;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->user = $this->createMock(IUser::class);
diff --git a/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php b/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php
index 61ffb404dd9..92d072608f2 100644
--- a/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php
@@ -45,7 +45,7 @@ class MandatoryTwoFactorTest extends TestCase {
/** @var MandatoryTwoFactor */
private $mandatoryTwoFactor;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php b/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php
index 55a1e173928..f3762976837 100644
--- a/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php
@@ -43,7 +43,7 @@ class ProviderLoaderTest extends TestCase {
/** @var ProviderLoader */
private $loader;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->appManager = $this->createMock(IAppManager::class);
@@ -52,11 +52,11 @@ class ProviderLoaderTest extends TestCase {
$this->loader = new ProviderLoader($this->appManager);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Could not load two-factor auth provider \OCA\MyFaulty2faApp\DoesNotExist
- */
+
public function testFailHardIfProviderCanNotBeLoaded() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Could not load two-factor auth provider \\OCA\\MyFaulty2faApp\\DoesNotExist');
+
$this->appManager->expects($this->once())
->method('getEnabledAppsForUser')
->with($this->user)
diff --git a/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php
index 736dfdb913b..e34d844c3a4 100644
--- a/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php
@@ -47,7 +47,7 @@ class ProviderManagerTest extends TestCase {
/** @var ProviderManager */
private $providerManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->providerLoader = $this->createMock(ProviderLoader::class);
@@ -59,10 +59,10 @@ class ProviderManagerTest extends TestCase {
);
}
- /**
- * @expectedException \OC\Authentication\Exceptions\InvalidProviderException
- */
+
public function testTryEnableInvalidProvider() {
+ $this->expectException(\OC\Authentication\Exceptions\InvalidProviderException::class);
+
$user = $this->createMock(IUser::class);
$this->providerManager->tryEnableProviderFor('none', $user);
}
@@ -105,10 +105,10 @@ class ProviderManagerTest extends TestCase {
$this->assertTrue($res);
}
- /**
- * @expectedException \OC\Authentication\Exceptions\InvalidProviderException
- */
+
public function testTryDisableInvalidProvider() {
+ $this->expectException(\OC\Authentication\Exceptions\InvalidProviderException::class);
+
$user = $this->createMock(IUser::class);
$this->providerManager->tryDisableProviderFor('none', $user);
}
diff --git a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
index ad29377e559..2f59d14992a 100644
--- a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
@@ -45,7 +45,7 @@ class RegistryTest extends TestCase {
/** @var Registry */
private $registry;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->dao = $this->createMock(ProviderUserAssignmentDao::class);
diff --git a/tests/lib/AutoLoaderTest.php b/tests/lib/AutoLoaderTest.php
index 38ba29bc085..b3ca21a90d4 100644
--- a/tests/lib/AutoLoaderTest.php
+++ b/tests/lib/AutoLoaderTest.php
@@ -14,7 +14,7 @@ class AutoLoaderTest extends TestCase {
*/
private $loader;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->loader = new \OC\AutoLoader([]);
}
diff --git a/tests/lib/Avatar/AvatarManagerTest.php b/tests/lib/Avatar/AvatarManagerTest.php
index ae3ee89cec2..5351a1069fc 100644
--- a/tests/lib/Avatar/AvatarManagerTest.php
+++ b/tests/lib/Avatar/AvatarManagerTest.php
@@ -51,7 +51,7 @@ class AvatarManagerTest extends \Test\TestCase {
/** @var AvatarManager | \PHPUnit_Framework_MockObject_MockObject */
private $avatarManager;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(Manager::class);
@@ -69,11 +69,11 @@ class AvatarManagerTest extends \Test\TestCase {
);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage user does not exist
- */
+
public function testGetAvatarInvalidUser() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('user does not exist');
+
$this->userManager
->expects($this->once())
->method('get')
diff --git a/tests/lib/Avatar/UserAvatarTest.php b/tests/lib/Avatar/UserAvatarTest.php
index 2ce9266cf4d..ff6c63df2a8 100644
--- a/tests/lib/Avatar/UserAvatarTest.php
+++ b/tests/lib/Avatar/UserAvatarTest.php
@@ -31,7 +31,7 @@ class UserAvatarTest extends \Test\TestCase {
/** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */
private $config;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->folder = $this->createMock(SimpleFolder::class);
diff --git a/tests/lib/BackgroundJob/JobListTest.php b/tests/lib/BackgroundJob/JobListTest.php
index 78299e81546..7e099b23d06 100644
--- a/tests/lib/BackgroundJob/JobListTest.php
+++ b/tests/lib/BackgroundJob/JobListTest.php
@@ -33,7 +33,7 @@ class JobListTest extends TestCase {
/** @var \OCP\AppFramework\Utility\ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */
protected $timeFactory;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
diff --git a/tests/lib/BackgroundJob/JobTest.php b/tests/lib/BackgroundJob/JobTest.php
index ecd8bde8626..6e5474e597c 100644
--- a/tests/lib/BackgroundJob/JobTest.php
+++ b/tests/lib/BackgroundJob/JobTest.php
@@ -13,7 +13,7 @@ use OCP\ILogger;
class JobTest extends \Test\TestCase {
private $run = false;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->run = false;
}
diff --git a/tests/lib/BackgroundJob/QueuedJobTest.php b/tests/lib/BackgroundJob/QueuedJobTest.php
index 73b245f93a5..9378816ce61 100644
--- a/tests/lib/BackgroundJob/QueuedJobTest.php
+++ b/tests/lib/BackgroundJob/QueuedJobTest.php
@@ -35,7 +35,7 @@ class QueuedJobTest extends \Test\TestCase {
*/
private $jobList;
- protected function setup() {
+ protected function setUp(): void {
parent::setUp();
$this->jobList = new DummyJobList();
diff --git a/tests/lib/BackgroundJob/TimedJobTest.php b/tests/lib/BackgroundJob/TimedJobTest.php
index e684ad8c1e6..12f1c43adde 100644
--- a/tests/lib/BackgroundJob/TimedJobTest.php
+++ b/tests/lib/BackgroundJob/TimedJobTest.php
@@ -44,7 +44,7 @@ class TimedJobTest extends \Test\TestCase {
/** @var ITimeFactory */
private $time;
- protected function setup() {
+ protected function setUp(): void {
parent::setUp();
$this->jobList = new DummyJobList();
diff --git a/tests/lib/Cache/CappedMemoryCacheTest.php b/tests/lib/Cache/CappedMemoryCacheTest.php
index 243a1ad74f1..00231004fe5 100644
--- a/tests/lib/Cache/CappedMemoryCacheTest.php
+++ b/tests/lib/Cache/CappedMemoryCacheTest.php
@@ -28,7 +28,7 @@ namespace Test\Cache;
* @package Test\Cache
*/
class CappedMemoryCacheTest extends TestCache {
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->instance = new \OC\Cache\CappedMemoryCache();
}
diff --git a/tests/lib/Cache/FileCacheTest.php b/tests/lib/Cache/FileCacheTest.php
index a90fc6678e9..26306458d83 100644
--- a/tests/lib/Cache/FileCacheTest.php
+++ b/tests/lib/Cache/FileCacheTest.php
@@ -52,7 +52,7 @@ class FileCacheTest extends TestCache {
//$this->skipUnless(OC_User::isLoggedIn());
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
//clear all proxies and hooks so we can do clean testing
@@ -87,7 +87,7 @@ class FileCacheTest extends TestCache {
$this->instance->set('hack', 'hack');
}
- protected function tearDown() {
+ protected function tearDown(): void {
if ($this->instance) {
$this->instance->remove('hack', 'hack');
}
diff --git a/tests/lib/Cache/TestCache.php b/tests/lib/Cache/TestCache.php
index 2642c014a78..62341a5698b 100644
--- a/tests/lib/Cache/TestCache.php
+++ b/tests/lib/Cache/TestCache.php
@@ -14,7 +14,7 @@ abstract class TestCache extends \Test\TestCase {
*/
protected $instance;
- protected function tearDown() {
+ protected function tearDown(): void {
if($this->instance) {
$this->instance->clear();
}
diff --git a/tests/lib/Calendar/ManagerTest.php b/tests/lib/Calendar/ManagerTest.php
index dca9368558f..fa459203dac 100644
--- a/tests/lib/Calendar/ManagerTest.php
+++ b/tests/lib/Calendar/ManagerTest.php
@@ -32,7 +32,7 @@ class ManagerTest extends TestCase {
/** @var Manager */
private $manager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->manager = new Manager();
diff --git a/tests/lib/Calendar/Resource/ManagerTest.php b/tests/lib/Calendar/Resource/ManagerTest.php
index 3e065c69908..71679a86a8c 100644
--- a/tests/lib/Calendar/Resource/ManagerTest.php
+++ b/tests/lib/Calendar/Resource/ManagerTest.php
@@ -36,7 +36,7 @@ class ManagerTest extends TestCase {
/** @var IServerContainer */
private $server;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->server = $this->createMock(IServerContainer::class);
diff --git a/tests/lib/Calendar/Room/ManagerTest.php b/tests/lib/Calendar/Room/ManagerTest.php
index 9a85132aa3a..56f05544e29 100644
--- a/tests/lib/Calendar/Room/ManagerTest.php
+++ b/tests/lib/Calendar/Room/ManagerTest.php
@@ -36,7 +36,7 @@ class ManagerTest extends TestCase {
/** @var IServerContainer */
private $server;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->server = $this->createMock(IServerContainer::class);
diff --git a/tests/lib/CapabilitiesManagerTest.php b/tests/lib/CapabilitiesManagerTest.php
index c967b77130d..e7d519a7493 100644
--- a/tests/lib/CapabilitiesManagerTest.php
+++ b/tests/lib/CapabilitiesManagerTest.php
@@ -35,7 +35,7 @@ class CapabilitiesManagerTest extends TestCase {
/** @var ILogger */
private $logger;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->logger = $this->getMockBuilder(ILogger::class)->getMock();
$this->manager = new CapabilitiesManager($this->logger);
@@ -81,10 +81,11 @@ class CapabilitiesManagerTest extends TestCase {
/**
* Test that we need something that implents ICapability
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage The given Capability (Test\NoCapability) does not implement the ICapability interface
*/
public function testNoICapability() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('The given Capability (Test\\NoCapability) does not implement the ICapability interface');
+
$this->manager->registerCapability(function() {
return new NoCapability();
});
diff --git a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
index 36d98ee302f..3d81134680a 100644
--- a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
@@ -60,7 +60,7 @@ class GroupPluginTest extends TestCase {
/** @var IUser|\PHPUnit_Framework_MockObject_MockObject */
protected $user;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
index e4be6a73ee1..15dccf2c84c 100644
--- a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
@@ -55,7 +55,7 @@ class LookupPluginTest extends TestCase {
/** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */
protected $logger;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userSession = $this->createMock(IUserSession::class);
diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
index a9d0244d38c..9cf308cd414 100644
--- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
@@ -59,7 +59,7 @@ class MailPluginTest extends TestCase {
/** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */
protected $userSession;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
index 560e72a984d..4ac2cc124ee 100644
--- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
@@ -57,7 +57,7 @@ class RemotePluginTest extends TestCase {
/** @var SearchResult */
protected $searchResult;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
@@ -137,9 +137,10 @@ class RemotePluginTest extends TestCase {
* @dataProvider dataTestSplitUserRemoteError
*
* @param string $id
- * @expectedException \Exception
*/
public function testSplitUserRemoteError($id) {
+ $this->expectException(\Exception::class);
+
$this->instantiatePlugin();
$this->plugin->splitUserRemote($id);
}
diff --git a/tests/lib/Collaboration/Collaborators/SearchResultTest.php b/tests/lib/Collaboration/Collaborators/SearchResultTest.php
index 90ea90237a1..43672345226 100644
--- a/tests/lib/Collaboration/Collaborators/SearchResultTest.php
+++ b/tests/lib/Collaboration/Collaborators/SearchResultTest.php
@@ -39,7 +39,7 @@ class SearchResultTest extends TestCase {
/** @var ISearch */
protected $search;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->container = $this->createMock(IContainer::class);
diff --git a/tests/lib/Collaboration/Collaborators/SearchTest.php b/tests/lib/Collaboration/Collaborators/SearchTest.php
index 80e6c7f0beb..284d8270c49 100644
--- a/tests/lib/Collaboration/Collaborators/SearchTest.php
+++ b/tests/lib/Collaboration/Collaborators/SearchTest.php
@@ -39,7 +39,7 @@ class SearchTest extends TestCase {
/** @var ISearch */
protected $search;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->container = $this->createMock(IContainer::class);
diff --git a/tests/lib/Collaboration/Collaborators/UserPluginTest.php b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
index 7513f9da5b6..3aeeaa3eecb 100644
--- a/tests/lib/Collaboration/Collaborators/UserPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
@@ -62,7 +62,7 @@ class UserPluginTest extends TestCase {
/** @var IUser|\PHPUnit_Framework_MockObject_MockObject */
protected $user;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
@@ -414,8 +414,8 @@ class UserPluginTest extends TestCase {
$this->groupManager->expects($this->exactly(2))
->method('getUserGroupIds')
->withConsecutive(
- $this->user,
- $singleUser
+ [$this->user],
+ [$singleUser]
)
->willReturn($groupResponse);
} else {
diff --git a/tests/lib/Command/AsyncBusTest.php b/tests/lib/Command/AsyncBusTest.php
index 8f07738bec6..31f28bb88c9 100644
--- a/tests/lib/Command/AsyncBusTest.php
+++ b/tests/lib/Command/AsyncBusTest.php
@@ -89,7 +89,7 @@ abstract class AsyncBusTest extends TestCase {
*/
abstract protected function createBus();
- public function setUp() {
+ protected function setUp(): void {
self::$lastCommand = '';
}
diff --git a/tests/lib/Command/CronBusTest.php b/tests/lib/Command/CronBusTest.php
index 9bf53ba92d2..ea610a135d8 100644
--- a/tests/lib/Command/CronBusTest.php
+++ b/tests/lib/Command/CronBusTest.php
@@ -31,7 +31,7 @@ class CronBusTest extends AsyncBusTest {
private $jobList;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->jobList = new DummyJobList();
diff --git a/tests/lib/Command/Integrity/SignAppTest.php b/tests/lib/Command/Integrity/SignAppTest.php
index 2615c6afc1e..6fa86a2e855 100644
--- a/tests/lib/Command/Integrity/SignAppTest.php
+++ b/tests/lib/Command/Integrity/SignAppTest.php
@@ -39,7 +39,7 @@ class SignAppTest extends TestCase {
/** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */
private $urlGenerator;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->checker = $this->createMock(Checker::class);
$this->fileAccessHelper = $this->createMock(FileAccessHelper::class);
@@ -232,12 +232,12 @@ class SignAppTest extends TestCase {
->expects($this->at(0))
->method('file_get_contents')
->with('privateKey')
- ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
+ ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
$this->fileAccessHelper
->expects($this->at(1))
->method('file_get_contents')
->with('certificate')
- ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'));
+ ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'));
$this->checker
->expects($this->once())
@@ -276,12 +276,12 @@ class SignAppTest extends TestCase {
->expects($this->at(0))
->method('file_get_contents')
->with('privateKey')
- ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
+ ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
$this->fileAccessHelper
->expects($this->at(1))
->method('file_get_contents')
->with('certificate')
- ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'));
+ ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'));
$this->checker
->expects($this->once())
diff --git a/tests/lib/Command/Integrity/SignCoreTest.php b/tests/lib/Command/Integrity/SignCoreTest.php
index e601b4a1a90..9bab016ec8f 100644
--- a/tests/lib/Command/Integrity/SignCoreTest.php
+++ b/tests/lib/Command/Integrity/SignCoreTest.php
@@ -36,7 +36,7 @@ class SignCoreTest extends TestCase {
/** @var SignCore */
private $signCore;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->checker = $this->createMock(Checker::class);
$this->fileAccessHelper = $this->createMock(FileAccessHelper::class);
@@ -150,7 +150,7 @@ class SignCoreTest extends TestCase {
->expects($this->at(0))
->method('file_get_contents')
->with('privateKey')
- ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
+ ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
$this->fileAccessHelper
->expects($this->at(1))
->method('file_get_contents')
@@ -189,12 +189,12 @@ class SignCoreTest extends TestCase {
->expects($this->at(0))
->method('file_get_contents')
->with('privateKey')
- ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
+ ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
$this->fileAccessHelper
->expects($this->at(1))
->method('file_get_contents')
->with('certificate')
- ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'));
+ ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'));
$this->checker
->expects($this->once())
@@ -233,12 +233,12 @@ class SignCoreTest extends TestCase {
->expects($this->at(0))
->method('file_get_contents')
->with('privateKey')
- ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
+ ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'));
$this->fileAccessHelper
->expects($this->at(1))
->method('file_get_contents')
->with('certificate')
- ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'));
+ ->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'));
$this->checker
->expects($this->once())
diff --git a/tests/lib/Comments/CommentTest.php b/tests/lib/Comments/CommentTest.php
index 27d75193bc7..bd58d3fb156 100644
--- a/tests/lib/Comments/CommentTest.php
+++ b/tests/lib/Comments/CommentTest.php
@@ -51,10 +51,10 @@ class CommentTest extends TestCase {
$this->assertSame($object['id'], $comment->getObjectId());
}
- /**
- * @expectedException \OCP\Comments\IllegalIDChangeException
- */
+
public function testSetIdIllegalInput() {
+ $this->expectException(\OCP\Comments\IllegalIDChangeException::class);
+
$comment = new Comment();
$comment->setId('c23');
@@ -86,9 +86,10 @@ class CommentTest extends TestCase {
/**
* @dataProvider simpleSetterProvider
- * @expectedException \InvalidArgumentException
*/
public function testSimpleSetterInvalidInput($field, $input) {
+ $this->expectException(\InvalidArgumentException::class);
+
$comment = new Comment();
$setter = 'set' . $field;
@@ -110,18 +111,19 @@ class CommentTest extends TestCase {
/**
* @dataProvider roleSetterProvider
- * @expectedException \InvalidArgumentException
*/
public function testSetRoleInvalidInput($role, $type, $id){
+ $this->expectException(\InvalidArgumentException::class);
+
$comment = new Comment();
$setter = 'set' . $role;
$comment->$setter($type, $id);
}
- /**
- * @expectedException \OCP\Comments\MessageTooLongException
- */
+
public function testSetUberlongMessage() {
+ $this->expectException(\OCP\Comments\MessageTooLongException::class);
+
$comment = new Comment();
$msg = str_pad('', IComment::MAX_MESSAGE_LENGTH + 1, 'x');
$comment->setMessage($msg);
diff --git a/tests/lib/Comments/ManagerTest.php b/tests/lib/Comments/ManagerTest.php
index 28002ff42cc..93cafc0f933 100644
--- a/tests/lib/Comments/ManagerTest.php
+++ b/tests/lib/Comments/ManagerTest.php
@@ -21,7 +21,7 @@ class ManagerTest extends TestCase {
/** @var IDBConnection */
private $connection;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -67,18 +67,18 @@ class ManagerTest extends TestCase {
return $factory->getManager();
}
- /**
- * @expectedException \OCP\Comments\NotFoundException
- */
+
public function testGetCommentNotFound() {
+ $this->expectException(\OCP\Comments\NotFoundException::class);
+
$manager = $this->getManager();
$manager->get('22');
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testGetCommentNotFoundInvalidInput() {
+ $this->expectException(\InvalidArgumentException::class);
+
$manager = $this->getManager();
$manager->get('unexisting22');
}
@@ -125,18 +125,18 @@ class ManagerTest extends TestCase {
$this->assertEquals($comment->getLatestChildDateTime(), $latestChildDT);
}
- /**
- * @expectedException \OCP\Comments\NotFoundException
- */
+
public function testGetTreeNotFound() {
+ $this->expectException(\OCP\Comments\NotFoundException::class);
+
$manager = $this->getManager();
$manager->getTree('22');
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testGetTreeNotFoundInvalidIpnut() {
+ $this->expectException(\InvalidArgumentException::class);
+
$manager = $this->getManager();
$manager->getTree('unexisting22');
}
@@ -411,13 +411,14 @@ class ManagerTest extends TestCase {
/**
* @dataProvider invalidCreateArgsProvider
- * @expectedException \InvalidArgumentException
* @param string $aType
* @param string $aId
* @param string $oType
* @param string $oId
*/
public function testCreateCommentInvalidArguments($aType, $aId, $oType, $oId) {
+ $this->expectException(\InvalidArgumentException::class);
+
$manager = $this->getManager();
$manager->create($aType, $aId, $oType, $oId);
}
@@ -436,10 +437,10 @@ class ManagerTest extends TestCase {
$this->assertSame($comment->getObjectId(), $objectId);
}
- /**
- * @expectedException \OCP\Comments\NotFoundException
- */
+
public function testDelete() {
+ $this->expectException(\OCP\Comments\NotFoundException::class);
+
$manager = $this->getManager();
$done = $manager->delete('404');
@@ -497,10 +498,10 @@ class ManagerTest extends TestCase {
$this->assertSame($comment->getMessage(), $loadedComment->getMessage());
}
- /**
- * @expectedException \OCP\Comments\NotFoundException
- */
+
public function testSaveUpdateException() {
+ $this->expectException(\OCP\Comments\NotFoundException::class);
+
$manager = $this->getManager();
$comment = new Comment();
$comment
@@ -516,10 +517,10 @@ class ManagerTest extends TestCase {
$manager->save($comment);
}
- /**
- * @expectedException \UnexpectedValueException
- */
+
public function testSaveIncomplete() {
+ $this->expectException(\UnexpectedValueException::class);
+
$manager = $this->getManager();
$comment = new Comment();
$comment->setMessage('from no one to nothing');
@@ -562,11 +563,12 @@ class ManagerTest extends TestCase {
/**
* @dataProvider invalidActorArgsProvider
- * @expectedException \InvalidArgumentException
* @param string $type
* @param string $id
*/
public function testDeleteReferencesOfActorInvalidInput($type, $id) {
+ $this->expectException(\InvalidArgumentException::class);
+
$manager = $this->getManager();
$manager->deleteReferencesOfActor($type, $id);
}
@@ -630,11 +632,12 @@ class ManagerTest extends TestCase {
/**
* @dataProvider invalidObjectArgsProvider
- * @expectedException \InvalidArgumentException
* @param string $type
* @param string $id
*/
public function testDeleteCommentsAtObjectInvalidInput($type, $id) {
+ $this->expectException(\InvalidArgumentException::class);
+
$manager = $this->getManager();
$manager->deleteCommentsAtObject($type, $id);
}
@@ -797,10 +800,10 @@ class ManagerTest extends TestCase {
$this->assertSame('SOMBRERO', $manager->resolveDisplayName('galaxy', 'sombrero'));
}
- /**
- * @expectedException \OutOfBoundsException
- */
+
public function testRegisterResolverDuplicate() {
+ $this->expectException(\OutOfBoundsException::class);
+
$manager = $this->getManager();
$planetClosure = function ($name) {
@@ -810,10 +813,10 @@ class ManagerTest extends TestCase {
$manager->registerDisplayNameResolver('planet', $planetClosure);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testRegisterResolverInvalidType() {
+ $this->expectException(\InvalidArgumentException::class);
+
$manager = $this->getManager();
$planetClosure = function ($name) {
@@ -822,10 +825,10 @@ class ManagerTest extends TestCase {
$manager->registerDisplayNameResolver(1337, $planetClosure);
}
- /**
- * @expectedException \OutOfBoundsException
- */
+
public function testResolveDisplayNameUnregisteredType() {
+ $this->expectException(\OutOfBoundsException::class);
+
$manager = $this->getManager();
$planetClosure = function ($name) {
@@ -847,10 +850,10 @@ class ManagerTest extends TestCase {
$this->assertTrue(is_string($manager->resolveDisplayName('planet', 'neptune')));
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testResolveDisplayNameInvalidType() {
+ $this->expectException(\InvalidArgumentException::class);
+
$manager = $this->getManager();
$planetClosure = function () {
diff --git a/tests/lib/ConfigTest.php b/tests/lib/ConfigTest.php
index 2a4c9620340..109f7471e96 100644
--- a/tests/lib/ConfigTest.php
+++ b/tests/lib/ConfigTest.php
@@ -20,7 +20,7 @@ class ConfigTest extends TestCase {
/** @var string */
private $randomTmpDir;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->randomTmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
@@ -29,7 +29,7 @@ class ConfigTest extends TestCase {
$this->config = new \OC\Config($this->randomTmpDir, 'testconfig.php');
}
- protected function tearDown() {
+ protected function tearDown(): void {
unlink($this->configFile);
parent::tearDown();
}
diff --git a/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php b/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php
index d1273c2b9ad..54106bbb642 100644
--- a/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php
@@ -33,7 +33,7 @@ class ActionFactoryTest extends TestCase {
/** @var ActionFactory */
private $actionFactory;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->actionFactory = new ActionFactory();
diff --git a/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php b/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php
index fb5e815447c..10584812c41 100644
--- a/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php
@@ -51,7 +51,7 @@ class ActionProviderStoreTest extends TestCase {
/** @var ActionProviderStore */
private $actionProviderStore;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->serverContainer = $this->createMock(IServerContainer::class);
@@ -115,10 +115,10 @@ class ActionProviderStoreTest extends TestCase {
$this->assertInstanceOf(EMailProvider::class, $providers[0]);
}
- /**
- * @expectedException Exception
- */
+
public function testGetProvidersWithQueryException() {
+ $this->expectException(\Exception::class);
+
$user = $this->createMock(IUser::class);
$this->appManager->expects($this->once())
->method('getEnabledAppsForUser')
diff --git a/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php b/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php
index 31654b40918..da2d6ac4517 100644
--- a/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php
+++ b/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php
@@ -31,7 +31,7 @@ class LinkActionTest extends TestCase {
private $action;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->action = new LinkAction();
diff --git a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
index cf801396cb1..49dc1d9d823 100644
--- a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
@@ -46,7 +46,7 @@ class ContactsStoreTest extends TestCase {
/** @var IConfig|PHPUnit_Framework_MockObject_MockObject */
private $config;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->contactsManager = $this->createMock(IManager::class);
diff --git a/tests/lib/Contacts/ContactsMenu/EntryTest.php b/tests/lib/Contacts/ContactsMenu/EntryTest.php
index e28248fb0fb..1ea4782a301 100644
--- a/tests/lib/Contacts/ContactsMenu/EntryTest.php
+++ b/tests/lib/Contacts/ContactsMenu/EntryTest.php
@@ -33,7 +33,7 @@ class EntryTest extends TestCase {
/** @var Entry */
private $entry;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->entry = new Entry();
diff --git a/tests/lib/Contacts/ContactsMenu/ManagerTest.php b/tests/lib/Contacts/ContactsMenu/ManagerTest.php
index d1630e8ddeb..b78420e5424 100644
--- a/tests/lib/Contacts/ContactsMenu/ManagerTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ManagerTest.php
@@ -52,7 +52,7 @@ class ManagerTest extends TestCase {
/** @var Manager */
private $manager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->contactsStore = $this->createMock(ContactsStore::class);
diff --git a/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php b/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php
index 353c8d6f58f..85ffd1e72b1 100644
--- a/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php
+++ b/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php
@@ -43,7 +43,7 @@ class EMailproviderTest extends TestCase {
/** @var EMailProvider */
private $provider;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->actionFactory = $this->createMock(IActionFactory::class);
diff --git a/tests/lib/ContactsManagerTest.php b/tests/lib/ContactsManagerTest.php
index c460330e7eb..9e8b75fbf4d 100644
--- a/tests/lib/ContactsManagerTest.php
+++ b/tests/lib/ContactsManagerTest.php
@@ -9,7 +9,7 @@ class ContactsManagerTest extends \Test\TestCase {
/** @var \OC\ContactsManager */
private $cm;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->cm = new \OC\ContactsManager();
}
diff --git a/tests/lib/DB/ConnectionTest.php b/tests/lib/DB/ConnectionTest.php
index 02dd6a1495c..607674d7a38 100644
--- a/tests/lib/DB/ConnectionTest.php
+++ b/tests/lib/DB/ConnectionTest.php
@@ -26,12 +26,12 @@ class ConnectionTest extends \Test\TestCase {
*/
private $connection;
- public static function setUpBeforeClass() {
+ public static function setUpBeforeClass(): void {
self::dropTestTable();
parent::setUpBeforeClass();
}
- public static function tearDownAfterClass() {
+ public static function tearDownAfterClass(): void {
self::dropTestTable();
parent::tearDownAfterClass();
}
@@ -42,12 +42,12 @@ class ConnectionTest extends \Test\TestCase {
}
}
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
}
- public function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
$this->connection->dropTable('table');
}
@@ -157,10 +157,10 @@ class ConnectionTest extends \Test\TestCase {
$this->assertEquals('bar', $this->getTextValueByIntergerField(1));
}
- /**
- * @expectedException \OCP\PreConditionNotMetException
- */
+
public function testSetValuesOverWritePreconditionFailed() {
+ $this->expectException(\OCP\PreConditionNotMetException::class);
+
$this->makeTestTable();
$this->connection->setValues('table', [
'integerfield' => 1
@@ -335,10 +335,10 @@ class ConnectionTest extends \Test\TestCase {
$this->assertEquals(0, $result);
}
- /**
- * @expectedException \Doctrine\DBAL\Exception\UniqueConstraintViolationException
- */
+
public function testUniqueConstraintViolating() {
+ $this->expectException(\Doctrine\DBAL\Exception\UniqueConstraintViolationException::class);
+
$this->makeTestTable();
$testQuery = 'INSERT INTO `*PREFIX*table` (`integerfield`, `textfield`) VALUES(?, ?)';
diff --git a/tests/lib/DB/DBSchemaTest.php b/tests/lib/DB/DBSchemaTest.php
index cc6059c163f..5fb68fdf258 100644
--- a/tests/lib/DB/DBSchemaTest.php
+++ b/tests/lib/DB/DBSchemaTest.php
@@ -27,7 +27,7 @@ class DBSchemaTest extends TestCase {
/** @var ITempManager */
protected $tempManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->tempManager = \OC::$server->getTempManager();
@@ -50,7 +50,7 @@ class DBSchemaTest extends TestCase {
$this->table2 = $r.'cntcts_cards';
}
- protected function tearDown() {
+ protected function tearDown(): void {
unlink($this->schema_file);
unlink($this->schema_file2);
diff --git a/tests/lib/DB/LegacyDBTest.php b/tests/lib/DB/LegacyDBTest.php
index 578d28139bc..200afac3f9a 100644
--- a/tests/lib/DB/LegacyDBTest.php
+++ b/tests/lib/DB/LegacyDBTest.php
@@ -21,7 +21,7 @@ class LegacyDBTest extends \Test\TestCase {
protected static $schema_file;
protected $test_prefix;
- public static function setUpBeforeClass() {
+ public static function setUpBeforeClass(): void {
self::$schema_file = \OC::$server->getTempManager()->getTemporaryFile();
}
@@ -56,7 +56,7 @@ class LegacyDBTest extends \Test\TestCase {
*/
private $text_table;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$dbFile = \OC::$SERVERROOT.'/tests/data/db_structure.xml';
@@ -76,7 +76,7 @@ class LegacyDBTest extends \Test\TestCase {
$this->text_table = $this->test_prefix.'text_table';
}
- protected function tearDown() {
+ protected function tearDown(): void {
OC_DB::removeDBStructure(self::$schema_file);
unlink(self::$schema_file);
@@ -122,12 +122,12 @@ class LegacyDBTest extends \Test\TestCase {
$result = $query->execute(array('uri_3'));
$this->assertTrue((bool)$result);
}
-
+
public function testLastInsertId() {
$query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)');
$result1 = OC_DB::executeAudited($query, array('insertid 1','uri_1'));
$id1 = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*'.$this->table2);
-
+
// we don't know the id we should expect, so insert another row
$result2 = OC_DB::executeAudited($query, array('insertid 2','uri_2'));
$id2 = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*'.$this->table2);
@@ -151,7 +151,7 @@ class LegacyDBTest extends \Test\TestCase {
* Insert, select and delete decimal(12,2) values
* @dataProvider decimalData
*/
- public function testDecimal($insert, $expect) {
+ public function XtestDecimal($insert, $expect) {
$table = "*PREFIX*" . $this->table4;
$rowname = 'decimaltest';
diff --git a/tests/lib/DB/MDB2SchemaManagerTest.php b/tests/lib/DB/MDB2SchemaManagerTest.php
index 75572bb36a5..8c9290c56b4 100644
--- a/tests/lib/DB/MDB2SchemaManagerTest.php
+++ b/tests/lib/DB/MDB2SchemaManagerTest.php
@@ -20,7 +20,7 @@ use Doctrine\DBAL\Platforms\OraclePlatform;
*/
class MDB2SchemaManagerTest extends \Test\TestCase {
- protected function tearDown() {
+ protected function tearDown(): void {
// do not drop the table for Oracle as it will create a bogus transaction
// that will break the following test suites requiring transactions
if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') !== 'oci') {
diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php
index 87547debe80..58f775febb0 100644
--- a/tests/lib/DB/MigrationsTest.php
+++ b/tests/lib/DB/MigrationsTest.php
@@ -36,7 +36,7 @@ class MigrationsTest extends \Test\TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject | IDBConnection $db */
private $db;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->db = $this->createMock(Connection::class);
@@ -60,27 +60,27 @@ class MigrationsTest extends \Test\TestCase {
$this->assertEquals('test_oc_migrations', $this->migrationService->getMigrationsTableName());
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Version 20170130180000 is unknown.
- */
+
public function testExecuteUnknownStep() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Version 20170130180000 is unknown.');
+
$this->migrationService->executeStep('20170130180000');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage App not found
- */
+
public function testUnknownApp() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('App not found');
+
$migrationService = new MigrationService('unknown-bloody-app', $this->db);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Migration step 'X' is unknown
- */
+
public function testExecuteStepWithUnknownClass() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Migration step \'X\' is unknown');
+
$this->migrationService = $this->getMockBuilder(MigrationService::class)
->setMethods(['findMigrations'])
->setConstructorArgs(['testing', $this->db])
@@ -375,10 +375,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongTableName() {
+ $this->expectException(\InvalidArgumentException::class);
+
$table = $this->createMock(Table::class);
$table->expects($this->any())
->method('getName')
@@ -400,10 +400,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongPrimaryWithDefault() {
+ $this->expectException(\InvalidArgumentException::class);
+
$defaultName = 'PRIMARY';
if ($this->db->getDatabasePlatform() instanceof PostgreSqlPlatform) {
$defaultName = \str_repeat('a', 27) . '_' . \str_repeat('b', 30) . '_seq';
@@ -453,10 +453,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongPrimaryWithName() {
+ $this->expectException(\InvalidArgumentException::class);
+
$index = $this->createMock(Index::class);
$index->expects($this->any())
->method('getName')
@@ -496,10 +496,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongColumnName() {
+ $this->expectException(\InvalidArgumentException::class);
+
$column = $this->createMock(Column::class);
$column->expects($this->any())
->method('getName')
@@ -530,10 +530,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongIndexName() {
+ $this->expectException(\InvalidArgumentException::class);
+
$index = $this->createMock(Index::class);
$index->expects($this->any())
->method('getName')
@@ -567,10 +567,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongForeignKeyName() {
+ $this->expectException(\InvalidArgumentException::class);
+
$foreignKey = $this->createMock(ForeignKeyConstraint::class);
$foreignKey->expects($this->any())
->method('getName')
@@ -607,10 +607,10 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testEnsureOracleIdentifierLengthLimitTooLongSequenceName() {
+ $this->expectException(\InvalidArgumentException::class);
+
$sequence = $this->createMock(Sequence::class);
$sequence->expects($this->any())
->method('getName')
diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php
index e9c52015dbe..e5cc28654e4 100644
--- a/tests/lib/DB/MigratorTest.php
+++ b/tests/lib/DB/MigratorTest.php
@@ -44,7 +44,7 @@ class MigratorTest extends \Test\TestCase {
/** @var string */
private $tableNameTmp;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = \OC::$server->getConfig();
@@ -61,7 +61,7 @@ class MigratorTest extends \Test\TestCase {
return strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_'));
}
- protected function tearDown() {
+ protected function tearDown(): void {
// Try to delete if exists (IF EXISTS NOT SUPPORTED IN ORACLE)
try {
$this->connection->exec('DROP TABLE ' . $this->connection->quoteIdentifier($this->tableNameTmp));
@@ -102,10 +102,10 @@ class MigratorTest extends \Test\TestCase {
return $this->connection->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver;
}
- /**
- * @expectedException \OC\DB\MigrationException
- */
+
public function testDuplicateKeyUpgrade() {
+ $this->expectException(\OC\DB\MigrationException::class);
+
if ($this->isSQLite()) {
$this->markTestSkipped('sqlite does not throw errors when creating a new key on existing data');
}
diff --git a/tests/lib/DB/MySqlMigrationTest.php b/tests/lib/DB/MySqlMigrationTest.php
index 3bbe89fe025..5ebbd273c33 100644
--- a/tests/lib/DB/MySqlMigrationTest.php
+++ b/tests/lib/DB/MySqlMigrationTest.php
@@ -21,7 +21,7 @@ class MySqlMigrationTest extends \Test\TestCase {
/** @var string */
private $tableName;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -34,7 +34,7 @@ class MySqlMigrationTest extends \Test\TestCase {
$this->connection->exec("CREATE TABLE $this->tableName(b BIT, e ENUM('1','2','3','4'))");
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->connection->getSchemaManager()->dropTable($this->tableName);
parent::tearDown();
}
diff --git a/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php b/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php
index c71e83f5fd6..8e0ce2fe934 100644
--- a/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php
+++ b/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php
@@ -31,7 +31,7 @@ class ExpressionBuilderDBTest extends TestCase {
/** @var \Doctrine\DBAL\Connection|\OCP\IDBConnection */
protected $connection;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
diff --git a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
index f5dc2a07246..b3e9124e7de 100644
--- a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
@@ -43,7 +43,7 @@ class ExpressionBuilderTest extends TestCase {
/** @var \Doctrine\DBAL\Connection|\OCP\IDBConnection */
protected $connection;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
diff --git a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
index a8af7f4fe07..d7617125faa 100644
--- a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
@@ -35,7 +35,7 @@ class FunctionBuilderTest extends TestCase {
/** @var \Doctrine\DBAL\Connection|\OCP\IDBConnection */
protected $connection;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
diff --git a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
index fa1c4add0ab..a9542e2d616 100644
--- a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
@@ -49,7 +49,7 @@ class QueryBuilderTest extends \Test\TestCase {
/** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */
protected $logger;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -1152,7 +1152,7 @@ class QueryBuilderTest extends \Test\TestCase {
$actual = $qB->getLastInsertId();
$this->assertNotNull($actual);
- $this->assertInternalType('int', $actual);
+ $this->assertIsInt($actual);
$this->assertEquals($this->connection->lastInsertId('*PREFIX*properties'), $actual);
$qB->delete('properties')
diff --git a/tests/lib/DB/QueryBuilder/QuoteHelperTest.php b/tests/lib/DB/QueryBuilder/QuoteHelperTest.php
index 3c1abd72f66..3b5562b69c9 100644
--- a/tests/lib/DB/QueryBuilder/QuoteHelperTest.php
+++ b/tests/lib/DB/QueryBuilder/QuoteHelperTest.php
@@ -31,7 +31,7 @@ class QuoteHelperTest extends \Test\TestCase {
/** @var QuoteHelper */
protected $helper;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->helper = new QuoteHelper();
diff --git a/tests/lib/DB/SchemaDiffTest.php b/tests/lib/DB/SchemaDiffTest.php
index f74d800bfec..78963698571 100644
--- a/tests/lib/DB/SchemaDiffTest.php
+++ b/tests/lib/DB/SchemaDiffTest.php
@@ -50,7 +50,7 @@ class SchemaDiffTest extends TestCase {
private $schemaFile;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->schemaFile = \OC::$server->getTempManager()->getTemporaryFile();
@@ -61,7 +61,7 @@ class SchemaDiffTest extends TestCase {
$this->testPrefix= strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_'), 3));
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->manager->removeDBStructure($this->schemaFile);
parent::tearDown();
}
diff --git a/tests/lib/DB/SqliteMigrationTest.php b/tests/lib/DB/SqliteMigrationTest.php
index 4712fc6d70b..ecc6cbe0951 100644
--- a/tests/lib/DB/SqliteMigrationTest.php
+++ b/tests/lib/DB/SqliteMigrationTest.php
@@ -21,7 +21,7 @@ class SqliteMigrationTest extends \Test\TestCase {
/** @var string */
private $tableName;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -34,7 +34,7 @@ class SqliteMigrationTest extends \Test\TestCase {
$this->connection->exec("CREATE TABLE $this->tableName(t0 tinyint unsigned, t1 tinyint)");
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->connection->getSchemaManager()->dropTable($this->tableName);
parent::tearDown();
}
diff --git a/tests/lib/DateTimeFormatterTest.php b/tests/lib/DateTimeFormatterTest.php
index deb6a7c783c..6cd8b572fcd 100644
--- a/tests/lib/DateTimeFormatterTest.php
+++ b/tests/lib/DateTimeFormatterTest.php
@@ -18,7 +18,7 @@ class DateTimeFormatterTest extends TestCase {
static protected $defaultTimeZone;
- public static function setUpBeforeClass() {
+ public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
self::$defaultTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
@@ -27,12 +27,12 @@ class DateTimeFormatterTest extends TestCase {
self::$oneYear = self::$oneDay * 365;
}
- public static function tearDownAfterClass() {
+ public static function tearDownAfterClass(): void {
date_default_timezone_set(self::$defaultTimeZone);
parent::tearDownAfterClass();
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->formatter = new \OC\DateTimeFormatter(new \DateTimeZone('UTC'), \OC::$server->getL10N('lib', 'en'));
}
@@ -175,10 +175,10 @@ class DateTimeFormatterTest extends TestCase {
$this->assertEquals($expected, (string) $this->formatter->formatDateTime($timestamp, 'long', 'long', $timeZone));
}
- /**
- * @expectedException \Exception
- */
+
function testFormatDateWithInvalidTZ() {
+ $this->expectException(\Exception::class);
+
$this->formatter->formatDate(1350129205, 'long', new \DateTimeZone('Mordor/Barad-dûr'));
}
}
diff --git a/tests/lib/Diagnostics/EventLoggerTest.php b/tests/lib/Diagnostics/EventLoggerTest.php
index 2d0c82ba72e..323ca5c20d7 100644
--- a/tests/lib/Diagnostics/EventLoggerTest.php
+++ b/tests/lib/Diagnostics/EventLoggerTest.php
@@ -29,7 +29,7 @@ class EventLoggerTest extends TestCase {
/** @var \OC\Diagnostics\EventLogger */
private $logger;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->logger = new EventLogger();
diff --git a/tests/lib/Diagnostics/QueryLoggerTest.php b/tests/lib/Diagnostics/QueryLoggerTest.php
index 99de60ed8e4..545a706c3cf 100644
--- a/tests/lib/Diagnostics/QueryLoggerTest.php
+++ b/tests/lib/Diagnostics/QueryLoggerTest.php
@@ -29,7 +29,7 @@ class QueryLoggerTest extends TestCase {
/** @var \OC\Diagnostics\QueryLogger */
private $logger;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->logger = new QueryLogger();
diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php
index 158e52f4a07..e2c76db7ed9 100644
--- a/tests/lib/Encryption/DecryptAllTest.php
+++ b/tests/lib/Encryption/DecryptAllTest.php
@@ -67,7 +67,7 @@ class DecryptAllTest extends TestCase {
/** @var DecryptAll */
protected $instance;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->getMockBuilder(IUserManager::class)
diff --git a/tests/lib/Encryption/EncryptionWrapperTest.php b/tests/lib/Encryption/EncryptionWrapperTest.php
index 6a51d769751..93987a8bb20 100644
--- a/tests/lib/Encryption/EncryptionWrapperTest.php
+++ b/tests/lib/Encryption/EncryptionWrapperTest.php
@@ -43,7 +43,7 @@ class EncryptionWrapperTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject | \OC\Memcache\ArrayCache */
private $arrayCache;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->arrayCache = $this->createMock(ArrayCache::class);
diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php
index cd8f1e9b953..31936a4176b 100644
--- a/tests/lib/Encryption/Keys/StorageTest.php
+++ b/tests/lib/Encryption/Keys/StorageTest.php
@@ -42,7 +42,7 @@ class StorageTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject */
protected $config;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->util = $this->getMockBuilder('OC\Encryption\Util')
diff --git a/tests/lib/Encryption/ManagerTest.php b/tests/lib/Encryption/ManagerTest.php
index 65234074955..6e18cd296a3 100644
--- a/tests/lib/Encryption/ManagerTest.php
+++ b/tests/lib/Encryption/ManagerTest.php
@@ -35,7 +35,7 @@ class ManagerTest extends TestCase {
/** @var ArrayCache|\PHPUnit_Framework_MockObject_MockObject */
private $arrayCache;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->logger = $this->createMock(ILogger::class);
@@ -81,10 +81,11 @@ class ManagerTest extends TestCase {
/**
* @depends testModuleRegistration
- * @expectedException \OC\Encryption\Exceptions\ModuleAlreadyExistsException
- * @expectedExceptionMessage Id "ID0" already used by encryption module "TestDummyModule0"
*/
public function testModuleReRegistration($manager) {
+ $this->expectException(\OC\Encryption\Exceptions\ModuleAlreadyExistsException::class);
+ $this->expectExceptionMessage('Id "ID0" already used by encryption module "TestDummyModule0"');
+
$this->addNewEncryptionModule($manager, 0);
}
@@ -98,11 +99,11 @@ class ManagerTest extends TestCase {
}
- /**
- * @expectedException \OC\Encryption\Exceptions\ModuleDoesNotExistsException
- * @expectedExceptionMessage Module with ID: unknown does not exist.
- */
+
public function testGetEncryptionModuleUnknown() {
+ $this->expectException(\OC\Encryption\Exceptions\ModuleDoesNotExistsException::class);
+ $this->expectExceptionMessage('Module with ID: unknown does not exist.');
+
$this->config->expects($this->any())->method('getAppValue')->willReturn(true);
$this->addNewEncryptionModule($this->manager, 0);
$this->assertCount(1, $this->manager->getEncryptionModules());
diff --git a/tests/lib/Encryption/UpdateTest.php b/tests/lib/Encryption/UpdateTest.php
index 68639ad6e24..28d7ca81163 100644
--- a/tests/lib/Encryption/UpdateTest.php
+++ b/tests/lib/Encryption/UpdateTest.php
@@ -53,7 +53,7 @@ class UpdateTest extends TestCase {
/** @var \OC\Encryption\File | \PHPUnit_Framework_MockObject_MockObject */
private $fileHelper;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->view = $this->getMockBuilder(View::class)
diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php
index 1e1b21d3671..e503da109a8 100644
--- a/tests/lib/Encryption/UtilTest.php
+++ b/tests/lib/Encryption/UtilTest.php
@@ -32,7 +32,7 @@ class UtilTest extends TestCase {
/** @var \OC\Encryption\Util */
private $util;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()
@@ -96,10 +96,10 @@ class UtilTest extends TestCase {
];
}
- /**
- * @expectedException \OC\Encryption\Exceptions\EncryptionHeaderKeyExistsException
- */
+
public function testCreateHeaderFailed() {
+ $this->expectException(\OC\Encryption\Exceptions\EncryptionHeaderKeyExistsException::class);
+
$header = array('header1' => 1, 'header2' => 2, 'oc_encryption_module' => 'foo');
diff --git a/tests/lib/Federation/CloudIdManagerTest.php b/tests/lib/Federation/CloudIdManagerTest.php
index fe673588bba..224acadbde4 100644
--- a/tests/lib/Federation/CloudIdManagerTest.php
+++ b/tests/lib/Federation/CloudIdManagerTest.php
@@ -28,7 +28,7 @@ class CloudIdManagerTest extends TestCase {
/** @var CloudIdManager */
private $cloudIdManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->cloudIdManager = new CloudIdManager();
}
@@ -71,9 +71,10 @@ class CloudIdManagerTest extends TestCase {
*
* @param string $cloudId
*
- * @expectedException \InvalidArgumentException
*/
public function testInvalidCloudId($cloudId) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->cloudIdManager->resolveCloudId($cloudId);
}
diff --git a/tests/lib/Files/AppData/AppDataTest.php b/tests/lib/Files/AppData/AppDataTest.php
index a9353540fff..1b3f705b9b6 100644
--- a/tests/lib/Files/AppData/AppDataTest.php
+++ b/tests/lib/Files/AppData/AppDataTest.php
@@ -42,7 +42,7 @@ class AppDataTest extends \Test\TestCase {
/** @var IAppData */
private $appData;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->rootFolder = $this->createMock(IRootFolder::class);
diff --git a/tests/lib/Files/AppData/FactoryTest.php b/tests/lib/Files/AppData/FactoryTest.php
index 9b7529b18d9..fec464d6e3a 100644
--- a/tests/lib/Files/AppData/FactoryTest.php
+++ b/tests/lib/Files/AppData/FactoryTest.php
@@ -37,7 +37,7 @@ class FactoryTest extends \Test\TestCase {
/** @var Factory */
private $factory;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->rootFolder = $this->createMock(IRootFolder::class);
diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php
index ccdfbbd065b..b2816c03094 100644
--- a/tests/lib/Files/Cache/CacheTest.php
+++ b/tests/lib/Files/Cache/CacheTest.php
@@ -777,7 +777,7 @@ class CacheTest extends \Test\TestCase {
$this->cache->remove("sub");
}
- protected function tearDown() {
+ protected function tearDown(): void {
if ($this->cache) {
$this->cache->clear();
}
@@ -785,7 +785,7 @@ class CacheTest extends \Test\TestCase {
parent::tearDown();
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->storage = new \OC\Files\Storage\Temporary(array());
diff --git a/tests/lib/Files/Cache/HomeCacheTest.php b/tests/lib/Files/Cache/HomeCacheTest.php
index a144b8cabb8..51fc2e5bc9b 100644
--- a/tests/lib/Files/Cache/HomeCacheTest.php
+++ b/tests/lib/Files/Cache/HomeCacheTest.php
@@ -66,7 +66,7 @@ class HomeCacheTest extends \Test\TestCase {
*/
private $user;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->user = new DummyUser('foo', \OC::$server->getTempManager()->getTemporaryFolder());
diff --git a/tests/lib/Files/Cache/MoveFromCacheTraitTest.php b/tests/lib/Files/Cache/MoveFromCacheTraitTest.php
index 3d4a55c0722..f93b95b5fe7 100644
--- a/tests/lib/Files/Cache/MoveFromCacheTraitTest.php
+++ b/tests/lib/Files/Cache/MoveFromCacheTraitTest.php
@@ -20,7 +20,7 @@ class FallBackCrossCacheMoveCache extends \OC\Files\Cache\Cache {
* @group DB
*/
class MoveFromCacheTraitTest extends CacheTest {
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->storage = new \OC\Files\Storage\Temporary(array());
diff --git a/tests/lib/Files/Cache/PropagatorTest.php b/tests/lib/Files/Cache/PropagatorTest.php
index 402b29c8c3e..ce6b84ee4d0 100644
--- a/tests/lib/Files/Cache/PropagatorTest.php
+++ b/tests/lib/Files/Cache/PropagatorTest.php
@@ -20,7 +20,7 @@ class PropagatorTest extends TestCase {
/** @var IStorage */
private $storage;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->storage = new Temporary();
$this->storage->mkdir('foo/bar');
diff --git a/tests/lib/Files/Cache/QuerySearchHelperTest.php b/tests/lib/Files/Cache/QuerySearchHelperTest.php
index addeac71350..d5aad09a8fb 100644
--- a/tests/lib/Files/Cache/QuerySearchHelperTest.php
+++ b/tests/lib/Files/Cache/QuerySearchHelperTest.php
@@ -48,7 +48,7 @@ class QuerySearchHelperTest extends TestCase {
/** @var integer */
private $numericStorageId;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->builder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$this->mimetypeLoader = $this->createMock(IMimeTypeLoader::class);
@@ -83,7 +83,7 @@ class QuerySearchHelperTest extends TestCase {
->where($this->builder->expr()->eq('storage', new Literal($this->numericStorageId)));
}
- public function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
$builder = \OC::$server->getDatabaseConnection()->getQueryBuilder();
diff --git a/tests/lib/Files/Cache/ScannerTest.php b/tests/lib/Files/Cache/ScannerTest.php
index 0f5335f4416..6a025410cc3 100644
--- a/tests/lib/Files/Cache/ScannerTest.php
+++ b/tests/lib/Files/Cache/ScannerTest.php
@@ -33,7 +33,7 @@ class ScannerTest extends \Test\TestCase {
*/
private $cache;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->storage = new \OC\Files\Storage\Temporary(array());
@@ -41,7 +41,7 @@ class ScannerTest extends \Test\TestCase {
$this->cache = new \OC\Files\Cache\Cache($this->storage);
}
- protected function tearDown() {
+ protected function tearDown(): void {
if ($this->cache) {
$this->cache->clear();
}
@@ -250,8 +250,8 @@ class ScannerTest extends \Test\TestCase {
$this->cache->put('folder', array('mtime' => $this->storage->filemtime('folder'), 'storage_mtime' => $this->storage->filemtime('folder')));
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_SIZE);
$newData = $this->cache->get('');
- $this->assertInternalType('string', $oldData['etag']);
- $this->assertInternalType('string', $newData['etag']);
+ $this->assertIsString($oldData['etag']);
+ $this->assertIsString($newData['etag']);
$this->assertNotSame($oldData['etag'], $newData['etag']);
$this->assertEquals($oldData['size'], $newData['size']);
@@ -320,11 +320,11 @@ class ScannerTest extends \Test\TestCase {
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG);
/** @var CacheEntry $data0 */
$data0 = $this->cache->get('folder/bar.txt');
- $this->assertInternalType('string', $data0['etag']);
+ $this->assertIsString($data0['etag']);
$data1 = $this->cache->get('folder');
- $this->assertInternalType('string', $data1['etag']);
+ $this->assertIsString($data1['etag']);
$data2 = $this->cache->get('');
- $this->assertInternalType('string', $data2['etag']);
+ $this->assertIsString($data2['etag']);
$data0['etag'] = '';
$this->cache->put('folder/bar.txt', $data0->getData());
@@ -333,7 +333,7 @@ class ScannerTest extends \Test\TestCase {
// verify cache content
$newData0 = $this->cache->get('folder/bar.txt');
- $this->assertInternalType('string', $newData0['etag']);
+ $this->assertIsString($newData0['etag']);
$this->assertNotEmpty($newData0['etag']);
}
diff --git a/tests/lib/Files/Cache/UpdaterLegacyTest.php b/tests/lib/Files/Cache/UpdaterLegacyTest.php
index a0cc1c5d89c..a3b1a428c28 100644
--- a/tests/lib/Files/Cache/UpdaterLegacyTest.php
+++ b/tests/lib/Files/Cache/UpdaterLegacyTest.php
@@ -37,7 +37,7 @@ class UpdaterLegacyTest extends \Test\TestCase {
private static $user;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->storage = new \OC\Files\Storage\Temporary(array());
@@ -68,7 +68,7 @@ class UpdaterLegacyTest extends \Test\TestCase {
\OC_Hook::clear('OC_Filesystem');
}
- protected function tearDown() {
+ protected function tearDown(): void {
if ($this->cache) {
$this->cache->clear();
}
@@ -93,13 +93,13 @@ class UpdaterLegacyTest extends \Test\TestCase {
Filesystem::file_put_contents('foo.txt', 'asd');
$cachedData = $this->cache->get('foo.txt');
$this->assertEquals(3, $cachedData['size']);
- $this->assertInternalType('string', $fooCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($fooCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($fooCachedData['etag'], $cachedData['etag']);
$cachedData = $this->cache->get('');
$this->assertEquals(2 * $textSize + $imageSize + 3, $cachedData['size']);
- $this->assertInternalType('string', $rootCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($rootCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
$rootCachedData = $cachedData;
@@ -111,8 +111,8 @@ class UpdaterLegacyTest extends \Test\TestCase {
$mtime = $cachedData['mtime'];
$cachedData = $this->cache->get('');
$this->assertEquals(2 * $textSize + $imageSize + 2 * 3, $cachedData['size']);
- $this->assertInternalType('string', $rootCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($rootCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $mtime);
}
@@ -133,13 +133,13 @@ class UpdaterLegacyTest extends \Test\TestCase {
$mtime = $cachedData['mtime'];
$cachedData = $cache2->get('');
- $this->assertInternalType('string', $substorageCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($substorageCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($oldEtag, $cachedData['etag']);
$cachedData = $view->getFileInfo('folder');
- $this->assertInternalType('string', $folderCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($folderCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($oldEtag, $cachedData['etag']);
}
@@ -155,8 +155,8 @@ class UpdaterLegacyTest extends \Test\TestCase {
$this->assertFalse($this->cache->inCache('foo.txt'));
$cachedData = $this->cache->get('');
$this->assertEquals(2 * $textSize + $imageSize, $cachedData['size']);
- $this->assertInternalType('string', $rootCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($rootCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($oldEtag, $cachedData['etag']);
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
$rootCachedData = $cachedData;
@@ -164,16 +164,16 @@ class UpdaterLegacyTest extends \Test\TestCase {
Filesystem::mkdir('bar_folder');
$this->assertTrue($this->cache->inCache('bar_folder'));
$cachedData = $this->cache->get('');
- $this->assertInternalType('string', $rootCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($rootCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($oldEtag, $cachedData['etag']);
$rootCachedData = $cachedData;
$oldEtag = $rootCachedData['etag'];
Filesystem::rmdir('bar_folder');
$this->assertFalse($this->cache->inCache('bar_folder'));
$cachedData = $this->cache->get('');
- $this->assertInternalType('string', $rootCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($rootCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($oldEtag, $cachedData['etag']);
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
}
@@ -192,14 +192,14 @@ class UpdaterLegacyTest extends \Test\TestCase {
$this->assertFalse($cache2->inCache('foo.txt'));
$cachedData = $cache2->get('');
- $this->assertInternalType('string', $substorageCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($substorageCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($substorageCachedData, $cachedData['etag']);
$this->assertGreaterThanOrEqual($substorageCachedData['mtime'], $cachedData['mtime']);
$cachedData = $view->getFileInfo('folder');
- $this->assertInternalType('string', $folderCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($folderCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($oldEtag, $cachedData['etag']);
$this->assertGreaterThanOrEqual($folderCachedData['mtime'], $cachedData['mtime']);
}
@@ -221,8 +221,8 @@ class UpdaterLegacyTest extends \Test\TestCase {
$mtime = $cachedData['mtime'];
$cachedData = $this->cache->get('');
$this->assertEquals(3 * $textSize + $imageSize, $cachedData['size']);
- $this->assertInternalType('string', $rootCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($rootCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
}
@@ -253,15 +253,15 @@ class UpdaterLegacyTest extends \Test\TestCase {
$mtime = $cachedData['mtime'];
$cachedData = $cache2->get('');
- $this->assertInternalType('string', $substorageCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($substorageCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($oldEtag, $cachedData['etag']);
// rename can cause mtime change - invalid assert
// $this->assertEquals($mtime, $cachedData['mtime']);
$cachedData = $view->getFileInfo('folder');
- $this->assertInternalType('string', $folderCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($folderCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($oldEtag, $cachedData['etag']);
// rename can cause mtime change - invalid assert
// $this->assertEquals($mtime, $cachedData['mtime']);
@@ -272,13 +272,13 @@ class UpdaterLegacyTest extends \Test\TestCase {
$fooCachedData = $this->cache->get('foo.txt');
Filesystem::touch('foo.txt');
$cachedData = $this->cache->get('foo.txt');
- $this->assertInternalType('string', $fooCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($fooCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertGreaterThanOrEqual($fooCachedData['mtime'], $cachedData['mtime']);
$cachedData = $this->cache->get('');
- $this->assertInternalType('string', $rootCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($rootCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
$rootCachedData = $cachedData;
@@ -289,19 +289,19 @@ class UpdaterLegacyTest extends \Test\TestCase {
$this->cache->put('', ['mtime' => $time - 100]);
Filesystem::touch('folder/bar.txt', $time);
$cachedData = $this->cache->get('folder/bar.txt');
- $this->assertInternalType('string', $barCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($barCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($barCachedData['etag'], $cachedData['etag']);
$this->assertEquals($time, $cachedData['mtime']);
$cachedData = $this->cache->get('folder');
- $this->assertInternalType('string', $folderCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($folderCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
$cachedData = $this->cache->get('');
- $this->assertInternalType('string', $rootCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
+ $this->assertIsString($rootCachedData['etag']);
+ $this->assertIsString($cachedData['etag']);
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
$this->assertEquals($time, $cachedData['mtime']);
}
diff --git a/tests/lib/Files/Cache/UpdaterTest.php b/tests/lib/Files/Cache/UpdaterTest.php
index 54fb3f3fc97..8dc5893007b 100644
--- a/tests/lib/Files/Cache/UpdaterTest.php
+++ b/tests/lib/Files/Cache/UpdaterTest.php
@@ -40,7 +40,7 @@ class UpdaterTest extends \Test\TestCase {
*/
protected $updater;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->loginAsUser();
@@ -50,7 +50,7 @@ class UpdaterTest extends \Test\TestCase {
$this->cache = $this->storage->getCache();
}
- protected function tearDown() {
+ protected function tearDown(): void {
Filesystem::clearMounts();
$this->logout();
diff --git a/tests/lib/Files/Cache/WatcherTest.php b/tests/lib/Files/Cache/WatcherTest.php
index d4aa9ac875e..18f0ebe98a9 100644
--- a/tests/lib/Files/Cache/WatcherTest.php
+++ b/tests/lib/Files/Cache/WatcherTest.php
@@ -22,13 +22,13 @@ class WatcherTest extends \Test\TestCase {
*/
private $storages = array();
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->loginAsUser();
}
- protected function tearDown() {
+ protected function tearDown(): void {
foreach ($this->storages as $storage) {
$cache = $storage->getCache();
$ids = $cache->getAll();
diff --git a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
index 365049c1cc6..9c1a8c14101 100644
--- a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
+++ b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
@@ -24,7 +24,7 @@ class CacheJailTest extends CacheTest {
*/
protected $sourceCache;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->storage->mkdir('foo');
$this->sourceCache = $this->cache;
diff --git a/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php b/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php
index c12b35867ff..9883fc1da27 100644
--- a/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php
+++ b/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php
@@ -24,7 +24,7 @@ class CachePermissionsMaskTest extends CacheTest {
*/
protected $sourceCache;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->storage->mkdir('foo');
$this->sourceCache = $this->cache;
diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php
index 4bfc8710951..d63693a655b 100644
--- a/tests/lib/Files/Config/UserMountCacheTest.php
+++ b/tests/lib/Files/Config/UserMountCacheTest.php
@@ -42,7 +42,7 @@ class UserMountCacheTest extends TestCase {
private $fileIds = [];
- public function setUp() {
+ protected function setUp(): void {
$this->fileIds = [];
$this->connection = \OC::$server->getDatabaseConnection();
$this->userManager = new Manager($this->createMock(IConfig::class), $this->createMock(EventDispatcherInterface::class));
@@ -54,7 +54,7 @@ class UserMountCacheTest extends TestCase {
$this->cache = new \OC\Files\Config\UserMountCache($this->connection, $this->userManager, $this->createMock(Log::class));
}
- public function tearDown() {
+ protected function tearDown(): void {
$builder = $this->connection->getQueryBuilder();
$builder->delete('mounts')->execute();
diff --git a/tests/lib/Files/EtagTest.php b/tests/lib/Files/EtagTest.php
index ef7bf7cfbb7..acda220d01f 100644
--- a/tests/lib/Files/EtagTest.php
+++ b/tests/lib/Files/EtagTest.php
@@ -28,7 +28,7 @@ class EtagTest extends \Test\TestCase {
*/
private $userBackend;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
\OC_Hook::clear('OC_Filesystem', 'setup');
@@ -46,7 +46,7 @@ class EtagTest extends \Test\TestCase {
\OC_User::useBackend($this->userBackend);
}
- protected function tearDown() {
+ protected function tearDown(): void {
\OC::$server->getConfig()->setSystemValue('datadirectory', $this->datadir);
$this->logout();
diff --git a/tests/lib/Files/FileInfoTest.php b/tests/lib/Files/FileInfoTest.php
index b1ab880ad70..0037941b629 100644
--- a/tests/lib/Files/FileInfoTest.php
+++ b/tests/lib/Files/FileInfoTest.php
@@ -23,7 +23,7 @@ class FileInfoTest extends TestCase {
private $config;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->createUser('foo', 'foo');
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
diff --git a/tests/lib/Files/FilesystemTest.php b/tests/lib/Files/FilesystemTest.php
index 6fc6fbe9d7c..6d0362772ca 100644
--- a/tests/lib/Files/FilesystemTest.php
+++ b/tests/lib/Files/FilesystemTest.php
@@ -77,7 +77,7 @@ class FilesystemTest extends \Test\TestCase {
return array('datadir' => $dir);
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$userBackend = new \Test\Util\User\Dummy();
$userBackend->createUser(self::TEST_FILESYSTEM_USER1, self::TEST_FILESYSTEM_USER1);
@@ -86,7 +86,7 @@ class FilesystemTest extends \Test\TestCase {
$this->loginAsUser();
}
- protected function tearDown() {
+ protected function tearDown(): void {
foreach ($this->tmpDirs as $dir) {
\OC_Helper::rmdirr($dir);
}
@@ -323,18 +323,19 @@ class FilesystemTest extends \Test\TestCase {
/**
* Tests that an exception is thrown when passed user does not exist.
*
- * @expectedException \OC\User\NoUserException
*/
public function testLocalMountWhenUserDoesNotExist() {
+ $this->expectException(\OC\User\NoUserException::class);
+
$userId = $this->getUniqueID('user_');
\OC\Files\Filesystem::initMountPoints($userId);
}
- /**
- * @expectedException \OC\User\NoUserException
- */
+
public function testNullUserThrows() {
+ $this->expectException(\OC\User\NoUserException::class);
+
\OC\Files\Filesystem::initMountPoints(null);
}
diff --git a/tests/lib/Files/Mount/ManagerTest.php b/tests/lib/Files/Mount/ManagerTest.php
index 7633ffb2f2d..f3cdc4264e4 100644
--- a/tests/lib/Files/Mount/ManagerTest.php
+++ b/tests/lib/Files/Mount/ManagerTest.php
@@ -22,7 +22,7 @@ class ManagerTest extends \Test\TestCase {
*/
private $manager;
- protected function setup() {
+ protected function setUp(): void {
parent::setUp();
$this->manager = new \OC\Files\Mount\Manager();
}
diff --git a/tests/lib/Files/Mount/MountPointTest.php b/tests/lib/Files/Mount/MountPointTest.php
index 03b106eb598..9b63c507b5f 100644
--- a/tests/lib/Files/Mount/MountPointTest.php
+++ b/tests/lib/Files/Mount/MountPointTest.php
@@ -11,6 +11,10 @@ namespace Test\Files\Mount;
use OC\Files\Storage\StorageFactory;
use OCP\Files\Storage;
+class DummyStorage {
+
+}
+
class MountPointTest extends \Test\TestCase {
public function testGetStorage() {
@@ -26,7 +30,7 @@ class MountPointTest extends \Test\TestCase {
$mountPoint = new \OC\Files\Mount\MountPoint(
// just use this because a real class is needed
- '\Test\Files\Mount\MountPointTest',
+ '\Test\Files\Mount\DummyStorage',
'/mountpoint',
null,
$loader
@@ -53,7 +57,7 @@ class MountPointTest extends \Test\TestCase {
$mountPoint = new \OC\Files\Mount\MountPoint(
// just use this because a real class is needed
- '\Test\Files\Mount\MountPointTest',
+ '\Test\Files\Mount\DummyStorage',
'/mountpoint',
null,
$loader
diff --git a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
index 9aa0143b4a7..278872b8728 100644
--- a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
+++ b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
@@ -21,7 +21,7 @@ class ObjectHomeMountProviderTest extends \Test\TestCase {
/** @var IStorageFactory|\PHPUnit_Framework_MockObject_MockObject */
protected $loader;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/tests/lib/Files/Node/FileTest.php b/tests/lib/Files/Node/FileTest.php
index a17cc1d1a3a..2cdf9cbdc5a 100644
--- a/tests/lib/Files/Node/FileTest.php
+++ b/tests/lib/Files/Node/FileTest.php
@@ -59,10 +59,10 @@ class FileTest extends NodeTest {
$this->assertEquals('bar', $node->getContent());
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
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')
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
@@ -105,10 +105,10 @@ class FileTest extends NodeTest {
$node->putContent('bar');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
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')
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
@@ -213,10 +213,10 @@ class FileTest extends NodeTest {
$this->assertEquals(2, $hooksCalled);
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testFOpenReadNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$root = new \OC\Files\Node\Root(
$this->manager,
$this->view,
@@ -238,10 +238,10 @@ class FileTest extends NodeTest {
$node->fopen('r');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testFOpenReadWriteNoReadPermissions() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$root = new \OC\Files\Node\Root(
$this->manager,
$this->view,
@@ -263,10 +263,10 @@ class FileTest extends NodeTest {
$node->fopen('w');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testFOpenReadWriteNoWritePermissions() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$root = new \OC\Files\Node\Root(
$this->manager,
new $this->view,
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php
index 3390d19feb7..d33fb4f68f8 100644
--- a/tests/lib/Files/Node/FolderTest.php
+++ b/tests/lib/Files/Node/FolderTest.php
@@ -176,10 +176,10 @@ class FolderTest extends NodeTest {
$this->assertEquals($child, $result);
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testNewFolderNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$manager = $this->createMock(Manager::class);
/**
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
@@ -230,10 +230,10 @@ class FolderTest extends NodeTest {
$this->assertEquals($child, $result);
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testNewFileNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$manager = $this->createMock(Manager::class);
/**
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
diff --git a/tests/lib/Files/Node/HookConnectorTest.php b/tests/lib/Files/Node/HookConnectorTest.php
index 5180dbb9fe2..4c747a562b8 100644
--- a/tests/lib/Files/Node/HookConnectorTest.php
+++ b/tests/lib/Files/Node/HookConnectorTest.php
@@ -53,7 +53,7 @@ class HookConnectorTest extends TestCase {
*/
private $userId;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userId = $this->getUniqueID();
$this->createUser($this->userId, 'pass');
@@ -71,7 +71,7 @@ class HookConnectorTest extends TestCase {
$this->eventDispatcher = \OC::$server->getEventDispatcher();
}
- public function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
\OC_Hook::clear('OC_Filesystem');
\OC_Util::tearDownFS();
diff --git a/tests/lib/Files/Node/IntegrationTest.php b/tests/lib/Files/Node/IntegrationTest.php
index 6d9b0ce20b9..2a542a1097a 100644
--- a/tests/lib/Files/Node/IntegrationTest.php
+++ b/tests/lib/Files/Node/IntegrationTest.php
@@ -38,7 +38,7 @@ class IntegrationTest extends \Test\TestCase {
*/
private $view;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$manager = \OC\Files\Filesystem::getMountManager();
@@ -65,7 +65,7 @@ class IntegrationTest extends \Test\TestCase {
$this->root->mount($subStorage, '/substorage/');
}
- protected function tearDown() {
+ protected function tearDown(): void {
foreach ($this->storages as $storage) {
$storage->getCache()->clear();
}
diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php
index 566c84e2c85..7c8ddee6b5f 100644
--- a/tests/lib/Files/Node/NodeTest.php
+++ b/tests/lib/Files/Node/NodeTest.php
@@ -43,7 +43,7 @@ abstract class NodeTest extends \Test\TestCase {
/** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */
protected $userManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->user = $this->createMock(IUser::class);
@@ -180,10 +180,10 @@ abstract class NodeTest extends \Test\TestCase {
$this->assertEquals(2, $hooksRun);
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testDeleteNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
@@ -437,10 +437,10 @@ abstract class NodeTest extends \Test\TestCase {
$this->assertEquals(2, $hooksRun);
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testTouchNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
@@ -454,10 +454,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->touch(100);
}
- /**
- * @expectedException \OCP\Files\InvalidPathException
- */
+
public function testInvalidPath() {
+ $this->expectException(\OCP\Files\InvalidPathException::class);
+
$node = $this->createTestNode($this->root, $this->view, '/../foo');
$node->getFileInfo();
}
@@ -488,10 +488,10 @@ abstract class NodeTest extends \Test\TestCase {
$this->assertEquals(3, $target->getId());
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testCopyNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
/**
* @var \OC\Files\Storage\Storage | \PHPUnit_Framework_MockObject_MockObject $storage
*/
@@ -519,10 +519,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->copy('/bar/asd');
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- */
+
public function testCopyNoParent() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+
$this->view->expects($this->never())
->method('copy');
@@ -536,10 +536,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->copy('/bar/asd/foo');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testCopyParentIsFile() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->view->expects($this->never())
->method('copy');
@@ -659,10 +659,10 @@ abstract class NodeTest extends \Test\TestCase {
$this->assertEquals(4, $hooksRun);
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testMoveNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->view->expects($this->any())
->method('getFileInfo')
->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])));
@@ -681,10 +681,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->move('/bar/asd');
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- */
+
public function testMoveNoParent() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+
/**
* @var \OC\Files\Storage\Storage | \PHPUnit_Framework_MockObject_MockObject $storage
*/
@@ -703,10 +703,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->move('/bar/asd');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testMoveParentIsFile() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->view->expects($this->never())
->method('rename');
@@ -721,10 +721,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->move('/bar/asd');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testMoveFailed() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->view->expects($this->any())
->method('rename')
->with('/bar/foo', '/bar/asd')
@@ -744,10 +744,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->move('/bar/asd');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testCopyFailed() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->view->expects($this->any())
->method('copy')
->with('/bar/foo', '/bar/asd')
diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php
index 8a6e5411f26..5067236ec58 100644
--- a/tests/lib/Files/Node/RootTest.php
+++ b/tests/lib/Files/Node/RootTest.php
@@ -36,7 +36,7 @@ class RootTest extends \Test\TestCase {
/** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */
private $userManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->user = $this->createMock(IUser::class);
@@ -87,10 +87,10 @@ class RootTest extends \Test\TestCase {
$this->assertInstanceOf('\OC\Files\Node\File', $node);
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- */
+
public function testGetNotFound() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+
/**
* @var \OC\Files\Storage\Storage $storage
*/
@@ -121,10 +121,10 @@ class RootTest extends \Test\TestCase {
$root->get('/bar/foo');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testGetInvalidPath() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
/**
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
@@ -143,10 +143,10 @@ class RootTest extends \Test\TestCase {
$root->get('/../foo');
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- */
+
public function testGetNoStorages() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+
/**
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
@@ -201,11 +201,11 @@ class RootTest extends \Test\TestCase {
$this->assertEquals($folder, $root->getUserFolder('MyUserId'));
}
- /**
- * @expectedException \OC\User\NoUserException
- * @expectedExceptionMessage Backends provided no user object
- */
+
public function testGetUserFolderWithNoUserObj() {
+ $this->expectException(\OC\User\NoUserException::class);
+ $this->expectExceptionMessage('Backends provided no user object');
+
$root = new \OC\Files\Node\Root(
$this->createMock(Manager::class),
$this->createMock(View::class),
diff --git a/tests/lib/Files/ObjectStore/NoopScannerTest.php b/tests/lib/Files/ObjectStore/NoopScannerTest.php
index 1832ed8d61a..8b879e8ab37 100644
--- a/tests/lib/Files/ObjectStore/NoopScannerTest.php
+++ b/tests/lib/Files/ObjectStore/NoopScannerTest.php
@@ -19,7 +19,7 @@ class NoopScannerTest extends \Test\TestCase {
/** @var \OC\Files\ObjectStore\NoopScanner $scanner */
private $scanner;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->storage = new \OC\Files\Storage\Temporary(array());
diff --git a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php
index ce9c9d2cd69..b8c7b15e039 100644
--- a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php
+++ b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php
@@ -38,7 +38,7 @@ class ObjectStoreStorageTest extends Storage {
*/
private $objectStorage;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$baseStorage = new Temporary();
@@ -47,7 +47,7 @@ class ObjectStoreStorageTest extends Storage {
$this->instance = new ObjectStoreStorageOverwrite($config);
}
- protected function tearDown() {
+ protected function tearDown(): void {
if (is_null($this->instance)) {
return;
}
diff --git a/tests/lib/Files/PathVerificationTest.php b/tests/lib/Files/PathVerificationTest.php
index 7e0b7dd2650..18637daf9d7 100644
--- a/tests/lib/Files/PathVerificationTest.php
+++ b/tests/lib/Files/PathVerificationTest.php
@@ -25,16 +25,16 @@ class PathVerificationTest extends \Test\TestCase {
*/
private $view;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->view = new View();
}
- /**
- * @expectedException \OCP\Files\InvalidPathException
- * @expectedExceptionMessage File name is too long
- */
+
public function testPathVerificationFileNameTooLong() {
+ $this->expectException(\OCP\Files\InvalidPathException::class);
+ $this->expectExceptionMessage('File name is too long');
+
$fileName = str_repeat('a', 500);
$this->view->verifyPath('', $fileName);
}
@@ -42,10 +42,11 @@ class PathVerificationTest extends \Test\TestCase {
/**
* @dataProvider providesEmptyFiles
- * @expectedException \OCP\Files\InvalidPathException
- * @expectedExceptionMessage Empty filename is not allowed
*/
public function testPathVerificationEmptyFileName($fileName) {
+ $this->expectException(\OCP\Files\InvalidPathException::class);
+ $this->expectExceptionMessage('Empty filename is not allowed');
+
$this->view->verifyPath('', $fileName);
}
@@ -58,10 +59,11 @@ class PathVerificationTest extends \Test\TestCase {
/**
* @dataProvider providesDotFiles
- * @expectedException \OCP\Files\InvalidPathException
- * @expectedExceptionMessage Dot files are not allowed
*/
public function testPathVerificationDotFiles($fileName) {
+ $this->expectException(\OCP\Files\InvalidPathException::class);
+ $this->expectExceptionMessage('Dot files are not allowed');
+
$this->view->verifyPath('', $fileName);
}
@@ -107,9 +109,10 @@ class PathVerificationTest extends \Test\TestCase {
/**
* @dataProvider providesInvalidCharsPosix
- * @expectedException \OCP\Files\InvalidCharacterInPathException
*/
public function testPathVerificationInvalidCharsPosix($fileName) {
+ $this->expectException(\OCP\Files\InvalidCharacterInPathException::class);
+
$storage = new Local(['datadir' => '']);
$fileName = " 123{$fileName}456 ";
diff --git a/tests/lib/Files/SimpleFS/SimpleFileTest.php b/tests/lib/Files/SimpleFS/SimpleFileTest.php
index b31fa348afa..07a7e79c7a3 100644
--- a/tests/lib/Files/SimpleFS/SimpleFileTest.php
+++ b/tests/lib/Files/SimpleFS/SimpleFileTest.php
@@ -36,7 +36,7 @@ class SimpleFileTest extends \Test\TestCase {
/** @var SimpleFile */
private $simpleFile;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->file = $this->createMock(File::class);
diff --git a/tests/lib/Files/SimpleFS/SimpleFolderTest.php b/tests/lib/Files/SimpleFS/SimpleFolderTest.php
index 551d8c95205..9dcca32090f 100644
--- a/tests/lib/Files/SimpleFS/SimpleFolderTest.php
+++ b/tests/lib/Files/SimpleFS/SimpleFolderTest.php
@@ -37,7 +37,7 @@ class SimpleFolderTest extends \Test\TestCase {
/** @var SimpleFolder */
private $simpleFolder;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->folder = $this->createMock(Folder::class);
diff --git a/tests/lib/Files/Storage/CommonTest.php b/tests/lib/Files/Storage/CommonTest.php
index f7be996e5ea..0900765c510 100644
--- a/tests/lib/Files/Storage/CommonTest.php
+++ b/tests/lib/Files/Storage/CommonTest.php
@@ -39,14 +39,14 @@ class CommonTest extends Storage {
*/
private $tmpDir;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
$this->instance = new \OC\Files\Storage\CommonTest(['datadir' => $this->tmpDir]);
}
- protected function tearDown() {
+ protected function tearDown(): void {
\OC_Helper::rmdirr($this->tmpDir);
parent::tearDown();
}
diff --git a/tests/lib/Files/Storage/CopyDirectoryTest.php b/tests/lib/Files/Storage/CopyDirectoryTest.php
index 034ffb5a53a..d56cc37124d 100644
--- a/tests/lib/Files/Storage/CopyDirectoryTest.php
+++ b/tests/lib/Files/Storage/CopyDirectoryTest.php
@@ -45,7 +45,7 @@ class CopyDirectoryStorage extends StorageNoRecursiveCopy {
*/
class CopyDirectoryTest extends Storage {
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->instance = new CopyDirectoryStorage([]);
}
diff --git a/tests/lib/Files/Storage/HomeTest.php b/tests/lib/Files/Storage/HomeTest.php
index e6899ff7d38..6075e9af293 100644
--- a/tests/lib/Files/Storage/HomeTest.php
+++ b/tests/lib/Files/Storage/HomeTest.php
@@ -67,7 +67,7 @@ class HomeTest extends Storage {
*/
private $user;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
@@ -76,7 +76,7 @@ class HomeTest extends Storage {
$this->instance = new \OC\Files\Storage\Home(array('user' => $this->user));
}
- protected function tearDown() {
+ protected function tearDown(): void {
\OC_Helper::rmdirr($this->tmpDir);
parent::tearDown();
}
diff --git a/tests/lib/Files/Storage/LocalTest.php b/tests/lib/Files/Storage/LocalTest.php
index c611a990236..23738a25c2a 100644
--- a/tests/lib/Files/Storage/LocalTest.php
+++ b/tests/lib/Files/Storage/LocalTest.php
@@ -35,14 +35,14 @@ class LocalTest extends Storage {
*/
private $tmpDir;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
$this->instance = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir));
}
- protected function tearDown() {
+ protected function tearDown(): void {
\OC_Helper::rmdirr($this->tmpDir);
parent::tearDown();
}
@@ -63,24 +63,24 @@ class LocalTest extends Storage {
$this->assertNotEquals($etag1, $etag2);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testInvalidArgumentsEmptyArray() {
+ $this->expectException(\InvalidArgumentException::class);
+
new \OC\Files\Storage\Local([]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testInvalidArgumentsNoArray() {
+ $this->expectException(\InvalidArgumentException::class);
+
new \OC\Files\Storage\Local(null);
}
- /**
- * @expectedException \OCP\Files\ForbiddenException
- */
+
public function testDisallowSymlinksOutsideDatadir() {
+ $this->expectException(\OCP\Files\ForbiddenException::class);
+
$subDir1 = $this->tmpDir . 'sub1';
$subDir2 = $this->tmpDir . 'sub2';
$sym = $this->tmpDir . 'sub1/sym';
diff --git a/tests/lib/Files/Storage/Wrapper/AvailabilityTest.php b/tests/lib/Files/Storage/Wrapper/AvailabilityTest.php
index 1672d17e36b..f36958ad552 100644
--- a/tests/lib/Files/Storage/Wrapper/AvailabilityTest.php
+++ b/tests/lib/Files/Storage/Wrapper/AvailabilityTest.php
@@ -35,7 +35,7 @@ class AvailabilityTest extends \Test\TestCase {
/** @var Availability */
protected $wrapper;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->storageCache = $this->createMock(StorageCache::class);
@@ -66,9 +66,10 @@ class AvailabilityTest extends \Test\TestCase {
/**
* Storage marked unavailable, TTL not expired
*
- * @expectedException \OCP\Files\StorageNotAvailableException
*/
public function testUnavailable() {
+ $this->expectException(\OCP\Files\StorageNotAvailableException::class);
+
$this->storage->expects($this->once())
->method('getAvailability')
->willReturn(['available' => false, 'last_checked' => time()]);
@@ -105,9 +106,10 @@ class AvailabilityTest extends \Test\TestCase {
/**
* Storage marked available, but throws StorageNotAvailableException
*
- * @expectedException \OCP\Files\StorageNotAvailableException
*/
public function testAvailableThrowStorageNotAvailable() {
+ $this->expectException(\OCP\Files\StorageNotAvailableException::class);
+
$this->storage->expects($this->once())
->method('getAvailability')
->willReturn(['available' => true, 'last_checked' => 0]);
@@ -146,9 +148,10 @@ class AvailabilityTest extends \Test\TestCase {
* Storage available, but throws exception
* Standard exception does not indicate storage unavailability
*
- * @expectedException \Exception
*/
public function testAvailableThrow() {
+ $this->expectException(\Exception::class);
+
$this->storage->expects($this->once())
->method('getAvailability')
->willReturn(['available' => true, 'last_checked' => 0]);
diff --git a/tests/lib/Files/Storage/Wrapper/EncodingTest.php b/tests/lib/Files/Storage/Wrapper/EncodingTest.php
index 24bf10eb789..9060ca2dac3 100644
--- a/tests/lib/Files/Storage/Wrapper/EncodingTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncodingTest.php
@@ -18,7 +18,7 @@ class EncodingTest extends \Test\Files\Storage\Storage {
*/
private $sourceStorage;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->sourceStorage = new \OC\Files\Storage\Temporary([]);
$this->instance = new \OC\Files\Storage\Wrapper\Encoding([
@@ -26,7 +26,7 @@ class EncodingTest extends \Test\Files\Storage\Storage {
]);
}
- public function tearDown() {
+ protected function tearDown(): void {
$this->sourceStorage->cleanUp();
parent::tearDown();
}
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index 70d94ab16e6..95ee0ada24f 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -108,7 +108,7 @@ class EncryptionTest extends Storage {
/** @var integer dummy unencrypted size */
private $dummySize = -1;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
@@ -284,13 +284,17 @@ class EncryptionTest extends Storage {
->method('getCache')
->with($path)
->willReturn($fileEntry);
- $fileEntry->expects($this->any())
- ->method('get')
- ->with($metaData['fileid']);
+ if ($metaData !== null) {
+ $fileEntry->expects($this->any())
+ ->method('get')
+ ->with($metaData['fileid']);
+ }
$this->instance->expects($this->any())->method('getCache')->willReturn($cache);
- $this->instance->expects($this->any())->method('verifyUnencryptedSize')
- ->with($path, 0)->willReturn($expected['size']);
+ if ($expected !== null) {
+ $this->instance->expects($this->any())->method('verifyUnencryptedSize')
+ ->with($path, 0)->willReturn($expected['size']);
+ }
$result = $this->instance->getMetaData($path);
if(isset($expected['encrypted'])) {
@@ -300,7 +304,12 @@ class EncryptionTest extends Storage {
$this->assertSame($expected['encryptedVersion'], $result['encryptedVersion']);
}
}
- $this->assertSame($expected['size'], $result['size']);
+
+ if ($expected !== null) {
+ $this->assertSame($expected['size'], $result['size']);
+ } else {
+ $this->assertSame(null, $result);
+ }
}
public function dataTestGetMetaData() {
diff --git a/tests/lib/Files/Storage/Wrapper/JailTest.php b/tests/lib/Files/Storage/Wrapper/JailTest.php
index b03eb0bcc63..cb7003cb7ea 100644
--- a/tests/lib/Files/Storage/Wrapper/JailTest.php
+++ b/tests/lib/Files/Storage/Wrapper/JailTest.php
@@ -15,7 +15,7 @@ class JailTest extends \Test\Files\Storage\Storage {
*/
private $sourceStorage;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->sourceStorage = new \OC\Files\Storage\Temporary(array());
$this->sourceStorage->mkdir('foo');
@@ -25,7 +25,7 @@ class JailTest extends \Test\Files\Storage\Storage {
));
}
- public function tearDown() {
+ protected function tearDown(): void {
// test that nothing outside our jail is touched
$contents = array();
$dh = $this->sourceStorage->opendir('');
diff --git a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php
index 388272b4107..bfdd3d3ddbb 100644
--- a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php
+++ b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php
@@ -22,13 +22,13 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage {
*/
private $sourceStorage;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->sourceStorage = new \OC\Files\Storage\Temporary(array());
$this->instance = $this->getMaskedStorage(Constants::PERMISSION_ALL);
}
- public function tearDown() {
+ protected function tearDown(): void {
$this->sourceStorage->cleanUp();
parent::tearDown();
}
diff --git a/tests/lib/Files/Storage/Wrapper/QuotaTest.php b/tests/lib/Files/Storage/Wrapper/QuotaTest.php
index 0b80467fcc4..0061ca3910e 100644
--- a/tests/lib/Files/Storage/Wrapper/QuotaTest.php
+++ b/tests/lib/Files/Storage/Wrapper/QuotaTest.php
@@ -27,7 +27,7 @@ class QuotaTest extends \Test\Files\Storage\Storage {
*/
private $tmpDir;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
@@ -35,7 +35,7 @@ class QuotaTest extends \Test\Files\Storage\Storage {
$this->instance = new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => 10000000));
}
- protected function tearDown() {
+ protected function tearDown(): void {
\OC_Helper::rmdirr($this->tmpDir);
parent::tearDown();
}
diff --git a/tests/lib/Files/Storage/Wrapper/WrapperTest.php b/tests/lib/Files/Storage/Wrapper/WrapperTest.php
index 942ff27fc35..2477b361bc1 100644
--- a/tests/lib/Files/Storage/Wrapper/WrapperTest.php
+++ b/tests/lib/Files/Storage/Wrapper/WrapperTest.php
@@ -14,7 +14,7 @@ class WrapperTest extends \Test\Files\Storage\Storage {
*/
private $tmpDir;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
@@ -22,7 +22,7 @@ class WrapperTest extends \Test\Files\Storage\Storage {
$this->instance = new \OC\Files\Storage\Wrapper\Wrapper(array('storage' => $storage));
}
- protected function tearDown() {
+ protected function tearDown(): void {
\OC_Helper::rmdirr($this->tmpDir);
parent::tearDown();
}
diff --git a/tests/lib/Files/Type/DetectionTest.php b/tests/lib/Files/Type/DetectionTest.php
index 1d01a96fcc0..e522239f001 100644
--- a/tests/lib/Files/Type/DetectionTest.php
+++ b/tests/lib/Files/Type/DetectionTest.php
@@ -28,7 +28,7 @@ class DetectionTest extends \Test\TestCase {
/** @var Detection */
private $detection;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->detection = new Detection(
\OC::$server->getURLGenerator(),
diff --git a/tests/lib/Files/Type/LoaderTest.php b/tests/lib/Files/Type/LoaderTest.php
index cf6aa31a047..a99c80dac47 100644
--- a/tests/lib/Files/Type/LoaderTest.php
+++ b/tests/lib/Files/Type/LoaderTest.php
@@ -30,12 +30,12 @@ class LoaderTest extends \Test\TestCase {
/** @var Loader */
protected $loader;
- protected function setUp() {
+ protected function setUp(): void {
$this->db = \OC::$server->getDatabaseConnection();
$this->loader = new Loader($this->db);
}
- protected function tearDown() {
+ protected function tearDown(): void {
$deleteMimetypes = $this->db->getQueryBuilder();
$deleteMimetypes->delete('mimetypes')
->where($deleteMimetypes->expr()->like(
diff --git a/tests/lib/Files/Utils/ScannerTest.php b/tests/lib/Files/Utils/ScannerTest.php
index 8748b52f0ca..4af252735f6 100644
--- a/tests/lib/Files/Utils/ScannerTest.php
+++ b/tests/lib/Files/Utils/ScannerTest.php
@@ -47,7 +47,7 @@ class ScannerTest extends \Test\TestCase {
*/
private $userBackend;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userBackend = new \Test\Util\User\Dummy();
@@ -55,7 +55,7 @@ class ScannerTest extends \Test\TestCase {
$this->loginAsUser();
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->logout();
\OC::$server->getUserManager()->removeBackend($this->userBackend);
parent::tearDown();
@@ -157,11 +157,12 @@ class ScannerTest extends \Test\TestCase {
/**
* @dataProvider invalidPathProvider
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Invalid path to scan
* @param string $invalidPath
*/
public function testInvalidPathScanning($invalidPath) {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Invalid path to scan');
+
$scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), \OC::$server->getLogger());
$scanner->scan($invalidPath);
}
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index c154c28e24a..57050059375 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -85,7 +85,7 @@ class ViewTest extends \Test\TestCase {
/** @var \OC\Files\Storage\Storage */
private $tempStorage;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
\OC_Hook::clear();
@@ -109,7 +109,7 @@ class ViewTest extends \Test\TestCase {
$this->tempStorage = null;
}
- protected function tearDown() {
+ protected function tearDown(): void {
\OC_User::setUserId($this->user);
foreach ($this->storages as $storage) {
$cache = $storage->getCache();
@@ -242,10 +242,10 @@ class ViewTest extends \Test\TestCase {
$this->assertEquals('/foo.txt', $folderView->getPath($id2));
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- */
+
public function testGetPathNotExisting() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+
$storage1 = $this->getTestStorage();
Filesystem::mount($storage1, [], '/');
@@ -1049,9 +1049,10 @@ class ViewTest extends \Test\TestCase {
/**
* @dataProvider tooLongPathDataProvider
- * @expectedException \OCP\Files\InvalidPathException
*/
public function testTooLongPath($operation, $param0 = null) {
+ $this->expectException(\OCP\Files\InvalidPathException::class);
+
$longPath = '';
// 4000 is the maximum path length in file_cache.path
@@ -1242,10 +1243,11 @@ class ViewTest extends \Test\TestCase {
/**
* @dataProvider directoryTraversalProvider
- * @expectedException \Exception
* @param string $root
*/
public function testConstructDirectoryTraversalException($root) {
+ $this->expectException(\Exception::class);
+
new View($root);
}
@@ -1289,17 +1291,16 @@ class ViewTest extends \Test\TestCase {
$this->assertNull($view->getRelativePath(null));
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testNullAsRoot() {
+ $this->expectException(\InvalidArgumentException::class);
+
new View(null);
}
/**
* e.g. reading from a folder that's being renamed
*
- * @expectedException \OCP\Lock\LockedException
*
* @dataProvider dataLockPaths
*
@@ -1307,6 +1308,8 @@ class ViewTest extends \Test\TestCase {
* @param string $pathPrefix
*/
public function testReadFromWriteLockedPath($rootPath, $pathPrefix) {
+ $this->expectException(\OCP\Lock\LockedException::class);
+
$rootPath = str_replace('{folder}', 'files', $rootPath);
$pathPrefix = str_replace('{folder}', 'files', $pathPrefix);
@@ -1339,7 +1342,6 @@ class ViewTest extends \Test\TestCase {
/**
* e.g. writing a file that's being downloaded
*
- * @expectedException \OCP\Lock\LockedException
*
* @dataProvider dataLockPaths
*
@@ -1347,6 +1349,8 @@ class ViewTest extends \Test\TestCase {
* @param string $pathPrefix
*/
public function testWriteToReadLockedFile($rootPath, $pathPrefix) {
+ $this->expectException(\OCP\Lock\LockedException::class);
+
$rootPath = str_replace('{folder}', 'files', $rootPath);
$pathPrefix = str_replace('{folder}', 'files', $pathPrefix);
@@ -1507,11 +1511,12 @@ class ViewTest extends \Test\TestCase {
/**
* @dataProvider pathRelativeToFilesProviderExceptionCases
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage $absolutePath must be relative to "files"
* @param string $path
*/
public function testGetPathRelativeToFilesWithInvalidArgument($path) {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('$absolutePath must be relative to "files"');
+
$view = new View();
$view->getPathRelativeToFiles($path);
}
@@ -2141,9 +2146,10 @@ class ViewTest extends \Test\TestCase {
* simulate a failed copy operation.
* We expect that we catch the exception, free the lock and re-throw it.
*
- * @expectedException \Exception
*/
public function testLockFileCopyException() {
+ $this->expectException(\Exception::class);
+
$view = new View('/' . $this->user . '/files/');
/** @var Temporary|\PHPUnit_Framework_MockObject_MockObject $storage */
diff --git a/tests/lib/GlobalScale/ConfigTest.php b/tests/lib/GlobalScale/ConfigTest.php
index ab5ef351fc0..5aaed1ed5bd 100644
--- a/tests/lib/GlobalScale/ConfigTest.php
+++ b/tests/lib/GlobalScale/ConfigTest.php
@@ -31,7 +31,7 @@ class ConfigTest extends TestCase {
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
private $config;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/tests/lib/Group/DatabaseTest.php b/tests/lib/Group/DatabaseTest.php
index 395a442c5e3..4af8b1cd430 100644
--- a/tests/lib/Group/DatabaseTest.php
+++ b/tests/lib/Group/DatabaseTest.php
@@ -45,12 +45,12 @@ class DatabaseTest extends Backend {
return $name;
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->backend = new \OC\Group\Database();
}
- protected function tearDown() {
+ protected function tearDown(): void {
foreach ($this->groups as $group) {
$this->backend->deleteGroup($group);
}
diff --git a/tests/lib/Group/Dummy.php b/tests/lib/Group/Dummy.php
index 5504cd63a0a..3be04159938 100644
--- a/tests/lib/Group/Dummy.php
+++ b/tests/lib/Group/Dummy.php
@@ -28,7 +28,7 @@ namespace Test\Group;
* @group DB
*/
class Dummy extends Backend {
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->backend=new \Test\Util\Group\Dummy();
}
diff --git a/tests/lib/Group/GroupTest.php b/tests/lib/Group/GroupTest.php
index 5ab7a645081..61e4b39c8f3 100644
--- a/tests/lib/Group/GroupTest.php
+++ b/tests/lib/Group/GroupTest.php
@@ -21,7 +21,7 @@ class GroupTest extends \Test\TestCase {
/** @var EventDispatcherInterface|MockObject */
protected $dispatcher;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
}
diff --git a/tests/lib/Group/ManagerTest.php b/tests/lib/Group/ManagerTest.php
index 3069f9d148b..d5f8baa3fa1 100644
--- a/tests/lib/Group/ManagerTest.php
+++ b/tests/lib/Group/ManagerTest.php
@@ -40,7 +40,7 @@ class ManagerTest extends TestCase {
/** @var ILogger|MockObject */
protected $logger;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(Manager::class);
@@ -409,7 +409,7 @@ class ManagerTest extends TestCase {
$this->assertCount(2, $groups);
foreach ($groups as $group) {
- $this->assertInternalType('string', $group);
+ $this->assertIsString($group);
}
}
diff --git a/tests/lib/Group/MetaDataTest.php b/tests/lib/Group/MetaDataTest.php
index c24155aef37..4332a6f036f 100644
--- a/tests/lib/Group/MetaDataTest.php
+++ b/tests/lib/Group/MetaDataTest.php
@@ -34,7 +34,7 @@ class MetaDataTest extends \Test\TestCase {
/** @var bool */
private $isAdmin = true;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->groupManager = $this->getMockBuilder('\OC\Group\Manager')
->disableOriginalConstructor()
diff --git a/tests/lib/HelperStorageTest.php b/tests/lib/HelperStorageTest.php
index dacd73a4f01..7b2fb665733 100644
--- a/tests/lib/HelperStorageTest.php
+++ b/tests/lib/HelperStorageTest.php
@@ -22,7 +22,7 @@ class HelperStorageTest extends \Test\TestCase {
/** @var \OC\Files\Storage\Storage */
private $storage;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->user = $this->getUniqueID('user_');
@@ -38,7 +38,7 @@ class HelperStorageTest extends \Test\TestCase {
$this->storageMock = null;
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->user = null;
if ($this->storageMock) {
diff --git a/tests/lib/Hooks/BasicEmitterTest.php b/tests/lib/Hooks/BasicEmitterTest.php
index 7b71bb8259e..1f88dee1032 100644
--- a/tests/lib/Hooks/BasicEmitterTest.php
+++ b/tests/lib/Hooks/BasicEmitterTest.php
@@ -37,7 +37,7 @@ class BasicEmitterTest extends \Test\TestCase {
*/
protected $emitter;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->emitter = new DummyEmitter();
}
@@ -50,28 +50,28 @@ class BasicEmitterTest extends \Test\TestCase {
throw new EmittedException;
}
- /**
- * @expectedException \Test\Hooks\EmittedException
- */
+
public function testAnonymousFunction() {
+ $this->expectException(\Test\Hooks\EmittedException::class);
+
$this->emitter->listen('Test', 'test', function () {
throw new EmittedException;
});
$this->emitter->emitEvent('Test', 'test');
}
- /**
- * @expectedException \Test\Hooks\EmittedException
- */
+
public function testStaticCallback() {
+ $this->expectException(\Test\Hooks\EmittedException::class);
+
$this->emitter->listen('Test', 'test', array('\Test\Hooks\BasicEmitterTest', 'staticCallBack'));
$this->emitter->emitEvent('Test', 'test');
}
- /**
- * @expectedException \Test\Hooks\EmittedException
- */
+
public function testNonStaticCallback() {
+ $this->expectException(\Test\Hooks\EmittedException::class);
+
$this->emitter->listen('Test', 'test', array($this, 'nonStaticCallBack'));
$this->emitter->emitEvent('Test', 'test');
}
@@ -125,10 +125,10 @@ class BasicEmitterTest extends \Test\TestCase {
$this->assertEquals(2, $count, 'Listener called an invalid number of times (' . $count . ') expected 2');
}
- /**
- * @expectedException \Test\Hooks\EmittedException
- */
+
public function testArguments() {
+ $this->expectException(\Test\Hooks\EmittedException::class);
+
$this->emitter->listen('Test', 'test', function ($foo, $bar) {
if ($foo == 'foo' and $bar == 'bar') {
throw new EmittedException;
@@ -137,10 +137,10 @@ class BasicEmitterTest extends \Test\TestCase {
$this->emitter->emitEvent('Test', 'test', array('foo', 'bar'));
}
- /**
- * @expectedException \Test\Hooks\EmittedException
- */
+
public function testNamedArguments() {
+ $this->expectException(\Test\Hooks\EmittedException::class);
+
$this->emitter->listen('Test', 'test', function ($foo, $bar) {
if ($foo == 'foo' and $bar == 'bar') {
throw new EmittedException;
@@ -216,10 +216,10 @@ class BasicEmitterTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @expectedException \Test\Hooks\EmittedException
- */
+
public function testRemoveKeepOtherCallback() {
+ $this->expectException(\Test\Hooks\EmittedException::class);
+
$listener1 = function () {
throw new EmittedException;
};
@@ -234,10 +234,10 @@ class BasicEmitterTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @expectedException \Test\Hooks\EmittedException
- */
+
public function testRemoveKeepOtherMethod() {
+ $this->expectException(\Test\Hooks\EmittedException::class);
+
$listener = function () {
throw new EmittedException;
};
@@ -249,10 +249,10 @@ class BasicEmitterTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @expectedException \Test\Hooks\EmittedException
- */
+
public function testRemoveKeepOtherScope() {
+ $this->expectException(\Test\Hooks\EmittedException::class);
+
$listener = function () {
throw new EmittedException;
};
@@ -264,10 +264,10 @@ class BasicEmitterTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @expectedException \Test\Hooks\EmittedException
- */
+
public function testRemoveNonExistingName() {
+ $this->expectException(\Test\Hooks\EmittedException::class);
+
$listener = function () {
throw new EmittedException;
};
diff --git a/tests/lib/Hooks/LegacyEmitterTest.php b/tests/lib/Hooks/LegacyEmitterTest.php
index 60a29f23245..32c923d8013 100644
--- a/tests/lib/Hooks/LegacyEmitterTest.php
+++ b/tests/lib/Hooks/LegacyEmitterTest.php
@@ -26,7 +26,7 @@ class LegacyEmitterTest extends BasicEmitterTest {
//we can't use exceptions here since OC_Hooks catches all exceptions
private static $emitted = false;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->emitter = new DummyLegacyEmitter();
diff --git a/tests/lib/Http/Client/ClientTest.php b/tests/lib/Http/Client/ClientTest.php
index 5c0693732bc..2a7bd6a185d 100644
--- a/tests/lib/Http/Client/ClientTest.php
+++ b/tests/lib/Http/Client/ClientTest.php
@@ -29,7 +29,7 @@ class ClientTest extends \Test\TestCase {
/** @var array */
private $defaultRequestOptions;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->guzzleClient = $this->getMockBuilder(\GuzzleHttp\Client::class)
diff --git a/tests/lib/Http/Client/ResponseTest.php b/tests/lib/Http/Client/ResponseTest.php
index f62563a95e9..963a3eb8179 100644
--- a/tests/lib/Http/Client/ResponseTest.php
+++ b/tests/lib/Http/Client/ResponseTest.php
@@ -19,7 +19,7 @@ class ResponseTest extends \Test\TestCase {
/** @var GuzzleResponse */
private $guzzleResponse;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->guzzleResponse = new GuzzleResponse(1337);
}
diff --git a/tests/lib/ImageTest.php b/tests/lib/ImageTest.php
index 8f37d9814f0..34fcf0e004d 100644
--- a/tests/lib/ImageTest.php
+++ b/tests/lib/ImageTest.php
@@ -12,7 +12,7 @@ use OC;
use OCP\IConfig;
class ImageTest extends \Test\TestCase {
- public static function tearDownAfterClass() {
+ public static function tearDownAfterClass(): void {
@unlink(OC::$SERVERROOT.'/tests/data/testimage2.png');
@unlink(OC::$SERVERROOT.'/tests/data/testimage2.jpg');
diff --git a/tests/lib/InitialStateServiceTest.php b/tests/lib/InitialStateServiceTest.php
index 08bff615e3e..2a97f07ac21 100644
--- a/tests/lib/InitialStateServiceTest.php
+++ b/tests/lib/InitialStateServiceTest.php
@@ -36,7 +36,7 @@ class InitialStateServiceTest extends TestCase {
/** @var InitialStateService */
private $service;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->service = new InitialStateService(
diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php
index 9fb813aaac6..fd21a1ae082 100644
--- a/tests/lib/InstallerTest.php
+++ b/tests/lib/InstallerTest.php
@@ -40,7 +40,7 @@ class InstallerTest extends TestCase {
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
private $config;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->appFetcher = $this->createMock(AppFetcher::class);
@@ -72,7 +72,7 @@ class InstallerTest extends TestCase {
);
}
- protected function tearDown() {
+ protected function tearDown(): void {
$installer = new Installer(
\OC::$server->getAppFetcher(),
\OC::$server->getHTTPClientService(),
@@ -159,11 +159,11 @@ class InstallerTest extends TestCase {
$this->assertSame($updateAvailable, $installer->isUpdateAvailable('files'), 'Cached result should be returned and fetcher should be only called once');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Certificate "4112" has been revoked
- */
+
public function testDownloadAppWithRevokedCertificate() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Certificate "4112" has been revoked');
+
$appArray = [
[
'id' => 'news',
@@ -203,11 +203,11 @@ gLgK8d8sKL60JMmKHN3boHrsThKBVA==
$installer->downloadApp('news');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage App with id news has a certificate not issued by a trusted Code Signing Authority
- */
+
public function testDownloadAppWithNotNextcloudCertificate() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('App with id news has a certificate not issued by a trusted Code Signing Authority');
+
$appArray = [
[
'id' => 'news',
@@ -246,11 +246,11 @@ YSu356M=
$installer->downloadApp('news');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage App with id news has a cert issued to passman
- */
+
public function testDownloadAppWithDifferentCN() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('App with id news has a cert issued to passman');
+
$appArray = [
[
'id' => 'news',
@@ -289,11 +289,11 @@ u/spPSSVhaun5BA1FlphB2TkgnzlCmxJa63nFY045e/Jq+IKMcqqZl/092gbI2EQ
$installer->downloadApp('news');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage App with id passman has invalid signature
- */
+
public function testDownloadAppWithInvalidSignature() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('App with id passman has invalid signature');
+
$appArray = [
[
'id' => 'passman',
@@ -357,11 +357,11 @@ u/spPSSVhaun5BA1FlphB2TkgnzlCmxJa63nFY045e/Jq+IKMcqqZl/092gbI2EQ
$installer->downloadApp('passman');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Extracted app testapp has more than 1 folder
- */
+
public function testDownloadAppWithMoreThanOneFolderDownloaded() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Extracted app testapp has more than 1 folder');
+
$appArray = [
[
'id' => 'testapp',
@@ -441,11 +441,11 @@ YwDVP+QmNRzx72jtqAN/Kc3CvQ9nkgYhU65B95aX0xA=',
$installer->downloadApp('testapp');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage App for id testapp has a wrong app ID in info.xml: testapp1
- */
+
public function testDownloadAppWithMismatchingIdentifier() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('App for id testapp has a wrong app ID in info.xml: testapp1');
+
$appArray = [
[
'id' => 'testapp',
@@ -606,11 +606,11 @@ MPLX6f5V9tCJtlH6ztmEcDROfvuVc0U3rEhqx2hphoyo+MZrPFpdcJL8KkIdMKbY
$this->assertEquals('0.9', \OC_App::getAppVersionByPath(__DIR__ . '/../../apps/testapp/'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage App for id testapp has version 0.9 and tried to update to lower version 0.8
- */
+
public function testDownloadAppWithDowngrade() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('App for id testapp has version 0.9 and tried to update to lower version 0.8');
+
$appArray = [
[
'id' => 'testapp',
diff --git a/tests/lib/IntegrityCheck/CheckerTest.php b/tests/lib/IntegrityCheck/CheckerTest.php
index febd9f56622..586a42ff547 100644
--- a/tests/lib/IntegrityCheck/CheckerTest.php
+++ b/tests/lib/IntegrityCheck/CheckerTest.php
@@ -51,7 +51,7 @@ class CheckerTest extends TestCase {
/** @var \OC\Files\Type\Detection|\PHPUnit_Framework_MockObject_MockObject */
private $mimeTypeDetector;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->environmentHelper = $this->createMock(EnvironmentHelper::class);
$this->fileAccessHelper = $this->createMock(FileAccessHelper::class);
@@ -82,11 +82,11 @@ class CheckerTest extends TestCase {
);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Exception message
- */
+
public function testWriteAppSignatureOfNotExistingApp() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Exception message');
+
$this->fileAccessHelper
->expects($this->at(0))
->method('assertDirectoryExists')
@@ -107,11 +107,11 @@ class CheckerTest extends TestCase {
$this->checker->writeAppSignature('NotExistingApp', $x509, $rsa);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessageRegExp /[a-zA-Z\/_-]+ is not writable/
- */
+
public function testWriteAppSignatureWrongPermissions() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessageRegExp('/[a-zA-Z\\/_-]+ is not writable/');
+
$this->fileAccessHelper
->expects($this->once())
->method('file_put_contents')
@@ -480,11 +480,11 @@ class CheckerTest extends TestCase {
$this->assertSame([], $this->checker->verifyAppSignature('SomeApp'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Exception message
- */
+
public function testWriteCoreSignatureWithException() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Exception message');
+
$this->fileAccessHelper
->expects($this->at(0))
->method('assertDirectoryExists')
@@ -504,11 +504,11 @@ class CheckerTest extends TestCase {
$this->checker->writeCoreSignature($x509, $rsa, __DIR__);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessageRegExp /[a-zA-Z\/_-]+ is not writable/
- */
+
public function testWriteCoreSignatureWrongPermissions() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessageRegExp('/[a-zA-Z\\/_-]+ is not writable/');
+
$this->fileAccessHelper
->expects($this->at(0))
->method('assertDirectoryExists')
diff --git a/tests/lib/IntegrityCheck/Helpers/AppLocatorTest.php b/tests/lib/IntegrityCheck/Helpers/AppLocatorTest.php
index d0083298b22..cf5899b663b 100644
--- a/tests/lib/IntegrityCheck/Helpers/AppLocatorTest.php
+++ b/tests/lib/IntegrityCheck/Helpers/AppLocatorTest.php
@@ -28,7 +28,7 @@ class AppLocatorTest extends TestCase {
/** @var AppLocator */
private $locator;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->locator = new AppLocator();
}
@@ -37,11 +37,11 @@ class AppLocatorTest extends TestCase {
$this->assertSame(\OC_App::getAppPath('files'), $this->locator->getAppPath('files'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage App not found
- */
+
public function testGetAppPathNotExistentApp() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('App not found');
+
$this->locator->getAppPath('aTotallyNotExistingApp');
}
diff --git a/tests/lib/IntegrityCheck/Helpers/EnvironmentHelperTest.php b/tests/lib/IntegrityCheck/Helpers/EnvironmentHelperTest.php
index 9dc9214a779..767cdf3aaab 100644
--- a/tests/lib/IntegrityCheck/Helpers/EnvironmentHelperTest.php
+++ b/tests/lib/IntegrityCheck/Helpers/EnvironmentHelperTest.php
@@ -28,9 +28,9 @@ class EnvironmentHelperTest extends TestCase {
/** @var EnvironmentHelper */
private $environmentHelper;
- public function setUp() {
+ protected function setUp(): void {
$this->environmentHelper = new EnvironmentHelper();
- return parent::setUp();
+ parent::setUp();
}
public function testGetServerRoot() {
diff --git a/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php b/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php
index f2ac46555f5..c4d724a3654 100644
--- a/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php
+++ b/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php
@@ -28,7 +28,7 @@ class FileAccessHelperTest extends TestCase {
/** @var FileAccessHelper */
private $fileAccessHelper;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->fileAccessHelper = new FileAccessHelper();
}
@@ -42,11 +42,11 @@ class FileAccessHelperTest extends TestCase {
$this->assertSame($data, $this->fileAccessHelper->file_get_contents($filePath));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Failed to write into /anabsolutelynotexistingfolder/on/the/system.txt
- */
+
public function testFile_put_contentsWithException() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Failed to write into /anabsolutelynotexistingfolder/on/the/system.txt');
+
$this->fileAccessHelper->file_put_contents('/anabsolutelynotexistingfolder/on/the/system.txt', 'MyFiles');
}
@@ -55,11 +55,11 @@ class FileAccessHelperTest extends TestCase {
$this->assertTrue($this->fileAccessHelper->is_writable(\OC::$server->getTempManager()->getTemporaryFile('MyFile')));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Directory /anabsolutelynotexistingfolder/on/the/system does not exist.
- */
+
public function testAssertDirectoryExistsWithException() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Directory /anabsolutelynotexistingfolder/on/the/system does not exist.');
+
$this->fileAccessHelper->assertDirectoryExists('/anabsolutelynotexistingfolder/on/the/system');
}
diff --git a/tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php b/tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php
index 735a5e2d19a..370b50a56e2 100644
--- a/tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php
+++ b/tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php
@@ -28,7 +28,7 @@ class ExcludeFileByNameFilterIteratorTest extends TestCase {
/** @var ExcludeFileByNameFilterIterator|\PHPUnit\Framework\MockObject\MockObject */
protected $filter;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->filter = $this->getMockBuilder(ExcludeFileByNameFilterIterator::class)
->disableOriginalConstructor()
diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php
index 6b9bd053568..c75bfba5b99 100644
--- a/tests/lib/L10N/FactoryTest.php
+++ b/tests/lib/L10N/FactoryTest.php
@@ -36,7 +36,7 @@ class FactoryTest extends TestCase {
/** @var string */
protected $serverRoot;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)
diff --git a/tests/lib/L10N/LanguageIteratorTest.php b/tests/lib/L10N/LanguageIteratorTest.php
index c8b1b24685f..9223db716f4 100644
--- a/tests/lib/L10N/LanguageIteratorTest.php
+++ b/tests/lib/L10N/LanguageIteratorTest.php
@@ -36,7 +36,7 @@ class LanguageIteratorTest extends TestCase {
/** @var LanguageIterator */
protected $iterator;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->user = $this->createMock(IUser::class);
diff --git a/tests/lib/LargeFileHelperGetFileSizeTest.php b/tests/lib/LargeFileHelperGetFileSizeTest.php
index b2735d7f619..530615f46b4 100644
--- a/tests/lib/LargeFileHelperGetFileSizeTest.php
+++ b/tests/lib/LargeFileHelperGetFileSizeTest.php
@@ -20,7 +20,7 @@ class LargeFileHelperGetFileSizeTest extends TestCase {
/** @var \OC\LargeFileHelper */
protected $helper;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->helper = new \OC\LargeFileHelper();
}
@@ -37,7 +37,7 @@ class LargeFileHelperGetFileSizeTest extends TestCase {
/**
* @dataProvider dataFileNameProvider
*/
- public function testGetFileSizeViaCurl($filename, $fileSize) {
+ public function XtestGetFileSizeViaCurl($filename, $fileSize) {
if (!extension_loaded('curl')) {
$this->markTestSkipped(
'The PHP curl extension is required for this test.'
diff --git a/tests/lib/LargeFileHelperTest.php b/tests/lib/LargeFileHelperTest.php
index 7d155ff8b44..3cc9d13d74c 100644
--- a/tests/lib/LargeFileHelperTest.php
+++ b/tests/lib/LargeFileHelperTest.php
@@ -11,7 +11,7 @@ namespace Test;
class LargeFileHelperTest extends TestCase {
protected $helper;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->helper = new \OC\LargeFileHelper;
}
@@ -37,10 +37,10 @@ class LargeFileHelperTest extends TestCase {
);
}
- /**
- * @expectedException \UnexpectedValueException
- */
+
public function testFormatUnsignedIntegerStringException() {
+ $this->expectException(\UnexpectedValueException::class);
+
$this->helper->formatUnsignedInteger('900ABCD254740993');
}
}
diff --git a/tests/lib/LegacyHelperTest.php b/tests/lib/LegacyHelperTest.php
index 96cd190fd62..21d5dbc8bab 100644
--- a/tests/lib/LegacyHelperTest.php
+++ b/tests/lib/LegacyHelperTest.php
@@ -15,11 +15,11 @@ class LegacyHelperTest extends \Test\TestCase {
/** @var string */
private $originalWebRoot;
- public function setUp() {
+ protected function setUp(): void {
$this->originalWebRoot = \OC::$WEBROOT;
}
- public function tearDown() {
+ protected function tearDown(): void {
// Reset webRoot
\OC::$WEBROOT = $this->originalWebRoot;
}
diff --git a/tests/lib/Lock/DBLockingProviderTest.php b/tests/lib/Lock/DBLockingProviderTest.php
index e8419815e31..73a7b6c3f83 100644
--- a/tests/lib/Lock/DBLockingProviderTest.php
+++ b/tests/lib/Lock/DBLockingProviderTest.php
@@ -49,7 +49,7 @@ class DBLockingProviderTest extends LockingProvider {
protected $currentTime;
- public function setUp() {
+ protected function setUp(): void {
$this->currentTime = time();
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->timeFactory->expects($this->any())
@@ -68,7 +68,7 @@ class DBLockingProviderTest extends LockingProvider {
return new \OC\Lock\DBLockingProvider($this->connection, \OC::$server->getLogger(), $this->timeFactory, 3600);
}
- public function tearDown() {
+ protected function tearDown(): void {
$this->connection->executeQuery('DELETE FROM `*PREFIX*file_locks`');
parent::tearDown();
}
diff --git a/tests/lib/Lock/LockingProvider.php b/tests/lib/Lock/LockingProvider.php
index 9c0461e2e60..93eba367af2 100644
--- a/tests/lib/Lock/LockingProvider.php
+++ b/tests/lib/Lock/LockingProvider.php
@@ -36,7 +36,7 @@ abstract class LockingProvider extends TestCase {
*/
abstract protected function getInstance();
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->instance = $this->getInstance();
}
@@ -73,10 +73,10 @@ abstract class LockingProvider extends TestCase {
$this->assertFalse($this->instance->isLocked('foo', ILockingProvider::LOCK_SHARED));
}
- /**
- * @expectedException \OCP\Lock\LockedException
- */
+
public function testDoubleExclusiveLock() {
+ $this->expectException(\OCP\Lock\LockedException::class);
+
$this->instance->acquireLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
$this->assertTrue($this->instance->isLocked('foo', ILockingProvider::LOCK_EXCLUSIVE));
$this->instance->acquireLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
@@ -90,10 +90,10 @@ abstract class LockingProvider extends TestCase {
$this->instance->acquireLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
}
- /**
- * @expectedException \OCP\Lock\LockedException
- */
+
public function testExclusiveLockAfterShared() {
+ $this->expectException(\OCP\Lock\LockedException::class);
+
$this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
$this->assertTrue($this->instance->isLocked('foo', ILockingProvider::LOCK_SHARED));
$this->instance->acquireLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
@@ -164,10 +164,10 @@ abstract class LockingProvider extends TestCase {
}
- /**
- * @expectedException \OCP\Lock\LockedException
- */
+
public function testSharedLockAfterExclusive() {
+ $this->expectException(\OCP\Lock\LockedException::class);
+
$this->instance->acquireLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
$this->assertTrue($this->instance->isLocked('foo', ILockingProvider::LOCK_EXCLUSIVE));
$this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
@@ -175,7 +175,10 @@ abstract class LockingProvider extends TestCase {
public function testLockedExceptionHasPathForShared() {
try {
- $this->testSharedLockAfterExclusive();
+ $this->instance->acquireLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
+ $this->assertTrue($this->instance->isLocked('foo', ILockingProvider::LOCK_EXCLUSIVE));
+ $this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
+
$this->fail('Expected locked exception');
} catch (LockedException $e) {
$this->assertEquals('foo', $e->getPath());
@@ -184,7 +187,10 @@ abstract class LockingProvider extends TestCase {
public function testLockedExceptionHasPathForExclusive() {
try {
- $this->testExclusiveLockAfterShared();
+ $this->instance->acquireLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
+ $this->assertTrue($this->instance->isLocked('foo', ILockingProvider::LOCK_EXCLUSIVE));
+ $this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
+
$this->fail('Expected locked exception');
} catch (LockedException $e) {
$this->assertEquals('foo', $e->getPath());
@@ -205,41 +211,41 @@ abstract class LockingProvider extends TestCase {
$this->assertTrue($this->instance->isLocked('foo', ILockingProvider::LOCK_SHARED));
}
- /**
- * @expectedException \OCP\Lock\LockedException
- */
+
public function testChangeLockToExclusiveDoubleShared() {
+ $this->expectException(\OCP\Lock\LockedException::class);
+
$this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
$this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
$this->instance->changeLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
}
- /**
- * @expectedException \OCP\Lock\LockedException
- */
+
public function testChangeLockToExclusiveNoShared() {
+ $this->expectException(\OCP\Lock\LockedException::class);
+
$this->instance->changeLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
}
- /**
- * @expectedException \OCP\Lock\LockedException
- */
+
public function testChangeLockToExclusiveFromExclusive() {
+ $this->expectException(\OCP\Lock\LockedException::class);
+
$this->instance->acquireLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
$this->instance->changeLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
}
- /**
- * @expectedException \OCP\Lock\LockedException
- */
+
public function testChangeLockToSharedNoExclusive() {
+ $this->expectException(\OCP\Lock\LockedException::class);
+
$this->instance->changeLock('foo', ILockingProvider::LOCK_SHARED);
}
- /**
- * @expectedException \OCP\Lock\LockedException
- */
+
public function testChangeLockToSharedFromShared() {
+ $this->expectException(\OCP\Lock\LockedException::class);
+
$this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
$this->instance->changeLock('foo', ILockingProvider::LOCK_SHARED);
}
diff --git a/tests/lib/Lock/MemcacheLockingProviderTest.php b/tests/lib/Lock/MemcacheLockingProviderTest.php
index baf99dbb2bb..7b7c649c886 100644
--- a/tests/lib/Lock/MemcacheLockingProviderTest.php
+++ b/tests/lib/Lock/MemcacheLockingProviderTest.php
@@ -38,7 +38,7 @@ class MemcacheLockingProviderTest extends LockingProvider {
return new \OC\Lock\MemcacheLockingProvider($this->memcache);
}
- public function tearDown() {
+ protected function tearDown(): void {
$this->memcache->clear();
parent::tearDown();
}
diff --git a/tests/lib/Lockdown/Filesystem/NoFSTest.php b/tests/lib/Lockdown/Filesystem/NoFSTest.php
index a0900ad769d..28bdb08c4a4 100644
--- a/tests/lib/Lockdown/Filesystem/NoFSTest.php
+++ b/tests/lib/Lockdown/Filesystem/NoFSTest.php
@@ -34,16 +34,16 @@ use Test\Traits\UserTrait;
class NoFSTest extends \Test\TestCase {
use UserTrait;
- public function tearDown() {
+ protected function tearDown(): void {
$token = new DefaultToken();
$token->setScope([
'filesystem' => true
]);
\OC::$server->getLockdownManager()->setToken($token);
- return parent::tearDown();
+ parent::tearDown();
}
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$token = new DefaultToken();
$token->setScope([
diff --git a/tests/lib/Lockdown/Filesystem/NullCacheTest.php b/tests/lib/Lockdown/Filesystem/NullCacheTest.php
index 7773241fca1..67d44c430f5 100644
--- a/tests/lib/Lockdown/Filesystem/NullCacheTest.php
+++ b/tests/lib/Lockdown/Filesystem/NullCacheTest.php
@@ -34,7 +34,7 @@ class NulLCacheTest extends \Test\TestCase {
/** @var NullCache */
private $cache;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->cache = new NullCache();
diff --git a/tests/lib/Lockdown/Filesystem/NullStorageTest.php b/tests/lib/Lockdown/Filesystem/NullStorageTest.php
index a8e2d8d6ba4..5bdf3b44ba0 100644
--- a/tests/lib/Lockdown/Filesystem/NullStorageTest.php
+++ b/tests/lib/Lockdown/Filesystem/NullStorageTest.php
@@ -36,7 +36,7 @@ class NullStorageTest extends TestCase {
/** @var NullStorage */
private $storage;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->storage = new NullStorage([]);
diff --git a/tests/lib/Lockdown/LockdownManagerTest.php b/tests/lib/Lockdown/LockdownManagerTest.php
index 1d206dbf409..7b52994d381 100644
--- a/tests/lib/Lockdown/LockdownManagerTest.php
+++ b/tests/lib/Lockdown/LockdownManagerTest.php
@@ -29,7 +29,7 @@ use Test\TestCase;
class LockdownManagerTest extends TestCase {
private $sessionCallback;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->sessionCallback = function() {
diff --git a/tests/lib/Log/FileTest.php b/tests/lib/Log/FileTest.php
index c2c3a4ff68b..0bbcdc0a23c 100644
--- a/tests/lib/Log/FileTest.php
+++ b/tests/lib/Log/FileTest.php
@@ -32,7 +32,7 @@ class FileTest extends TestCase
/** @var File */
protected $logFile;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$config = \OC::$server->getSystemConfig();
$this->restore_logfile = $config->getValue("logfile");
@@ -41,7 +41,7 @@ class FileTest extends TestCase
$config->setValue("logfile", $config->getValue('datadirectory') . "/logtest.log");
$this->logFile = new File($config->getValue('datadirectory') . '/logtest.log', '', $config);
}
- protected function tearDown() {
+ protected function tearDown(): void {
$config = \OC::$server->getSystemConfig();
if (isset($this->restore_logfile)) {
$config->getValue("logfile", $this->restore_logfile);
diff --git a/tests/lib/Log/LogFactoryTest.php b/tests/lib/Log/LogFactoryTest.php
index ea6b12436e6..37dbf1d97b8 100644
--- a/tests/lib/Log/LogFactoryTest.php
+++ b/tests/lib/Log/LogFactoryTest.php
@@ -48,7 +48,7 @@ class LogFactoryTest extends TestCase {
/** @var SystemConfig|\PHPUnit_Framework_MockObject_MockObject */
protected $systemConfig;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->c = $this->createMock(IServerContainer::class);
diff --git a/tests/lib/LoggerTest.php b/tests/lib/LoggerTest.php
index 83cb87b8733..b8e45d09c63 100644
--- a/tests/lib/LoggerTest.php
+++ b/tests/lib/LoggerTest.php
@@ -26,7 +26,7 @@ class LoggerTest extends TestCase implements IWriter {
/** @var array */
private $logs = [];
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->logs = [];
@@ -73,7 +73,6 @@ class LoggerTest extends TestCase implements IWriter {
public function userAndPasswordData() {
return [
- ['abc', 'def'],
['mySpecialUsername', 'MySuperSecretPassword'],
['my-user', '324324()#ä234'],
['my-user', ')qwer'],
diff --git a/tests/lib/Mail/EMailTemplateTest.php b/tests/lib/Mail/EMailTemplateTest.php
index d4687c44b06..d48826ff5c5 100644
--- a/tests/lib/Mail/EMailTemplateTest.php
+++ b/tests/lib/Mail/EMailTemplateTest.php
@@ -39,7 +39,7 @@ class EMailTemplateTest extends TestCase {
/** @var EMailTemplate */
private $emailTemplate;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->defaults = $this->createMock(Defaults::class);
diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php
index 1913cc1176c..3a08cd9acf2 100644
--- a/tests/lib/Mail/MailerTest.php
+++ b/tests/lib/Mail/MailerTest.php
@@ -31,7 +31,7 @@ class MailerTest extends TestCase {
/** @var Mailer */
private $mailer;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
@@ -126,10 +126,10 @@ class MailerTest extends TestCase {
$this->assertInstanceOf('\OC\Mail\Message', $this->mailer->createMessage());
}
- /**
- * @expectedException \Exception
- */
+
public function testSendInvalidMailException() {
+ $this->expectException(\Exception::class);
+
$message = $this->getMockBuilder('\OC\Mail\Message')
->disableOriginalConstructor()->getMock();
$message->expects($this->once())
diff --git a/tests/lib/Mail/MessageTest.php b/tests/lib/Mail/MessageTest.php
index 4b656938e48..e0a0f468a50 100644
--- a/tests/lib/Mail/MessageTest.php
+++ b/tests/lib/Mail/MessageTest.php
@@ -31,7 +31,7 @@ class MessageTest extends TestCase {
);
}
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->swiftMessage = $this->getMockBuilder('\Swift_Message')
diff --git a/tests/lib/Memcache/APCuTest.php b/tests/lib/Memcache/APCuTest.php
index 41de75a8ea8..199acbe263b 100644
--- a/tests/lib/Memcache/APCuTest.php
+++ b/tests/lib/Memcache/APCuTest.php
@@ -10,7 +10,7 @@
namespace Test\Memcache;
class APCuTest extends Cache {
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
if(!\OC\Memcache\APCu::isAvailable()) {
diff --git a/tests/lib/Memcache/ArrayCacheTest.php b/tests/lib/Memcache/ArrayCacheTest.php
index 3ae8c116a01..4e3623d344d 100644
--- a/tests/lib/Memcache/ArrayCacheTest.php
+++ b/tests/lib/Memcache/ArrayCacheTest.php
@@ -10,7 +10,7 @@
namespace Test\Memcache;
class ArrayCacheTest extends Cache {
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->instance = new \OC\Memcache\ArrayCache('');
}
diff --git a/tests/lib/Memcache/Cache.php b/tests/lib/Memcache/Cache.php
index 8d6a231dd8d..ab316738c9c 100644
--- a/tests/lib/Memcache/Cache.php
+++ b/tests/lib/Memcache/Cache.php
@@ -123,7 +123,7 @@ abstract class Cache extends \Test\Cache\TestCache {
}
- protected function tearDown() {
+ protected function tearDown(): void {
if ($this->instance) {
$this->instance->clear();
}
diff --git a/tests/lib/Memcache/FactoryTest.php b/tests/lib/Memcache/FactoryTest.php
index 971b22d69b2..cf4da7839c4 100644
--- a/tests/lib/Memcache/FactoryTest.php
+++ b/tests/lib/Memcache/FactoryTest.php
@@ -127,9 +127,10 @@ class FactoryTest extends \Test\TestCase {
/**
* @dataProvider cacheUnavailableProvider
- * @expectedException \OC\HintException
*/
public function testCacheNotAvailableException($localCache, $distributedCache) {
+ $this->expectException(\OC\HintException::class);
+
$logger = $this->getMockBuilder(ILogger::class)->getMock();
new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache);
}
diff --git a/tests/lib/Memcache/MemcachedTest.php b/tests/lib/Memcache/MemcachedTest.php
index 865d8594bbb..96b88992665 100644
--- a/tests/lib/Memcache/MemcachedTest.php
+++ b/tests/lib/Memcache/MemcachedTest.php
@@ -10,7 +10,7 @@
namespace Test\Memcache;
class MemcachedTest extends Cache {
- static public function setUpBeforeClass() {
+ static public function setUpBeforeClass(): void {
parent::setUpBeforeClass();
if (!\OC\Memcache\Memcached::isAvailable()) {
@@ -22,7 +22,7 @@ class MemcachedTest extends Cache {
}
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->instance = new \OC\Memcache\Memcached($this->getUniqueID());
}
diff --git a/tests/lib/Memcache/RedisTest.php b/tests/lib/Memcache/RedisTest.php
index 6a0a82f6aa7..e6a940599d7 100644
--- a/tests/lib/Memcache/RedisTest.php
+++ b/tests/lib/Memcache/RedisTest.php
@@ -10,13 +10,17 @@
namespace Test\Memcache;
class RedisTest extends Cache {
- static public function setUpBeforeClass() {
+ static public function setUpBeforeClass(): void {
parent::setUpBeforeClass();
if (!\OC\Memcache\Redis::isAvailable()) {
self::markTestSkipped('The redis extension is not available.');
}
+ if (\OC::$server->getConfig()->getSystemValue('redis', []) === []) {
+ self::markTestSkipped('Redis not configured in config.php');
+ }
+
$errorOccurred = false;
set_error_handler(
function($errno, $errstr) {
@@ -44,7 +48,7 @@ class RedisTest extends Cache {
}
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->instance = new \OC\Memcache\Redis($this->getUniqueID());
}
diff --git a/tests/lib/Migration/BackgroundRepairTest.php b/tests/lib/Migration/BackgroundRepairTest.php
index df81fd45772..8c467d58269 100644
--- a/tests/lib/Migration/BackgroundRepairTest.php
+++ b/tests/lib/Migration/BackgroundRepairTest.php
@@ -68,7 +68,7 @@ class BackgroundRepairTest extends TestCase {
/** @var EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject $dispatcher */
private $dispatcher;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->jobList = $this->getMockBuilder('OC\BackgroundJob\JobList')
diff --git a/tests/lib/NavigationManagerTest.php b/tests/lib/NavigationManagerTest.php
index acf08088784..74cb3948c5e 100644
--- a/tests/lib/NavigationManagerTest.php
+++ b/tests/lib/NavigationManagerTest.php
@@ -41,7 +41,7 @@ class NavigationManagerTest extends TestCase {
/** @var \OC\NavigationManager */
protected $navigationManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->appManager = $this->createMock(AppManager::class);
diff --git a/tests/lib/Notification/ActionTest.php b/tests/lib/Notification/ActionTest.php
index 9160ea7a7c3..1923f2305e1 100644
--- a/tests/lib/Notification/ActionTest.php
+++ b/tests/lib/Notification/ActionTest.php
@@ -30,7 +30,7 @@ class ActionTest extends TestCase {
/** @var IAction */
protected $action;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->action = new Action();
}
@@ -64,9 +64,10 @@ class ActionTest extends TestCase {
* @dataProvider dataSetLabelInvalid
* @param mixed $label
*
- * @expectedException \InvalidArgumentException
*/
public function testSetLabelInvalid($label) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->action->setLabel($label);
}
@@ -98,9 +99,10 @@ class ActionTest extends TestCase {
* @dataProvider dataSetParsedLabelInvalid
* @param mixed $label
*
- * @expectedException \InvalidArgumentException
*/
public function testSetParsedLabelInvalid($label) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->action->setParsedLabel($label);
}
@@ -141,9 +143,10 @@ class ActionTest extends TestCase {
* @param mixed $link
* @param mixed $type
*
- * @expectedException \InvalidArgumentException
*/
public function testSetLinkInvalid($link, $type) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->action->setLink($link, $type);
}
diff --git a/tests/lib/Notification/ManagerTest.php b/tests/lib/Notification/ManagerTest.php
index 259ac0beefe..6ca83b4b367 100644
--- a/tests/lib/Notification/ManagerTest.php
+++ b/tests/lib/Notification/ManagerTest.php
@@ -40,7 +40,7 @@ class ManagerTest extends TestCase {
/** @var ILogger|MockObject */
protected $logger;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->validator = $this->createMock(IValidator::class);
$this->logger = $this->createMock(ILogger::class);
@@ -119,10 +119,10 @@ class ManagerTest extends TestCase {
$manager->notify($notification);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testNotifyInvalid() {
+ $this->expectException(\InvalidArgumentException::class);
+
/** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
$notification = $this->getMockBuilder(INotification::class)
->disableOriginalConstructor()
diff --git a/tests/lib/Notification/NotificationTest.php b/tests/lib/Notification/NotificationTest.php
index d72c9f62ae0..c70fa1ec7df 100644
--- a/tests/lib/Notification/NotificationTest.php
+++ b/tests/lib/Notification/NotificationTest.php
@@ -35,7 +35,7 @@ class NotificationTest extends TestCase {
/** @var IValidator|\PHPUnit_Framework_MockObject_MockObject */
protected $validator;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->validator = $this->createMock(IValidator::class);
$this->notification = new Notification($this->validator);
@@ -85,9 +85,10 @@ class NotificationTest extends TestCase {
* @dataProvider dataSetAppInvalid
* @param mixed $app
*
- * @expectedException \InvalidArgumentException
*/
public function testSetAppInvalid($app) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->notification->setApp($app);
}
@@ -114,9 +115,10 @@ class NotificationTest extends TestCase {
* @dataProvider dataSetUserInvalid
* @param mixed $user
*
- * @expectedException \InvalidArgumentException
*/
public function testSetUserInvalid($user) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->notification->setUser($user);
}
@@ -156,10 +158,11 @@ class NotificationTest extends TestCase {
* @dataProvider dataSetDateTimeZero
* @param \DateTime $dateTime
*
- * @expectedException \InvalidArgumentException
* @expectedMessage 'The given date time is invalid'
*/
public function testSetDateTimeZero($dateTime) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->notification->setDateTime($dateTime);
}
@@ -198,10 +201,11 @@ class NotificationTest extends TestCase {
* @dataProvider dataSetObjectIdInvalid
* @param mixed $id
*
- * @expectedException \InvalidArgumentException
* @expectedMessage 'The given object id is invalid'
*/
public function testSetObjectIdInvalid($id) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->notification->setObject('object', $id);
}
@@ -234,9 +238,10 @@ class NotificationTest extends TestCase {
* @dataProvider dataSetSubjectInvalidSubject
* @param mixed $subject
*
- * @expectedException \InvalidArgumentException
*/
public function testSetSubjectInvalidSubject($subject) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->notification->setSubject($subject, []);
}
@@ -262,9 +267,10 @@ class NotificationTest extends TestCase {
* @dataProvider dataSetParsedSubjectInvalid
* @param mixed $subject
*
- * @expectedException \InvalidArgumentException
*/
public function testSetParsedSubjectInvalid($subject) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->notification->setParsedSubject($subject);
}
@@ -297,9 +303,10 @@ class NotificationTest extends TestCase {
* @dataProvider dataSetMessageInvalidMessage
* @param mixed $message
*
- * @expectedException \InvalidArgumentException
*/
public function testSetMessageInvalidMessage($message) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->notification->setMessage($message, []);
}
@@ -325,9 +332,10 @@ class NotificationTest extends TestCase {
* @dataProvider dataSetParsedMessageInvalid
* @param mixed $message
*
- * @expectedException \InvalidArgumentException
*/
public function testSetParsedMessageInvalid($message) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->notification->setParsedMessage($message);
}
@@ -353,9 +361,10 @@ class NotificationTest extends TestCase {
* @dataProvider dataSetLinkInvalid
* @param mixed $link
*
- * @expectedException \InvalidArgumentException
*/
public function testSetLinkInvalid($link) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->notification->setLink($link);
}
@@ -381,9 +390,10 @@ class NotificationTest extends TestCase {
* @dataProvider dataSetIconInvalid
* @param mixed $icon
*
- * @expectedException \InvalidArgumentException
*/
public function testSetIconInvalid($icon) {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->notification->setIcon($icon);
}
@@ -407,10 +417,10 @@ class NotificationTest extends TestCase {
$this->assertEquals([], $this->notification->getParsedActions());
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testAddActionInvalid() {
+ $this->expectException(\InvalidArgumentException::class);
+
/** @var \OCP\Notification\IAction|\PHPUnit_Framework_MockObject_MockObject $action */
$action = $this->createMock(IAction::class);
$action->expects($this->once())
@@ -453,10 +463,10 @@ class NotificationTest extends TestCase {
$this->assertEquals([], $this->notification->getActions());
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testAddParsedActionInvalid() {
+ $this->expectException(\InvalidArgumentException::class);
+
/** @var \OCP\Notification\IAction|\PHPUnit_Framework_MockObject_MockObject $action */
$action = $this->createMock(IAction::class);
$action->expects($this->once())
diff --git a/tests/lib/OCS/DiscoveryServiceTest.php b/tests/lib/OCS/DiscoveryServiceTest.php
index f8ec68f6f55..710d683841f 100644
--- a/tests/lib/OCS/DiscoveryServiceTest.php
+++ b/tests/lib/OCS/DiscoveryServiceTest.php
@@ -39,7 +39,7 @@ class DiscoveryServiceTest extends TestCase {
/** @var IDiscoveryService */
private $discoveryService;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->cacheFactory = $this->getMockBuilder(ICacheFactory::class)->getMock();
diff --git a/tests/lib/OCS/ProviderTest.php b/tests/lib/OCS/ProviderTest.php
index 9444544d12a..7ee802e54fb 100644
--- a/tests/lib/OCS/ProviderTest.php
+++ b/tests/lib/OCS/ProviderTest.php
@@ -31,7 +31,7 @@ class ProviderTest extends \Test\TestCase {
/** @var Provider */
private $ocsProvider;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->getMockBuilder('\\OCP\\IRequest')->getMock();
diff --git a/tests/lib/Preview/BackgroundCleanupJobTest.php b/tests/lib/Preview/BackgroundCleanupJobTest.php
index b33d75c6aa6..09c4a16f87a 100644
--- a/tests/lib/Preview/BackgroundCleanupJobTest.php
+++ b/tests/lib/Preview/BackgroundCleanupJobTest.php
@@ -61,7 +61,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase {
/** @var IRootFolder */
private $rootFolder;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->userId = $this->getUniqueID();
@@ -87,7 +87,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase {
$this->rootFolder = \OC::$server->getRootFolder();
}
- public function tearDown() {
+ protected function tearDown(): void {
if ($this->trashEnabled) {
$appManager = \OC::$server->getAppManager();
$appManager->enableApp('files_trashbin');
@@ -95,7 +95,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase {
$this->logout();
- return parent::tearDown();
+ parent::tearDown();
}
private function setup11Previews(): array {
diff --git a/tests/lib/Preview/BitmapTest.php b/tests/lib/Preview/BitmapTest.php
index 32d6ce896e4..952f72b276a 100644
--- a/tests/lib/Preview/BitmapTest.php
+++ b/tests/lib/Preview/BitmapTest.php
@@ -30,7 +30,7 @@ namespace Test\Preview;
*/
class BitmapTest extends Provider {
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$fileName = 'testimage.eps';
diff --git a/tests/lib/Preview/GeneratorTest.php b/tests/lib/Preview/GeneratorTest.php
index c7fe1ea5f8a..cfb78a05da5 100644
--- a/tests/lib/Preview/GeneratorTest.php
+++ b/tests/lib/Preview/GeneratorTest.php
@@ -58,7 +58,7 @@ class GeneratorTest extends \Test\TestCase {
/** @var Generator */
private $generator;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/tests/lib/Preview/HEICTest.php b/tests/lib/Preview/HEICTest.php
index a3cc37d24fb..f75ae3192a1 100644
--- a/tests/lib/Preview/HEICTest.php
+++ b/tests/lib/Preview/HEICTest.php
@@ -30,7 +30,7 @@ namespace Test\Preview;
*/
class HEICTest extends Provider {
- public function setUp() {
+ protected function setUp(): void {
if ( !in_array("HEIC", \Imagick::queryFormats("HEI*")) ) {
$this->markTestSkipped('ImageMagick is not HEIC aware. Skipping tests');
} else {
diff --git a/tests/lib/Preview/ImageTest.php b/tests/lib/Preview/ImageTest.php
index a55433a2682..40267538804 100644
--- a/tests/lib/Preview/ImageTest.php
+++ b/tests/lib/Preview/ImageTest.php
@@ -30,7 +30,7 @@ namespace Test\Preview;
*/
class ImageTest extends Provider {
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$fileName = 'testimage.jpg';
diff --git a/tests/lib/Preview/MP3Test.php b/tests/lib/Preview/MP3Test.php
index 576eea20b8b..15915ac2578 100644
--- a/tests/lib/Preview/MP3Test.php
+++ b/tests/lib/Preview/MP3Test.php
@@ -30,7 +30,7 @@ namespace Test\Preview;
*/
class MP3Test extends Provider {
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$fileName = 'testimage.mp3';
diff --git a/tests/lib/Preview/MovieTest.php b/tests/lib/Preview/MovieTest.php
index 0c174a40ca6..2415102a83d 100644
--- a/tests/lib/Preview/MovieTest.php
+++ b/tests/lib/Preview/MovieTest.php
@@ -30,7 +30,7 @@ namespace Test\Preview;
*/
class MovieTest extends Provider {
- public function setUp() {
+ protected function setUp(): void {
$avconvBinary = \OC_Helper::findBinaryPath('avconv');
$ffmpegBinary = ($avconvBinary) ? null : \OC_Helper::findBinaryPath('ffmpeg');
diff --git a/tests/lib/Preview/OfficeTest.php b/tests/lib/Preview/OfficeTest.php
index 15d66352c18..555b3f77747 100644
--- a/tests/lib/Preview/OfficeTest.php
+++ b/tests/lib/Preview/OfficeTest.php
@@ -30,7 +30,7 @@ namespace Test\Preview;
*/
class OfficeTest extends Provider {
- public function setUp() {
+ protected function setUp(): void {
$libreofficeBinary = \OC_Helper::findBinaryPath('libreoffice');
$openofficeBinary = ($libreofficeBinary) ? null : \OC_Helper::findBinaryPath('openoffice');
diff --git a/tests/lib/Preview/Provider.php b/tests/lib/Preview/Provider.php
index 2050b3f56b4..761f6b7f83f 100644
--- a/tests/lib/Preview/Provider.php
+++ b/tests/lib/Preview/Provider.php
@@ -46,7 +46,7 @@ abstract class Provider extends \Test\TestCase {
/** @var \OC\Files\Storage\Storage */
protected $storage;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$userManager = \OC::$server->getUserManager();
@@ -68,7 +68,7 @@ abstract class Provider extends \Test\TestCase {
$this->userId = $userId;
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->logout();
parent::tearDown();
diff --git a/tests/lib/Preview/SVGTest.php b/tests/lib/Preview/SVGTest.php
index 39bf3f1dfc9..73ccbc0b136 100644
--- a/tests/lib/Preview/SVGTest.php
+++ b/tests/lib/Preview/SVGTest.php
@@ -30,7 +30,7 @@ namespace Test\Preview;
*/
class SVGTest extends Provider {
- public function setUp() {
+ protected function setUp(): void {
$checkImagick = new \Imagick();
if (count($checkImagick->queryFormats('SVG')) === 1) {
parent::setUp();
diff --git a/tests/lib/Preview/TXTTest.php b/tests/lib/Preview/TXTTest.php
index dfa0b920e16..e4c6e76c47f 100644
--- a/tests/lib/Preview/TXTTest.php
+++ b/tests/lib/Preview/TXTTest.php
@@ -30,7 +30,7 @@ namespace Test\Preview;
*/
class TXTTest extends Provider {
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$fileName = 'lorem-big.txt';
diff --git a/tests/lib/Remote/Api/OCSTest.php b/tests/lib/Remote/Api/OCSTest.php
index 5bdc0c21a9c..43e7c61a4cd 100644
--- a/tests/lib/Remote/Api/OCSTest.php
+++ b/tests/lib/Remote/Api/OCSTest.php
@@ -35,7 +35,7 @@ class OCSTest extends TestCase {
/** @var IInstanceFactory */
private $instanceFactory;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->instanceFactory = new InstanceFactory(new ArrayCache(), $this->getClientService());
@@ -67,11 +67,11 @@ class OCSTest extends TestCase {
$this->assertEquals('user', $user->getUserId());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Invalid user response, expected field email not found
- */
+
public function testGetUserInvalidResponse() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Invalid user response, expected field email not found');
+
$client = $this->getOCSClient();
$this->expectGetRequest($this->getOCSUrl('cloud/users/user'),
@@ -81,10 +81,10 @@ class OCSTest extends TestCase {
$client->getUser('user');
}
- /**
- * @expectedException \OC\ForbiddenException
- */
+
public function testInvalidPassword() {
+ $this->expectException(\OC\ForbiddenException::class);
+
$client = $this->getOCSClient();
$this->expectGetRequest($this->getOCSUrl('cloud/users/user'),
diff --git a/tests/lib/Remote/InstanceTest.php b/tests/lib/Remote/InstanceTest.php
index 9fc4cfc0177..0adb608d875 100644
--- a/tests/lib/Remote/InstanceTest.php
+++ b/tests/lib/Remote/InstanceTest.php
@@ -34,7 +34,7 @@ class InstanceTest extends TestCase {
/** @var ICache */
private $cache;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->cache = new ArrayCache();
@@ -73,11 +73,11 @@ class InstanceTest extends TestCase {
$this->assertEquals(false, $instance2->isActive());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage refusing to connect to remote instance(example.com) over http that was previously accessible over https
- */
+
public function testPreventDowngradeAttach() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('refusing to connect to remote instance(example.com) over http that was previously accessible over https');
+
$instance = new Instance('example.com', $this->cache, $this->getClientService());
$this->expectGetRequest('https://example.com/status.php', '{"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"13.0.0.5","versionstring":"13.0.0 alpha","edition":"","productname":"Nextcloud"}');
diff --git a/tests/lib/Repair/CleanTagsTest.php b/tests/lib/Repair/CleanTagsTest.php
index 58fc6af6efb..5ff13beba76 100644
--- a/tests/lib/Repair/CleanTagsTest.php
+++ b/tests/lib/Repair/CleanTagsTest.php
@@ -35,7 +35,7 @@ class CleanTagsTest extends \Test\TestCase {
/** @var IOutput */
private $outputMock;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->outputMock = $this->getMockBuilder('\OCP\Migration\IOutput')
@@ -51,7 +51,7 @@ class CleanTagsTest extends \Test\TestCase {
$this->cleanUpTables();
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->cleanUpTables();
parent::tearDown();
diff --git a/tests/lib/Repair/ClearFrontendCachesTest.php b/tests/lib/Repair/ClearFrontendCachesTest.php
index 7c3a54cf1db..ea33d331c4d 100644
--- a/tests/lib/Repair/ClearFrontendCachesTest.php
+++ b/tests/lib/Repair/ClearFrontendCachesTest.php
@@ -45,7 +45,7 @@ class ClearFrontendCachesTest extends \Test\TestCase {
/** @var IOutput */
private $outputMock;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->outputMock = $this->createMock(IOutput::class);
diff --git a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php b/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php
index e52fcbe7c21..218a59caa3b 100644
--- a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php
+++ b/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php
@@ -42,7 +42,7 @@ class ClearGeneratedAvatarCacheTest extends \Test\TestCase {
/** @var ClearGeneratedAvatarCache */
protected $repair;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->outputMock = $this->createMock(IOutput::class);
diff --git a/tests/lib/Repair/NC11/FixMountStoragesTest.php b/tests/lib/Repair/NC11/FixMountStoragesTest.php
index fe1b75cac9b..1d5af18a8a3 100644
--- a/tests/lib/Repair/NC11/FixMountStoragesTest.php
+++ b/tests/lib/Repair/NC11/FixMountStoragesTest.php
@@ -43,7 +43,7 @@ class FixMountStoragesTest extends TestCase {
/** @var FixMountStorages */
private $repair;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->db = \OC::$server->getDatabaseConnection();
diff --git a/tests/lib/Repair/OldGroupMembershipSharesTest.php b/tests/lib/Repair/OldGroupMembershipSharesTest.php
index cc04a80eef9..331a86d01d0 100644
--- a/tests/lib/Repair/OldGroupMembershipSharesTest.php
+++ b/tests/lib/Repair/OldGroupMembershipSharesTest.php
@@ -30,7 +30,7 @@ class OldGroupMembershipSharesTest extends \Test\TestCase {
/** @var \OCP\IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
protected $groupManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
/** \OCP\IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
@@ -42,7 +42,7 @@ class OldGroupMembershipSharesTest extends \Test\TestCase {
$this->deleteAllShares();
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->deleteAllShares();
parent::tearDown();
diff --git a/tests/lib/Repair/RepairCollationTest.php b/tests/lib/Repair/RepairCollationTest.php
index d84f689cc52..62471fbbe3a 100644
--- a/tests/lib/Repair/RepairCollationTest.php
+++ b/tests/lib/Repair/RepairCollationTest.php
@@ -58,7 +58,7 @@ class RepairCollationTest extends TestCase {
/** @var ILogger */
private $logger;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -75,7 +75,7 @@ class RepairCollationTest extends TestCase {
$this->repair = new TestCollationRepair($this->config, $this->logger, $this->connection, false);
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->connection->getSchemaManager()->dropTable($this->tableName);
parent::tearDown();
}
diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php
index f28d6807d6a..1baaf89e0a0 100644
--- a/tests/lib/Repair/RepairInvalidSharesTest.php
+++ b/tests/lib/Repair/RepairInvalidSharesTest.php
@@ -31,7 +31,7 @@ class RepairInvalidSharesTest extends TestCase {
/** @var \OCP\IDBConnection */
private $connection;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$config = $this->getMockBuilder(IConfig::class)
@@ -49,7 +49,7 @@ class RepairInvalidSharesTest extends TestCase {
$this->repair = new RepairInvalidShares($config, $this->connection);
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->deleteAllShares();
parent::tearDown();
diff --git a/tests/lib/Repair/RepairMimeTypesTest.php b/tests/lib/Repair/RepairMimeTypesTest.php
index 6579c3213c4..013e170cc9d 100644
--- a/tests/lib/Repair/RepairMimeTypesTest.php
+++ b/tests/lib/Repair/RepairMimeTypesTest.php
@@ -33,7 +33,7 @@ class RepairMimeTypesTest extends \Test\TestCase {
/** @var IMimeTypeLoader */
private $mimetypeLoader;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->savedMimetypeLoader = \OC::$server->getMimeTypeLoader();
@@ -53,7 +53,7 @@ class RepairMimeTypesTest extends \Test\TestCase {
$this->repair = new \OC\Repair\RepairMimeTypes($config);
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->storage->getCache()->clear();
$qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
diff --git a/tests/lib/Repair/RepairSqliteAutoincrementTest.php b/tests/lib/Repair/RepairSqliteAutoincrementTest.php
index 22186283779..c7008179a0d 100644
--- a/tests/lib/Repair/RepairSqliteAutoincrementTest.php
+++ b/tests/lib/Repair/RepairSqliteAutoincrementTest.php
@@ -36,7 +36,7 @@ class RepairSqliteAutoincrementTest extends \Test\TestCase {
*/
private $config;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -52,7 +52,7 @@ class RepairSqliteAutoincrementTest extends \Test\TestCase {
$this->repair = new \OC\Repair\SqliteAutoincrement($this->connection);
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->connection->getSchemaManager()->dropTable($this->tableName);
parent::tearDown();
}
diff --git a/tests/lib/RepairStepTest.php b/tests/lib/RepairStepTest.php
index 1ec28de8768..433a161e8fa 100644
--- a/tests/lib/RepairStepTest.php
+++ b/tests/lib/RepairStepTest.php
@@ -39,7 +39,7 @@ class RepairTest extends TestCase {
/** @var string[] */
private $outputArray;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$dispatcher = new EventDispatcher();
$this->repair = new \OC\Repair([], $dispatcher);
diff --git a/tests/lib/RichObjectStrings/DefinitionsTest.php b/tests/lib/RichObjectStrings/DefinitionsTest.php
index e0d400bff2c..829689704e7 100644
--- a/tests/lib/RichObjectStrings/DefinitionsTest.php
+++ b/tests/lib/RichObjectStrings/DefinitionsTest.php
@@ -36,11 +36,11 @@ class DefinitionsTest extends TestCase {
return $testsuite;
}
- /**
- * @expectedException \OCP\RichObjectStrings\InvalidObjectExeption
- * @expectedExceptionMessage Object type is undefined
- */
+
public function testGetDefinitionNotExisting() {
+ $this->expectException(\OCP\RichObjectStrings\InvalidObjectExeption::class);
+ $this->expectExceptionMessage('Object type is undefined');
+
$definitions = new Definitions();
$definitions->getDefinition('NotExistingType');
}
diff --git a/tests/lib/Security/Bruteforce/CapabilitiesTest.php b/tests/lib/Security/Bruteforce/CapabilitiesTest.php
index e9b998c7bc8..60873236e44 100644
--- a/tests/lib/Security/Bruteforce/CapabilitiesTest.php
+++ b/tests/lib/Security/Bruteforce/CapabilitiesTest.php
@@ -36,7 +36,7 @@ class CapabilitiesTest extends TestCase {
/** @var Throttler|\PHPUnit_Framework_MockObject_MockObject */
private $throttler;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/tests/lib/Security/Bruteforce/ThrottlerTest.php b/tests/lib/Security/Bruteforce/ThrottlerTest.php
index e68ae70e152..048540fb5a5 100644
--- a/tests/lib/Security/Bruteforce/ThrottlerTest.php
+++ b/tests/lib/Security/Bruteforce/ThrottlerTest.php
@@ -44,7 +44,7 @@ class ThrottlerTest extends TestCase {
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
private $config;
- public function setUp() {
+ protected function setUp(): void {
$this->dbConnection = $this->createMock(IDBConnection::class);
$this->logger = $this->createMock(ILogger::class);
$this->config = $this->createMock(IConfig::class);
diff --git a/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php b/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php
index 7ee7350c661..009613fbe32 100644
--- a/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php
+++ b/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php
@@ -37,7 +37,7 @@ class ContentSecurityPolicyManagerTest extends TestCase {
/** @var ContentSecurityPolicyManager */
private $contentSecurityPolicyManager;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->dispatcher = \OC::$server->query(IEventDispatcher::class);
$this->contentSecurityPolicyManager = new ContentSecurityPolicyManager($this->dispatcher);
diff --git a/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php b/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php
index 705a0b22db8..346ace943d9 100644
--- a/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php
+++ b/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php
@@ -35,7 +35,7 @@ class ContentSecurityPolicyNonceManagerTest extends TestCase {
/** @var ContentSecurityPolicyNonceManager */
private $nonceManager;
- public function setUp() {
+ protected function setUp(): void {
$this->csrfTokenManager = $this->createMock(CsrfTokenManager::class);
$this->request = $this->createMock(Request::class);
$this->nonceManager = new ContentSecurityPolicyNonceManager(
diff --git a/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php b/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php
index 424f620b619..5ab15c73bf2 100644
--- a/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php
+++ b/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php
@@ -27,7 +27,7 @@ class CsrfTokenGeneratorTest extends \Test\TestCase {
/** @var \OC\Security\CSRF\CsrfTokenGenerator */
private $csrfTokenGenerator;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->random = $this->getMockBuilder('\OCP\Security\ISecureRandom')
->disableOriginalConstructor()->getMock();
diff --git a/tests/lib/Security/CSRF/CsrfTokenManagerTest.php b/tests/lib/Security/CSRF/CsrfTokenManagerTest.php
index f9dd8127e5a..29fbbfe3b26 100644
--- a/tests/lib/Security/CSRF/CsrfTokenManagerTest.php
+++ b/tests/lib/Security/CSRF/CsrfTokenManagerTest.php
@@ -29,7 +29,7 @@ class CsrfTokenManagerTest extends \Test\TestCase {
/** @var \OC\Security\CSRF\TokenStorage\SessionStorage */
private $storageInterface;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->tokenGenerator = $this->getMockBuilder('\OC\Security\CSRF\CsrfTokenGenerator')
->disableOriginalConstructor()->getMock();
diff --git a/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php b/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php
index 92a6557f8e3..8d4a966efea 100644
--- a/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php
+++ b/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php
@@ -29,7 +29,7 @@ class SessionStorageTest extends \Test\TestCase {
/** @var \OC\Security\CSRF\TokenStorage\SessionStorage */
private $sessionStorage;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->session = $this->getMockBuilder(ISession::class)
->disableOriginalConstructor()->getMock();
@@ -54,10 +54,11 @@ class SessionStorageTest extends \Test\TestCase {
* @param string $token
* @dataProvider getTokenDataProvider
*
- * @expectedException \Exception
- * @expectedExceptionMessage Session does not contain a requesttoken
*/
public function testGetTokenWithEmptyToken($token) {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Session does not contain a requesttoken');
+
$this->session
->expects($this->once())
->method('get')
diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php
index 04da057a14c..136c3160413 100644
--- a/tests/lib/Security/CertificateManagerTest.php
+++ b/tests/lib/Security/CertificateManagerTest.php
@@ -31,7 +31,7 @@ class CertificateManagerTest extends \Test\TestCase {
/** @var ISecureRandom */
private $random;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->username = $this->getUniqueID('', 20);
@@ -62,7 +62,7 @@ class CertificateManagerTest extends \Test\TestCase {
);
}
- protected function tearDown() {
+ protected function tearDown(): void {
$user = \OC::$server->getUserManager()->get($this->username);
if ($user !== null) {
$user->delete();
@@ -93,11 +93,11 @@ class CertificateManagerTest extends \Test\TestCase {
$this->assertEqualsArrays($certificateStore, $this->certificateManager->listCertificates());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Certificate could not get parsed.
- */
+
function testAddInvalidCertificate() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Certificate could not get parsed.');
+
$this->certificateManager->addCertificate('InvalidCertificate', 'invalidCertificate');
}
@@ -113,12 +113,13 @@ class CertificateManagerTest extends \Test\TestCase {
}
/**
- * @expectedException \Exception
- * @expectedExceptionMessage Filename is not valid
* @dataProvider dangerousFileProvider
* @param string $filename
*/
function testAddDangerousFile($filename) {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Filename is not valid');
+
$this->certificateManager->addCertificate(file_get_contents(__DIR__ . '/../../data/certificates/expiredCertificate.crt'), $filename);
}
diff --git a/tests/lib/Security/CertificateTest.php b/tests/lib/Security/CertificateTest.php
index 21d1dab4ab8..986554cf967 100644
--- a/tests/lib/Security/CertificateTest.php
+++ b/tests/lib/Security/CertificateTest.php
@@ -32,7 +32,7 @@ class CertificateTest extends \Test\TestCase {
/** @var Certificate That contains an expired certificate */
protected $expiredCertificate;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$goodCertificate = file_get_contents(__DIR__ . '/../../data/certificates/goodCertificate.crt');
@@ -43,20 +43,20 @@ class CertificateTest extends \Test\TestCase {
$this->expiredCertificate = new Certificate($expiredCertificate, 'ExpiredCertificate');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Certificate could not get parsed.
- */
+
public function testBogusData() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Certificate could not get parsed.');
+
$certificate = new Certificate('foo', 'bar');
$certificate->getIssueDate();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Certificate could not get parsed.
- */
+
function testCertificateStartingWithFileReference() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Certificate could not get parsed.');
+
new Certificate('file://'.__DIR__ . '/../../data/certificates/goodCertificate.crt', 'bar');
}
diff --git a/tests/lib/Security/CredentialsManagerTest.php b/tests/lib/Security/CredentialsManagerTest.php
index d1cbdcd3366..0b93c704b5c 100644
--- a/tests/lib/Security/CredentialsManagerTest.php
+++ b/tests/lib/Security/CredentialsManagerTest.php
@@ -38,7 +38,7 @@ class CredentialsManagerTest extends \Test\TestCase {
/** @var CredentialsManager */
protected $manager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->crypto = $this->createMock(ICrypto::class);
$this->dbConnection = $this->getMockBuilder('\OC\DB\Connection')
diff --git a/tests/lib/Security/CryptoTest.php b/tests/lib/Security/CryptoTest.php
index ff164cddc9d..a2c8055750b 100644
--- a/tests/lib/Security/CryptoTest.php
+++ b/tests/lib/Security/CryptoTest.php
@@ -24,7 +24,7 @@ class CryptoTest extends \Test\TestCase {
/** @var Crypto */
protected $crypto;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->crypto = new Crypto(\OC::$server->getConfig(), \OC::$server->getSecureRandom());
}
@@ -37,11 +37,11 @@ class CryptoTest extends \Test\TestCase {
$this->assertEquals($stringToEncrypt, $this->crypto->decrypt($ciphertext));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage HMAC does not match.
- */
+
function testWrongPassword() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('HMAC does not match.');
+
$stringToEncrypt = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.';
$ciphertext = $this->crypto->encrypt($stringToEncrypt);
$this->crypto->decrypt($ciphertext, 'A wrong password!');
@@ -53,20 +53,20 @@ class CryptoTest extends \Test\TestCase {
$this->assertEquals($stringToEncrypt, $this->crypto->decrypt($encryptedString, 'ThisIsAVeryS3cur3P4ssw0rd'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage HMAC does not match.
- */
+
function testWrongIV() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('HMAC does not match.');
+
$encryptedString = '560f5436ba864b9f12f7f7ca6d41c327554a6f2c0a160a03316b202af07c65163274993f3a46e7547c07ba89304f00594a2f3bd99f83859097c58049c39d0d4ade10e0de914ff0604961e7c849d0271ed6c0b23f984ba16e7d033e3305fb0910e7b6a2a65c988d17dbee71d8f953684d|d2kdFUspVjC0o0sr|1a5feacf87eaa6869a6abdfba9a296e7bbad45b6ad89f7dce67cdc98e2da5dc4379cc672cc655e52bbf19599bf59482fbea13a73937697fa656bf10f3fc4f1aa';
$this->crypto->decrypt($encryptedString, 'ThisIsAVeryS3cur3P4ssw0rd');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Authenticated ciphertext could not be decoded.
- */
+
function testWrongParameters() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Authenticated ciphertext could not be decoded.');
+
$encryptedString = '1|2';
$this->crypto->decrypt($encryptedString, 'ThisIsAVeryS3cur3P4ssw0rd');
}
diff --git a/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php b/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php
index b4182068b8a..179bd6630ba 100644
--- a/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php
+++ b/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php
@@ -42,7 +42,7 @@ class FeaturePolicyManagerTest extends TestCase {
/** @var FeaturePolicyManager */
private $manager;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->dispatcher = \OC::$server->query(IEventDispatcher::class);
$this->manager = new FeaturePolicyManager($this->dispatcher);
diff --git a/tests/lib/Security/HasherTest.php b/tests/lib/Security/HasherTest.php
index c994b68f781..3222b5d0984 100644
--- a/tests/lib/Security/HasherTest.php
+++ b/tests/lib/Security/HasherTest.php
@@ -97,7 +97,7 @@ class HasherTest extends \Test\TestCase {
/** @var IConfig */
protected $config;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/tests/lib/Security/IdentityProof/KeyTest.php b/tests/lib/Security/IdentityProof/KeyTest.php
index bb550bd1b2a..ae5f77f1609 100644
--- a/tests/lib/Security/IdentityProof/KeyTest.php
+++ b/tests/lib/Security/IdentityProof/KeyTest.php
@@ -30,7 +30,7 @@ class KeyTest extends TestCase {
/** @var Key */
private $key;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->key = new Key('public', 'private');
diff --git a/tests/lib/Security/IdentityProof/ManagerTest.php b/tests/lib/Security/IdentityProof/ManagerTest.php
index 2d66845ba8d..aff6d3ed5c7 100644
--- a/tests/lib/Security/IdentityProof/ManagerTest.php
+++ b/tests/lib/Security/IdentityProof/ManagerTest.php
@@ -50,7 +50,7 @@ class ManagerTest extends TestCase {
/** @var ILogger|MockObject */
private $logger;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
/** @var Factory|\PHPUnit_Framework_MockObject_MockObject $factory */
@@ -219,10 +219,10 @@ class ManagerTest extends TestCase {
}
- /**
- * @expectedException \RuntimeException
- */
+
public function testGetSystemKeyFailure() {
+ $this->expectException(\RuntimeException::class);
+
$manager = $this->getManager(['retrieveKey']);
/** @var Key|\PHPUnit_Framework_MockObject_MockObject $key */
diff --git a/tests/lib/Security/IdentityProof/SignerTest.php b/tests/lib/Security/IdentityProof/SignerTest.php
index 114c03348f6..884065e6a1a 100644
--- a/tests/lib/Security/IdentityProof/SignerTest.php
+++ b/tests/lib/Security/IdentityProof/SignerTest.php
@@ -89,7 +89,7 @@ gQIDAQAB
/** @var Signer */
private $signer;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->key = new Key($this->public, $this->private);
diff --git a/tests/lib/Security/RateLimiting/Backend/MemoryCacheTest.php b/tests/lib/Security/RateLimiting/Backend/MemoryCacheTest.php
index 098c40ba0e8..e4df424c2ca 100644
--- a/tests/lib/Security/RateLimiting/Backend/MemoryCacheTest.php
+++ b/tests/lib/Security/RateLimiting/Backend/MemoryCacheTest.php
@@ -37,7 +37,7 @@ class MemoryCacheTest extends TestCase {
/** @var MemoryCache */
private $memoryCache;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->cacheFactory = $this->createMock(ICacheFactory::class);
diff --git a/tests/lib/Security/RateLimiting/LimiterTest.php b/tests/lib/Security/RateLimiting/LimiterTest.php
index 5d42104ba82..20b35029050 100644
--- a/tests/lib/Security/RateLimiting/LimiterTest.php
+++ b/tests/lib/Security/RateLimiting/LimiterTest.php
@@ -38,7 +38,7 @@ class LimiterTest extends TestCase {
/** @var Limiter */
private $limiter;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->timeFactory = $this->createMock(ITimeFactory::class);
@@ -50,11 +50,11 @@ class LimiterTest extends TestCase {
);
}
- /**
- * @expectedException \OC\Security\RateLimiting\Exception\RateLimitExceededException
- * @expectedExceptionMessage Rate limit exceeded
- */
+
public function testRegisterAnonRequestExceeded() {
+ $this->expectException(\OC\Security\RateLimiting\Exception\RateLimitExceededException::class);
+ $this->expectExceptionMessage('Rate limit exceeded');
+
$this->backend
->expects($this->once())
->method('getAttempts')
@@ -94,11 +94,11 @@ class LimiterTest extends TestCase {
$this->limiter->registerAnonRequest('MyIdentifier', 100, 100, '127.0.0.1');
}
- /**
- * @expectedException \OC\Security\RateLimiting\Exception\RateLimitExceededException
- * @expectedExceptionMessage Rate limit exceeded
- */
+
public function testRegisterUserRequestExceeded() {
+ $this->expectException(\OC\Security\RateLimiting\Exception\RateLimitExceededException::class);
+ $this->expectExceptionMessage('Rate limit exceeded');
+
/** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
$user = $this->createMock(IUser::class);
$user
diff --git a/tests/lib/Security/SecureRandomTest.php b/tests/lib/Security/SecureRandomTest.php
index 500e18d0ca6..71839115a3c 100644
--- a/tests/lib/Security/SecureRandomTest.php
+++ b/tests/lib/Security/SecureRandomTest.php
@@ -35,7 +35,7 @@ class SecureRandomTest extends \Test\TestCase {
/** @var SecureRandom */
protected $rng;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->rng = new \OC\Security\SecureRandom();
}
diff --git a/tests/lib/Security/TrustedDomainHelperTest.php b/tests/lib/Security/TrustedDomainHelperTest.php
index 3fe0889b796..26158401f79 100644
--- a/tests/lib/Security/TrustedDomainHelperTest.php
+++ b/tests/lib/Security/TrustedDomainHelperTest.php
@@ -18,7 +18,7 @@ class TrustedDomainHelperTest extends \Test\TestCase {
/** @var IConfig */
protected $config;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
diff --git a/tests/lib/ServerTest.php b/tests/lib/ServerTest.php
index 604e11ec11e..fbedad61fd7 100644
--- a/tests/lib/ServerTest.php
+++ b/tests/lib/ServerTest.php
@@ -38,7 +38,7 @@ class ServerTest extends \Test\TestCase {
protected $server;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$config = new \OC\Config(\OC::$configDir);
$this->server = new \OC\Server('', $config);
diff --git a/tests/lib/Session/CryptoSessionDataTest.php b/tests/lib/Session/CryptoSessionDataTest.php
index ee6bcbf11c1..6de44032530 100644
--- a/tests/lib/Session/CryptoSessionDataTest.php
+++ b/tests/lib/Session/CryptoSessionDataTest.php
@@ -22,6 +22,7 @@
namespace Test\Session;
use OC\Session\CryptoSessionData;
+use OCP\Security\ICrypto;
class CryptoSessionDataTest extends Session {
/** @var \PHPUnit_Framework_MockObject_MockObject|\OCP\Security\ICrypto */
@@ -30,13 +31,11 @@ class CryptoSessionDataTest extends Session {
/** @var \OCP\ISession */
protected $wrappedSession;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->wrappedSession = new \OC\Session\Memory($this->getUniqueID());
- $this->crypto = $this->getMockBuilder('OCP\Security\ICrypto')
- ->disableOriginalConstructor()
- ->getMock();
+ $this->crypto = $this->createMock(ICrypto::class);
$this->crypto->expects($this->any())
->method('encrypt')
->willReturnCallback(function ($input) {
@@ -45,6 +44,9 @@ class CryptoSessionDataTest extends Session {
$this->crypto->expects($this->any())
->method('decrypt')
->willReturnCallback(function ($input) {
+ if ($input === '') {
+ return '';
+ }
return substr($input, 1, -1);
});
diff --git a/tests/lib/Session/CryptoWrappingTest.php b/tests/lib/Session/CryptoWrappingTest.php
index f34148fb50e..fac515c8f52 100644
--- a/tests/lib/Session/CryptoWrappingTest.php
+++ b/tests/lib/Session/CryptoWrappingTest.php
@@ -35,7 +35,7 @@ class CryptoWrappingTest extends TestCase {
/** @var \OC\Session\CryptoSessionData */
protected $instance;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->wrappedSession = $this->getMockBuilder(ISession::class)
@@ -52,6 +52,9 @@ class CryptoWrappingTest extends TestCase {
$this->crypto->expects($this->any())
->method('decrypt')
->willReturnCallback(function ($input) {
+ if ($input === '') {
+ return '';
+ }
return substr($input, 1, -1);
});
diff --git a/tests/lib/Session/MemoryTest.php b/tests/lib/Session/MemoryTest.php
index d92d7b90e5e..79053ccb1c8 100644
--- a/tests/lib/Session/MemoryTest.php
+++ b/tests/lib/Session/MemoryTest.php
@@ -11,15 +11,15 @@ namespace Test\Session;
class MemoryTest extends Session {
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->instance = new \OC\Session\Memory($this->getUniqueID());
}
- /**
- * @expectedException \OCP\Session\Exceptions\SessionNotAvailableException
- */
+
public function testThrowsExceptionOnGetId() {
+ $this->expectException(\OCP\Session\Exceptions\SessionNotAvailableException::class);
+
$this->instance->getId();
}
diff --git a/tests/lib/Session/Session.php b/tests/lib/Session/Session.php
index a1ed01b2ec8..0c947b8d302 100644
--- a/tests/lib/Session/Session.php
+++ b/tests/lib/Session/Session.php
@@ -15,7 +15,7 @@ abstract class Session extends \Test\TestCase {
*/
protected $instance;
- protected function tearDown() {
+ protected function tearDown(): void {
$this->instance->clear();
parent::tearDown();
}
diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php
index 3339c50c4d2..761f5f9a5c1 100644
--- a/tests/lib/Settings/ManagerTest.php
+++ b/tests/lib/Settings/ManagerTest.php
@@ -51,7 +51,7 @@ class ManagerTest extends TestCase {
/** @var IServerContainer|\PHPUnit_Framework_MockObject_MockObject */
private $container;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->logger = $this->createMock(ILogger::class);
diff --git a/tests/lib/SetupTest.php b/tests/lib/SetupTest.php
index 176a5b19f29..7ab3eb78539 100644
--- a/tests/lib/SetupTest.php
+++ b/tests/lib/SetupTest.php
@@ -36,7 +36,7 @@ class SetupTest extends \Test\TestCase {
/** @var Installer|\PHPUnit_Framework_MockObject_MockObject */
protected $installer;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(SystemConfig::class);
@@ -120,11 +120,11 @@ class SetupTest extends \Test\TestCase {
$this->assertSame($expectedResult, $result);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Supported databases are not properly configured.
- */
+
public function testGetSupportedDatabaseException() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Supported databases are not properly configured.');
+
$this->config
->expects($this->once())
->method('getValue')
diff --git a/tests/lib/Share/HelperTest.php b/tests/lib/Share/HelperTest.php
index 02118bf0e2e..dc2d26509e3 100644
--- a/tests/lib/Share/HelperTest.php
+++ b/tests/lib/Share/HelperTest.php
@@ -122,9 +122,10 @@ class HelperTest extends \Test\TestCase {
* @dataProvider dataTestSplitUserRemoteError
*
* @param string $id
- * @expectedException \OC\HintException
*/
public function testSplitUserRemoteError($id) {
+ $this->expectException(\OC\HintException::class);
+
\OC\Share\Helper::splitUserRemote($id);
}
diff --git a/tests/lib/Share/ShareTest.php b/tests/lib/Share/ShareTest.php
index 7db58d744d5..af05d0c4bdd 100644
--- a/tests/lib/Share/ShareTest.php
+++ b/tests/lib/Share/ShareTest.php
@@ -67,7 +67,7 @@ class ShareTest extends \Test\TestCase {
/** @var IUserManager */
protected $userManager;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->groupManager = \OC::$server->getGroupManager();
@@ -113,7 +113,7 @@ class ShareTest extends \Test\TestCase {
$this->dateInFuture = date($dateFormat, $now + 20 * 60);
}
- protected function tearDown() {
+ protected function tearDown(): void {
$query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `item_type` = ?');
$query->execute(array('test'));
\OC::$server->getConfig()->setAppValue('core', 'shareapi_allow_resharing', $this->resharing);
diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php
index a9852882fa8..ff3cafbdf7c 100644
--- a/tests/lib/Share20/DefaultShareProviderTest.php
+++ b/tests/lib/Share20/DefaultShareProviderTest.php
@@ -73,7 +73,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject|IURLGenerator */
protected $urlGenerator;
- public function setUp() {
+ protected function setUp(): void {
$this->dbConn = \OC::$server->getDatabaseConnection();
$this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
@@ -100,7 +100,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
);
}
- public function tearDown() {
+ protected function tearDown(): void {
$this->dbConn->getQueryBuilder()->delete('share')->execute();
$this->dbConn->getQueryBuilder()->delete('filecache')->execute();
$this->dbConn->getQueryBuilder()->delete('storages')->execute();
@@ -143,10 +143,10 @@ class DefaultShareProviderTest extends \Test\TestCase {
- /**
- * @expectedException \OCP\Share\Exceptions\ShareNotFound
- */
+
public function testGetShareByIdNotExist() {
+ $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class);
+
$this->provider->getShareById(1);
}
@@ -835,10 +835,10 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame(null, $share->getSharedWith());
}
- /**
- * @expectedException \OCP\Share\Exceptions\ShareNotFound
- */
+
public function testGetShareByTokenNotFound() {
+ $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class);
+
$this->provider->getShareByToken('invalidtoken');
}
@@ -1538,11 +1538,11 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals('user2', $share2['share_with']);
}
- /**
- * @expectedException \OC\Share20\Exception\ProviderException
- * @expectedExceptionMessage Recipient not in receiving group
- */
+
public function testDeleteFromSelfGroupUserNotInGroup() {
+ $this->expectException(\OC\Share20\Exception\ProviderException::class);
+ $this->expectExceptionMessage('Recipient not in receiving group');
+
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
@@ -1583,11 +1583,11 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->provider->deleteFromSelf($share, 'user2');
}
- /**
- * @expectedException \OC\Share20\Exception\ProviderException
- * @expectedExceptionMessage Group "group" does not exist
- */
+
public function testDeleteFromSelfGroupDoesNotExist() {
+ $this->expectException(\OC\Share20\Exception\ProviderException::class);
+ $this->expectExceptionMessage('Group "group" does not exist');
+
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
@@ -1674,11 +1674,11 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertCount(0, $shares);
}
- /**
- * @expectedException \OC\Share20\Exception\ProviderException
- * @expectedExceptionMessage Recipient does not match
- */
+
public function testDeleteFromSelfUserNotRecipient() {
+ $this->expectException(\OC\Share20\Exception\ProviderException::class);
+ $this->expectExceptionMessage('Recipient does not match');
+
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
@@ -1717,11 +1717,11 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->provider->deleteFromSelf($share, $user3);
}
- /**
- * @expectedException \OC\Share20\Exception\ProviderException
- * @expectedExceptionMessage Invalid shareType
- */
+
public function testDeleteFromSelfLink() {
+ $this->expectException(\OC\Share20\Exception\ProviderException::class);
+ $this->expectExceptionMessage('Invalid shareType');
+
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
diff --git a/tests/lib/Share20/LegacyHooksTest.php b/tests/lib/Share20/LegacyHooksTest.php
index 057173c4f33..14fe32323c1 100644
--- a/tests/lib/Share20/LegacyHooksTest.php
+++ b/tests/lib/Share20/LegacyHooksTest.php
@@ -42,7 +42,7 @@ class LegacyHooksTest extends TestCase {
/** @var Manager */
private $manager;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->eventDispatcher = new EventDispatcher();
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 3e34a64acf3..c4cc335dd5e 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -101,7 +101,7 @@ class ManagerTest extends \Test\TestCase {
/** @var \OC_Defaults|MockObject */
protected $defaults;
- public function setUp() {
+ protected function setUp(): void {
$this->logger = $this->createMock(ILogger::class);
$this->config = $this->createMock(IConfig::class);
@@ -172,10 +172,10 @@ class ManagerTest extends \Test\TestCase {
]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testDeleteNoShareId() {
+ $this->expectException(\InvalidArgumentException::class);
+
$share = $this->manager->newShare();
$this->manager->deleteShare($share);
@@ -336,7 +336,7 @@ class ManagerTest extends \Test\TestCase {
$this->defaultProvider
->method('delete')
- ->withConsecutive($share3, $share2, $share1);
+ ->withConsecutive([$share3], [$share2], [$share1]);
$this->eventDispatcher->expects($this->at(0))
->method('dispatch')
@@ -427,7 +427,7 @@ class ManagerTest extends \Test\TestCase {
$this->defaultProvider
->expects($this->exactly(3))
->method('delete')
- ->withConsecutive($child1, $child2, $child3);
+ ->withConsecutive([$child1], [$child2], [$child3]);
$result = self::invokePrivate($manager, 'deleteChildren', [$share]);
$this->assertSame($shares, $result);
@@ -445,10 +445,10 @@ class ManagerTest extends \Test\TestCase {
$this->assertEquals($share, $this->manager->getShareById('default:42'));
}
- /**
- * @expectedException \OCP\Share\Exceptions\ShareNotFound
- */
+
public function testGetExpiredShareById() {
+ $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class);
+
$manager = $this->createManagerMock()
->setMethods(['deleteShare'])
->getMock();
@@ -472,11 +472,11 @@ class ManagerTest extends \Test\TestCase {
$manager->getShareById('default:42');
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Passwords are enforced for link shares
- */
+
public function testVerifyPasswordNullButEnforced() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Passwords are enforced for link shares');
+
$this->config->method('getAppValue')->will($this->returnValueMap([
['core', 'shareapi_enforce_links_password', 'no', 'yes'],
]));
@@ -510,11 +510,11 @@ class ManagerTest extends \Test\TestCase {
$this->assertNull($result);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage password not accepted
- */
+
public function testVerifyPasswordHookFails() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('password not accepted');
+
$this->config->method('getAppValue')->will($this->returnValueMap([
['core', 'shareapi_enforce_links_password', 'no', 'no'],
]));
@@ -719,11 +719,11 @@ class ManagerTest extends \Test\TestCase {
$this->assertSame($exception, $thrown);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage You can’t share your root folder
- */
+
public function testGeneralCheckShareRoot() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('You can’t share your root folder');
+
$thrown = null;
$this->userManager->method('userExists')->will($this->returnValueMap([
@@ -745,11 +745,11 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'generalCreateChecks', [$share]);
}
- /**
- * @expectedException \OCP\Share\Exceptions\GenericShareException
- * @expectedExceptionMessage Expiration date is in the past
- */
+
public function testvalidateExpirationDateInPast() {
+ $this->expectException(\OCP\Share\Exceptions\GenericShareException::class);
+ $this->expectExceptionMessage('Expiration date is in the past');
+
// Expire date in the past
$past = new \DateTime();
@@ -761,11 +761,11 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Expiration date is enforced
- */
+
public function testvalidateExpirationDateEnforceButNotSet() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Expiration date is enforced');
+
$share = $this->manager->newShare();
$share->setProviderId('foo')->setId('bar');
@@ -950,11 +950,11 @@ class ManagerTest extends \Test\TestCase {
$this->assertEquals($save, $share->getExpirationDate());
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Invalid date!
- */
+
public function testValidateExpirationDateHookException() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Invalid date!');
+
$nextWeek = new \DateTime();
$nextWeek->add(new \DateInterval('P7D'));
$nextWeek->setTime(0,0,0);
@@ -988,11 +988,11 @@ class ManagerTest extends \Test\TestCase {
$this->assertEquals(null, $share->getExpirationDate());
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Sharing is only allowed with group members
- */
+
public function testUserCreateChecksShareWithGroupMembersOnlyDifferentGroups() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Sharing is only allowed with group members');
+
$share = $this->manager->newShare();
$sharedBy = $this->createMock(IUser::class);
@@ -1061,11 +1061,11 @@ class ManagerTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Path is already shared with this user
- */
+
public function testUserCreateChecksIdenticalShareExists() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Path is already shared with this user');
+
$share = $this->manager->newShare();
$share2 = $this->manager->newShare();
@@ -1086,11 +1086,11 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'userCreateChecks', [$share]);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Path is already shared with this user
- */
+
public function testUserCreateChecksIdenticalPathSharedViaGroup() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Path is already shared with this user');
+
$share = $this->manager->newShare();
$sharedWith = $this->createMock(IUser::class);
@@ -1197,11 +1197,11 @@ class ManagerTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Group sharing is now allowed
- */
+
public function testGroupCreateChecksShareWithGroupMembersGroupSharingNotAllowed() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Group sharing is now allowed');
+
$share = $this->manager->newShare();
$this->config
@@ -1213,11 +1213,11 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'groupCreateChecks', [$share]);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Sharing is only allowed within your own groups
- */
+
public function testGroupCreateChecksShareWithGroupMembersOnlyNotInGroup() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Sharing is only allowed within your own groups');
+
$share = $this->manager->newShare();
$user = $this->createMock(IUser::class);
@@ -1239,11 +1239,11 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'groupCreateChecks', [$share]);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Sharing is only allowed within your own groups
- */
+
public function testGroupCreateChecksShareWithGroupMembersOnlyNullGroup() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Sharing is only allowed within your own groups');
+
$share = $this->manager->newShare();
$user = $this->createMock(IUser::class);
@@ -1292,11 +1292,11 @@ class ManagerTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Path is already shared with this group
- */
+
public function testGroupCreateChecksPathAlreadySharedWithSameGroup() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Path is already shared with this group');
+
$share = $this->manager->newShare();
$path = $this->createMock(Node::class);
@@ -1348,11 +1348,11 @@ class ManagerTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Link sharing is not allowed
- */
+
public function testLinkCreateChecksNoLinkSharesAllowed() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Link sharing is not allowed');
+
$share = $this->manager->newShare();
$this->config
@@ -1364,11 +1364,11 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'linkCreateChecks', [$share]);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Link shares can’t have reshare permissions
- */
+
public function testLinkCreateChecksSharePermissions() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Link shares can’t have reshare permissions');
+
$share = $this->manager->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_SHARE);
@@ -1382,11 +1382,11 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'linkCreateChecks', [$share]);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Public upload is not allowed
- */
+
public function testLinkCreateChecksNoPublicUpload() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Public upload is not allowed');
+
$share = $this->manager->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE);
@@ -1433,11 +1433,11 @@ class ManagerTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Path contains files shared with you
- */
+
public function testPathCreateChecksContainsSharedMount() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Path contains files shared with you');
+
$path = $this->createMock(Folder::class);
$path->method('getPath')->willReturn('path');
@@ -1924,11 +1924,11 @@ class ManagerTest extends \Test\TestCase {
$this->assertEquals('token', $share->getToken());
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage I won't let you share
- */
+
public function testCreateShareHookError() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('I won\'t let you share');
+
$manager = $this->createManagerMock()
->setMethods([
'canShare',
@@ -2311,11 +2311,11 @@ class ManagerTest extends \Test\TestCase {
$this->assertSame($share, $ret);
}
- /**
- * @expectedException \OCP\Share\Exceptions\ShareNotFound
- * @expectedExceptionMessage The requested share does not exist anymore
- */
+
public function testGetShareByTokenExpired() {
+ $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class);
+ $this->expectExceptionMessage('The requested share does not exist anymore');
+
$this->config
->expects($this->once())
->method('getAppValue')
@@ -2370,10 +2370,10 @@ class ManagerTest extends \Test\TestCase {
$this->assertSame($share, $res);
}
- /**
- * @expectedException \OCP\Share\Exceptions\ShareNotFound
- */
+
public function testGetShareByTokenWithPublicLinksDisabled() {
+ $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class);
+
$this->config
->expects($this->once())
->method('getAppValue')
@@ -2466,11 +2466,11 @@ class ManagerTest extends \Test\TestCase {
$this->assertTrue($this->manager->checkPassword($share, 'password'));
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Can’t change share type
- */
+
public function testUpdateShareCantChangeShareType() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Can’t change share type');
+
$manager = $this->createManagerMock()
->setMethods([
'canShare',
@@ -2492,11 +2492,11 @@ class ManagerTest extends \Test\TestCase {
$manager->updateShare($share);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Can only update recipient on user shares
- */
+
public function testUpdateShareCantChangeRecipientForGroupShare() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Can only update recipient on user shares');
+
$manager = $this->createManagerMock()
->setMethods([
'canShare',
@@ -2520,11 +2520,11 @@ class ManagerTest extends \Test\TestCase {
$manager->updateShare($share);
}
- /**
- * @expectedException Exception
- * @expectedExceptionMessage Can’t share with the share owner
- */
+
public function testUpdateShareCantShareWithOwner() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Can’t share with the share owner');
+
$manager = $this->createManagerMock()
->setMethods([
'canShare',
@@ -2889,11 +2889,11 @@ class ManagerTest extends \Test\TestCase {
$manager->updateShare($share);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Can’t enable sending the password by Talk without setting a new password
- */
+
public function testUpdateShareMailEnableSendPasswordByTalkWithNoPassword() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Can’t enable sending the password by Talk without setting a new password');
+
$manager = $this->createManagerMock()
->setMethods([
'canShare',
@@ -2961,11 +2961,11 @@ class ManagerTest extends \Test\TestCase {
$manager->updateShare($share);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Can’t enable sending the password by Talk without setting a new password
- */
+
public function testUpdateShareMailEnableSendPasswordByTalkRemovingPassword() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Can’t enable sending the password by Talk without setting a new password');
+
$manager = $this->createManagerMock()
->setMethods([
'canShare',
@@ -3033,11 +3033,11 @@ class ManagerTest extends \Test\TestCase {
$manager->updateShare($share);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Can’t enable sending the password by Talk without setting a new password
- */
+
public function testUpdateShareMailEnableSendPasswordByTalkRemovingPasswordWithEmptyString() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Can’t enable sending the password by Talk without setting a new password');
+
$manager = $this->createManagerMock()
->setMethods([
'canShare',
@@ -3105,11 +3105,11 @@ class ManagerTest extends \Test\TestCase {
$manager->updateShare($share);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Can’t enable sending the password by Talk without setting a new password
- */
+
public function testUpdateShareMailEnableSendPasswordByTalkWithPreviousPassword() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Can’t enable sending the password by Talk without setting a new password');
+
$manager = $this->createManagerMock()
->setMethods([
'canShare',
@@ -3247,11 +3247,11 @@ class ManagerTest extends \Test\TestCase {
$manager->updateShare($share);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Can’t change target of link share
- */
+
public function testMoveShareLink() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Can’t change target of link share');
+
$share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_LINK);
@@ -3260,11 +3260,11 @@ class ManagerTest extends \Test\TestCase {
$this->manager->moveShare($share, $recipient);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Invalid recipient
- */
+
public function testMoveShareUserNotRecipient() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Invalid recipient');
+
$share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_USER);
@@ -3287,11 +3287,11 @@ class ManagerTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Invalid recipient
- */
+
public function testMoveShareGroupNotRecipient() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Invalid recipient');
+
$share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
@@ -3307,11 +3307,11 @@ class ManagerTest extends \Test\TestCase {
$this->manager->moveShare($share, 'recipient');
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Group "shareWith" does not exist
- */
+
public function testMoveShareGroupNull() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Group "shareWith" does not exist');
+
$share = $this->manager->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
$share->setSharedWith('shareWith');
diff --git a/tests/lib/Share20/ShareHelperTest.php b/tests/lib/Share20/ShareHelperTest.php
index 39141418f35..d2f5cd79284 100644
--- a/tests/lib/Share20/ShareHelperTest.php
+++ b/tests/lib/Share20/ShareHelperTest.php
@@ -37,7 +37,7 @@ class ShareHelperTest extends TestCase {
/** @var ShareHelper */
private $helper;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->manager = $this->createMock(IManager::class);
diff --git a/tests/lib/Share20/ShareTest.php b/tests/lib/Share20/ShareTest.php
index 9e5c4970d3b..f7ea479350d 100644
--- a/tests/lib/Share20/ShareTest.php
+++ b/tests/lib/Share20/ShareTest.php
@@ -36,17 +36,17 @@ class ShareTest extends \Test\TestCase {
/** @var \OCP\Share\IShare */
protected $share;
- public function setUp() {
+ protected function setUp(): void {
$this->rootFolder = $this->createMock(IRootFolder::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->share = new \OC\Share20\Share($this->rootFolder, $this->userManager);
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage String expected.
- */
+
public function testSetIdInvalid() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('String expected.');
+
$this->share->setId(1.2);
}
@@ -61,20 +61,20 @@ class ShareTest extends \Test\TestCase {
$this->assertEquals('foo', $this->share->getId());
}
- /**
- * @expectedException \OCP\Share\Exceptions\IllegalIDChangeException
- * @expectedExceptionMessage Not allowed to assign a new internal id to a share
- */
+
public function testSetIdOnce() {
+ $this->expectException(\OCP\Share\Exceptions\IllegalIDChangeException::class);
+ $this->expectExceptionMessage('Not allowed to assign a new internal id to a share');
+
$this->share->setId('foo');
$this->share->setId('bar');
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage String expected.
- */
+
public function testSetProviderIdInt() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('String expected.');
+
$this->share->setProviderId(42);
}
@@ -85,11 +85,11 @@ class ShareTest extends \Test\TestCase {
$this->assertEquals('foo:bar', $this->share->getFullId());
}
- /**
- * @expectedException \OCP\Share\Exceptions\IllegalIDChangeException
- * @expectedExceptionMessage Not allowed to assign a new provider id to a share
- */
+
public function testSetProviderIdOnce() {
+ $this->expectException(\OCP\Share\Exceptions\IllegalIDChangeException::class);
+ $this->expectExceptionMessage('Not allowed to assign a new provider id to a share');
+
$this->share->setProviderId('foo');
$this->share->setProviderId('bar');
}
diff --git a/tests/lib/SubAdminTest.php b/tests/lib/SubAdminTest.php
index 8b293426e75..b2c15894391 100644
--- a/tests/lib/SubAdminTest.php
+++ b/tests/lib/SubAdminTest.php
@@ -41,7 +41,7 @@ class SubAdminTest extends \Test\TestCase {
/** @var \OCP\IGroup[] */
private $groups;
- public function setup() {
+ protected function setUp(): void {
$this->users = [];
$this->groups = [];
@@ -83,7 +83,7 @@ class SubAdminTest extends \Test\TestCase {
->execute();
}
- public function tearDown() {
+ protected function tearDown(): void {
foreach($this->users as $user) {
$user->delete();
}
diff --git a/tests/lib/Support/CrashReport/RegistryTest.php b/tests/lib/Support/CrashReport/RegistryTest.php
index be769e257fc..c45848b6186 100644
--- a/tests/lib/Support/CrashReport/RegistryTest.php
+++ b/tests/lib/Support/CrashReport/RegistryTest.php
@@ -36,7 +36,7 @@ class RegistryTest extends TestCase {
/** @var Registry */
private $registry;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->registry = new Registry();
diff --git a/tests/lib/Support/Subscription/RegistryTest.php b/tests/lib/Support/Subscription/RegistryTest.php
index c9557def0fd..3793026be0f 100644
--- a/tests/lib/Support/Subscription/RegistryTest.php
+++ b/tests/lib/Support/Subscription/RegistryTest.php
@@ -32,7 +32,7 @@ class RegistryTest extends TestCase {
/** @var Registry */
private $registry;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->registry = new Registry();
@@ -46,10 +46,10 @@ class RegistryTest extends TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @expectedException \OCP\Support\Subscription\Exception\AlreadyRegisteredException
- */
+
public function testDoubleRegistration() {
+ $this->expectException(\OCP\Support\Subscription\Exception\AlreadyRegisteredException::class);
+
/* @var ISubscription $subscription1 */
$subscription1 = $this->createMock(ISubscription::class);
/* @var ISubscription $subscription2 */
diff --git a/tests/lib/SystemTag/SystemTagManagerTest.php b/tests/lib/SystemTag/SystemTagManagerTest.php
index 41c838914c7..a5a54fce09f 100644
--- a/tests/lib/SystemTag/SystemTagManagerTest.php
+++ b/tests/lib/SystemTag/SystemTagManagerTest.php
@@ -49,7 +49,7 @@ class SystemTagManagerTest extends TestCase {
*/
private $dispatcher;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -67,7 +67,7 @@ class SystemTagManagerTest extends TestCase {
$this->pruneTagsTables();
}
- public function tearDown() {
+ protected function tearDown(): void {
$this->pruneTagsTables();
parent::tearDown();
}
@@ -249,9 +249,10 @@ class SystemTagManagerTest extends TestCase {
/**
* @dataProvider oneTagMultipleFlagsProvider
- * @expectedException \OCP\SystemTag\TagAlreadyExistsException
*/
public function testCreateDuplicate($name, $userVisible, $userAssignable) {
+ $this->expectException(\OCP\SystemTag\TagAlreadyExistsException::class);
+
try {
$this->tagManager->createTag($name, $userVisible, $userAssignable);
} catch (\Exception $e) {
@@ -282,25 +283,25 @@ class SystemTagManagerTest extends TestCase {
$this->assertSameTag($tag2, $tagList[$tag2->getId()]);
}
- /**
- * @expectedException \OCP\SystemTag\TagNotFoundException
- */
+
public function testGetNonExistingTag() {
+ $this->expectException(\OCP\SystemTag\TagNotFoundException::class);
+
$this->tagManager->getTag('nonexist', false, false);
}
- /**
- * @expectedException \OCP\SystemTag\TagNotFoundException
- */
+
public function testGetNonExistingTagsById() {
+ $this->expectException(\OCP\SystemTag\TagNotFoundException::class);
+
$tag1 = $this->tagManager->createTag('one', true, false);
$this->tagManager->getTagsByIds([$tag1->getId(), 100, 101]);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testGetInvalidTagIdFormat() {
+ $this->expectException(\InvalidArgumentException::class);
+
$tag1 = $this->tagManager->createTag('one', true, false);
$this->tagManager->getTagsByIds([$tag1->getId() . 'suffix']);
}
@@ -359,9 +360,10 @@ class SystemTagManagerTest extends TestCase {
/**
* @dataProvider updateTagProvider
- * @expectedException \OCP\SystemTag\TagAlreadyExistsException
*/
public function testUpdateTagDuplicate($tagCreate, $tagUpdated) {
+ $this->expectException(\OCP\SystemTag\TagAlreadyExistsException::class);
+
$this->tagManager->createTag(
$tagCreate[0],
$tagCreate[1],
@@ -391,10 +393,10 @@ class SystemTagManagerTest extends TestCase {
$this->assertEmpty($this->tagManager->getAllTags());
}
- /**
- * @expectedException \OCP\SystemTag\TagNotFoundException
- */
+
public function testDeleteNonExistingTag() {
+ $this->expectException(\OCP\SystemTag\TagNotFoundException::class);
+
$this->tagManager->deleteTags([100]);
}
diff --git a/tests/lib/SystemTag/SystemTagObjectMapperTest.php b/tests/lib/SystemTag/SystemTagObjectMapperTest.php
index 69cf7e8f816..f0e535b0f67 100644
--- a/tests/lib/SystemTag/SystemTagObjectMapperTest.php
+++ b/tests/lib/SystemTag/SystemTagObjectMapperTest.php
@@ -64,7 +64,7 @@ class SystemTagObjectMapperTest extends TestCase {
*/
private $tag3;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -108,7 +108,7 @@ class SystemTagObjectMapperTest extends TestCase {
$this->tagMapper->assignTags('3', 'anothertype', $this->tag1->getId());
}
- public function tearDown() {
+ protected function tearDown(): void {
$this->pruneTagsTables();
parent::tearDown();
}
@@ -166,10 +166,10 @@ class SystemTagObjectMapperTest extends TestCase {
], $objectIds);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testGetObjectsForTagsLimitWithMultipleTags() {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->tagMapper->getObjectIdsForTags(
[$this->tag1->getId(), $this->tag2->getId(), $this->tag3->getId()],
'testtype',
@@ -190,10 +190,10 @@ class SystemTagObjectMapperTest extends TestCase {
], $objectIds);
}
- /**
- * @expectedException \OCP\SystemTag\TagNotFoundException
- */
+
public function testGetObjectsForNonExistingTag() {
+ $this->expectException(\OCP\SystemTag\TagNotFoundException::class);
+
$this->tagMapper->getObjectIdsForTags(
[100],
'testtype'
@@ -228,10 +228,10 @@ class SystemTagObjectMapperTest extends TestCase {
$this->assertTrue(true, 'No error when reassigning/unassigning');
}
- /**
- * @expectedException \OCP\SystemTag\TagNotFoundException
- */
+
public function testAssignNonExistingTags() {
+ $this->expectException(\OCP\SystemTag\TagNotFoundException::class);
+
$this->tagMapper->assignTags('1', 'testtype', [100]);
}
@@ -255,10 +255,10 @@ class SystemTagObjectMapperTest extends TestCase {
], $tagIdMapping, 'None of the tags got assigned');
}
- /**
- * @expectedException \OCP\SystemTag\TagNotFoundException
- */
+
public function testUnassignNonExistingTags() {
+ $this->expectException(\OCP\SystemTag\TagNotFoundException::class);
+
$this->tagMapper->unassignTags('1', 'testtype', [100]);
}
@@ -386,10 +386,10 @@ class SystemTagObjectMapperTest extends TestCase {
);
}
- /**
- * @expectedException \OCP\SystemTag\TagNotFoundException
- */
+
public function testHaveTagNonExisting() {
+ $this->expectException(\OCP\SystemTag\TagNotFoundException::class);
+
$this->tagMapper->haveTag(
['1'],
'testtype',
diff --git a/tests/lib/TagsTest.php b/tests/lib/TagsTest.php
index 268521bed51..db0a77f68f0 100644
--- a/tests/lib/TagsTest.php
+++ b/tests/lib/TagsTest.php
@@ -42,7 +42,7 @@ class TagsTest extends \Test\TestCase {
/** @var \OCP\ITagManager */
protected $tagMgr;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
\OC_User::clearBackends();
@@ -65,7 +65,7 @@ class TagsTest extends \Test\TestCase {
}
- protected function tearDown() {
+ protected function tearDown(): void {
$conn = \OC::$server->getDatabaseConnection();
$conn->executeQuery('DELETE FROM `*PREFIX*vcategory_to_object`');
$conn->executeQuery('DELETE FROM `*PREFIX*vcategory`');
diff --git a/tests/lib/TempManagerTest.php b/tests/lib/TempManagerTest.php
index c9e069d9d0d..6262bd5a00a 100644
--- a/tests/lib/TempManagerTest.php
+++ b/tests/lib/TempManagerTest.php
@@ -26,7 +26,7 @@ class TempManagerTest extends \Test\TestCase {
protected $baseDir = null;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->baseDir = $this->getManager()->getTempBaseDir() . $this->getUniqueID('/oc_tmp_test');
@@ -35,7 +35,7 @@ class TempManagerTest extends \Test\TestCase {
}
}
- protected function tearDown() {
+ protected function tearDown(): void {
\OC_Helper::rmdirr($this->baseDir);
$this->baseDir = null;
parent::tearDown();
diff --git a/tests/lib/Template/CSSResourceLocatorTest.php b/tests/lib/Template/CSSResourceLocatorTest.php
index 790d1f44e1b..7c9f3585038 100644
--- a/tests/lib/Template/CSSResourceLocatorTest.php
+++ b/tests/lib/Template/CSSResourceLocatorTest.php
@@ -54,7 +54,7 @@ class CSSResourceLocatorTest extends \Test\TestCase {
/** @var ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */
private $timeFactory;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->logger = $this->createMock(ILogger::class);
diff --git a/tests/lib/Template/IconsCacherTest.php b/tests/lib/Template/IconsCacherTest.php
index 50b678da6d3..8e36426393f 100644
--- a/tests/lib/Template/IconsCacherTest.php
+++ b/tests/lib/Template/IconsCacherTest.php
@@ -50,7 +50,7 @@ class IconsCacherTest extends \Test\TestCase {
/** @var ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */
private $timeFactory;
- protected function setUp() {
+ protected function setUp(): void {
$this->logger = $this->createMock(ILogger::class);
$this->appData = $this->createMock(AppData::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
diff --git a/tests/lib/Template/JSCombinerTest.php b/tests/lib/Template/JSCombinerTest.php
index 51b15b80405..b12124ea5a9 100644
--- a/tests/lib/Template/JSCombinerTest.php
+++ b/tests/lib/Template/JSCombinerTest.php
@@ -52,7 +52,7 @@ class JSCombinerTest extends \Test\TestCase {
/** @var ICacheFactory|\PHPUnit_Framework_MockObject_MockObject */
protected $cacheFactory;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->appData = $this->createMock(IAppData::class);
diff --git a/tests/lib/Template/JSResourceLocatorTest.php b/tests/lib/Template/JSResourceLocatorTest.php
index 400637ae960..38c5fc0eadd 100644
--- a/tests/lib/Template/JSResourceLocatorTest.php
+++ b/tests/lib/Template/JSResourceLocatorTest.php
@@ -43,7 +43,7 @@ class JSResourceLocatorTest extends \Test\TestCase {
/** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */
protected $logger;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->appData = $this->createMock(IAppData::class);
diff --git a/tests/lib/Template/ResourceLocatorTest.php b/tests/lib/Template/ResourceLocatorTest.php
index 580dfd60d0e..90488071b4f 100644
--- a/tests/lib/Template/ResourceLocatorTest.php
+++ b/tests/lib/Template/ResourceLocatorTest.php
@@ -15,7 +15,7 @@ class ResourceLocatorTest extends \Test\TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject */
protected $logger;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->logger = $this->createMock(ILogger::class);
}
diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php
index 421046b38f3..6f9fdf1e7fb 100644
--- a/tests/lib/Template/SCSSCacherTest.php
+++ b/tests/lib/Template/SCSSCacherTest.php
@@ -62,7 +62,7 @@ class SCSSCacherTest extends \Test\TestCase {
/** @var ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */
protected $timeFactory;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->logger = $this->createMock(ILogger::class);
$this->appData = $this->createMock(AppData::class);
diff --git a/tests/lib/TemplateFunctionsTest.php b/tests/lib/TemplateFunctionsTest.php
index aa3c73d4743..ac73873ce37 100644
--- a/tests/lib/TemplateFunctionsTest.php
+++ b/tests/lib/TemplateFunctionsTest.php
@@ -24,7 +24,7 @@ namespace Test;
class TemplateFunctionsTest extends \Test\TestCase {
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$loader = new \OC\Autoloader([\OC::$SERVERROOT . '/lib']);
diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php
index 96ee0f06f8c..b80e720efd3 100644
--- a/tests/lib/TestCase.php
+++ b/tests/lib/TestCase.php
@@ -108,7 +108,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
});
}
- protected function setUp() {
+ protected function setUp(): void {
// overwrite the command bus with one we can run ourselves
$this->commandBus = new QueueBus();
$this->overwriteService('AsyncCommandBus', $this->commandBus);
@@ -134,7 +134,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
}
}
- protected function onNotSuccessfulTest(\Throwable $t) {
+ protected function onNotSuccessfulTest(\Throwable $t): void {
$this->restoreAllServices();
// restore database connection
@@ -147,7 +147,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
parent::onNotSuccessfulTest($t);
}
- protected function tearDown() {
+ protected function tearDown(): void {
$this->restoreAllServices();
// restore database connection
@@ -238,7 +238,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
);
}
- public static function tearDownAfterClass() {
+ public static function tearDownAfterClass(): void {
if (!self::$wasDatabaseAllowed && self::$realDatabase !== null) {
// in case an error is thrown in a test, PHPUnit jumps straight to tearDownAfterClass,
// so we need the database again
diff --git a/tests/lib/Traits/EncryptionTrait.php b/tests/lib/Traits/EncryptionTrait.php
index 1f389fc82c8..ad98ba91212 100644
--- a/tests/lib/Traits/EncryptionTrait.php
+++ b/tests/lib/Traits/EncryptionTrait.php
@@ -23,8 +23,8 @@ trait EncryptionTrait {
abstract protected function registerStorageWrapper($name, $wrapper);
// from phpunit
- abstract protected function markTestSkipped($reason = '');
- abstract protected function assertTrue($condition, $message = '');
+ abstract protected function markTestSkipped(string $message = ''): void;
+ abstract protected function assertTrue($condition, string $message = ''): void;
private $encryptionWasEnabled;
diff --git a/tests/lib/Updater/ChangesCheckTest.php b/tests/lib/Updater/ChangesCheckTest.php
index fe25e8cebaf..a979007573d 100644
--- a/tests/lib/Updater/ChangesCheckTest.php
+++ b/tests/lib/Updater/ChangesCheckTest.php
@@ -49,7 +49,7 @@ class ChangesCheckTest extends TestCase {
/** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */
protected $logger;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->clientService = $this->createMock(IClientService::class);
diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php
index eef16eeb520..b25557d5569 100644
--- a/tests/lib/Updater/VersionCheckTest.php
+++ b/tests/lib/Updater/VersionCheckTest.php
@@ -33,7 +33,7 @@ class VersionCheckTest extends \Test\TestCase {
/** @var VersionCheck | \PHPUnit_Framework_MockObject_MockObject*/
private $updater;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
diff --git a/tests/lib/UpdaterTest.php b/tests/lib/UpdaterTest.php
index 47028cf3f18..1732cf4c1cf 100644
--- a/tests/lib/UpdaterTest.php
+++ b/tests/lib/UpdaterTest.php
@@ -40,7 +40,7 @@ class UpdaterTest extends TestCase {
/** @var Installer|\PHPUnit_Framework_MockObject_MockObject */
private $installer;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php
index 9a8e588a229..afde88e3995 100644
--- a/tests/lib/UrlGeneratorTest.php
+++ b/tests/lib/UrlGeneratorTest.php
@@ -28,7 +28,7 @@ class UrlGeneratorTest extends \Test\TestCase {
/** @var string */
private $originalWebRoot;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
@@ -41,7 +41,7 @@ class UrlGeneratorTest extends \Test\TestCase {
$this->originalWebRoot = \OC::$WEBROOT;
}
- public function tearDown() {
+ protected function tearDown(): void {
// Reset webRoot
\OC::$WEBROOT = $this->originalWebRoot;
}
diff --git a/tests/lib/User/DatabaseTest.php b/tests/lib/User/DatabaseTest.php
index 8e52be50c75..65d483734d9 100644
--- a/tests/lib/User/DatabaseTest.php
+++ b/tests/lib/User/DatabaseTest.php
@@ -47,7 +47,7 @@ class DatabaseTest extends Backend {
return $user;
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
@@ -55,7 +55,7 @@ class DatabaseTest extends Backend {
$this->backend=new \OC\User\Database($this->eventDispatcher);
}
- protected function tearDown() {
+ protected function tearDown(): void {
if(!isset($this->users)) {
return;
}
@@ -82,11 +82,11 @@ class DatabaseTest extends Backend {
$this->assertSame($user, $this->backend->checkPassword($user, 'newpass'));
}
- /**
- * @expectedException \OC\HintException
- * @expectedExceptionMessage password change failed
- */
+
public function testVerifyPasswordEventFail() {
+ $this->expectException(\OC\HintException::class);
+ $this->expectExceptionMessage('password change failed');
+
$user = $this->getUser();
$this->backend->createUser($user, 'pass1');
diff --git a/tests/lib/User/Dummy.php b/tests/lib/User/Dummy.php
index 50382aa8fe6..7eb5cc41ba8 100644
--- a/tests/lib/User/Dummy.php
+++ b/tests/lib/User/Dummy.php
@@ -23,7 +23,7 @@
namespace Test\User;
class Dummy extends Backend {
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->backend=new \Test\Util\User\Dummy();
}
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php
index b99d499b2a8..58a6b550658 100644
--- a/tests/lib/User/ManagerTest.php
+++ b/tests/lib/User/ManagerTest.php
@@ -30,7 +30,7 @@ class ManagerTest extends TestCase {
/** @var EventDispatcherInterface */
private $dispatcher;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
@@ -367,10 +367,10 @@ class ManagerTest extends TestCase {
$this->assertEquals('foo', $user->getUID());
}
- /**
- * @expectedException \Exception
- */
+
public function testCreateUserSingleBackendExists() {
+ $this->expectException(\Exception::class);
+
/**
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
*/
@@ -420,11 +420,11 @@ class ManagerTest extends TestCase {
$this->assertFalse($manager->createUser('foo', 'bar'));
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Could not create user
- */
+
public function testCreateUserFromBackendWithBackendError() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Could not create user');
+
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject $config */
$config = $this->createMock(IConfig::class);
/** @var \Test\Util\User\Dummy|\PHPUnit_Framework_MockObject_MockObject $backend */
@@ -439,10 +439,10 @@ class ManagerTest extends TestCase {
$manager->createUserFromBackend('MyUid', 'MyPassword', $backend);
}
- /**
- * @expectedException \Exception
- */
+
public function testCreateUserTwoBackendExists() {
+ $this->expectException(\Exception::class);
+
/**
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1
*/
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php
index a37181c504c..3567aa9cf62 100644
--- a/tests/lib/User/SessionTest.php
+++ b/tests/lib/User/SessionTest.php
@@ -61,7 +61,7 @@ class SessionTest extends \Test\TestCase {
/** @var IEventDispatcher|MockObject */
private $dispatcher;
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->timeFactory = $this->createMock(ITimeFactory::class);
@@ -271,10 +271,10 @@ class SessionTest extends \Test\TestCase {
$this->assertEquals($user, $userSession->getUser());
}
- /**
- * @expectedException \OC\User\LoginException
- */
+
public function testLoginValidPasswordDisabled() {
+ $this->expectException(\OC\User\LoginException::class);
+
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock();
$session->expects($this->never())
->method('set');
@@ -404,10 +404,10 @@ class SessionTest extends \Test\TestCase {
$userSession->login('foo', 'bar');
}
- /**
- * @expectedException \OC\Authentication\Exceptions\PasswordLoginForbiddenException
- */
+
public function testLogClientInNoTokenPasswordWith2fa() {
+ $this->expectException(\OC\Authentication\Exceptions\PasswordLoginForbiddenException::class);
+
$manager = $this->createMock(Manager::class);
$session = $this->createMock(ISession::class);
$request = $this->createMock(IRequest::class);
@@ -508,10 +508,10 @@ class SessionTest extends \Test\TestCase {
$this->assertTrue($userSession->logClientIn('john', 'I-AM-AN-APP-PASSWORD', $request, $this->throttler));
}
- /**
- * @expectedException \OC\Authentication\Exceptions\PasswordLoginForbiddenException
- */
+
public function testLogClientInNoTokenPasswordNo2fa() {
+ $this->expectException(\OC\Authentication\Exceptions\PasswordLoginForbiddenException::class);
+
$manager = $this->createMock(Manager::class);
$session = $this->createMock(ISession::class);
$request = $this->createMock(IRequest::class);
@@ -973,10 +973,10 @@ class SessionTest extends \Test\TestCase {
$this->assertFalse($userSession->createSessionToken($request, $uid, $loginName, $password));
}
- /**
- * @expectedException \OC\User\LoginException
- */
+
public function testTryTokenLoginWithDisabledUser() {
+ $this->expectException(\OC\User\LoginException::class);
+
$manager = $this->getMockBuilder('\OC\User\Manager')
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php
index a800e790370..0bf582727ff 100644
--- a/tests/lib/User/UserTest.php
+++ b/tests/lib/User/UserTest.php
@@ -33,7 +33,7 @@ class UserTest extends TestCase {
/** @var EventDispatcherInterface|MockObject */
protected $dispatcher;
- public function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
}
diff --git a/tests/lib/UtilCheckServerTest.php b/tests/lib/UtilCheckServerTest.php
index c597a6b770b..3f956601ce4 100644
--- a/tests/lib/UtilCheckServerTest.php
+++ b/tests/lib/UtilCheckServerTest.php
@@ -36,7 +36,7 @@ class UtilCheckServerTest extends \Test\TestCase {
return $config;
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
$this->datadir = \OC::$server->getTempManager()->getTemporaryFolder();
@@ -45,7 +45,7 @@ class UtilCheckServerTest extends \Test\TestCase {
\OC::$server->getSession()->set('checkServer_succeeded', false);
}
- protected function tearDown() {
+ protected function tearDown(): void {
// clean up
@unlink($this->datadir . '/.ocdata');
parent::tearDown();
diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php
index d731085af46..a5ddd50ab27 100644
--- a/tests/lib/UtilTest.php
+++ b/tests/lib/UtilTest.php
@@ -348,13 +348,13 @@ class UtilTest extends \Test\TestCase {
$this->assertNotEmpty($errors);
}
- protected function setUp() {
+ protected function setUp(): void {
parent::setUp();
\OC_Util::$scripts = [];
\OC_Util::$styles = [];
}
- protected function tearDown() {
+ protected function tearDown(): void {
parent::tearDown();
\OC_Util::$scripts = [];
diff --git a/tests/phpunit-autotest.xml b/tests/phpunit-autotest.xml
index b09b571c1c7..da786c765f8 100644
--- a/tests/phpunit-autotest.xml
+++ b/tests/phpunit-autotest.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="bootstrap.php"
- strict="true"
verbose="true"
backupGlobals="false"
timeoutForSmallTests="900"
diff --git a/tests/startsessionlistener.php b/tests/startsessionlistener.php
index 24a72db0065..d9d23ee6db8 100644
--- a/tests/startsessionlistener.php
+++ b/tests/startsessionlistener.php
@@ -18,7 +18,7 @@ class StartSessionListener implements TestListener {
use TestListenerDefaultImplementation;
- public function endTest(Test $test, $time) {
+ public function endTest(Test $test, float $time): void {
// reopen the session - only allowed for memory session
if (\OC::$server->getSession() instanceof Memory) {
/** @var $session Memory */