aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js108
-rw-r--r--tests/data/integritycheck/mimetypeListModified/core/signature.json4
-rw-r--r--tests/lib/Accounts/AccountManagerTest.php23
-rw-r--r--tests/lib/Accounts/AccountPropertyTest.php7
-rw-r--r--tests/lib/Accounts/HooksTest.php12
-rw-r--r--tests/lib/Activity/ManagerTest.php6
-rw-r--r--tests/lib/AllConfigTest.php2
-rw-r--r--tests/lib/App/AppManagerTest.php4
-rw-r--r--tests/lib/App/AppStore/Fetcher/AppDiscoverFetcherTest.php2
-rw-r--r--tests/lib/App/AppStore/Fetcher/AppFetcherTest.php2
-rw-r--r--tests/lib/App/AppStore/Version/VersionParserTest.php6
-rw-r--r--tests/lib/App/CompareVersionTest.php2
-rw-r--r--tests/lib/App/DependencyAnalyzerTest.php12
-rw-r--r--tests/lib/App/InfoParserTest.php2
-rw-r--r--tests/lib/App/PlatformRepositoryTest.php2
-rw-r--r--tests/lib/AppConfigTest.php30
-rw-r--r--tests/lib/AppFramework/AppTest.php2
-rw-r--r--tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php2
-rw-r--r--tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php10
-rw-r--r--tests/lib/AppFramework/Controller/ControllerTest.php2
-rw-r--r--tests/lib/AppFramework/Controller/PublicShareControllerTest.php2
-rw-r--r--tests/lib/AppFramework/Db/EntityTest.php2
-rw-r--r--tests/lib/AppFramework/Db/QBMapperTest.php95
-rw-r--r--tests/lib/AppFramework/DependencyInjection/DIContainerTest.php2
-rw-r--r--tests/lib/AppFramework/Http/DispatcherTest.php40
-rw-r--r--tests/lib/AppFramework/Http/DownloadResponseTest.php2
-rw-r--r--tests/lib/AppFramework/Http/JSONResponseTest.php5
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php17
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareTest.php7
-rw-r--r--tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php120
-rw-r--r--tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php41
-rw-r--r--tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php16
-rw-r--r--tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php20
-rw-r--r--tests/lib/AppFramework/OCS/V2ResponseTest.php2
-rw-r--r--tests/lib/AppFramework/Routing/RouteParserTest.php347
-rw-r--r--tests/lib/AppFramework/Routing/RoutingTest.php476
-rw-r--r--tests/lib/AppFramework/Services/AppConfigTest.php16
-rw-r--r--tests/lib/AppFramework/Utility/SimpleContainerTest.php2
-rw-r--r--tests/lib/AppTest.php6
-rw-r--r--tests/lib/Archive/ZIPTest.php6
-rw-r--r--tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php15
-rw-r--r--tests/lib/Authentication/Login/ALoginTestCommand.php (renamed from tests/lib/Authentication/Login/ALoginCommandTest.php)5
-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/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/Token/ManagerTest.php41
-rw-r--r--tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php47
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/ManagerTest.php115
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/RegistryTest.php13
-rw-r--r--tests/lib/Avatar/AvatarManagerTest.php2
-rw-r--r--tests/lib/Avatar/UserAvatarTest.php2
-rw-r--r--tests/lib/BackgroundJob/JobListTest.php2
-rw-r--r--tests/lib/Cache/FileCacheTest.php4
-rw-r--r--tests/lib/Calendar/ManagerTest.php10
-rw-r--r--tests/lib/Collaboration/Collaborators/MailPluginTest.php4
-rw-r--r--tests/lib/Collaboration/Collaborators/RemotePluginTest.php6
-rw-r--r--tests/lib/Collaboration/Collaborators/SearchResultTest.php4
-rw-r--r--tests/lib/Collaboration/Collaborators/SearchTest.php2
-rw-r--r--tests/lib/Collaboration/Collaborators/UserPluginTest.php6
-rw-r--r--tests/lib/Command/AsyncBusTestCase.php (renamed from tests/lib/Command/AsyncBusTest.php)20
-rw-r--r--tests/lib/Command/BackgroundModeTest.php5
-rw-r--r--tests/lib/Command/CronBusTest.php5
-rw-r--r--tests/lib/Command/Integrity/SignAppTest.php217
-rw-r--r--tests/lib/Command/Integrity/SignCoreTest.php166
-rw-r--r--tests/lib/Comments/CommentTest.php6
-rw-r--r--tests/lib/Config/UserConfigTest.php69
-rw-r--r--tests/lib/ContactsManagerTest.php2
-rw-r--r--tests/lib/DB/ConnectionFactoryTest.php2
-rw-r--r--tests/lib/DB/Exception/DbalExceptionTest.php2
-rw-r--r--tests/lib/DB/MigrationsTest.php2
-rw-r--r--tests/lib/DB/MigratorTest.php2
-rw-r--r--tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php9
-rw-r--r--tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php14
-rw-r--r--tests/lib/DB/QueryBuilder/FunctionBuilderTest.php6
-rw-r--r--tests/lib/DB/QueryBuilder/Partitioned/JoinConditionTest.php2
-rw-r--r--tests/lib/DB/QueryBuilder/QueryBuilderTest.php50
-rw-r--r--tests/lib/DB/QueryBuilder/QuoteHelperTest.php4
-rw-r--r--tests/lib/DateTimeFormatterTest.php56
-rw-r--r--tests/lib/EmojiHelperTest.php7
-rw-r--r--tests/lib/Encryption/EncryptionWrapperTest.php11
-rw-r--r--tests/lib/Encryption/UpdateTest.php195
-rw-r--r--tests/lib/Encryption/UtilTest.php30
-rw-r--r--tests/lib/ErrorHandlerTest.php14
-rw-r--r--tests/lib/Federation/CloudIdManagerTest.php8
-rw-r--r--tests/lib/Federation/CloudIdTest.php2
-rw-r--r--tests/lib/Files/Cache/CacheTest.php50
-rw-r--r--tests/lib/Files/Cache/ScannerTest.php2
-rw-r--r--tests/lib/Files/Cache/SearchBuilderTest.php2
-rw-r--r--tests/lib/Files/Cache/UpdaterTest.php2
-rw-r--r--tests/lib/Files/Cache/Wrapper/CacheJailTest.php11
-rw-r--r--tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php2
-rw-r--r--tests/lib/Files/Config/UserMountCacheTest.php23
-rw-r--r--tests/lib/Files/FilenameValidatorTest.php8
-rw-r--r--tests/lib/Files/FilesystemTest.php8
-rw-r--r--tests/lib/Files/Node/FileTest.php14
-rw-r--r--tests/lib/Files/Node/FolderTest.php24
-rw-r--r--tests/lib/Files/Node/HookConnectorTest.php4
-rw-r--r--tests/lib/Files/Node/NodeTestCase.php (renamed from tests/lib/Files/Node/NodeTest.php)11
-rw-r--r--tests/lib/Files/ObjectStore/AzureTest.php2
-rw-r--r--tests/lib/Files/ObjectStore/LocalTest.php2
-rw-r--r--tests/lib/Files/ObjectStore/MapperTest.php2
-rw-r--r--tests/lib/Files/ObjectStore/ObjectStoreStoragesDifferentBucketTest.php4
-rw-r--r--tests/lib/Files/ObjectStore/ObjectStoreStoragesSameBucketTest.php4
-rw-r--r--tests/lib/Files/ObjectStore/ObjectStoreTestCase.php (renamed from tests/lib/Files/ObjectStore/ObjectStoreTest.php)21
-rw-r--r--tests/lib/Files/ObjectStore/S3Test.php4
-rw-r--r--tests/lib/Files/ObjectStore/SwiftTest.php2
-rw-r--r--tests/lib/Files/PathVerificationTest.php8
-rw-r--r--tests/lib/Files/Storage/Storage.php10
-rw-r--r--tests/lib/Files/Storage/StoragesTestCase.php (renamed from tests/lib/Files/Storage/StoragesTest.php)2
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncodingTest.php12
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php81
-rw-r--r--tests/lib/Files/Storage/Wrapper/QuotaTest.php4
-rw-r--r--tests/lib/Files/Stream/EncryptionTest.php44
-rw-r--r--tests/lib/Files/Stream/HashWrapperTest.php2
-rw-r--r--tests/lib/Files/Utils/ScannerTest.php5
-rw-r--r--tests/lib/Files/ViewTest.php24
-rw-r--r--tests/lib/GlobalScale/ConfigTest.php4
-rw-r--r--tests/lib/Group/ManagerTest.php55
-rw-r--r--tests/lib/HelperStorageTest.php4
-rw-r--r--tests/lib/ImageTest.php8
-rw-r--r--tests/lib/InfoXmlTest.php2
-rw-r--r--tests/lib/InitialStateServiceTest.php2
-rw-r--r--tests/lib/InstallerTest.php2
-rw-r--r--tests/lib/IntegrityCheck/CheckerTest.php9
-rw-r--r--tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php8
-rw-r--r--tests/lib/L10N/L10nTest.php13
-rw-r--r--tests/lib/L10N/LanguageIteratorTest.php2
-rw-r--r--tests/lib/LargeFileHelperGetFileSizeTest.php2
-rw-r--r--tests/lib/LegacyHelperTest.php107
-rw-r--r--tests/lib/Log/PsrLoggerAdapterTest.php4
-rw-r--r--tests/lib/LoggerTest.php4
-rw-r--r--tests/lib/Mail/MailerTest.php6
-rw-r--r--tests/lib/Mail/MessageTest.php5
-rw-r--r--tests/lib/Memcache/FactoryTest.php4
-rw-r--r--tests/lib/MemoryInfoTest.php17
-rw-r--r--tests/lib/Migration/BackgroundRepairTest.php13
-rw-r--r--tests/lib/NaturalSortTest.php4
-rw-r--r--tests/lib/NavigationManagerTest.php12
-rw-r--r--tests/lib/Net/HostnameClassifierTest.php4
-rw-r--r--tests/lib/Net/IpAddressClassifierTest.php4
-rw-r--r--tests/lib/Notification/ActionTest.php14
-rw-r--r--tests/lib/Notification/ManagerTest.php10
-rw-r--r--tests/lib/Notification/NotificationTest.php86
-rw-r--r--tests/lib/OCS/ApiHelperTest.php5
-rw-r--r--tests/lib/OCS/DiscoveryServiceTest.php4
-rw-r--r--tests/lib/Preview/GeneratorTest.php2
-rw-r--r--tests/lib/Preview/SVGTest.php2
-rw-r--r--tests/lib/Repair/ClearGeneratedAvatarCacheTest.php2
-rw-r--r--tests/lib/Repair/RepairInvalidSharesTest.php2
-rw-r--r--tests/lib/RichObjectStrings/DefinitionsTest.php4
-rw-r--r--tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php4
-rw-r--r--tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php2
-rw-r--r--tests/lib/Security/CertificateManagerTest.php9
-rw-r--r--tests/lib/Security/CredentialsManagerTest.php2
-rw-r--r--tests/lib/Security/CryptoTest.php2
-rw-r--r--tests/lib/Security/HasherTest.php11
-rw-r--r--tests/lib/Security/Ip/BruteforceAllowListTest.php2
-rw-r--r--tests/lib/Security/Ip/RemoteAddressTest.php2
-rw-r--r--tests/lib/Security/Normalizer/IpAddressTest.php2
-rw-r--r--tests/lib/Security/RateLimiting/LimiterTest.php23
-rw-r--r--tests/lib/Security/RemoteHostValidatorIntegrationTest.php4
-rw-r--r--tests/lib/Security/RemoteHostValidatorTest.php2
-rw-r--r--tests/lib/Security/SecureRandomTest.php6
-rw-r--r--tests/lib/Security/TrustedDomainHelperTest.php2
-rw-r--r--tests/lib/ServerTest.php2
-rw-r--r--tests/lib/SetupTest.php4
-rw-r--r--tests/lib/Share/HelperTest.php4
-rw-r--r--tests/lib/Share/ShareTest.php4
-rw-r--r--tests/lib/Share20/DefaultShareProviderTest.php16
-rw-r--r--tests/lib/Share20/LegacyHooksTest.php25
-rw-r--r--tests/lib/Share20/ShareHelperTest.php10
-rw-r--r--tests/lib/Support/Subscription/RegistryTest.php2
-rw-r--r--tests/lib/SystemTag/SystemTagManagerTest.php16
-rw-r--r--tests/lib/Updater/ReleaseMetadataTest.php14
-rw-r--r--tests/lib/Updater/VersionCheckTest.php2
-rw-r--r--tests/lib/UpdaterTest.php2
-rw-r--r--tests/lib/UrlGeneratorTest.php14
-rw-r--r--tests/lib/User/SessionTest.php52
-rw-r--r--tests/lib/User/UserTest.php10
191 files changed, 1871 insertions, 1877 deletions
diff --git a/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js b/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js
index 2a33e82c214..8d5c7702caa 100644
--- a/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js
+++ b/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js
@@ -152,5 +152,111 @@ OC.MimeTypeList={
"x-office-presentation",
"x-office-spreadsheet"
],
- themes: []
+ themes: [],
+ names: {'application/epub+zip': t('core', "Electronic book document"),
+'application/gpx+xml': t('core', "GPX geographic data"),
+'application/gzip': t('core', "Gzip archive"),
+'application/illustrator': t('core', "Adobe Illustrator document"),
+'application/json': t('core', "JSON document"),
+'application/msword': t('core', "Word document"),
+'application/octet-stream': t('core', "Unknown"),
+'application/pdf': t('core', "PDF document"),
+'application/postscript': t('core', "PostScript document"),
+'application/rss+xml': t('core', "RSS summary"),
+'application/vnd.android.package-archive': t('core', "Android package"),
+'application/vnd.google-earth.kml+xml': t('core', "KML geographic data"),
+'application/vnd.google-earth.kmz': t('core', "KML geographic compressed data"),
+'application/vnd.lotus-wordpro': t('core', "Lotus Word Pro document"),
+'application/vnd.ms-excel': t('core', "Excel spreadsheet"),
+'application/vnd.ms-excel.addin.macroEnabled.12': t('core', "Excel add-in"),
+'application/vnd.ms-excel.sheet.binary.macroEnabled.12': t('core', "Excel 2007 binary spreadsheet"),
+'application/vnd.ms-excel.sheet.macroEnabled.12': t('core', "Excel spreadsheet"),
+'application/vnd.ms-excel.template.macroEnabled.12': t('core', "Excel spreadsheet template"),
+'application/vnd.ms-powerpoint': t('core', "PowerPoint presentation"),
+'application/vnd.ms-powerpoint.addin.macroEnabled.12': t('core', "PowerPoint add-in"),
+'application/vnd.ms-powerpoint.presentation.macroEnabled.12': t('core', "PowerPoint presentation"),
+'application/vnd.ms-powerpoint.slideshow.macroEnabled.12': t('core', "PowerPoint presentation"),
+'application/vnd.ms-powerpoint.template.macroEnabled.12': t('core', "PowerPoint presentation template"),
+'application/vnd.ms-word.document.macroEnabled.12': t('core', "Word document"),
+'application/vnd.oasis.opendocument.formula': t('core', "ODF formula"),
+'application/vnd.oasis.opendocument.graphics': t('core', "ODG drawing"),
+'application/vnd.oasis.opendocument.graphics-flat-xml': t('core', "ODG drawing (Flat XML)"),
+'application/vnd.oasis.opendocument.graphics-template': t('core', "ODG template"),
+'application/vnd.oasis.opendocument.presentation': t('core', "ODP presentation"),
+'application/vnd.oasis.opendocument.presentation-flat-xml': t('core', "ODP presentation (Flat XML)"),
+'application/vnd.oasis.opendocument.presentation-template': t('core', "ODP template"),
+'application/vnd.oasis.opendocument.spreadsheet': t('core', "ODS spreadsheet"),
+'application/vnd.oasis.opendocument.spreadsheet-flat-xml': t('core', "ODS spreadsheet (Flat XML)"),
+'application/vnd.oasis.opendocument.spreadsheet-template': t('core', "ODS template"),
+'application/vnd.oasis.opendocument.text': t('core', "ODT document"),
+'application/vnd.oasis.opendocument.text-flat-xml': t('core', "ODT document (Flat XML)"),
+'application/vnd.oasis.opendocument.text-template': t('core', "ODT template"),
+'application/vnd.openxmlformats-officedocument.presentationml.presentation': t('core', "PowerPoint 2007 presentation"),
+'application/vnd.openxmlformats-officedocument.presentationml.slideshow': t('core', "PowerPoint 2007 show"),
+'application/vnd.openxmlformats-officedocument.presentationml.template': t('core', "PowerPoint 2007 presentation template"),
+'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': t('core', "Excel 2007 spreadsheet"),
+'application/vnd.openxmlformats-officedocument.spreadsheetml.template': t('core', "Excel 2007 spreadsheet template"),
+'application/vnd.openxmlformats-officedocument.wordprocessingml.document': t('core', "Word 2007 document"),
+'application/vnd.openxmlformats-officedocument.wordprocessingml.template': t('core', "Word 2007 document template"),
+'application/vnd.visio': t('core', "Microsoft Visio document"),
+'application/vnd.wordperfect': t('core', "WordPerfect document"),
+'application/x-7z-compressed': t('core', "7-zip archive"),
+'application/x-blender': t('core', "Blender scene"),
+'application/x-bzip2': t('core', "Bzip2 archive"),
+'application/x-fictionbook+xml': t('core', "FictionBook document"),
+'application/x-krita': t('core', "Krita document"),
+'application/x-mobipocket-ebook': t('core', "Mobipocket e-book"),
+'application/x-msi': t('core', "Windows Installer package"),
+'application/x-perl': t('core', "Perl script"),
+'application/x-php': t('core', "PHP script"),
+'application/x-tar': t('core', "Tar archive"),
+'application/xml': t('core', "XML document"),
+'application/yaml': t('core', "YAML document"),
+'application/zip': t('core', "Zip archive"),
+'application/zstd': t('core', "Zstandard archive"),
+'audio/aac': t('core', "AAC audio"),
+'audio/flac': t('core', "FLAC audio"),
+'audio/mp4': t('core', "MPEG-4 audio"),
+'audio/mpeg': t('core', "MP3 audio"),
+'audio/ogg': t('core', "Ogg audio"),
+'audio/webm': t('core', "WebM audio"),
+'audio/x-scpls': t('core', "MP3 ShoutCast playlist"),
+'image/bmp': t('core', "Windows BMP image"),
+'image/emf': t('core', "EMF image"),
+'image/gif': t('core', "GIF image"),
+'image/heif': t('core', "HEIF image"),
+'image/jp2': t('core', "JPEG-2000 JP2 image"),
+'image/jpeg': t('core', "JPEG image"),
+'image/png': t('core', "PNG image"),
+'image/svg+xml': t('core', "SVG image"),
+'image/tiff': t('core', "TIFF image"),
+'image/webp': t('core', "WebP image"),
+'image/x-dcraw': t('core', "Digital raw image"),
+'message/rfc822': t('core', "Email message"),
+'text/calendar': t('core', "VCS\/ICS calendar"),
+'text/css': t('core', "CSS stylesheet"),
+'text/csv': t('core', "CSV document"),
+'text/html': t('core', "HTML document"),
+'text/markdown': t('core', "Markdown document"),
+'text/org': t('core', "Org-mode file"),
+'text/plain': t('core', "Plain text document"),
+'text/vcard': t('core', "Electronic business card"),
+'text/x-c++src': t('core', "C++ source code"),
+'text/x-ldif': t('core', "LDIF address book"),
+'text/x-nfo': t('core', "NFO document"),
+'text/x-python': t('core', "Python script"),
+'text/x-rst': t('core', "ReStructuredText document"),
+'video/3gpp': t('core', "3GPP multimedia file"),
+'video/dv': t('core', "DV video"),
+'video/mp2t': t('core', "MPEG-2 transport stream"),
+'video/mp4': t('core', "MPEG-4 video"),
+'video/mpeg': t('core', "MPEG video"),
+'video/ogg': t('core', "Ogg video"),
+'video/quicktime': t('core', "QuickTime video"),
+'video/webm': t('core', "WebM video"),
+'video/x-flv': t('core', "Flash video"),
+'video/x-matroska': t('core', "Matroska video"),
+'video/x-ms-wmv': t('core', "Windows Media video"),
+'my-custom/mimetype': t('core', "Custom Document"),
+},
};
diff --git a/tests/data/integritycheck/mimetypeListModified/core/signature.json b/tests/data/integritycheck/mimetypeListModified/core/signature.json
index f4c5ee55857..cac26e900c5 100644
--- a/tests/data/integritycheck/mimetypeListModified/core/signature.json
+++ b/tests/data/integritycheck/mimetypeListModified/core/signature.json
@@ -1,7 +1,7 @@
{
"hashes": {
- "core\/js\/mimetypelist.js": "46f0174073339b822fc7d4a0f02bda57f211eb85b42995bd300232e77712ca05e14f6491f67c7b2da76d90b94fde8e16e01f5258a7586c2498d66247f81feaf8"
+ "core\/js\/mimetypelist.js": "1f672ccc11dd5f0cf8753461476b05fbf6fec018db00fc59b074947953ba99481103f84ace140255995278da7ef4e3b49d263cc29a4b29786fb19413083fe928"
},
- "signature": "ZTndGos1JFlIVm38RMTuSWaD32D09kJ8yiin7zlXpF4NWJmcOca2WQQOtgnBxcawSS6Udhnu27gyYQDV9ZkDPcAQAc7oj0yBjNTgcABkhif3XKCJ+nJBMHWxdrItJ+dXplLNQSdwX0CeNfbkBbp6bLCBDmjG3FyxNdsbJEtlCAmA+PrxwsWUwsoZJR8MJVuIBQl\/nu+17a1Q6B9t8KBbbdN59FDv\/lTPYRp8YJSlfR6\/lPRPSk1Q9p\/vhjBE25wo6HfXYxb1LhnO6g78bcE\/MBuX3BhCbARImuwLOiOLl\/RUXePOgH\/M2sNpjETu4LOmludd4mgJJ78YygjPvCcp8BMHL\/s8q+2z1OSDj6W\/Qjw4iHAW0oigaaajjwFD1agjsVHYK9M0ypL8BH\/cDKQDFvMU6s\/+aDjUgqZDspqovbcmujtHWU\/bRY89OcOBJcLoGWcjUvpk6o12ONUtihOgt7OdtHL33ZUYu0MOgTmCPjE84xqiOPgfRV+sPUpBKwsPyYDPy4sIj53W4nJswIh+Z3R+DUv85LLwx0g1AZTT1gOxMNRILJrFSAHFpbEFeVOhOS\/9b1FiVs7XtShPNXWxArltVd2BjqLhhjPbgRuiALlUuBJN2UyxGlLoDcOm4bIymG1dUtNSWJRjMxKxdQjpuxuhspEaDmHWzq6htO+6elI=",
+ "signature": "V7eDZqrauafx5b\/taQ0Z2GYyuX6gjLU2\/igpQxs4o3YGG+ruBNk5PFoJxBbLogt5QrUIPilVJy3+2f4BkzWl7E2El51d2O+Ctg+cWATCvF6SJyhCdzZQLknyLXr4n+r7FlvHpiSQ8c88Aq2gNrBpK34Lq7YKjfln7q19vWIGUIYcE5gJJzhloSTF76\/yq3gIw48EXVrYMdT0nhE5zzk+pKJSvJCmtZGeyocXfHdRKGViH1egKvB8AJkTMByDbLKd9ZXhGrrQ1QWtJHLCDLrv6oBykz7N9J8yRbrKXjeuBtDAUfYHZeUbx7DYStNEWa3npXtst1HSJ7mMV5QYT9S9HbQp7qMQQBoze81QH3DS7jpksSkRr5w\/kE6FiNe8B8s56DMrNUo6NOFhsNRZF\/SNkVMgbRuckpCDHAE6hkz3+DwTQB7uYGu3qc965Yxn9YiGD83ep++c9CkEMOQL2q+CftbVMXVjF++Ml9P\/9N+ARF1t9mffEC8vOGaU1OR6DmPsbl1mlvkdP1RMKwa3Kp0nWEsWhDjjcB9b1hf4KCsPb6iiiyAV21qgigK73Aq\/8NRy0RlNB4rWsbb1NAV2tnnrJRbwdJrtS5dvTBADmsazt73jzkpc36vJNhBRaMUKTW05x7wnrw9K6MQDkjLuzfXJQWEJQtr+4dP9oyasamBufKc=",
"certificate": "-----BEGIN CERTIFICATE-----\r\nMIIEvjCCAqagAwIBAgIUc\/0FxYrsgSs9rDxp03EJmbjN0NwwDQYJKoZIhvcNAQEF\r\nBQAwIzEhMB8GA1UECgwYb3duQ2xvdWQgQ29kZSBTaWduaW5nIENBMB4XDTE1MTEw\r\nMzIxMDMzM1oXDTE2MTEwMzIxMDMzM1owDzENMAsGA1UEAwwEY29yZTCCAiIwDQYJ\r\nKoZIhvcNAQEBBQADggIPADCCAgoCggIBALb6EgHpkAqZbO5vRO8XSh7G7XGWHw5s\r\niOf4RwPXR6SE9bWZEm\/b72SfWk\/\/J6AbrD8WiOzBuT\/ODy6k5T1arEdHO+Pux0W1\r\nMxYJJI4kH74KKgMpC0SB0Rt+8WrMqV1r3hhJ46df6Xr\/xolP3oD+eLbShPcblhdS\r\nVtkZEkoev8Sh6L2wDCeHDyPxzvj1w2dTdGVO9Kztn0xIlyfEBakqvBWtcxyi3Ln0\r\nklnxlMx3tPDUE4kqvpia9qNiB1AN2PV93eNr5\/2riAzIssMFSCarWCx0AKYb54+d\r\nxLpcYFyqPJ0ydBCkF78DD45RCZet6PNYkdzgbqlUWEGGomkuDoJbBg4wzgzO0D77\r\nH87KFhYW8tKFFvF1V3AHl\/sFQ9tDHaxM9Y0pZ2jPp\/ccdiqnmdkBxBDqsiRvHvVB\r\nCn6qpb4vWGFC7vHOBfYspmEL1zLlKXZv3ezMZEZw7O9ZvUP3VO\/wAtd2vUW8UFiq\r\ns2v1QnNLN6jNh51obcwmrBvWhJy9vQIdtIjQbDxqWTHh1zUSrw9wrlklCBZ\/zrM0\r\ni8nfCFwTxWRxp3H9KoECzO\/zS5R5KIS7s3\/wq\/w9T2Ie4rcecgXwDizwnn0C\/aKc\r\nbDIjujpL1s9HO05pcD\/V3wKcPZ1izymBkmMyIbL52iRVN5FTVHeZdXPpFuq+CTQJ\r\nQ238lC+A\/KOVAgMBAAEwDQYJKoZIhvcNAQEFBQADggIBAGoKTnh8RfJV4sQItVC2\r\nAvfJagkrIqZ3iiQTUBQGTKBsTnAqE1H7QgUSV9vSd+8rgvHkyZsRjmtyR1e3A6Ji\r\noNCXUbExC\/0iCPUqdHZIVb+Lc\/vWuv4ByFMybGPydgtLoEUX2ZrKFWmcgZFDUSRd\r\n9Uj26vtUhCC4bU4jgu6hIrR9IuxOBLQUxGTRZyAcXvj7obqRAEZwFAKQgFpfpqTb\r\nH+kjcbZSaAlLVSF7vBc1syyI8RGYbqpwvtREqJtl5IEIwe6huEqJ3zPnlP2th\/55\r\ncf3Fovj6JJgbb9XFxrdnsOsDOu\/tpnaRWlvv5ib4+SzG5wWFT5UUEo4Wg2STQiiX\r\nuVSRQxK1LE1yg84bs3NZk9FSQh4B8vZVuRr5FaJsZZkwlFlhRO\/\/+TJtXRbyNgsf\r\noMRZGi8DLGU2SGEAHcRH\/QZHq\/XDUWVzdxrSBYcy7GSpT7UDVzGv1rEJUrn5veP1\r\n0KmauAqtiIaYRm4f6YBsn0INcZxzIPZ0p8qFtVZBPeHhvQtvOt0iXI\/XUxEWOa2F\r\nK2EqhErgMK\/N07U1JJJay5tYZRtvkGq46oP\/5kQG8hYST0MDK6VihJoPpvCmAm4E\r\npEYKQ96x6A4EH9Y9mZlYozH\/eqmxPbTK8n89\/p7Ydun4rI+B2iiLnY8REWWy6+UQ\r\nV204fGUkJqW5CrKy3P3XvY9X\r\n-----END CERTIFICATE-----"
} \ No newline at end of file
diff --git a/tests/lib/Accounts/AccountManagerTest.php b/tests/lib/Accounts/AccountManagerTest.php
index fab3aaf5fdd..05c7efd08fb 100644
--- a/tests/lib/Accounts/AccountManagerTest.php
+++ b/tests/lib/Accounts/AccountManagerTest.php
@@ -499,7 +499,7 @@ class AccountManagerTest extends TestCase {
$this->invokePrivate($accountManager, 'updateUser', [$user, $newData, $oldData]);
}
- public function dataTrueFalse(): array {
+ public static function dataTrueFalse(): array {
return [
#$newData | $oldData | $insertNew | $updateExisting
[['myProperty' => ['value' => 'newData']], ['myProperty' => ['value' => 'oldData']], false, true],
@@ -896,7 +896,7 @@ class AccountManagerTest extends TestCase {
}
}
- public function searchDataProvider(): array {
+ public static function searchDataProvider(): array {
return [
[ #0 Search for an existing name
IAccountManager::PROPERTY_DISPLAYNAME,
@@ -948,21 +948,22 @@ class AccountManagerTest extends TestCase {
];
}
- public function dataCheckEmailVerification(): array {
+ public static function dataCheckEmailVerification(): array {
return [
- [$this->makeUser('steve', 'Steve Smith', 'steve@steve.steve'), null],
- [$this->makeUser('emma', 'Emma Morales', 'emma@emma.com'), 'emma@morales.com'],
- [$this->makeUser('sarah@web.org', 'Sarah Foster', 'sarah@web.org'), null],
- [$this->makeUser('cole@web.org', 'Cole Harrison', 'cole@web.org'), 'cole@example.com'],
- [$this->makeUser('8d29e358-cf69-4849-bbf9-28076c0b908b', 'Alice McPherson', 'alice@example.com'), 'alice@mcpherson.com'],
- [$this->makeUser('11da2744-3f4d-4c17-8c13-4c057a379237', 'James Loranger', 'james@example.com'), ''],
+ [['steve', 'Steve Smith', 'steve@steve.steve'], null],
+ [['emma', 'Emma Morales', 'emma@emma.com'], 'emma@morales.com'],
+ [['sarah@web.org', 'Sarah Foster', 'sarah@web.org'], null],
+ [['cole@web.org', 'Cole Harrison', 'cole@web.org'], 'cole@example.com'],
+ [['8d29e358-cf69-4849-bbf9-28076c0b908b', 'Alice McPherson', 'alice@example.com'], 'alice@mcpherson.com'],
+ [['11da2744-3f4d-4c17-8c13-4c057a379237', 'James Loranger', 'james@example.com'], ''],
];
}
/**
* @dataProvider dataCheckEmailVerification
*/
- public function testCheckEmailVerification(IUser $user, ?string $newEmail): void {
+ public function testCheckEmailVerification(array $userData, ?string $newEmail): void {
+ $user = $this->makeUser(...$userData);
// Once because of getAccount, once because of getUser
$this->config->expects($this->exactly(2))->method('getSystemValue')->with('account_manager.default_property_scope', [])->willReturn([]);
$account = $this->accountManager->getAccount($user);
@@ -988,7 +989,7 @@ class AccountManagerTest extends TestCase {
$this->invokePrivate($this->accountManager, 'checkEmailVerification', [$account, $oldData]);
}
- public function dataSetDefaultPropertyScopes(): array {
+ public static function dataSetDefaultPropertyScopes(): array {
return [
[
[],
diff --git a/tests/lib/Accounts/AccountPropertyTest.php b/tests/lib/Accounts/AccountPropertyTest.php
index 5df66eaa117..68e1da41557 100644
--- a/tests/lib/Accounts/AccountPropertyTest.php
+++ b/tests/lib/Accounts/AccountPropertyTest.php
@@ -56,18 +56,13 @@ class AccountPropertyTest extends TestCase {
$this->assertEquals(IAccountManager::SCOPE_LOCAL, $actualReturn->getScope());
}
- public function scopesProvider() {
+ public static function scopesProvider(): array {
return [
// current values
[IAccountManager::SCOPE_PRIVATE, IAccountManager::SCOPE_PRIVATE],
[IAccountManager::SCOPE_LOCAL, IAccountManager::SCOPE_LOCAL],
[IAccountManager::SCOPE_FEDERATED, IAccountManager::SCOPE_FEDERATED],
[IAccountManager::SCOPE_PUBLISHED, IAccountManager::SCOPE_PUBLISHED],
- // legacy values
- [IAccountManager::VISIBILITY_PRIVATE, IAccountManager::SCOPE_LOCAL],
- [IAccountManager::VISIBILITY_CONTACTS_ONLY, IAccountManager::SCOPE_FEDERATED],
- [IAccountManager::VISIBILITY_PUBLIC, IAccountManager::SCOPE_PUBLISHED],
- ['', IAccountManager::SCOPE_LOCAL],
// invalid values
['unknown', null],
['v2-unknown', null],
diff --git a/tests/lib/Accounts/HooksTest.php b/tests/lib/Accounts/HooksTest.php
index 75772089f43..73cef2e2c65 100644
--- a/tests/lib/Accounts/HooksTest.php
+++ b/tests/lib/Accounts/HooksTest.php
@@ -96,14 +96,14 @@ class HooksTest extends TestCase {
}
}
+ $params['user'] = $this->createMock(IUser::class);
$this->hooks->changeUserHook($params['user'], $params['feature'], $params['value']);
}
- public function dataTestChangeUserHook() {
- $user = $this->createMock(IUser::class);
+ public static function dataTestChangeUserHook(): array {
return [
[
- ['user' => $user, 'feature' => '', 'value' => ''],
+ ['feature' => '', 'value' => ''],
[
IAccountManager::PROPERTY_EMAIL => ['value' => ''],
IAccountManager::PROPERTY_DISPLAYNAME => ['value' => '']
@@ -111,7 +111,7 @@ class HooksTest extends TestCase {
false, false, true
],
[
- ['user' => $user, 'feature' => 'foo', 'value' => 'bar'],
+ ['feature' => 'foo', 'value' => 'bar'],
[
IAccountManager::PROPERTY_EMAIL => ['value' => 'oldMail@example.com'],
IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'oldDisplayName']
@@ -119,7 +119,7 @@ class HooksTest extends TestCase {
false, false, false
],
[
- ['user' => $user, 'feature' => 'eMailAddress', 'value' => 'newMail@example.com'],
+ ['feature' => 'eMailAddress', 'value' => 'newMail@example.com'],
[
IAccountManager::PROPERTY_EMAIL => ['value' => 'oldMail@example.com'],
IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'oldDisplayName']
@@ -127,7 +127,7 @@ class HooksTest extends TestCase {
true, false, false
],
[
- ['user' => $user, 'feature' => 'displayName', 'value' => 'newDisplayName'],
+ ['feature' => 'displayName', 'value' => 'newDisplayName'],
[
IAccountManager::PROPERTY_EMAIL => ['value' => 'oldMail@example.com'],
IAccountManager::PROPERTY_DISPLAYNAME => ['value' => 'oldDisplayName']
diff --git a/tests/lib/Activity/ManagerTest.php b/tests/lib/Activity/ManagerTest.php
index 61eeee82c43..f42a38eab53 100644
--- a/tests/lib/Activity/ManagerTest.php
+++ b/tests/lib/Activity/ManagerTest.php
@@ -74,7 +74,7 @@ class ManagerTest extends TestCase {
self::invokePrivate($this->activityManager, 'getConsumers');
}
- public function getUserFromTokenThrowInvalidTokenData() {
+ public static function getUserFromTokenThrowInvalidTokenData(): array {
return [
[null, []],
['', []],
@@ -98,7 +98,7 @@ class ManagerTest extends TestCase {
self::invokePrivate($this->activityManager, 'getUserFromToken');
}
- public function getUserFromTokenData() {
+ public static function getUserFromTokenData(): array {
return [
[null, '123456789012345678901234567890', 'user1'],
['user2', null, 'user2'],
@@ -190,7 +190,7 @@ class ManagerTest extends TestCase {
$this->activityManager->publish($event);
}
- public function dataPublish() {
+ public static function dataPublish(): array {
return [
[null, ''],
['test_author', 'test_author'],
diff --git a/tests/lib/AllConfigTest.php b/tests/lib/AllConfigTest.php
index e892e441ecf..b4137c07ac5 100644
--- a/tests/lib/AllConfigTest.php
+++ b/tests/lib/AllConfigTest.php
@@ -125,7 +125,7 @@ class AllConfigTest extends \Test\TestCase {
$config->deleteUserValue('userPreCond', 'appPreCond', 'keyPreCond');
}
- public function dataSetUserValueUnexpectedValue() {
+ public static function dataSetUserValueUnexpectedValue(): array {
return [
[true],
[false],
diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php
index 19039366aa8..2e1163cf9db 100644
--- a/tests/lib/App/AppManagerTest.php
+++ b/tests/lib/App/AppManagerTest.php
@@ -301,7 +301,7 @@ class AppManagerTest extends TestCase {
$this->assertEquals('["group1","group2"]', $this->appConfig->getValue('test', 'enabled', 'no'));
}
- public function dataEnableAppForGroupsAllowedTypes() {
+ public static function dataEnableAppForGroupsAllowedTypes(): array {
return [
[[]],
[[
@@ -361,7 +361,7 @@ class AppManagerTest extends TestCase {
$this->assertEquals('["group1","group2"]', $this->appConfig->getValue('test', 'enabled', 'no'));
}
- public function dataEnableAppForGroupsForbiddenTypes() {
+ public static function dataEnableAppForGroupsForbiddenTypes(): array {
return [
['filesystem'],
['prelogin'],
diff --git a/tests/lib/App/AppStore/Fetcher/AppDiscoverFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppDiscoverFetcherTest.php
index e7652d5c50c..5a9c37af7fb 100644
--- a/tests/lib/App/AppStore/Fetcher/AppDiscoverFetcherTest.php
+++ b/tests/lib/App/AppStore/Fetcher/AppDiscoverFetcherTest.php
@@ -104,7 +104,7 @@ class AppDiscoverFetcherTest extends FetcherBase {
}
}
- public function dataGetETag(): array {
+ public static function dataGetETag(): array {
return [
'file not found' => [null, true],
'empty file' => [null, false, ''],
diff --git a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
index 61fe24be1a9..0d311d8878a 100644
--- a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
+++ b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
@@ -1840,7 +1840,7 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg==
$this->registry = $this->createMock(IRegistry::class);
$this->fetcher = $this->getMockBuilder(AppFetcher::class)
- ->setMethods(['getChannel'])
+ ->onlyMethods(['getChannel'])
->setConstructorArgs([
$factory,
$this->clientService,
diff --git a/tests/lib/App/AppStore/Version/VersionParserTest.php b/tests/lib/App/AppStore/Version/VersionParserTest.php
index 5bd9ee16b39..c4dd78af496 100644
--- a/tests/lib/App/AppStore/Version/VersionParserTest.php
+++ b/tests/lib/App/AppStore/Version/VersionParserTest.php
@@ -22,7 +22,7 @@ class VersionParserTest extends TestCase {
/**
* @return array
*/
- public function versionProvider() {
+ public static function versionProvider(): array {
return [
[
'*',
@@ -66,7 +66,7 @@ class VersionParserTest extends TestCase {
$this->assertEquals($expected, $this->versionParser->getVersion($input));
}
-
+
public function testGetVersionException(): void {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Version cannot be parsed: BogusVersion');
@@ -74,7 +74,7 @@ class VersionParserTest extends TestCase {
$this->versionParser->getVersion('BogusVersion');
}
-
+
public function testGetVersionExceptionWithMultiple(): void {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Version cannot be parsed: >=8.2 <=9.1a');
diff --git a/tests/lib/App/CompareVersionTest.php b/tests/lib/App/CompareVersionTest.php
index 0d020428fed..f357e47d670 100644
--- a/tests/lib/App/CompareVersionTest.php
+++ b/tests/lib/App/CompareVersionTest.php
@@ -23,7 +23,7 @@ class CompareVersionTest extends TestCase {
$this->compare = new CompareVersion();
}
- public function comparisonData() {
+ public static function comparisonData(): array {
return [
// Compatible versions
['13.0.0.3', '13.0.0', '>=', true],
diff --git a/tests/lib/App/DependencyAnalyzerTest.php b/tests/lib/App/DependencyAnalyzerTest.php
index 31eeb77d7e5..d3874b5bb60 100644
--- a/tests/lib/App/DependencyAnalyzerTest.php
+++ b/tests/lib/App/DependencyAnalyzerTest.php
@@ -195,7 +195,7 @@ class DependencyAnalyzerTest extends TestCase {
/**
* @return array
*/
- public function providesOC() {
+ public static function providesOC(): array {
return [
// no version -> no missing dependency
[
@@ -423,7 +423,7 @@ class DependencyAnalyzerTest extends TestCase {
/**
* @return array
*/
- public function providesOS() {
+ public static function providesOS(): array {
return [
[[], null],
[[], []],
@@ -435,7 +435,7 @@ class DependencyAnalyzerTest extends TestCase {
/**
* @return array
*/
- public function providesLibs() {
+ public static function providesLibs(): array {
return [
// we expect curl to exist
[[], 'curl'],
@@ -465,7 +465,7 @@ class DependencyAnalyzerTest extends TestCase {
/**
* @return array
*/
- public function providesCommands() {
+ public static function providesCommands(): array {
return [
[[], null],
// grep is known on linux
@@ -483,7 +483,7 @@ class DependencyAnalyzerTest extends TestCase {
/**
* @return array
*/
- public function providesDatabases() {
+ public static function providesDatabases(): array {
return [
// non BC - in case on databases are defined -> all are supported
[[], null],
@@ -496,7 +496,7 @@ class DependencyAnalyzerTest extends TestCase {
/**
* @return array
*/
- public function providesPhpVersion() {
+ public static function providesPhpVersion(): array {
return [
[[], null, null, null],
[[], '5.4', null, null],
diff --git a/tests/lib/App/InfoParserTest.php b/tests/lib/App/InfoParserTest.php
index 1c429ccc405..3611a562a74 100644
--- a/tests/lib/App/InfoParserTest.php
+++ b/tests/lib/App/InfoParserTest.php
@@ -45,7 +45,7 @@ class InfoParserTest extends TestCase {
$this->parserTest($expectedJson, $xmlFile, self::$cache);
}
- public function providesInfoXml(): array {
+ public static function providesInfoXml(): array {
return [
['expected-info.json', 'valid-info.xml'],
[null, 'invalid-info.xml'],
diff --git a/tests/lib/App/PlatformRepositoryTest.php b/tests/lib/App/PlatformRepositoryTest.php
index 921d24159c9..8f621eebce9 100644
--- a/tests/lib/App/PlatformRepositoryTest.php
+++ b/tests/lib/App/PlatformRepositoryTest.php
@@ -20,7 +20,7 @@ class PlatformRepositoryTest extends \Test\TestCase {
$this->assertEquals($expected, $normalizedVersion);
}
- public function providesVersions() {
+ public static function providesVersions(): array {
return [
'none' => ['1.0.0', '1.0.0.0'],
'none/2' => ['1.2.3.4', '1.2.3.4'],
diff --git a/tests/lib/AppConfigTest.php b/tests/lib/AppConfigTest.php
index 518d7909d70..faeaa4c4560 100644
--- a/tests/lib/AppConfigTest.php
+++ b/tests/lib/AppConfigTest.php
@@ -32,10 +32,10 @@ class AppConfigTest extends TestCase {
private array $originalConfig;
/**
- * @var array<string, array<array<string, string, int, bool, bool>>>
- * [appId => [configKey, configValue, valueType, lazy, sensitive]]
+ * @var array<string, array<string, array<string, string, int, bool, bool>>>
+ * [appId => [configKey, configValue, valueType, lazy, sensitive]]
*/
- private array $baseStruct =
+ private static array $baseStruct =
[
'testapp' => [
'enabled' => ['enabled', 'true'],
@@ -114,14 +114,14 @@ class AppConfigTest extends TestCase {
]
);
- foreach ($this->baseStruct as $appId => $appData) {
+ foreach (self::$baseStruct as $appId => $appData) {
foreach ($appData as $key => $row) {
$value = $row[1];
$type = $row[2] ?? IAppConfig::VALUE_MIXED;
if (($row[4] ?? false) === true) {
$type |= IAppConfig::VALUE_SENSITIVE;
$value = self::invokePrivate(AppConfig::class, 'ENCRYPTION_PREFIX') . $this->crypto->encrypt($value);
- $this->baseStruct[$appId][$key]['encrypted'] = $value;
+ self::$baseStruct[$appId][$key]['encrypted'] = $value;
}
$sql->setParameters(
@@ -197,7 +197,7 @@ class AppConfigTest extends TestCase {
$this->assertSame(true, $status['fastLoaded'], $msg);
$this->assertSame(false, $status['lazyLoaded'], $msg);
- $apps = array_values(array_diff(array_keys($this->baseStruct), ['only-lazy']));
+ $apps = array_values(array_diff(array_keys(self::$baseStruct), ['only-lazy']));
$this->assertEqualsCanonicalizing($apps, array_keys($status['fastCache']), $msg);
$this->assertSame([], array_keys($status['lazyCache']), $msg);
}
@@ -208,7 +208,7 @@ class AppConfigTest extends TestCase {
public function testGetApps(): void {
$config = $this->generateAppConfig(false);
- $this->assertEqualsCanonicalizing(array_keys($this->baseStruct), $config->getApps());
+ $this->assertEqualsCanonicalizing(array_keys(self::$baseStruct), $config->getApps());
}
/**
@@ -217,9 +217,9 @@ class AppConfigTest extends TestCase {
* @return array<string, string[]> ['appId' => ['key1', 'key2', ]]
* @see testGetKeys
*/
- public function providerGetAppKeys(): array {
+ public static function providerGetAppKeys(): array {
$appKeys = [];
- foreach ($this->baseStruct as $appId => $appData) {
+ foreach (self::$baseStruct as $appId => $appData) {
$keys = [];
foreach ($appData as $row) {
$keys[] = $row[0];
@@ -238,9 +238,9 @@ class AppConfigTest extends TestCase {
* @see testIsLazy
* @see testGetKeys
*/
- public function providerGetKeys(): array {
+ public static function providerGetKeys(): array {
$appKeys = [];
- foreach ($this->baseStruct as $appId => $appData) {
+ foreach (self::$baseStruct as $appId => $appData) {
foreach ($appData as $row) {
$appKeys[] = [
(string)$appId, $row[0], $row[1], $row[2] ?? IAppConfig::VALUE_MIXED, $row[3] ?? false,
@@ -283,7 +283,7 @@ class AppConfigTest extends TestCase {
public function testHasKeyOnNonExistentKeyReturnsFalse(): void {
$config = $this->generateAppConfig();
- $this->assertEquals(false, $config->hasKey(array_keys($this->baseStruct)[0], 'inexistant-key'));
+ $this->assertEquals(false, $config->hasKey(array_keys(self::$baseStruct)[0], 'inexistant-key'));
}
public function testHasKeyOnUnknownAppReturnsFalse(): void {
@@ -319,7 +319,7 @@ class AppConfigTest extends TestCase {
public function testIsSensitiveOnNonExistentKeyThrowsException(): void {
$config = $this->generateAppConfig();
$this->expectException(AppConfigUnknownKeyException::class);
- $config->isSensitive(array_keys($this->baseStruct)[0], 'inexistant-key');
+ $config->isSensitive(array_keys(self::$baseStruct)[0], 'inexistant-key');
}
public function testIsSensitiveOnUnknownAppThrowsException(): void {
@@ -362,7 +362,7 @@ class AppConfigTest extends TestCase {
public function testIsLazyOnNonExistentKeyThrowsException(): void {
$config = $this->generateAppConfig();
$this->expectException(AppConfigUnknownKeyException::class);
- $config->isLazy(array_keys($this->baseStruct)[0], 'inexistant-key');
+ $config->isLazy(array_keys(self::$baseStruct)[0], 'inexistant-key');
}
public function testIsLazyOnUnknownAppThrowsException(): void {
@@ -530,7 +530,7 @@ class AppConfigTest extends TestCase {
*
* @see testGetValueMixed
*/
- public function providerGetValueMixed(): array {
+ public static function providerGetValueMixed(): array {
return [
// key, value, type
['mixed', 'mix', IAppConfig::VALUE_MIXED],
diff --git a/tests/lib/AppFramework/AppTest.php b/tests/lib/AppFramework/AppTest.php
index 3c535a4bf7a..87c96fdb9a8 100644
--- a/tests/lib/AppFramework/AppTest.php
+++ b/tests/lib/AppFramework/AppTest.php
@@ -124,7 +124,7 @@ class AppTest extends \Test\TestCase {
App::main($this->controllerName, $this->controllerMethod, $this->container, []);
}
- public function dataNoOutput() {
+ public static function dataNoOutput(): array {
return [
['HTTP/2.0 204 No content'],
['HTTP/2.0 304 Not modified'],
diff --git a/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php b/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php
index 1e0b13b5755..6469a01cce3 100644
--- a/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php
+++ b/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php
@@ -156,7 +156,7 @@ class RegistrationContextTest extends TestCase {
);
}
- public function dataProvider_TrueFalse() {
+ public static function dataProvider_TrueFalse(): array {
return[
[true],
[false]
diff --git a/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php b/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php
index d6e0321023e..bcc0daf002f 100644
--- a/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php
+++ b/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php
@@ -38,7 +38,7 @@ class AuthPublicShareControllerTest extends \Test\TestCase {
$this->request,
$this->session,
$this->urlGenerator
- ])->setMethods([
+ ])->onlyMethods([
'authFailed',
'getPasswordHash',
'isAuthenticated',
@@ -64,7 +64,9 @@ class AuthPublicShareControllerTest extends \Test\TestCase {
$this->controller->setToken('myToken');
$this->session->method('get')
- ->willReturnMap(['public_link_authenticate_redirect', ['foo' => 'bar']]);
+ ->willReturnMap([
+ ['public_link_authenticate_redirect', json_encode(['foo' => 'bar'])],
+ ]);
$this->urlGenerator->method('linkToRoute')
->willReturn('myLink!');
@@ -107,7 +109,9 @@ class AuthPublicShareControllerTest extends \Test\TestCase {
$this->session->expects($this->once())
->method('regenerateId');
$this->session->method('get')
- ->willReturnMap(['public_link_authenticate_redirect', ['foo' => 'bar']]);
+ ->willReturnMap([
+ ['public_link_authenticate_redirect', json_encode(['foo' => 'bar'])],
+ ]);
$tokenSet = false;
$hashSet = false;
diff --git a/tests/lib/AppFramework/Controller/ControllerTest.php b/tests/lib/AppFramework/Controller/ControllerTest.php
index 7c466e3a5b7..aa016872847 100644
--- a/tests/lib/AppFramework/Controller/ControllerTest.php
+++ b/tests/lib/AppFramework/Controller/ControllerTest.php
@@ -66,7 +66,7 @@ class ControllerTest extends \Test\TestCase {
);
$this->app = $this->getMockBuilder(DIContainer::class)
- ->setMethods(['getAppName'])
+ ->onlyMethods(['getAppName'])
->setConstructorArgs(['test'])
->getMock();
$this->app->expects($this->any())
diff --git a/tests/lib/AppFramework/Controller/PublicShareControllerTest.php b/tests/lib/AppFramework/Controller/PublicShareControllerTest.php
index f8430d42ef1..6f0e433f2fb 100644
--- a/tests/lib/AppFramework/Controller/PublicShareControllerTest.php
+++ b/tests/lib/AppFramework/Controller/PublicShareControllerTest.php
@@ -57,7 +57,7 @@ class PublicShareControllerTest extends \Test\TestCase {
$this->assertEquals('test', $controller->getToken());
}
- public function dataIsAuthenticated() {
+ public static function dataIsAuthenticated(): array {
return [
[false, 'token1', 'token1', 'hash1', 'hash1', true],
[false, 'token1', 'token1', 'hash1', 'hash2', true],
diff --git a/tests/lib/AppFramework/Db/EntityTest.php b/tests/lib/AppFramework/Db/EntityTest.php
index 3c844780b07..ccd0ae4bbaf 100644
--- a/tests/lib/AppFramework/Db/EntityTest.php
+++ b/tests/lib/AppFramework/Db/EntityTest.php
@@ -211,7 +211,7 @@ class EntityTest extends \Test\TestCase {
}
- public function dataSetterCasts(): array {
+ public static function dataSetterCasts(): array {
return [
['Id', '3', 3],
['smallInt', '3', 3],
diff --git a/tests/lib/AppFramework/Db/QBMapperTest.php b/tests/lib/AppFramework/Db/QBMapperTest.php
index 3cf32e56f12..c1d8bf07234 100644
--- a/tests/lib/AppFramework/Db/QBMapperTest.php
+++ b/tests/lib/AppFramework/Db/QBMapperTest.php
@@ -99,7 +99,7 @@ class QBMapperTest extends \Test\TestCase {
$this->mapper = new QBTestMapper($this->db);
}
-
+
public function testInsertEntityParameterTypeMapping(): void {
$datetime = new \DateTimeImmutable();
$entity = new QBTestEntity();
@@ -117,31 +117,40 @@ class QBMapperTest extends \Test\TestCase {
$booleanParam = $this->qb->createNamedParameter('boolean_prop', IQueryBuilder::PARAM_BOOL);
$datetimeParam = $this->qb->createNamedParameter('datetime_prop', IQueryBuilder::PARAM_DATETIME_IMMUTABLE);
+ $createNamedParameterCalls = [
+ [123, IQueryBuilder::PARAM_INT, null],
+ [true, IQueryBuilder::PARAM_BOOL, null],
+ ['string', IQueryBuilder::PARAM_STR, null],
+ [456, IQueryBuilder::PARAM_INT, null],
+ [false, IQueryBuilder::PARAM_BOOL, null],
+ [$datetime, IQueryBuilder::PARAM_DATETIME_IMMUTABLE, null],
+ ];
$this->qb->expects($this->exactly(6))
->method('createNamedParameter')
- ->withConsecutive(
- [$this->equalTo(123), $this->equalTo(IQueryBuilder::PARAM_INT)],
- [$this->equalTo(true), $this->equalTo(IQueryBuilder::PARAM_BOOL)],
- [$this->equalTo('string'), $this->equalTo(IQueryBuilder::PARAM_STR)],
- [$this->equalTo(456), $this->equalTo(IQueryBuilder::PARAM_INT)],
- [$this->equalTo(false), $this->equalTo(IQueryBuilder::PARAM_BOOL)],
- [$this->equalTo($datetime), $this->equalTo(IQueryBuilder::PARAM_DATETIME_IMMUTABLE)],
- );
+ ->willReturnCallback(function () use (&$createNamedParameterCalls) {
+ $expected = array_shift($createNamedParameterCalls);
+ $this->assertEquals($expected, func_get_args());
+ });
+
+ $setValueCalls = [
+ ['int_prop', $intParam],
+ ['bool_prop', $boolParam],
+ ['string_prop', $stringParam],
+ ['integer_prop', $integerParam],
+ ['boolean_prop', $booleanParam],
+ ['datetime_prop', $datetimeParam],
+ ];
$this->qb->expects($this->exactly(6))
->method('setValue')
- ->withConsecutive(
- [$this->equalTo('int_prop'), $this->equalTo($intParam)],
- [$this->equalTo('bool_prop'), $this->equalTo($boolParam)],
- [$this->equalTo('string_prop'), $this->equalTo($stringParam)],
- [$this->equalTo('integer_prop'), $this->equalTo($integerParam)],
- [$this->equalTo('boolean_prop'), $this->equalTo($booleanParam)],
- [$this->equalTo('datetime_prop'), $this->equalTo($datetimeParam)],
- );
+ ->willReturnCallback(function () use (&$setValueCalls) {
+ $expected = array_shift($setValueCalls);
+ $this->assertEquals($expected, func_get_args());
+ });
$this->mapper->insert($entity);
}
-
+
public function testUpdateEntityParameterTypeMapping(): void {
$datetime = new \DateTimeImmutable();
$entity = new QBTestEntity();
@@ -163,30 +172,38 @@ class QBMapperTest extends \Test\TestCase {
$jsonParam = $this->qb->createNamedParameter('json_prop', IQueryBuilder::PARAM_JSON);
$datetimeParam = $this->qb->createNamedParameter('datetime_prop', IQueryBuilder::PARAM_DATETIME_IMMUTABLE);
+ $createNamedParameterCalls = [
+ [123, IQueryBuilder::PARAM_INT, null],
+ [true, IQueryBuilder::PARAM_BOOL, null],
+ ['string', IQueryBuilder::PARAM_STR, null],
+ [456, IQueryBuilder::PARAM_INT, null],
+ [false, IQueryBuilder::PARAM_BOOL, null],
+ [['hello' => 'world'], IQueryBuilder::PARAM_JSON, null],
+ [$datetime, IQueryBuilder::PARAM_DATETIME_IMMUTABLE, null],
+ [789, IQueryBuilder::PARAM_INT, null],
+ ];
$this->qb->expects($this->exactly(8))
->method('createNamedParameter')
- ->withConsecutive(
- [$this->equalTo(123), $this->equalTo(IQueryBuilder::PARAM_INT)],
- [$this->equalTo(true), $this->equalTo(IQueryBuilder::PARAM_BOOL)],
- [$this->equalTo('string'), $this->equalTo(IQueryBuilder::PARAM_STR)],
- [$this->equalTo(456), $this->equalTo(IQueryBuilder::PARAM_INT)],
- [$this->equalTo(false), $this->equalTo(IQueryBuilder::PARAM_BOOL)],
- [$this->equalTo(['hello' => 'world']), $this->equalTo(IQueryBuilder::PARAM_JSON)],
- [$this->equalTo($datetime), $this->equalTo(IQueryBuilder::PARAM_DATETIME_IMMUTABLE)],
- [$this->equalTo(789), $this->equalTo(IQueryBuilder::PARAM_INT)],
- );
-
+ ->willReturnCallback(function () use (&$createNamedParameterCalls) {
+ $expected = array_shift($createNamedParameterCalls);
+ $this->assertEquals($expected, func_get_args());
+ });
+
+ $setCalls = [
+ ['int_prop', $intParam],
+ ['bool_prop', $boolParam],
+ ['string_prop', $stringParam],
+ ['integer_prop', $integerParam],
+ ['boolean_prop', $booleanParam],
+ ['json_prop', $datetimeParam],
+ ['datetime_prop', $datetimeParam],
+ ];
$this->qb->expects($this->exactly(7))
->method('set')
- ->withConsecutive(
- [$this->equalTo('int_prop'), $this->equalTo($intParam)],
- [$this->equalTo('bool_prop'), $this->equalTo($boolParam)],
- [$this->equalTo('string_prop'), $this->equalTo($stringParam)],
- [$this->equalTo('integer_prop'), $this->equalTo($integerParam)],
- [$this->equalTo('boolean_prop'), $this->equalTo($booleanParam)],
- [$this->equalTo('json_prop'), $this->equalTo($jsonParam)],
- [$this->equalTo('datetime_prop'), $this->equalTo($datetimeParam)],
- );
+ ->willReturnCallback(function () use (&$setCalls) {
+ $expected = array_shift($setCalls);
+ $this->assertEquals($expected, func_get_args());
+ });
$this->expr->expects($this->once())
->method('eq')
@@ -196,7 +213,7 @@ class QBMapperTest extends \Test\TestCase {
$this->mapper->update($entity);
}
-
+
public function testGetParameterTypeForProperty(): void {
$entity = new QBTestEntity();
diff --git a/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php b/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php
index f3d2cff1ffd..e84b44db9a0 100644
--- a/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php
+++ b/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php
@@ -29,7 +29,7 @@ class DIContainerTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();
$this->container = $this->getMockBuilder(DIContainer::class)
- ->setMethods(['isAdminUser'])
+ ->onlyMethods(['isAdminUser'])
->setConstructorArgs(['name'])
->getMock();
}
diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php
index 7415ecd9486..404d3f4c90b 100644
--- a/tests/lib/AppFramework/Http/DispatcherTest.php
+++ b/tests/lib/AppFramework/Http/DispatcherTest.php
@@ -8,6 +8,7 @@
namespace Test\AppFramework\Http;
+use OC\AppFramework\DependencyInjection\DIContainer;
use OC\AppFramework\Http\Dispatcher;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Middleware\MiddlewareDispatcher;
@@ -20,6 +21,7 @@ use OCP\AppFramework\Http\ParameterOutOfRangeException;
use OCP\AppFramework\Http\Response;
use OCP\Diagnostics\IEventLogger;
use OCP\IConfig;
+use OCP\IDBConnection;
use OCP\IRequest;
use OCP\IRequestId;
use PHPUnit\Framework\MockObject\MockObject;
@@ -63,6 +65,10 @@ class TestController extends Controller {
'text' => [$int, $bool, $test, $test2]
]);
}
+
+ public function test(): Response {
+ return new DataResponse();
+ }
}
/**
@@ -104,33 +110,17 @@ class DispatcherTest extends \Test\TestCase {
$this->logger = $this->createMock(LoggerInterface::class);
$this->eventLogger = $this->createMock(IEventLogger::class);
$this->container = $this->createMock(ContainerInterface::class);
- $app = $this->getMockBuilder(
- 'OC\AppFramework\DependencyInjection\DIContainer')
- ->disableOriginalConstructor()
- ->getMock();
- $request = $this->getMockBuilder(
- '\OC\AppFramework\Http\Request')
- ->disableOriginalConstructor()
- ->getMock();
- $this->http = $this->getMockBuilder(
- \OC\AppFramework\Http::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $app = $this->createMock(DIContainer::class);
+ $request = $this->createMock(Request::class);
+ $this->http = $this->createMock(\OC\AppFramework\Http::class);
- $this->middlewareDispatcher = $this->getMockBuilder(
- '\OC\AppFramework\Middleware\MiddlewareDispatcher')
- ->disableOriginalConstructor()
- ->getMock();
- $this->controller = $this->getMockBuilder(
- '\OCP\AppFramework\Controller')
- ->setMethods([$this->controllerMethod])
+ $this->middlewareDispatcher = $this->createMock(MiddlewareDispatcher::class);
+ $this->controller = $this->getMockBuilder(TestController::class)
+ ->onlyMethods([$this->controllerMethod])
->setConstructorArgs([$app, $request])
->getMock();
- $this->request = $this->getMockBuilder(
- '\OC\AppFramework\Http\Request')
- ->disableOriginalConstructor()
- ->getMock();
+ $this->request = $this->createMock(Request::class);
$this->reflector = new ControllerMethodReflector();
@@ -140,7 +130,7 @@ class DispatcherTest extends \Test\TestCase {
$this->reflector,
$this->request,
$this->config,
- \OC::$server->getDatabaseConnection(),
+ \OCP\Server::get(IDBConnection::class),
$this->logger,
$this->eventLogger,
$this->container,
@@ -545,7 +535,7 @@ class DispatcherTest extends \Test\TestCase {
}
- public function rangeDataProvider(): array {
+ public static function rangeDataProvider(): array {
return [
[PHP_INT_MIN, PHP_INT_MAX, 42, false],
[0, 12, -5, true],
diff --git a/tests/lib/AppFramework/Http/DownloadResponseTest.php b/tests/lib/AppFramework/Http/DownloadResponseTest.php
index ee89e8e55d1..cf179ba270b 100644
--- a/tests/lib/AppFramework/Http/DownloadResponseTest.php
+++ b/tests/lib/AppFramework/Http/DownloadResponseTest.php
@@ -37,7 +37,7 @@ class DownloadResponseTest extends \Test\TestCase {
$this->assertEquals('attachment; filename="' . $expected . '"', $headers['Content-Disposition']);
}
- public function filenameEncodingProvider() : array {
+ public static function filenameEncodingProvider() : array {
return [
['TestName.txt', 'TestName.txt'],
['A "Quoted" Filename.txt', 'A \\"Quoted\\" Filename.txt'],
diff --git a/tests/lib/AppFramework/Http/JSONResponseTest.php b/tests/lib/AppFramework/Http/JSONResponseTest.php
index 175ed852c7b..703e6d89dd1 100644
--- a/tests/lib/AppFramework/Http/JSONResponseTest.php
+++ b/tests/lib/AppFramework/Http/JSONResponseTest.php
@@ -46,10 +46,7 @@ class JSONResponseTest extends \Test\TestCase {
$this->assertEquals($expected, $this->json->render());
}
- /**
- * @return array
- */
- public function renderDataProvider() {
+ public static function renderDataProvider(): array {
return [
[
['test' => 'hi'], '{"test":"hi"}',
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
index fae5f5d9f1c..a8273be362b 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
@@ -10,6 +10,7 @@ namespace Test\AppFramework\Middleware;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Middleware\MiddlewareDispatcher;
+use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Middleware;
use OCP\IConfig;
@@ -84,6 +85,10 @@ class TestMiddleware extends Middleware {
}
}
+class TestController extends Controller {
+ public function method(): void {
+ }
+}
class MiddlewareDispatcherTest extends \Test\TestCase {
public $exception;
@@ -110,8 +115,8 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
private function getControllerMock() {
- return $this->getMockBuilder('OCP\AppFramework\Controller')
- ->setMethods(['method'])
+ return $this->getMockBuilder(TestController::class)
+ ->onlyMethods(['method'])
->setConstructorArgs(['app',
new Request(
['method' => 'GET'],
@@ -131,14 +136,14 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
public function testAfterExceptionShouldReturnResponseOfMiddleware(): void {
$response = new Response();
- $m1 = $this->getMockBuilder('\OCP\AppFramework\Middleware')
- ->setMethods(['afterException', 'beforeController'])
+ $m1 = $this->getMockBuilder(\OCP\AppFramework\Middleware::class)
+ ->onlyMethods(['afterException', 'beforeController'])
->getMock();
$m1->expects($this->never())
->method('afterException');
- $m2 = $this->getMockBuilder('OCP\AppFramework\Middleware')
- ->setMethods(['afterException', 'beforeController'])
+ $m2 = $this->getMockBuilder(\OCP\AppFramework\Middleware::class)
+ ->onlyMethods(['afterException', 'beforeController'])
->getMock();
$m2->expects($this->once())
->method('afterException')
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareTest.php b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
index c1e5c44c4db..addd9683122 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
@@ -36,12 +36,9 @@ class MiddlewareTest extends \Test\TestCase {
$this->middleware = new ChildMiddleware();
- $this->api = $this->getMockBuilder(DIContainer::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->api = $this->createMock(DIContainer::class);
$this->controller = $this->getMockBuilder(Controller::class)
- ->setMethods([])
->setConstructorArgs([
$this->api,
new Request(
@@ -51,7 +48,7 @@ class MiddlewareTest extends \Test\TestCase {
)
])->getMock();
$this->exception = new \Exception();
- $this->response = $this->getMockBuilder(Response::class)->getMock();
+ $this->response = $this->createMock(Response::class);
}
diff --git a/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php b/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php
index 58ae6b13aed..204cc647cad 100644
--- a/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php
@@ -32,7 +32,7 @@ class NotModifiedMiddlewareTest extends \Test\TestCase {
$this->controller = $this->createMock(Controller::class);
}
- public function dataModified(): array {
+ public static function dataModified(): array {
$now = new \DateTime();
return [
diff --git a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
index 6724f841c5e..62e20a2dcd0 100644
--- a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
@@ -12,6 +12,7 @@ use OC\AppFramework\OCS\V1Response;
use OC\AppFramework\OCS\V2Response;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Response;
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSForbiddenException;
@@ -32,49 +33,37 @@ class OCSMiddlewareTest extends \Test\TestCase {
->getMock();
}
- public function dataAfterException() {
- $OCSController = $this->getMockBuilder(OCSController::class)
- ->disableOriginalConstructor()
- ->getMock();
- $controller = $this->getMockBuilder(Controller::class)
- ->disableOriginalConstructor()
- ->getMock();
-
+ public static function dataAfterException(): array {
return [
- [$OCSController, new \Exception(), true],
- [$OCSController, new OCSException(), false, '', Http::STATUS_INTERNAL_SERVER_ERROR],
- [$OCSController, new OCSException('foo'), false, 'foo', Http::STATUS_INTERNAL_SERVER_ERROR],
- [$OCSController, new OCSException('foo', Http::STATUS_IM_A_TEAPOT), false, 'foo', Http::STATUS_IM_A_TEAPOT],
- [$OCSController, new OCSBadRequestException(), false, '', Http::STATUS_BAD_REQUEST],
- [$OCSController, new OCSBadRequestException('foo'), false, 'foo', Http::STATUS_BAD_REQUEST],
- [$OCSController, new OCSForbiddenException(), false, '', Http::STATUS_FORBIDDEN],
- [$OCSController, new OCSForbiddenException('foo'), false, 'foo', Http::STATUS_FORBIDDEN],
- [$OCSController, new OCSNotFoundException(), false, '', Http::STATUS_NOT_FOUND],
- [$OCSController, new OCSNotFoundException('foo'), false, 'foo', Http::STATUS_NOT_FOUND],
-
- [$controller, new \Exception(), true],
- [$controller, new OCSException(), true],
- [$controller, new OCSException('foo'), true],
- [$controller, new OCSException('foo', Http::STATUS_IM_A_TEAPOT), true],
- [$controller, new OCSBadRequestException(), true],
- [$controller, new OCSBadRequestException('foo'), true],
- [$controller, new OCSForbiddenException(), true],
- [$controller, new OCSForbiddenException('foo'), true],
- [$controller, new OCSNotFoundException(), true],
- [$controller, new OCSNotFoundException('foo'), true],
+ [OCSController::class, new \Exception(), true],
+ [OCSController::class, new OCSException(), false, '', Http::STATUS_INTERNAL_SERVER_ERROR],
+ [OCSController::class, new OCSException('foo'), false, 'foo', Http::STATUS_INTERNAL_SERVER_ERROR],
+ [OCSController::class, new OCSException('foo', Http::STATUS_IM_A_TEAPOT), false, 'foo', Http::STATUS_IM_A_TEAPOT],
+ [OCSController::class, new OCSBadRequestException(), false, '', Http::STATUS_BAD_REQUEST],
+ [OCSController::class, new OCSBadRequestException('foo'), false, 'foo', Http::STATUS_BAD_REQUEST],
+ [OCSController::class, new OCSForbiddenException(), false, '', Http::STATUS_FORBIDDEN],
+ [OCSController::class, new OCSForbiddenException('foo'), false, 'foo', Http::STATUS_FORBIDDEN],
+ [OCSController::class, new OCSNotFoundException(), false, '', Http::STATUS_NOT_FOUND],
+ [OCSController::class, new OCSNotFoundException('foo'), false, 'foo', Http::STATUS_NOT_FOUND],
+
+ [Controller::class, new \Exception(), true],
+ [Controller::class, new OCSException(), true],
+ [Controller::class, new OCSException('foo'), true],
+ [Controller::class, new OCSException('foo', Http::STATUS_IM_A_TEAPOT), true],
+ [Controller::class, new OCSBadRequestException(), true],
+ [Controller::class, new OCSBadRequestException('foo'), true],
+ [Controller::class, new OCSForbiddenException(), true],
+ [Controller::class, new OCSForbiddenException('foo'), true],
+ [Controller::class, new OCSNotFoundException(), true],
+ [Controller::class, new OCSNotFoundException('foo'), true],
];
}
/**
* @dataProvider dataAfterException
- *
- * @param Controller $controller
- * @param \Exception $exception
- * @param bool $forward
- * @param string $message
- * @param int $code
*/
- public function testAfterExceptionOCSv1($controller, $exception, $forward, $message = '', $code = 0): void {
+ public function testAfterExceptionOCSv1(string $controller, \Exception $exception, bool $forward, string $message = '', int $code = 0): void {
+ $controller = $this->createMock($controller);
$this->request
->method('getScriptName')
->willReturn('/ocs/v1.php');
@@ -103,14 +92,9 @@ class OCSMiddlewareTest extends \Test\TestCase {
/**
* @dataProvider dataAfterException
- *
- * @param Controller $controller
- * @param \Exception $exception
- * @param bool $forward
- * @param string $message
- * @param int $code
*/
- public function testAfterExceptionOCSv2($controller, $exception, $forward, $message = '', $code = 0): void {
+ public function testAfterExceptionOCSv2(string $controller, \Exception $exception, bool $forward, string $message = '', int $code = 0): void {
+ $controller = $this->createMock($controller);
$this->request
->method('getScriptName')
->willReturn('/ocs/v2.php');
@@ -137,14 +121,9 @@ class OCSMiddlewareTest extends \Test\TestCase {
/**
* @dataProvider dataAfterException
- *
- * @param Controller $controller
- * @param \Exception $exception
- * @param bool $forward
- * @param string $message
- * @param int $code
*/
- public function testAfterExceptionOCSv2SubFolder($controller, $exception, $forward, $message = '', $code = 0): void {
+ public function testAfterExceptionOCSv2SubFolder(string $controller, \Exception $exception, bool $forward, string $message = '', int $code = 0): void {
+ $controller = $this->createMock($controller);
$this->request
->method('getScriptName')
->willReturn('/mysubfolder/ocs/v2.php');
@@ -152,7 +131,7 @@ class OCSMiddlewareTest extends \Test\TestCase {
$OCSMiddleware->beforeController($controller, 'method');
if ($forward) {
- $this->expectException(get_class($exception));
+ $this->expectException($exception::class);
$this->expectExceptionMessage($exception->getMessage());
}
@@ -169,39 +148,28 @@ class OCSMiddlewareTest extends \Test\TestCase {
$this->assertSame($code, $result->getStatus());
}
- public function dataAfterController() {
- $OCSController = $this->getMockBuilder(OCSController::class)
- ->disableOriginalConstructor()
- ->getMock();
- $controller = $this->getMockBuilder(Controller::class)
- ->disableOriginalConstructor()
- ->getMock();
-
+ public static function dataAfterController(): array {
return [
- [$OCSController, new Http\Response(), false],
- [$OCSController, new Http\JSONResponse(), false],
- [$OCSController, new Http\JSONResponse(['message' => 'foo']), false],
- [$OCSController, new Http\JSONResponse(['message' => 'foo'], Http::STATUS_UNAUTHORIZED), true, OCSController::RESPOND_UNAUTHORISED],
- [$OCSController, new Http\JSONResponse(['message' => 'foo'], Http::STATUS_FORBIDDEN), true],
-
- [$controller, new Http\Response(), false],
- [$controller, new Http\JSONResponse(), false],
- [$controller, new Http\JSONResponse(['message' => 'foo']), false],
- [$controller, new Http\JSONResponse(['message' => 'foo'], Http::STATUS_UNAUTHORIZED), false],
- [$controller, new Http\JSONResponse(['message' => 'foo'], Http::STATUS_FORBIDDEN), false],
+ [OCSController::class, new Response(), false],
+ [OCSController::class, new Http\JSONResponse(), false],
+ [OCSController::class, new Http\JSONResponse(['message' => 'foo']), false],
+ [OCSController::class, new Http\JSONResponse(['message' => 'foo'], Http::STATUS_UNAUTHORIZED), true, OCSController::RESPOND_UNAUTHORISED],
+ [OCSController::class, new Http\JSONResponse(['message' => 'foo'], Http::STATUS_FORBIDDEN), true],
+
+ [Controller::class, new Response(), false],
+ [Controller::class, new Http\JSONResponse(), false],
+ [Controller::class, new Http\JSONResponse(['message' => 'foo']), false],
+ [Controller::class, new Http\JSONResponse(['message' => 'foo'], Http::STATUS_UNAUTHORIZED), false],
+ [Controller::class, new Http\JSONResponse(['message' => 'foo'], Http::STATUS_FORBIDDEN), false],
];
}
/**
* @dataProvider dataAfterController
- *
- * @param Controller $controller
- * @param Http\Response $response
- * @param bool $converted
- * @param int $convertedOCSStatus
*/
- public function testAfterController($controller, $response, $converted, $convertedOCSStatus = 0): void {
+ public function testAfterController(string $controller, Response $response, bool $converted, int $convertedOCSStatus = 0): void {
+ $controller = $this->createMock($controller);
$OCSMiddleware = new OCSMiddleware($this->request);
$newResponse = $OCSMiddleware->afterController($controller, 'foo', $response);
diff --git a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
index 8433aa93f4a..bf0d719f46e 100644
--- a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
@@ -58,7 +58,7 @@ class PublicShareMiddlewareTest extends \Test\TestCase {
$this->assertTrue(true);
}
- public function dataShareApi() {
+ public static function dataShareApi(): array {
return [
['no', 'no',],
['no', 'yes',],
diff --git a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php
index a224ebae949..c516c1e6c89 100644
--- a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php
@@ -98,13 +98,19 @@ class BruteForceMiddlewareTest extends TestCase {
->expects($this->once())
->method('getRemoteAddress')
->willReturn('::1');
+
+ $calls = [
+ ['::1', 'first'],
+ ['::1', 'second'],
+ ];
$this->throttler
->expects($this->exactly(2))
->method('sleepDelayOrThrowOnMax')
- ->withConsecutive(
- ['::1', 'first'],
- ['::1', 'second'],
- );
+ ->willReturnCallback(function () use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ return 0;
+ });
$controller = new TestController('test', $this->request);
$this->reflector->reflect($controller, 'multipleAttributes');
@@ -221,20 +227,31 @@ class BruteForceMiddlewareTest extends TestCase {
->expects($this->once())
->method('getRemoteAddress')
->willReturn('::1');
+
+ $sleepCalls = [
+ ['::1', 'first'],
+ ['::1', 'second'],
+ ];
$this->throttler
->expects($this->exactly(2))
->method('sleepDelayOrThrowOnMax')
- ->withConsecutive(
- ['::1', 'first'],
- ['::1', 'second'],
- );
+ ->willReturnCallback(function () use (&$sleepCalls) {
+ $expected = array_shift($sleepCalls);
+ $this->assertEquals($expected, func_get_args());
+ return 0;
+ });
+
+ $attemptCalls = [
+ ['first', '::1', []],
+ ['second', '::1', []],
+ ];
$this->throttler
->expects($this->exactly(2))
->method('registerAttempt')
- ->withConsecutive(
- ['first', '::1'],
- ['second', '::1'],
- );
+ ->willReturnCallback(function () use (&$attemptCalls) {
+ $expected = array_shift($attemptCalls);
+ $this->assertEquals($expected, func_get_args());
+ });
$controller = new TestController('test', $this->request);
$this->reflector->reflect($controller, 'multipleAttributes');
diff --git a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
index b703b10c554..f22933a5884 100644
--- a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
@@ -44,7 +44,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
);
}
- public function dataSetCORSAPIHeader(): array {
+ public static function dataSetCORSAPIHeader(): array {
return [
['testSetCORSAPIHeader'],
['testSetCORSAPIHeaderAttribute'],
@@ -89,7 +89,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
$this->assertFalse(array_key_exists('Access-Control-Allow-Origin', $headers));
}
- public function dataNoOriginHeaderNoCORSHEADER(): array {
+ public static function dataNoOriginHeaderNoCORSHEADER(): array {
return [
['testNoOriginHeaderNoCORSHEADER'],
['testNoOriginHeaderNoCORSHEADERAttribute'],
@@ -113,7 +113,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
$this->assertFalse(array_key_exists('Access-Control-Allow-Origin', $headers));
}
- public function dataCorsIgnoredIfWithCredentialsHeaderPresent(): array {
+ public static function dataCorsIgnoredIfWithCredentialsHeaderPresent(): array {
return [
['testCorsIgnoredIfWithCredentialsHeaderPresent'],
['testCorsAttributeIgnoredIfWithCredentialsHeaderPresent'],
@@ -143,7 +143,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
$middleware->afterController($this->controller, $method, $response);
}
- public function dataNoCORSOnAnonymousPublicPage(): array {
+ public static function dataNoCORSOnAnonymousPublicPage(): array {
return [
['testNoCORSOnAnonymousPublicPage'],
['testNoCORSOnAnonymousPublicPageAttribute'],
@@ -177,7 +177,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
$middleware->beforeController($this->controller, $method);
}
- public function dataCORSShouldNeverAllowCookieAuth(): array {
+ public static function dataCORSShouldNeverAllowCookieAuth(): array {
return [
['testCORSShouldNeverAllowCookieAuth'],
['testCORSShouldNeverAllowCookieAuthAttribute'],
@@ -211,7 +211,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
$middleware->beforeController($this->controller, $method);
}
- public function dataCORSShouldRelogin(): array {
+ public static function dataCORSShouldRelogin(): array {
return [
['testCORSShouldRelogin'],
['testCORSAttributeShouldRelogin'],
@@ -242,7 +242,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
$middleware->beforeController($this->controller, $method);
}
- public function dataCORSShouldFailIfPasswordLoginIsForbidden(): array {
+ public static function dataCORSShouldFailIfPasswordLoginIsForbidden(): array {
return [
['testCORSShouldFailIfPasswordLoginIsForbidden'],
['testCORSAttributeShouldFailIfPasswordLoginIsForbidden'],
@@ -275,7 +275,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
$middleware->beforeController($this->controller, $method);
}
- public function dataCORSShouldNotAllowCookieAuth(): array {
+ public static function dataCORSShouldNotAllowCookieAuth(): array {
return [
['testCORSShouldNotAllowCookieAuth'],
['testCORSAttributeShouldNotAllowCookieAuth'],
diff --git a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
index 3dec030d438..e607b19d1ef 100644
--- a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
@@ -162,7 +162,7 @@ class PasswordConfirmationMiddlewareTest extends TestCase {
- public function dataProvider() {
+ public static function dataProvider(): array {
return [
['foo', 2000, 4000, true],
['foo', 2000, 3000, false],
diff --git a/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php
index 0ca4a455cba..44897fa21ef 100644
--- a/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php
@@ -103,7 +103,7 @@ class SameSiteCookieMiddlewareTest extends TestCase {
$middleware = $this->getMockBuilder(SameSiteCookieMiddleware::class)
->setConstructorArgs([$this->request, $this->reflector])
- ->setMethods(['setSameSiteCookie'])
+ ->onlyMethods(['setSameSiteCookie'])
->getMock();
$middleware->expects($this->once())
diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
index 07e368fd1e6..3b5861cbba9 100644
--- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
@@ -125,7 +125,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
);
}
- public function dataNoCSRFRequiredPublicPage(): array {
+ public static function dataNoCSRFRequiredPublicPage(): array {
return [
['testAnnotationNoCSRFRequiredPublicPage'],
['testAnnotationNoCSRFRequiredAttributePublicPage'],
@@ -134,21 +134,21 @@ class SecurityMiddlewareTest extends \Test\TestCase {
];
}
- public function dataPublicPage(): array {
+ public static function dataPublicPage(): array {
return [
['testAnnotationPublicPage'],
['testAttributePublicPage'],
];
}
- public function dataNoCSRFRequired(): array {
+ public static function dataNoCSRFRequired(): array {
return [
['testAnnotationNoCSRFRequired'],
['testAttributeNoCSRFRequired'],
];
}
- public function dataPublicPageStrictCookieRequired(): array {
+ public static function dataPublicPageStrictCookieRequired(): array {
return [
['testAnnotationPublicPageStrictCookieRequired'],
['testAnnotationStrictCookieRequiredAttributePublicPage'],
@@ -157,28 +157,28 @@ class SecurityMiddlewareTest extends \Test\TestCase {
];
}
- public function dataNoCSRFRequiredPublicPageStrictCookieRequired(): array {
+ public static function dataNoCSRFRequiredPublicPageStrictCookieRequired(): array {
return [
['testAnnotationNoCSRFRequiredPublicPageStrictCookieRequired'],
['testAttributeNoCSRFRequiredPublicPageStrictCookiesRequired'],
];
}
- public function dataNoAdminRequiredNoCSRFRequired(): array {
+ public static function dataNoAdminRequiredNoCSRFRequired(): array {
return [
['testAnnotationNoAdminRequiredNoCSRFRequired'],
['testAttributeNoAdminRequiredNoCSRFRequired'],
];
}
- public function dataNoAdminRequiredNoCSRFRequiredPublicPage(): array {
+ public static function dataNoAdminRequiredNoCSRFRequiredPublicPage(): array {
return [
['testAnnotationNoAdminRequiredNoCSRFRequiredPublicPage'],
['testAttributeNoAdminRequiredNoCSRFRequiredPublicPage'],
];
}
- public function dataNoCSRFRequiredSubAdminRequired(): array {
+ public static function dataNoCSRFRequiredSubAdminRequired(): array {
return [
['testAnnotationNoCSRFRequiredSubAdminRequired'],
['testAnnotationNoCSRFRequiredAttributeSubAdminRequired'],
@@ -429,7 +429,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
$this->middleware->beforeController($this->controller, $method);
}
- public function dataCsrfOcsController(): array {
+ public static function dataCsrfOcsController(): array {
return [
[NormalController::class, false, false, true],
[NormalController::class, false, true, true],
@@ -659,7 +659,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
/**
* @return array
*/
- public function exceptionProvider() {
+ public static function exceptionProvider(): array {
return [
[
new AppNotEnabledException(),
diff --git a/tests/lib/AppFramework/OCS/V2ResponseTest.php b/tests/lib/AppFramework/OCS/V2ResponseTest.php
index 97a227418f3..0037763f163 100644
--- a/tests/lib/AppFramework/OCS/V2ResponseTest.php
+++ b/tests/lib/AppFramework/OCS/V2ResponseTest.php
@@ -23,7 +23,7 @@ class V2ResponseTest extends \Test\TestCase {
$this->assertEquals($expected, $response->getStatus());
}
- public function providesStatusCodes(): array {
+ public static function providesStatusCodes(): array {
return [
[Http::STATUS_OK, 200],
[Http::STATUS_BAD_REQUEST, 104],
diff --git a/tests/lib/AppFramework/Routing/RouteParserTest.php b/tests/lib/AppFramework/Routing/RouteParserTest.php
new file mode 100644
index 00000000000..406c5f1f3a5
--- /dev/null
+++ b/tests/lib/AppFramework/Routing/RouteParserTest.php
@@ -0,0 +1,347 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace Test\AppFramework\Routing;
+
+use OC\AppFramework\Routing\RouteParser;
+use Symfony\Component\Routing\Route as RoutingRoute;
+use Symfony\Component\Routing\RouteCollection;
+
+class RouteParserTest extends \Test\TestCase {
+
+ protected RouteParser $parser;
+
+ protected function setUp(): void {
+ $this->parser = new RouteParser();
+ }
+
+ public function testParseRoutes(): void {
+ $routes = ['routes' => [
+ ['name' => 'folders#open', 'url' => '/{folderId}/open', 'verb' => 'GET'],
+ ['name' => 'folders#create', 'url' => '/{folderId}/create', 'verb' => 'POST']
+ ]];
+
+ $collection = $this->parser->parseDefaultRoutes($routes, 'app1');
+ $this->assertArrayHasKey('app1.folders.open', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/open', 'GET', 'FoldersController', 'open', route: $collection->get('app1.folders.open'));
+ $this->assertArrayHasKey('app1.folders.create', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/create', 'POST', 'FoldersController', 'create', route: $collection->get('app1.folders.create'));
+ }
+
+ public function testParseRoutesRootApps(): void {
+ $routes = ['routes' => [
+ ['name' => 'folders#open', 'url' => '/{folderId}/open', 'verb' => 'GET'],
+ ['name' => 'folders#create', 'url' => '/{folderId}/create', 'verb' => 'POST']
+ ]];
+
+ $collection = $this->parser->parseDefaultRoutes($routes, 'core');
+ $this->assertArrayHasKey('core.folders.open', $collection->all());
+ $this->assertSimpleRoute('/{folderId}/open', 'GET', 'FoldersController', 'open', app: 'core', route: $collection->get('core.folders.open'));
+ $this->assertArrayHasKey('core.folders.create', $collection->all());
+ $this->assertSimpleRoute('/{folderId}/create', 'POST', 'FoldersController', 'create', app: 'core', route: $collection->get('core.folders.create'));
+ }
+
+ public function testParseRoutesWithResources(): void {
+ $routes = ['routes' => [
+ ['name' => 'folders#open', 'url' => '/{folderId}/open', 'verb' => 'GET'],
+ ], 'resources' => [
+ 'names' => ['url' => '/names'],
+ 'folder_names' => ['url' => '/folder/names'],
+ ]];
+
+ $collection = $this->parser->parseDefaultRoutes($routes, 'app1');
+ $this->assertArrayHasKey('app1.folders.open', $collection->all());
+ $this->assertSimpleResource('/apps/app1/folder/names', 'folder_names', 'FolderNamesController', 'app1', $collection);
+ $this->assertSimpleResource('/apps/app1/names', 'names', 'NamesController', 'app1', $collection);
+ }
+
+ public function testParseRoutesWithPostfix(): void {
+ $routes = ['routes' => [
+ ['name' => 'folders#update', 'url' => '/{folderId}/update', 'verb' => 'POST'],
+ ['name' => 'folders#update', 'url' => '/{folderId}/update', 'verb' => 'PUT', 'postfix' => '-edit']
+ ]];
+
+ $collection = $this->parser->parseDefaultRoutes($routes, 'app1');
+ $this->assertArrayHasKey('app1.folders.update', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/update', 'POST', 'FoldersController', 'update', route: $collection->get('app1.folders.update'));
+ $this->assertArrayHasKey('app1.folders.update-edit', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/update', 'PUT', 'FoldersController', 'update', route: $collection->get('app1.folders.update-edit'));
+ }
+
+ public function testParseRoutesKebabCaseAction(): void {
+ $routes = ['routes' => [
+ ['name' => 'folders#open_folder', 'url' => '/{folderId}/open', 'verb' => 'GET']
+ ]];
+
+ $collection = $this->parser->parseDefaultRoutes($routes, 'app1');
+ $this->assertArrayHasKey('app1.folders.open_folder', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/open', 'GET', 'FoldersController', 'openFolder', route: $collection->get('app1.folders.open_folder'));
+ }
+
+ public function testParseRoutesKebabCaseController(): void {
+ $routes = ['routes' => [
+ ['name' => 'my_folders#open', 'url' => '/{folderId}/open', 'verb' => 'GET']
+ ]];
+
+ $collection = $this->parser->parseDefaultRoutes($routes, 'app1');
+ $this->assertArrayHasKey('app1.my_folders.open', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/open', 'GET', 'MyFoldersController', 'open', route: $collection->get('app1.my_folders.open'));
+ }
+
+ public function testParseRoutesLowercaseVerb(): void {
+ $routes = ['routes' => [
+ ['name' => 'folders#delete', 'url' => '/{folderId}/delete', 'verb' => 'delete']
+ ]];
+
+ $collection = $this->parser->parseDefaultRoutes($routes, 'app1');
+ $this->assertArrayHasKey('app1.folders.delete', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/delete', 'DELETE', 'FoldersController', 'delete', route: $collection->get('app1.folders.delete'));
+ }
+
+ public function testParseRoutesMissingVerb(): void {
+ $routes = ['routes' => [
+ ['name' => 'folders#open', 'url' => '/{folderId}/open']
+ ]];
+
+ $collection = $this->parser->parseDefaultRoutes($routes, 'app1');
+ $this->assertArrayHasKey('app1.folders.open', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/open', 'GET', 'FoldersController', 'open', route: $collection->get('app1.folders.open'));
+ }
+
+ public function testParseRoutesWithRequirements(): void {
+ $routes = ['routes' => [
+ ['name' => 'folders#open', 'url' => '/{folderId}/open', 'verb' => 'GET', 'requirements' => ['folderId' => '\d+']]
+ ]];
+
+ $collection = $this->parser->parseDefaultRoutes($routes, 'app1');
+ $this->assertArrayHasKey('app1.folders.open', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/open', 'GET', 'FoldersController', 'open', requirements: ['folderId' => '\d+'], route: $collection->get('app1.folders.open'));
+ }
+
+ public function testParseRoutesWithDefaults(): void {
+ $routes = ['routes' => [
+ ['name' => 'folders#open', 'url' => '/{folderId}/open', 'verb' => 'GET', 'defaults' => ['hello' => 'world']]
+ ]];
+
+ $collection = $this->parser->parseDefaultRoutes($routes, 'app1');
+ $this->assertArrayHasKey('app1.folders.open', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/open', 'GET', 'FoldersController', 'open', defaults: ['hello' => 'world'], route: $collection->get('app1.folders.open'));
+ }
+
+ public function testParseRoutesInvalidName(): void {
+ $routes = ['routes' => [
+ ['name' => 'folders', 'url' => '/{folderId}/open', 'verb' => 'GET']
+ ]];
+
+ $this->expectException(\UnexpectedValueException::class);
+ $this->parser->parseDefaultRoutes($routes, 'app1');
+ }
+
+ public function testParseRoutesInvalidName2(): void {
+ $routes = ['routes' => [
+ ['name' => 'folders#open#action', 'url' => '/{folderId}/open', 'verb' => 'GET']
+ ]];
+
+ $this->expectException(\UnexpectedValueException::class);
+ $this->parser->parseDefaultRoutes($routes, 'app1');
+ }
+
+ public function testParseRoutesEmpty(): void {
+ $routes = ['routes' => []];
+
+ $collection = $this->parser->parseDefaultRoutes($routes, 'app1');
+ $this->assertEquals(0, $collection->count());
+ }
+
+ // OCS routes
+
+ public function testParseOcsRoutes(): void {
+ $routes = ['ocs' => [
+ ['name' => 'folders#open', 'url' => '/{folderId}/open', 'verb' => 'GET'],
+ ['name' => 'folders#create', 'url' => '/{folderId}/create', 'verb' => 'POST']
+ ]];
+
+ $collection = $this->parser->parseOCSRoutes($routes, 'app1');
+ $this->assertArrayHasKey('ocs.app1.folders.open', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/open', 'GET', 'FoldersController', 'open', route: $collection->get('ocs.app1.folders.open'));
+ $this->assertArrayHasKey('ocs.app1.folders.create', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/create', 'POST', 'FoldersController', 'create', route: $collection->get('ocs.app1.folders.create'));
+ }
+
+ public function testParseOcsRoutesRootApps(): void {
+ $routes = ['ocs' => [
+ ['name' => 'folders#open', 'url' => '/{folderId}/open', 'verb' => 'GET'],
+ ['name' => 'folders#create', 'url' => '/{folderId}/create', 'verb' => 'POST']
+ ]];
+
+ $collection = $this->parser->parseOCSRoutes($routes, 'core');
+ $this->assertArrayHasKey('ocs.core.folders.open', $collection->all());
+ $this->assertSimpleRoute('/{folderId}/open', 'GET', 'FoldersController', 'open', app: 'core', route: $collection->get('ocs.core.folders.open'));
+ $this->assertArrayHasKey('ocs.core.folders.create', $collection->all());
+ $this->assertSimpleRoute('/{folderId}/create', 'POST', 'FoldersController', 'create', app: 'core', route: $collection->get('ocs.core.folders.create'));
+ }
+
+ public function testParseOcsRoutesWithPostfix(): void {
+ $routes = ['ocs' => [
+ ['name' => 'folders#update', 'url' => '/{folderId}/update', 'verb' => 'POST'],
+ ['name' => 'folders#update', 'url' => '/{folderId}/update', 'verb' => 'PUT', 'postfix' => '-edit']
+ ]];
+
+ $collection = $this->parser->parseOCSRoutes($routes, 'app1');
+ $this->assertArrayHasKey('ocs.app1.folders.update', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/update', 'POST', 'FoldersController', 'update', route: $collection->get('ocs.app1.folders.update'));
+ $this->assertArrayHasKey('ocs.app1.folders.update-edit', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/update', 'PUT', 'FoldersController', 'update', route: $collection->get('ocs.app1.folders.update-edit'));
+ }
+
+ public function testParseOcsRoutesKebabCaseAction(): void {
+ $routes = ['ocs' => [
+ ['name' => 'folders#open_folder', 'url' => '/{folderId}/open', 'verb' => 'GET']
+ ]];
+
+ $collection = $this->parser->parseOCSRoutes($routes, 'app1');
+ $this->assertArrayHasKey('ocs.app1.folders.open_folder', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/open', 'GET', 'FoldersController', 'openFolder', route: $collection->get('ocs.app1.folders.open_folder'));
+ }
+
+ public function testParseOcsRoutesKebabCaseController(): void {
+ $routes = ['ocs' => [
+ ['name' => 'my_folders#open', 'url' => '/{folderId}/open', 'verb' => 'GET']
+ ]];
+
+ $collection = $this->parser->parseOCSRoutes($routes, 'app1');
+ $this->assertArrayHasKey('ocs.app1.my_folders.open', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/open', 'GET', 'MyFoldersController', 'open', route: $collection->get('ocs.app1.my_folders.open'));
+ }
+
+ public function testParseOcsRoutesLowercaseVerb(): void {
+ $routes = ['ocs' => [
+ ['name' => 'folders#delete', 'url' => '/{folderId}/delete', 'verb' => 'delete']
+ ]];
+
+ $collection = $this->parser->parseOCSRoutes($routes, 'app1');
+ $this->assertArrayHasKey('ocs.app1.folders.delete', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/delete', 'DELETE', 'FoldersController', 'delete', route: $collection->get('ocs.app1.folders.delete'));
+ }
+
+ public function testParseOcsRoutesMissingVerb(): void {
+ $routes = ['ocs' => [
+ ['name' => 'folders#open', 'url' => '/{folderId}/open']
+ ]];
+
+ $collection = $this->parser->parseOCSRoutes($routes, 'app1');
+ $this->assertArrayHasKey('ocs.app1.folders.open', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/open', 'GET', 'FoldersController', 'open', route: $collection->get('ocs.app1.folders.open'));
+ }
+
+ public function testParseOcsRoutesWithRequirements(): void {
+ $routes = ['ocs' => [
+ ['name' => 'folders#open', 'url' => '/{folderId}/open', 'verb' => 'GET', 'requirements' => ['folderId' => '\d+']]
+ ]];
+
+ $collection = $this->parser->parseOCSRoutes($routes, 'app1');
+ $this->assertArrayHasKey('ocs.app1.folders.open', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/open', 'GET', 'FoldersController', 'open', requirements: ['folderId' => '\d+'], route: $collection->get('ocs.app1.folders.open'));
+ }
+
+ public function testParseOcsRoutesWithDefaults(): void {
+ $routes = ['ocs' => [
+ ['name' => 'folders#open', 'url' => '/{folderId}/open', 'verb' => 'GET', 'defaults' => ['hello' => 'world']]
+ ]];
+
+ $collection = $this->parser->parseOCSRoutes($routes, 'app1');
+ $this->assertArrayHasKey('ocs.app1.folders.open', $collection->all());
+ $this->assertSimpleRoute('/apps/app1/{folderId}/open', 'GET', 'FoldersController', 'open', defaults: ['hello' => 'world'], route: $collection->get('ocs.app1.folders.open'));
+ }
+
+ public function testParseOcsRoutesInvalidName(): void {
+ $routes = ['ocs' => [
+ ['name' => 'folders', 'url' => '/{folderId}/open', 'verb' => 'GET']
+ ]];
+
+ $this->expectException(\UnexpectedValueException::class);
+ $this->parser->parseOCSRoutes($routes, 'app1');
+ }
+
+ public function testParseOcsRoutesEmpty(): void {
+ $routes = ['ocs' => []];
+
+ $collection = $this->parser->parseOCSRoutes($routes, 'app1');
+ $this->assertEquals(0, $collection->count());
+ }
+
+ public function testParseOcsRoutesWithResources(): void {
+ $routes = ['ocs' => [
+ ['name' => 'folders#open', 'url' => '/{folderId}/open', 'verb' => 'GET'],
+ ], 'ocs-resources' => [
+ 'names' => ['url' => '/names', 'root' => '/core/something'],
+ 'folder_names' => ['url' => '/folder/names'],
+ ]];
+
+ $collection = $this->parser->parseOCSRoutes($routes, 'app1');
+ $this->assertArrayHasKey('ocs.app1.folders.open', $collection->all());
+ $this->assertOcsResource('/apps/app1/folder/names', 'folder_names', 'FolderNamesController', 'app1', $collection);
+ $this->assertOcsResource('/core/something/names', 'names', 'NamesController', 'app1', $collection);
+ }
+
+ protected function assertSimpleRoute(
+ string $path,
+ string $method,
+ string $controller,
+ string $action,
+ string $app = 'app1',
+ array $requirements = [],
+ array $defaults = [],
+ ?RoutingRoute $route = null,
+ ): void {
+ self::assertEquals($path, $route->getPath());
+ self::assertEqualsCanonicalizing([$method], $route->getMethods());
+ self::assertEqualsCanonicalizing($requirements, $route->getRequirements());
+ self::assertEquals([...$defaults, 'action' => null, 'caller' => [$app, $controller, $action]], $route->getDefaults());
+ }
+
+ protected function assertSimpleResource(
+ string $path,
+ string $resourceName,
+ string $controller,
+ string $app,
+ RouteCollection $collection,
+ ): void {
+ self::assertArrayHasKey("$app.$resourceName.index", $collection->all());
+ self::assertArrayHasKey("$app.$resourceName.show", $collection->all());
+ self::assertArrayHasKey("$app.$resourceName.create", $collection->all());
+ self::assertArrayHasKey("$app.$resourceName.update", $collection->all());
+ self::assertArrayHasKey("$app.$resourceName.destroy", $collection->all());
+
+ $this->assertSimpleRoute($path, 'GET', $controller, 'index', $app, route: $collection->get("$app.$resourceName.index"));
+ $this->assertSimpleRoute($path, 'POST', $controller, 'create', $app, route: $collection->get("$app.$resourceName.create"));
+ $this->assertSimpleRoute("$path/{id}", 'GET', $controller, 'show', $app, route: $collection->get("$app.$resourceName.show"));
+ $this->assertSimpleRoute("$path/{id}", 'PUT', $controller, 'update', $app, route: $collection->get("$app.$resourceName.update"));
+ $this->assertSimpleRoute("$path/{id}", 'DELETE', $controller, 'destroy', $app, route: $collection->get("$app.$resourceName.destroy"));
+ }
+
+ protected function assertOcsResource(
+ string $path,
+ string $resourceName,
+ string $controller,
+ string $app,
+ RouteCollection $collection,
+ ): void {
+ self::assertArrayHasKey("ocs.$app.$resourceName.index", $collection->all());
+ self::assertArrayHasKey("ocs.$app.$resourceName.show", $collection->all());
+ self::assertArrayHasKey("ocs.$app.$resourceName.create", $collection->all());
+ self::assertArrayHasKey("ocs.$app.$resourceName.update", $collection->all());
+ self::assertArrayHasKey("ocs.$app.$resourceName.destroy", $collection->all());
+
+ $this->assertSimpleRoute($path, 'GET', $controller, 'index', $app, route: $collection->get("ocs.$app.$resourceName.index"));
+ $this->assertSimpleRoute($path, 'POST', $controller, 'create', $app, route: $collection->get("ocs.$app.$resourceName.create"));
+ $this->assertSimpleRoute("$path/{id}", 'GET', $controller, 'show', $app, route: $collection->get("ocs.$app.$resourceName.show"));
+ $this->assertSimpleRoute("$path/{id}", 'PUT', $controller, 'update', $app, route: $collection->get("ocs.$app.$resourceName.update"));
+ $this->assertSimpleRoute("$path/{id}", 'DELETE', $controller, 'destroy', $app, route: $collection->get("ocs.$app.$resourceName.destroy"));
+ }
+}
diff --git a/tests/lib/AppFramework/Routing/RoutingTest.php b/tests/lib/AppFramework/Routing/RoutingTest.php
deleted file mode 100644
index 8522382ddcc..00000000000
--- a/tests/lib/AppFramework/Routing/RoutingTest.php
+++ /dev/null
@@ -1,476 +0,0 @@
-<?php
-/**
- * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
- * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-namespace Test\AppFramework\Routing;
-
-use OC\AppFramework\DependencyInjection\DIContainer;
-use OC\AppFramework\Routing\RouteConfig;
-use OC\Route\Route;
-use OC\Route\Router;
-use OCP\App\IAppManager;
-use OCP\Diagnostics\IEventLogger;
-use OCP\IConfig;
-use OCP\IRequest;
-use OCP\Route\IRouter;
-use PHPUnit\Framework\MockObject\MockObject;
-use Psr\Container\ContainerInterface;
-use Psr\Log\LoggerInterface;
-
-class RoutingTest extends \Test\TestCase {
- public function testSimpleRoute(): void {
- $routes = ['routes' => [
- ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'GET']
- ]];
-
- $this->assertSimpleRoute($routes, 'folders.open', 'GET', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open');
- }
-
- public function testSimpleRouteWithUnderScoreNames(): void {
- $routes = ['routes' => [
- ['name' => 'admin_folders#open_current', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'root' => '']
- ]];
-
- $this->assertSimpleRoute($routes, 'admin_folders.open_current', 'DELETE', '/folders/{folderId}/open', 'AdminFoldersController', 'openCurrent', [], [], '', true);
- }
-
- public function testSimpleOCSRoute(): void {
- $routes = ['ocs' => [
- ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'GET']
- ]
- ];
-
- $this->assertSimpleOCSRoute($routes, 'folders.open', 'GET', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open');
- }
-
- public function testSimpleRouteWithMissingVerb(): void {
- $routes = ['routes' => [
- ['name' => 'folders#open', 'url' => '/folders/{folderId}/open']
- ]];
-
- $this->assertSimpleRoute($routes, 'folders.open', 'GET', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open');
- }
-
- public function testSimpleOCSRouteWithMissingVerb(): void {
- $routes = ['ocs' => [
- ['name' => 'folders#open', 'url' => '/folders/{folderId}/open']
- ]
- ];
-
- $this->assertSimpleOCSRoute($routes, 'folders.open', 'GET', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open');
- }
-
- public function testSimpleRouteWithLowercaseVerb(): void {
- $routes = ['routes' => [
- ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete']
- ]];
-
- $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open');
- }
-
- public function testSimpleOCSRouteWithLowercaseVerb(): void {
- $routes = ['ocs' => [
- ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete']
- ]
- ];
-
- $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open');
- }
-
- public function testSimpleRouteWithRequirements(): void {
- $routes = ['routes' => [
- ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'requirements' => ['something']]
- ]];
-
- $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', ['something']);
- }
-
- public function testSimpleOCSRouteWithRequirements(): void {
- $routes = ['ocs' => [
- ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'requirements' => ['something']]
- ]
- ];
-
- $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', ['something']);
- }
-
- public function testSimpleRouteWithDefaults(): void {
- $routes = ['routes' => [
- ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', [], 'defaults' => ['param' => 'foobar']]
- ]];
-
- $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], ['param' => 'foobar']);
- }
-
-
- public function testSimpleOCSRouteWithDefaults(): void {
- $routes = ['ocs' => [
- ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'defaults' => ['param' => 'foobar']]
- ]
- ];
-
- $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], ['param' => 'foobar']);
- }
-
- public function testSimpleRouteWithPostfix(): void {
- $routes = ['routes' => [
- ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'postfix' => '_something']
- ]];
-
- $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], [], '_something');
- }
-
- public function testSimpleOCSRouteWithPostfix(): void {
- $routes = ['ocs' => [
- ['name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'postfix' => '_something']
- ]
- ];
-
- $this->assertSimpleOCSRoute($routes, 'folders.open', 'DELETE', '/apps/app1/folders/{folderId}/open', 'FoldersController', 'open', [], [], '_something');
- }
-
-
- public function testSimpleRouteWithBrokenName(): void {
- $this->expectException(\UnexpectedValueException::class);
-
- $routes = ['routes' => [
- ['name' => 'folders_open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete']
- ]];
-
- /** @var IRouter|MockObject $router */
- $router = $this->getMockBuilder(Router::class)
- ->onlyMethods(['create'])
- ->setConstructorArgs([
- $this->createMock(LoggerInterface::class),
- $this->createMock(IRequest::class),
- $this->createMock(IConfig::class),
- $this->createMock(IEventLogger::class),
- $this->createMock(ContainerInterface::class),
- $this->createMock(IAppManager::class),
- ])
- ->getMock();
-
- // load route configuration
- $container = new DIContainer('app1');
- $config = new RouteConfig($container, $router, $routes);
-
- $config->register();
- }
-
-
- public function testSimpleOCSRouteWithBrokenName(): void {
- $this->expectException(\UnexpectedValueException::class);
-
- $routes = ['ocs' => [
- ['name' => 'folders_open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete']
- ]];
-
- /** @var IRouter|MockObject $router */
- $router = $this->getMockBuilder(Router::class)
- ->onlyMethods(['create'])
- ->setConstructorArgs([
- $this->createMock(LoggerInterface::class),
- $this->createMock(IRequest::class),
- $this->createMock(IConfig::class),
- $this->createMock(IEventLogger::class),
- $this->createMock(ContainerInterface::class),
- $this->createMock(IAppManager::class),
- ])
- ->getMock();
-
- // load route configuration
- $container = new DIContainer('app1');
- $config = new RouteConfig($container, $router, $routes);
-
- $config->register();
- }
-
- public function testSimpleOCSRouteWithUnderScoreNames(): void {
- $routes = ['ocs' => [
- ['name' => 'admin_folders#open_current', 'url' => '/folders/{folderId}/open', 'verb' => 'delete']
- ]];
-
- $this->assertSimpleOCSRoute($routes, 'admin_folders.open_current', 'DELETE', '/apps/app1/folders/{folderId}/open', 'AdminFoldersController', 'openCurrent');
- }
-
- public function testOCSResource(): void {
- $routes = ['ocs-resources' => ['account' => ['url' => '/accounts']]];
-
- $this->assertOCSResource($routes, 'account', '/apps/app1/accounts', 'AccountController', 'id');
- }
-
- public function testOCSResourceWithUnderScoreName(): void {
- $routes = ['ocs-resources' => ['admin_accounts' => ['url' => '/admin/accounts']]];
-
- $this->assertOCSResource($routes, 'admin_accounts', '/apps/app1/admin/accounts', 'AdminAccountsController', 'id');
- }
-
- public function testOCSResourceWithRoot(): void {
- $routes = ['ocs-resources' => ['admin_accounts' => ['url' => '/admin/accounts', 'root' => '/core/endpoint']]];
-
- $this->assertOCSResource($routes, 'admin_accounts', '/core/endpoint/admin/accounts', 'AdminAccountsController', 'id');
- }
-
- public function testResource(): void {
- $routes = ['resources' => ['account' => ['url' => '/accounts']]];
-
- $this->assertResource($routes, 'account', '/apps/app1/accounts', 'AccountController', 'id');
- }
-
- public function testResourceWithUnderScoreName(): void {
- $routes = ['resources' => ['admin_accounts' => ['url' => '/admin/accounts']]];
-
- $this->assertResource($routes, 'admin_accounts', '/apps/app1/admin/accounts', 'AdminAccountsController', 'id');
- }
-
- private function assertSimpleRoute($routes, $name, $verb, $url, $controllerName, $actionName, array $requirements = [], array $defaults = [], $postfix = '', $allowRootUrl = false): void {
- if ($postfix) {
- $name .= $postfix;
- }
-
- // route mocks
- $container = new DIContainer('app1');
- $route = $this->mockRoute($container, $verb, $controllerName, $actionName, $requirements, $defaults);
-
- /** @var IRouter|MockObject $router */
- $router = $this->getMockBuilder(Router::class)
- ->onlyMethods(['create'])
- ->setConstructorArgs([
- $this->createMock(LoggerInterface::class),
- $this->createMock(IRequest::class),
- $this->createMock(IConfig::class),
- $this->createMock(IEventLogger::class),
- $this->createMock(ContainerInterface::class),
- $this->createMock(IAppManager::class),
- ])
- ->getMock();
-
- // we expect create to be called once:
- $router
- ->expects($this->once())
- ->method('create')
- ->with($this->equalTo('app1.' . $name), $this->equalTo($url))
- ->willReturn($route);
-
- // load route configuration
- $config = new RouteConfig($container, $router, $routes);
- if ($allowRootUrl) {
- self::invokePrivate($config, 'rootUrlApps', [['app1']]);
- }
-
- $config->register();
- }
-
- /**
- * @param $routes
- * @param string $name
- * @param string $verb
- * @param string $url
- * @param string $controllerName
- * @param string $actionName
- * @param array $requirements
- * @param array $defaults
- * @param string $postfix
- */
- private function assertSimpleOCSRoute($routes,
- $name,
- $verb,
- $url,
- $controllerName,
- $actionName,
- array $requirements = [],
- array $defaults = [],
- $postfix = '') {
- if ($postfix) {
- $name .= $postfix;
- }
-
- // route mocks
- $container = new DIContainer('app1');
- $route = $this->mockRoute($container, $verb, $controllerName, $actionName, $requirements, $defaults);
-
- /** @var IRouter|MockObject $router */
- $router = $this->getMockBuilder(Router::class)
- ->onlyMethods(['create'])
- ->setConstructorArgs([
- $this->createMock(LoggerInterface::class),
- $this->createMock(IRequest::class),
- $this->createMock(IConfig::class),
- $this->createMock(IEventLogger::class),
- $this->createMock(ContainerInterface::class),
- $this->createMock(IAppManager::class),
- ])
- ->getMock();
-
- // we expect create to be called once:
- $router
- ->expects($this->once())
- ->method('create')
- ->with($this->equalTo('ocs.app1.' . $name), $this->equalTo($url))
- ->willReturn($route);
-
- // load route configuration
- $config = new RouteConfig($container, $router, $routes);
-
- $config->register();
- }
-
- /**
- * @param array $yaml
- * @param string $resourceName
- * @param string $url
- * @param string $controllerName
- * @param string $paramName
- */
- private function assertOCSResource($yaml, $resourceName, $url, $controllerName, $paramName): void {
- /** @var IRouter|MockObject $router */
- $router = $this->getMockBuilder(Router::class)
- ->onlyMethods(['create'])
- ->setConstructorArgs([
- $this->createMock(LoggerInterface::class),
- $this->createMock(IRequest::class),
- $this->createMock(IConfig::class),
- $this->createMock(IEventLogger::class),
- $this->createMock(ContainerInterface::class),
- $this->createMock(IAppManager::class),
- ])
- ->getMock();
-
- // route mocks
- $container = new DIContainer('app1');
- $indexRoute = $this->mockRoute($container, 'GET', $controllerName, 'index');
- $showRoute = $this->mockRoute($container, 'GET', $controllerName, 'show');
- $createRoute = $this->mockRoute($container, 'POST', $controllerName, 'create');
- $updateRoute = $this->mockRoute($container, 'PUT', $controllerName, 'update');
- $destroyRoute = $this->mockRoute($container, 'DELETE', $controllerName, 'destroy');
-
- $urlWithParam = $url . '/{' . $paramName . '}';
-
- // we expect create to be called five times:
- $router
- ->expects($this->exactly(5))
- ->method('create')
- ->withConsecutive(
- [$this->equalTo('ocs.app1.' . $resourceName . '.index'), $this->equalTo($url)],
- [$this->equalTo('ocs.app1.' . $resourceName . '.show'), $this->equalTo($urlWithParam)],
- [$this->equalTo('ocs.app1.' . $resourceName . '.create'), $this->equalTo($url)],
- [$this->equalTo('ocs.app1.' . $resourceName . '.update'), $this->equalTo($urlWithParam)],
- [$this->equalTo('ocs.app1.' . $resourceName . '.destroy'), $this->equalTo($urlWithParam)],
- )->willReturnOnConsecutiveCalls(
- $indexRoute,
- $showRoute,
- $createRoute,
- $updateRoute,
- $destroyRoute,
- );
-
- // load route configuration
- $config = new RouteConfig($container, $router, $yaml);
-
- $config->register();
- }
-
- /**
- * @param string $resourceName
- * @param string $url
- * @param string $controllerName
- * @param string $paramName
- */
- private function assertResource($yaml, $resourceName, $url, $controllerName, $paramName) {
- /** @var IRouter|MockObject $router */
- $router = $this->getMockBuilder(Router::class)
- ->onlyMethods(['create'])
- ->setConstructorArgs([
- $this->createMock(LoggerInterface::class),
- $this->createMock(IRequest::class),
- $this->createMock(IConfig::class),
- $this->createMock(IEventLogger::class),
- $this->createMock(ContainerInterface::class),
- $this->createMock(IAppManager::class),
- ])
- ->getMock();
-
- // route mocks
- $container = new DIContainer('app1');
- $indexRoute = $this->mockRoute($container, 'GET', $controllerName, 'index');
- $showRoute = $this->mockRoute($container, 'GET', $controllerName, 'show');
- $createRoute = $this->mockRoute($container, 'POST', $controllerName, 'create');
- $updateRoute = $this->mockRoute($container, 'PUT', $controllerName, 'update');
- $destroyRoute = $this->mockRoute($container, 'DELETE', $controllerName, 'destroy');
-
- $urlWithParam = $url . '/{' . $paramName . '}';
-
- // we expect create to be called five times:
- $router
- ->expects($this->exactly(5))
- ->method('create')
- ->withConsecutive(
- [$this->equalTo('app1.' . $resourceName . '.index'), $this->equalTo($url)],
- [$this->equalTo('app1.' . $resourceName . '.show'), $this->equalTo($urlWithParam)],
- [$this->equalTo('app1.' . $resourceName . '.create'), $this->equalTo($url)],
- [$this->equalTo('app1.' . $resourceName . '.update'), $this->equalTo($urlWithParam)],
- [$this->equalTo('app1.' . $resourceName . '.destroy'), $this->equalTo($urlWithParam)],
- )->willReturnOnConsecutiveCalls(
- $indexRoute,
- $showRoute,
- $createRoute,
- $updateRoute,
- $destroyRoute,
- );
-
- // load route configuration
- $config = new RouteConfig($container, $router, $yaml);
-
- $config->register();
- }
-
- /**
- * @param DIContainer $container
- * @param string $verb
- * @param string $controllerName
- * @param string $actionName
- * @param array $requirements
- * @param array $defaults
- * @return MockObject
- */
- private function mockRoute(
- DIContainer $container,
- $verb,
- $controllerName,
- $actionName,
- array $requirements = [],
- array $defaults = [],
- ) {
- $route = $this->getMockBuilder(Route::class)
- ->onlyMethods(['method', 'requirements', 'defaults'])
- ->disableOriginalConstructor()
- ->getMock();
- $route
- ->expects($this->once())
- ->method('method')
- ->with($this->equalTo($verb))
- ->willReturn($route);
-
- if (count($requirements) > 0) {
- $route
- ->expects($this->once())
- ->method('requirements')
- ->with($this->equalTo($requirements))
- ->willReturn($route);
- }
-
- $route->expects($this->once())
- ->method('defaults')
- ->with($this->callback(function (array $def) use ($defaults, $controllerName, $actionName) {
- $defaults['caller'] = ['app1', $controllerName, $actionName];
-
- $this->assertEquals($defaults, $def);
- return true;
- }))
- ->willReturn($route);
-
- return $route;
- }
-}
diff --git a/tests/lib/AppFramework/Services/AppConfigTest.php b/tests/lib/AppFramework/Services/AppConfigTest.php
index 46f73a8c088..718817a7636 100644
--- a/tests/lib/AppFramework/Services/AppConfigTest.php
+++ b/tests/lib/AppFramework/Services/AppConfigTest.php
@@ -28,7 +28,7 @@ class AppConfigTest extends TestCase {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->appConfigCore = $this->createMock(AppConfigCore::class);
-
+
$this->appConfig = new AppConfig($this->config, $this->appConfigCore, self::TEST_APPID);
}
@@ -46,7 +46,7 @@ class AppConfigTest extends TestCase {
* @return array
* @see testHasAppKey
*/
- public function providerHasAppKey(): array {
+ public static function providerHasAppKey(): array {
return [
// lazy, expected
[false, true],
@@ -76,7 +76,7 @@ class AppConfigTest extends TestCase {
* @return array
* @see testIsSensitive
*/
- public function providerIsSensitive(): array {
+ public static function providerIsSensitive(): array {
return [
// lazy, expected
[false, true],
@@ -123,7 +123,7 @@ class AppConfigTest extends TestCase {
* @return array
* @see testIsLazy
*/
- public function providerIsLazy(): array {
+ public static function providerIsLazy(): array {
return [
// expected
[true],
@@ -161,7 +161,7 @@ class AppConfigTest extends TestCase {
* @return array
* @see testGetAllAppValues
*/
- public function providerGetAllAppValues(): array {
+ public static function providerGetAllAppValues(): array {
return [
// key, filtered
['', false],
@@ -214,7 +214,7 @@ class AppConfigTest extends TestCase {
* @see testSetAppValueArray
* @see testSetAppValueArrayException
*/
- public function providerSetAppValue(): array {
+ public static function providerSetAppValue(): array {
return [
// lazy, sensitive, expected
[false, false, true],
@@ -340,7 +340,7 @@ class AppConfigTest extends TestCase {
* @return array
* @see testSetAppValueBool
*/
- public function providerSetAppValueBool(): array {
+ public static function providerSetAppValueBool(): array {
return [
// lazy, expected
[false, true],
@@ -456,7 +456,7 @@ class AppConfigTest extends TestCase {
* @see testGetAppValueArray
* @see testGetAppValueArrayException
*/
- public function providerGetAppValue(): array {
+ public static function providerGetAppValue(): array {
return [
// lazy, exist
[false, false],
diff --git a/tests/lib/AppFramework/Utility/SimpleContainerTest.php b/tests/lib/AppFramework/Utility/SimpleContainerTest.php
index d3e9dec18e0..754da8e5fb3 100644
--- a/tests/lib/AppFramework/Utility/SimpleContainerTest.php
+++ b/tests/lib/AppFramework/Utility/SimpleContainerTest.php
@@ -191,7 +191,7 @@ class SimpleContainerTest extends \Test\TestCase {
$this->container->query('test'), $this->container->query('test1'));
}
- public function sanitizeNameProvider() {
+ public static function sanitizeNameProvider(): array {
return [
['ABC\\Foo', 'ABC\\Foo'],
['\\ABC\\Foo', '\\ABC\\Foo'],
diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php
index 3e4d762a0a4..b817d968910 100644
--- a/tests/lib/AppTest.php
+++ b/tests/lib/AppTest.php
@@ -34,7 +34,7 @@ class AppTest extends \Test\TestCase {
public const TEST_GROUP1 = 'group1';
public const TEST_GROUP2 = 'group2';
- public function appVersionsProvider() {
+ public static function appVersionsProvider(): array {
return [
// exact match
[
@@ -335,7 +335,7 @@ class AppTest extends \Test\TestCase {
/**
* Providers for the app config values
*/
- public function appConfigValuesProvider() {
+ public static function appConfigValuesProvider(): array {
return [
// logged in user1
[
@@ -591,7 +591,7 @@ class AppTest extends \Test\TestCase {
/**
* Providers for the app data values
*/
- public function appDataProvider() {
+ public static function appDataProvider(): array {
return [
[
['description' => " \t This is a multiline \n test with \n \t \n \n some new lines "],
diff --git a/tests/lib/Archive/ZIPTest.php b/tests/lib/Archive/ZIPTest.php
index 25707e4b051..59fb91006a3 100644
--- a/tests/lib/Archive/ZIPTest.php
+++ b/tests/lib/Archive/ZIPTest.php
@@ -16,6 +16,10 @@ class ZIPTest extends TestBase {
}
protected function getNew() {
- return new ZIP(\OC::$server->getTempManager()->getTempBaseDir() . '/newArchive.zip');
+ $newZip = \OC::$server->getTempManager()->getTempBaseDir() . '/newArchive.zip';
+ if (file_exists($newZip)) {
+ unlink($newZip);
+ }
+ return new ZIP($newZip);
}
}
diff --git a/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php b/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php
index f91371a86b7..a7590cdd244 100644
--- a/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php
+++ b/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php
@@ -83,13 +83,18 @@ class UserDeletedTokenCleanupListenerTest extends TestCase {
$token2,
$token3,
]);
+
+ $calls = [
+ ['user123', 1],
+ ['user123', 2],
+ ['user123', 3],
+ ];
$this->manager->expects($this->exactly(3))
->method('invalidateTokenById')
- ->withConsecutive(
- ['user123', 1],
- ['user123', 2],
- ['user123', 3]
- );
+ ->willReturnCallback(function () use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
$this->logger->expects($this->never())
->method('error');
diff --git a/tests/lib/Authentication/Login/ALoginCommandTest.php b/tests/lib/Authentication/Login/ALoginTestCommand.php
index 2ab59835bfe..502380bc3fe 100644
--- a/tests/lib/Authentication/Login/ALoginCommandTest.php
+++ b/tests/lib/Authentication/Login/ALoginTestCommand.php
@@ -8,14 +8,13 @@ declare(strict_types=1);
namespace Test\Authentication\Login;
-use OC\Authentication\Login\ALoginCommand;
use OC\Authentication\Login\LoginData;
use OCP\IRequest;
use OCP\IUser;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
-abstract class ALoginCommandTest extends TestCase {
+abstract class ALoginTestCommand extends TestCase {
/** @var IRequest|MockObject */
protected $request;
@@ -36,7 +35,7 @@ abstract class ALoginCommandTest extends TestCase {
/** @var IUser|MockObject */
protected $user;
- /** @var ALoginCommand */
+ /** @var ALoginTestCommand */
protected $cmd;
protected function setUp(): void {
diff --git a/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php b/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php
index 025612e963e..5ff2da28946 100644
--- a/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php
+++ b/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php
@@ -13,7 +13,7 @@ use OC\Authentication\Login\ClearLostPasswordTokensCommand;
use OCP\IConfig;
use PHPUnit\Framework\MockObject\MockObject;
-class ClearLostPasswordTokensCommandTest extends ALoginCommandTest {
+class ClearLostPasswordTokensCommandTest extends ALoginTestCommand {
/** @var IConfig|MockObject */
private $config;
diff --git a/tests/lib/Authentication/Login/CompleteLoginCommandTest.php b/tests/lib/Authentication/Login/CompleteLoginCommandTest.php
index 4ddb26e7648..5b08368671f 100644
--- a/tests/lib/Authentication/Login/CompleteLoginCommandTest.php
+++ b/tests/lib/Authentication/Login/CompleteLoginCommandTest.php
@@ -13,7 +13,7 @@ use OC\Authentication\Login\CompleteLoginCommand;
use OC\User\Session;
use PHPUnit\Framework\MockObject\MockObject;
-class CompleteLoginCommandTest extends ALoginCommandTest {
+class CompleteLoginCommandTest extends ALoginTestCommand {
/** @var Session|MockObject */
private $session;
diff --git a/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php b/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php
index fd6a154ef5d..668c0a6d6ea 100644
--- a/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php
+++ b/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php
@@ -15,7 +15,7 @@ use OC\User\Session;
use OCP\IConfig;
use PHPUnit\Framework\MockObject\MockObject;
-class CreateSessionTokenCommandTest extends ALoginCommandTest {
+class CreateSessionTokenCommandTest extends ALoginTestCommand {
/** @var IConfig|MockObject */
private $config;
diff --git a/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php b/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php
index 4eb4f94055f..499abafa6e3 100644
--- a/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php
+++ b/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php
@@ -14,7 +14,7 @@ use OC\User\Session;
use OCP\IConfig;
use PHPUnit\Framework\MockObject\MockObject;
-class FinishRememberedLoginCommandTest extends ALoginCommandTest {
+class FinishRememberedLoginCommandTest extends ALoginTestCommand {
/** @var Session|MockObject */
private $userSession;
/** @var IConfig|MockObject */
diff --git a/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php b/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php
index ce783050921..7b011d70673 100644
--- a/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php
+++ b/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php
@@ -15,7 +15,7 @@ use OCP\EventDispatcher\IEventDispatcher;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
-class LoggedInCheckCommandTest extends ALoginCommandTest {
+class LoggedInCheckCommandTest extends ALoginTestCommand {
/** @var LoggerInterface|MockObject */
private $logger;
diff --git a/tests/lib/Authentication/Login/PreLoginHookCommandTest.php b/tests/lib/Authentication/Login/PreLoginHookCommandTest.php
index b6d826f1c21..0e5096baf55 100644
--- a/tests/lib/Authentication/Login/PreLoginHookCommandTest.php
+++ b/tests/lib/Authentication/Login/PreLoginHookCommandTest.php
@@ -14,7 +14,7 @@ use OC\User\Manager;
use OCP\IUserManager;
use PHPUnit\Framework\MockObject\MockObject;
-class PreLoginHookCommandTest extends ALoginCommandTest {
+class PreLoginHookCommandTest extends ALoginTestCommand {
/** @var IUserManager|MockObject */
private $userManager;
diff --git a/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php b/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php
index d4e15f68257..fb8240c4b1e 100644
--- a/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php
+++ b/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php
@@ -14,7 +14,7 @@ use OCP\IConfig;
use OCP\ISession;
use PHPUnit\Framework\MockObject\MockObject;
-class SetUserTimezoneCommandTest extends ALoginCommandTest {
+class SetUserTimezoneCommandTest extends ALoginTestCommand {
/** @var IConfig|MockObject */
private $config;
diff --git a/tests/lib/Authentication/Login/TwoFactorCommandTest.php b/tests/lib/Authentication/Login/TwoFactorCommandTest.php
index af7d7446bfb..a95e4b50cbc 100644
--- a/tests/lib/Authentication/Login/TwoFactorCommandTest.php
+++ b/tests/lib/Authentication/Login/TwoFactorCommandTest.php
@@ -18,7 +18,7 @@ use OCP\Authentication\TwoFactorAuth\IProvider as ITwoFactorAuthProvider;
use OCP\IURLGenerator;
use PHPUnit\Framework\MockObject\MockObject;
-class TwoFactorCommandTest extends ALoginCommandTest {
+class TwoFactorCommandTest extends ALoginTestCommand {
/** @var Manager|MockObject */
private $twoFactorManager;
diff --git a/tests/lib/Authentication/Login/UidLoginCommandTest.php b/tests/lib/Authentication/Login/UidLoginCommandTest.php
index 3073aac1859..daae34e2212 100644
--- a/tests/lib/Authentication/Login/UidLoginCommandTest.php
+++ b/tests/lib/Authentication/Login/UidLoginCommandTest.php
@@ -13,7 +13,7 @@ use OC\Authentication\Login\UidLoginCommand;
use OC\User\Manager;
use PHPUnit\Framework\MockObject\MockObject;
-class UidLoginCommandTest extends ALoginCommandTest {
+class UidLoginCommandTest extends ALoginTestCommand {
/** @var Manager|MockObject */
private $userManager;
diff --git a/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php b/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php
index f5760f3f232..1a845a05c23 100644
--- a/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php
+++ b/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php
@@ -13,7 +13,7 @@ use OC\Authentication\Login\UpdateLastPasswordConfirmCommand;
use OCP\ISession;
use PHPUnit\Framework\MockObject\MockObject;
-class UpdateLastPasswordConfirmCommandTest extends ALoginCommandTest {
+class UpdateLastPasswordConfirmCommandTest extends ALoginTestCommand {
/** @var ISession|MockObject */
private $session;
diff --git a/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php b/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php
index 84b1018e5fa..ee4e171d443 100644
--- a/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php
+++ b/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php
@@ -15,7 +15,7 @@ use OCP\IUserManager;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
-class UserDisabledCheckCommandTest extends ALoginCommandTest {
+class UserDisabledCheckCommandTest extends ALoginTestCommand {
/** @var IUserManager|MockObject */
private $userManager;
diff --git a/tests/lib/Authentication/Token/ManagerTest.php b/tests/lib/Authentication/Token/ManagerTest.php
index 4fde9817d09..0f95d1d2f2c 100644
--- a/tests/lib/Authentication/Token/ManagerTest.php
+++ b/tests/lib/Authentication/Token/ManagerTest.php
@@ -128,10 +128,10 @@ class ManagerTest extends TestCase {
$this->assertSame(121, mb_strlen($actual->getName()));
}
- public function tokenData(): array {
+ public static function tokenData(): array {
return [
[new PublicKeyToken()],
- [$this->createMock(IToken::class)],
+ [IToken::class],
];
}
@@ -160,7 +160,11 @@ class ManagerTest extends TestCase {
/**
* @dataProvider tokenData
*/
- public function testUpdateToken(IToken $token): void {
+ public function testUpdateToken(IToken|string $token): void {
+ if (is_string($token)) {
+ $token = $this->createMock($token);
+ }
+
$this->setNoCall($token);
$this->setCall($token, 'updateToken');
$this->setException($token);
@@ -171,7 +175,11 @@ class ManagerTest extends TestCase {
/**
* @dataProvider tokenData
*/
- public function testUpdateTokenActivity(IToken $token): void {
+ public function testUpdateTokenActivity(IToken|string $token): void {
+ if (is_string($token)) {
+ $token = $this->createMock($token);
+ }
+
$this->setNoCall($token);
$this->setCall($token, 'updateTokenActivity');
$this->setException($token);
@@ -182,7 +190,11 @@ class ManagerTest extends TestCase {
/**
* @dataProvider tokenData
*/
- public function testGetPassword(IToken $token): void {
+ public function testGetPassword(IToken|string $token): void {
+ if (is_string($token)) {
+ $token = $this->createMock($token);
+ }
+
$this->setNoCall($token);
$this->setCall($token, 'getPassword', 'password');
$this->setException($token);
@@ -195,7 +207,11 @@ class ManagerTest extends TestCase {
/**
* @dataProvider tokenData
*/
- public function testSetPassword(IToken $token): void {
+ public function testSetPassword(IToken|string $token): void {
+ if (is_string($token)) {
+ $token = $this->createMock($token);
+ }
+
$this->setNoCall($token);
$this->setCall($token, 'setPassword');
$this->setException($token);
@@ -358,13 +374,18 @@ class ManagerTest extends TestCase {
->method('getTokenByUser')
->with('theUser')
->willReturn([$t1, $t2]);
+
+ $calls = [
+ ['theUser', 123],
+ ['theUser', 456],
+ ];
$this->publicKeyTokenProvider
->expects($this->exactly(2))
->method('invalidateTokenById')
- ->withConsecutive(
- ['theUser', 123],
- ['theUser', 456],
- );
+ ->willReturnCallback(function () use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
$this->manager->invalidateTokensOfUser('theUser', null);
}
diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
index 6097c1f482d..dc6ec7c7f3e 100644
--- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
+++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
@@ -304,12 +304,17 @@ class PublicKeyTokenProviderTest extends TestCase {
}
public function testInvalidateToken(): void {
+ $calls = [
+ [hash('sha512', 'token7' . '1f4h9s')],
+ [hash('sha512', 'token7')]
+ ];
+
$this->mapper->expects($this->exactly(2))
->method('invalidate')
- ->withConsecutive(
- [hash('sha512', 'token7' . '1f4h9s')],
- [hash('sha512', 'token7')]
- );
+ ->willReturnCallback(function () use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
$this->tokenProvider->invalidateToken('token7');
}
@@ -336,14 +341,19 @@ class PublicKeyTokenProviderTest extends TestCase {
['token_auth_wipe_token_retention', $wipeTokenLifetime, 500],
['token_auth_token_retention', 60 * 60 * 24 * 365, 800],
]);
+
+ $calls = [
+ [$this->time - 150, IToken::TEMPORARY_TOKEN, IToken::DO_NOT_REMEMBER],
+ [$this->time - 300, IToken::TEMPORARY_TOKEN, IToken::REMEMBER],
+ [$this->time - 500, IToken::WIPE_TOKEN, null],
+ [$this->time - 800, IToken::PERMANENT_TOKEN, null],
+ ];
$this->mapper->expects($this->exactly(4))
->method('invalidateOld')
- ->withConsecutive(
- [$this->time - 150, IToken::TEMPORARY_TOKEN, IToken::DO_NOT_REMEMBER],
- [$this->time - 300, IToken::TEMPORARY_TOKEN, IToken::REMEMBER],
- [$this->time - 500, IToken::WIPE_TOKEN, null],
- [$this->time - 800, IToken::PERMANENT_TOKEN, null],
- );
+ ->willReturnCallback(function () use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
$this->tokenProvider->invalidateOldTokens();
}
@@ -453,16 +463,17 @@ class PublicKeyTokenProviderTest extends TestCase {
public function testGetInvalidToken(): void {
$this->expectException(InvalidTokenException::class);
+ $calls = [
+ 'unhashedTokentokentokentokentoken' . '1f4h9s',
+ 'unhashedTokentokentokentokentoken',
+ ];
$this->mapper->expects($this->exactly(2))
->method('getToken')
- ->withConsecutive(
- [$this->callback(function (string $token): bool {
- return hash('sha512', 'unhashedTokentokentokentokentoken' . '1f4h9s') === $token;
- })],
- [$this->callback(function (string $token): bool {
- return hash('sha512', 'unhashedTokentokentokentokentoken') === $token;
- })]
- )->willThrowException(new DoesNotExistException('nope'));
+ ->willReturnCallback(function (string $token) use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals(hash('sha512', $expected), $token);
+ throw new DoesNotExistException('nope');
+ });
$this->tokenProvider->getToken('unhashedTokentokentokentokentoken');
}
diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
index 52792c29ed0..75691627ce7 100644
--- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
@@ -204,7 +204,7 @@ class ManagerTest extends TestCase {
$this->assertTrue($this->manager->isTwoFactorAuthenticated($this->user));
}
- public function providerStatesFixData(): array {
+ public static function providerStatesFixData(): array {
return [
[false, false],
[true, true],
@@ -356,12 +356,18 @@ class ManagerTest extends TestCase {
->method('get')
->with('two_factor_remember_login')
->willReturn(false);
+
+ $calls = [
+ ['two_factor_auth_uid'],
+ ['two_factor_remember_login'],
+ ];
$this->session->expects($this->exactly(2))
->method('remove')
- ->withConsecutive(
- ['two_factor_auth_uid'],
- ['two_factor_remember_login']
- );
+ ->willReturnCallback(function () use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
+
$this->session->expects($this->once())
->method('set')
->with(Manager::SESSION_UID_DONE, 'jos');
@@ -474,14 +480,19 @@ class ManagerTest extends TestCase {
public function testNeedsSecondFactor(): void {
$user = $this->createMock(IUser::class);
+
+ $calls = [
+ ['app_password'],
+ ['two_factor_auth_uid'],
+ [Manager::SESSION_UID_DONE],
+ ];
$this->session->expects($this->exactly(3))
->method('exists')
- ->withConsecutive(
- ['app_password'],
- ['two_factor_auth_uid'],
- [Manager::SESSION_UID_DONE],
- )
- ->willReturn(false);
+ ->willReturnCallback(function () use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ return false;
+ });
$this->session->method('getId')
->willReturn('mysessionid');
@@ -513,7 +524,7 @@ class ManagerTest extends TestCase {
$this->timeFactory,
$this->dispatcher,
])
- ->setMethods(['loadTwoFactorApp', 'isTwoFactorAuthenticated'])// Do not actually load the apps
+ ->onlyMethods(['isTwoFactorAuthenticated'])// Do not actually load the apps
->getMock();
$manager->method('isTwoFactorAuthenticated')
@@ -550,12 +561,16 @@ class ManagerTest extends TestCase {
$this->user->method('getUID')
->willReturn('ferdinand');
+ $calls = [
+ ['two_factor_auth_uid', 'ferdinand'],
+ ['two_factor_remember_login', true],
+ ];
$this->session->expects($this->exactly(2))
->method('set')
- ->withConsecutive(
- ['two_factor_auth_uid', 'ferdinand'],
- ['two_factor_remember_login', true]
- );
+ ->willReturnCallback(function () use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
$this->session->method('getId')
->willReturn('mysessionid');
@@ -580,12 +595,16 @@ class ManagerTest extends TestCase {
$this->user->method('getUID')
->willReturn('ferdinand');
+ $calls = [
+ ['two_factor_auth_uid', 'ferdinand'],
+ ['two_factor_remember_login', false],
+ ];
$this->session->expects($this->exactly(2))
->method('set')
- ->withConsecutive(
- ['two_factor_auth_uid', 'ferdinand'],
- ['two_factor_remember_login', false]
- );
+ ->willReturnCallback(function () use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
$this->session->method('getId')
->willReturn('mysessionid');
@@ -710,21 +729,29 @@ class ManagerTest extends TestCase {
'42', '43', '44'
]);
+ $deleteUserValueCalls = [
+ ['theUserId', 'login_token_2fa', '42'],
+ ['theUserId', 'login_token_2fa', '43'],
+ ['theUserId', 'login_token_2fa', '44'],
+ ];
$this->config->expects($this->exactly(3))
->method('deleteUserValue')
- ->withConsecutive(
- ['theUserId', 'login_token_2fa', '42'],
- ['theUserId', 'login_token_2fa', '43'],
- ['theUserId', 'login_token_2fa', '44'],
- );
+ ->willReturnCallback(function () use (&$deleteUserValueCalls) {
+ $expected = array_shift($deleteUserValueCalls);
+ $this->assertEquals($expected, func_get_args());
+ });
+ $invalidateCalls = [
+ ['theUserId', 42],
+ ['theUserId', 43],
+ ['theUserId', 44],
+ ];
$this->tokenProvider->expects($this->exactly(3))
->method('invalidateTokenById')
- ->withConsecutive(
- ['theUserId', 42],
- ['theUserId', 43],
- ['theUserId', 44],
- );
+ ->willReturnCallback(function () use (&$invalidateCalls) {
+ $expected = array_shift($invalidateCalls);
+ $this->assertEquals($expected, func_get_args());
+ });
$this->manager->clearTwoFactorPending('theUserId');
}
@@ -736,22 +763,28 @@ class ManagerTest extends TestCase {
'42', '43', '44'
]);
+ $deleteUserValueCalls = [
+ ['theUserId', 'login_token_2fa', '42'],
+ ['theUserId', 'login_token_2fa', '43'],
+ ['theUserId', 'login_token_2fa', '44'],
+ ];
$this->config->expects($this->exactly(3))
->method('deleteUserValue')
- ->withConsecutive(
- ['theUserId', 'login_token_2fa', '42'],
- ['theUserId', 'login_token_2fa', '43'],
- ['theUserId', 'login_token_2fa', '44'],
- );
+ ->willReturnCallback(function () use (&$deleteUserValueCalls) {
+ $expected = array_shift($deleteUserValueCalls);
+ $this->assertEquals($expected, func_get_args());
+ });
+ $invalidateCalls = [
+ ['theUserId', 42],
+ ['theUserId', 43],
+ ['theUserId', 44],
+ ];
$this->tokenProvider->expects($this->exactly(3))
->method('invalidateTokenById')
- ->withConsecutive(
- ['theUserId', 42],
- ['theUserId', 43],
- ['theUserId', 44],
- )
- ->willReturnCallback(function ($user, $tokenId) {
+ ->willReturnCallback(function ($user, $tokenId) use (&$invalidateCalls) {
+ $expected = array_shift($invalidateCalls);
+ $this->assertEquals($expected, func_get_args());
if ($tokenId === 43) {
throw new DoesNotExistException('token does not exist');
}
diff --git a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
index 77e619d03a2..252b57e7983 100644
--- a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
@@ -119,12 +119,17 @@ class RegistryTest extends TestCase {
'provider_id' => 'twofactor_u2f',
]
]);
+
+ $calls = [
+ [new TwoFactorProviderDisabled('twofactor_u2f')],
+ [new TwoFactorProviderUserDeleted($user, 'twofactor_u2f')],
+ ];
$this->dispatcher->expects($this->exactly(2))
->method('dispatchTyped')
- ->withConsecutive(
- [new TwoFactorProviderDisabled('twofactor_u2f')],
- [new TwoFactorProviderUserDeleted($user, 'twofactor_u2f')],
- );
+ ->willReturnCallback(function () use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
$this->registry->deleteUserData($user);
}
diff --git a/tests/lib/Avatar/AvatarManagerTest.php b/tests/lib/Avatar/AvatarManagerTest.php
index 25e8e1563f5..5fac90e0f34 100644
--- a/tests/lib/Avatar/AvatarManagerTest.php
+++ b/tests/lib/Avatar/AvatarManagerTest.php
@@ -186,7 +186,7 @@ class AvatarManagerTest extends \Test\TestCase {
$this->assertEquals($expected, $this->avatarManager->getAvatar('vaLid-USER'));
}
- public function dataGetAvatarScopes() {
+ public static function dataGetAvatarScopes(): array {
return [
// public access cannot see real avatar
[IAccountManager::SCOPE_PRIVATE, true, false, true],
diff --git a/tests/lib/Avatar/UserAvatarTest.php b/tests/lib/Avatar/UserAvatarTest.php
index 0e2bfe6872f..633a0fda368 100644
--- a/tests/lib/Avatar/UserAvatarTest.php
+++ b/tests/lib/Avatar/UserAvatarTest.php
@@ -41,7 +41,7 @@ class UserAvatarTest extends \Test\TestCase {
$this->avatar = $this->getUserAvatar($this->user);
}
- public function avatarTextData() {
+ public static function avatarTextData(): array {
return [
['', '?'],
['matchish', 'M'],
diff --git a/tests/lib/BackgroundJob/JobListTest.php b/tests/lib/BackgroundJob/JobListTest.php
index bf21639d3aa..64279c11a35 100644
--- a/tests/lib/BackgroundJob/JobListTest.php
+++ b/tests/lib/BackgroundJob/JobListTest.php
@@ -73,7 +73,7 @@ class JobListTest extends TestCase {
return $jobs;
}
- public function argumentProvider() {
+ public static function argumentProvider(): array {
return [
[null],
[false],
diff --git a/tests/lib/Cache/FileCacheTest.php b/tests/lib/Cache/FileCacheTest.php
index 1d12147af0d..8d3db539dd0 100644
--- a/tests/lib/Cache/FileCacheTest.php
+++ b/tests/lib/Cache/FileCacheTest.php
@@ -88,7 +88,7 @@ class FileCacheTest extends TestCache {
private function setupMockStorage() {
$mockStorage = $this->getMockBuilder(Local::class)
- ->setMethods(['filemtime', 'unlink'])
+ ->onlyMethods(['filemtime', 'unlink'])
->setConstructorArgs([['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]])
->getMock();
@@ -125,7 +125,7 @@ class FileCacheTest extends TestCache {
$this->instance->gc();
}
- public function lockExceptionProvider() {
+ public static function lockExceptionProvider(): array {
return [
[new \OCP\Lock\LockedException('key1')],
[new \OCP\Files\LockNotAcquiredException('key1', 1)],
diff --git a/tests/lib/Calendar/ManagerTest.php b/tests/lib/Calendar/ManagerTest.php
index cecebcfc4cf..1fb64d97f47 100644
--- a/tests/lib/Calendar/ManagerTest.php
+++ b/tests/lib/Calendar/ManagerTest.php
@@ -199,7 +199,7 @@ class ManagerTest extends TestCase {
$this->assertEquals($expected, $result);
}
- public function searchProvider() {
+ public static function searchProvider(): array {
$search1 = [
[
'id' => 1,
@@ -1096,7 +1096,7 @@ class ManagerTest extends TestCase {
$this->userManager,
$this->serverFactory,
])
- ->setMethods([
+ ->onlyMethods([
'getCalendarsForPrincipal'
])
->getMock();
@@ -1544,11 +1544,11 @@ class ManagerTest extends TestCase {
$this->userManager,
$this->serverFactory,
])
- ->setMethods([
+ ->onlyMethods([
'getCalendarsForPrincipal'
])
->getMock();
-
+
$principalUri = 'principals/user/pierre';
$sender = 'clint@stardew-tent-living.com';
$recipient = 'pierre@general-store.com';
@@ -1588,7 +1588,7 @@ class ManagerTest extends TestCase {
$this->userManager,
$this->serverFactory,
])
- ->setMethods([
+ ->onlyMethods([
'getCalendarsForPrincipal'
])
->getMock();
diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
index 02b1034240f..5112795ec7c 100644
--- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
@@ -134,7 +134,7 @@ class MailPluginTest extends TestCase {
$this->assertSame($reachedEnd, $moreResults);
}
- public function dataGetEmail() {
+ public static function dataGetEmail(): array {
return [
// data set 0
['test', [], true, ['emails' => [], 'exact' => ['emails' => []]], false, false, false],
@@ -636,7 +636,7 @@ class MailPluginTest extends TestCase {
$this->assertSame($reachedEnd, $moreResults);
}
- public function dataGetEmailGroupsOnly() {
+ public static function dataGetEmailGroupsOnly(): array {
return [
// The user `User` can share with the current user
[
diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
index 14894aa2df6..aa7e4c8afd5 100644
--- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
@@ -141,7 +141,7 @@ class RemotePluginTest extends TestCase {
$this->plugin->splitUserRemote($id);
}
- public function dataGetRemote() {
+ public static function dataGetRemote() {
return [
['test', [], true, ['remotes' => [], 'exact' => ['remotes' => []]], false, true],
['test', [], false, ['remotes' => [], 'exact' => ['remotes' => []]], false, true],
@@ -374,7 +374,7 @@ class RemotePluginTest extends TestCase {
];
}
- public function dataTestSplitUserRemote() {
+ public static function dataTestSplitUserRemote(): array {
$userPrefix = ['user@name', 'username'];
$protocols = ['', 'http://', 'https://'];
$remotes = [
@@ -410,7 +410,7 @@ class RemotePluginTest extends TestCase {
return $testCases;
}
- public function dataTestSplitUserRemoteError() {
+ public static function dataTestSplitUserRemoteError(): array {
return [
// Invalid path
['user@'],
diff --git a/tests/lib/Collaboration/Collaborators/SearchResultTest.php b/tests/lib/Collaboration/Collaborators/SearchResultTest.php
index 6641a2caed1..7a0afe87e4b 100644
--- a/tests/lib/Collaboration/Collaborators/SearchResultTest.php
+++ b/tests/lib/Collaboration/Collaborators/SearchResultTest.php
@@ -27,7 +27,7 @@ class SearchResultTest extends TestCase {
$this->search = new Search($this->container);
}
- public function dataAddResultSet() {
+ public static function dataAddResultSet(): array {
return [
[[], ['exact' => []]],
[['users' => ['exact' => null, 'loose' => []]], ['exact' => ['users' => []], 'users' => []]],
@@ -51,7 +51,7 @@ class SearchResultTest extends TestCase {
$this->assertEquals($expected, $result->asArray());
}
- public function dataHasResult() {
+ public static function dataHasResult(): array {
$result = ['value' => ['shareWith' => 'l1']];
return [
[[],'users', 'n1', false],
diff --git a/tests/lib/Collaboration/Collaborators/SearchTest.php b/tests/lib/Collaboration/Collaborators/SearchTest.php
index 3e43d6331b2..146befe966e 100644
--- a/tests/lib/Collaboration/Collaborators/SearchTest.php
+++ b/tests/lib/Collaboration/Collaborators/SearchTest.php
@@ -115,7 +115,7 @@ class SearchTest extends TestCase {
$this->assertSame($expectedMoreResults, $moreResults);
}
- public function dataSearchSharees() {
+ public static function dataSearchSharees(): array {
return [
// #0
[
diff --git a/tests/lib/Collaboration/Collaborators/UserPluginTest.php b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
index 453f16c6686..3b342b7938b 100644
--- a/tests/lib/Collaboration/Collaborators/UserPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
@@ -124,7 +124,7 @@ class UserPluginTest extends TestCase {
return $group;
}
- public function dataGetUsers() {
+ public function dataGetUsers(): array {
return [
['test', false, true, [], [], [], [], true, false],
['test', false, false, [], [], [], [], true, false],
@@ -508,7 +508,7 @@ class UserPluginTest extends TestCase {
$this->assertSame($reachedEnd, $moreResults);
}
- public function takeOutCurrentUserProvider() {
+ public static function takeOutCurrentUserProvider(): array {
$inputUsers = [
'alice' => 'Alice',
'bob' => 'Bob',
@@ -555,7 +555,7 @@ class UserPluginTest extends TestCase {
$this->assertSame($expectedUIDs, array_keys($users));
}
- public function dataSearchEnumeration() {
+ public static function dataSearchEnumeration(): array {
return [
[
'test',
diff --git a/tests/lib/Command/AsyncBusTest.php b/tests/lib/Command/AsyncBusTestCase.php
index e8d7a857129..c4f173f8b32 100644
--- a/tests/lib/Command/AsyncBusTest.php
+++ b/tests/lib/Command/AsyncBusTestCase.php
@@ -15,7 +15,7 @@ use Test\TestCase;
class SimpleCommand implements ICommand {
public function handle() {
- AsyncBusTest::$lastCommand = 'SimpleCommand';
+ AsyncBusTestCase::$lastCommand = 'SimpleCommand';
}
}
@@ -27,7 +27,7 @@ class StateFullCommand implements ICommand {
}
public function handle() {
- AsyncBusTest::$lastCommand = $this->state;
+ AsyncBusTestCase::$lastCommand = $this->state;
}
}
@@ -35,18 +35,18 @@ class FilesystemCommand implements ICommand {
use FileAccess;
public function handle() {
- AsyncBusTest::$lastCommand = 'FileAccess';
+ AsyncBusTestCase::$lastCommand = 'FileAccess';
}
}
function basicFunction() {
- AsyncBusTest::$lastCommand = 'function';
+ AsyncBusTestCase::$lastCommand = 'function';
}
// clean class to prevent phpunit putting closure in $this
class ThisClosureTest {
private function privateMethod() {
- AsyncBusTest::$lastCommand = 'closure-this';
+ AsyncBusTestCase::$lastCommand = 'closure-this';
}
public function test(IBus $bus) {
@@ -56,7 +56,7 @@ class ThisClosureTest {
}
}
-abstract class AsyncBusTest extends TestCase {
+abstract class AsyncBusTestCase extends TestCase {
/**
* Basic way to check output from a command
*
@@ -107,7 +107,7 @@ abstract class AsyncBusTest extends TestCase {
}
public function testStaticCallable(): void {
- $this->getBus()->push(['\Test\Command\AsyncBusTest', 'DummyCommand']);
+ $this->getBus()->push(['\Test\Command\AsyncBusTestCase', 'DummyCommand']);
$this->runJobs();
$this->assertEquals('static', self::$lastCommand);
}
@@ -127,7 +127,7 @@ abstract class AsyncBusTest extends TestCase {
public function testClosure(): void {
$this->getBus()->push(function () {
- AsyncBusTest::$lastCommand = 'closure';
+ AsyncBusTestCase::$lastCommand = 'closure';
});
$this->runJobs();
$this->assertEquals('closure', self::$lastCommand);
@@ -135,7 +135,7 @@ abstract class AsyncBusTest extends TestCase {
public function testClosureSelf(): void {
$this->getBus()->push(function () {
- AsyncBusTest::$lastCommand = 'closure-self';
+ AsyncBusTestCase::$lastCommand = 'closure-self';
});
$this->runJobs();
$this->assertEquals('closure-self', self::$lastCommand);
@@ -153,7 +153,7 @@ abstract class AsyncBusTest extends TestCase {
public function testClosureBind(): void {
$state = 'bar';
$this->getBus()->push(function () use ($state) {
- AsyncBusTest::$lastCommand = 'closure-' . $state;
+ AsyncBusTestCase::$lastCommand = 'closure-' . $state;
});
$this->runJobs();
$this->assertEquals('closure-bar', self::$lastCommand);
diff --git a/tests/lib/Command/BackgroundModeTest.php b/tests/lib/Command/BackgroundModeTest.php
index 941449c98bb..2f874deb78a 100644
--- a/tests/lib/Command/BackgroundModeTest.php
+++ b/tests/lib/Command/BackgroundModeTest.php
@@ -16,6 +16,9 @@ use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Tester\CommandTester;
use Test\TestCase;
+/**
+ * @group DB
+ */
class BackgroundModeTest extends TestCase {
private IAppConfig $appConfig;
@@ -49,7 +52,7 @@ class BackgroundModeTest extends TestCase {
$this->assertStringContainsString($mode, $output);
}
- public function dataModeCommand(): array {
+ public static function dataModeCommand(): array {
return [
'ajax' => ['ajax'],
'cron' => ['cron'],
diff --git a/tests/lib/Command/CronBusTest.php b/tests/lib/Command/CronBusTest.php
index 96190f717c6..2e5617efb31 100644
--- a/tests/lib/Command/CronBusTest.php
+++ b/tests/lib/Command/CronBusTest.php
@@ -9,7 +9,10 @@ namespace Test\Command;
use OC\Command\CronBus;
use Test\BackgroundJob\DummyJobList;
-class CronBusTest extends AsyncBusTest {
+/**
+ * @group DB
+ */
+class CronBusTest extends AsyncBusTestCase {
/**
* @var \OCP\BackgroundJob\IJobList
*/
diff --git a/tests/lib/Command/Integrity/SignAppTest.php b/tests/lib/Command/Integrity/SignAppTest.php
index d4921c79431..38b5c68e026 100644
--- a/tests/lib/Command/Integrity/SignAppTest.php
+++ b/tests/lib/Command/Integrity/SignAppTest.php
@@ -44,22 +44,28 @@ class SignAppTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['path'],
- ['privateKey'],
- ['certificate'],
- )->willReturnOnConsecutiveCalls(
- null,
- 'PrivateKey',
- 'Certificate',
- );
-
+ ->willReturnMap([
+ ['path', null],
+ ['privateKey', 'PrivateKey'],
+ ['certificate', 'Certificate'],
+ ]);
+
+ $calls = [
+ 'This command requires the --path, --privateKey and --certificate.',
+ '*',
+ '*',
+ ];
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['This command requires the --path, --privateKey and --certificate.']
- );
+ ->willReturnCallback(function (string $message) use (&$calls) {
+ $expected = array_shift($calls);
+ if ($expected === '*') {
+ $this->assertNotEmpty($message);
+ } else {
+ $this->assertEquals($expected, $message);
+ }
+ });
$this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
@@ -71,22 +77,28 @@ class SignAppTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['path'],
- ['privateKey'],
- ['certificate'],
- )->willReturnOnConsecutiveCalls(
- 'AppId',
- null,
- 'Certificate',
- );
-
+ ->willReturnMap([
+ ['path', 'AppId'],
+ ['privateKey', null],
+ ['certificate', 'Certificate'],
+ ]);
+
+ $calls = [
+ 'This command requires the --path, --privateKey and --certificate.',
+ '*',
+ '*',
+ ];
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['This command requires the --path, --privateKey and --certificate.']
- );
+ ->willReturnCallback(function (string $message) use (&$calls) {
+ $expected = array_shift($calls);
+ if ($expected === '*') {
+ $this->assertNotEmpty($message);
+ } else {
+ $this->assertEquals($expected, $message);
+ }
+ });
$this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
@@ -98,22 +110,28 @@ class SignAppTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['path'],
- ['privateKey'],
- ['certificate'],
- )->willReturnOnConsecutiveCalls(
- 'AppId',
- 'privateKey',
- null,
- );
-
+ ->willReturnMap([
+ ['path', 'AppId'],
+ ['privateKey', 'PrivateKey'],
+ ['certificate', null],
+ ]);
+
+ $calls = [
+ 'This command requires the --path, --privateKey and --certificate.',
+ '*',
+ '*',
+ ];
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['This command requires the --path, --privateKey and --certificate.']
- );
+ ->willReturnCallback(function (string $message) use (&$calls) {
+ $expected = array_shift($calls);
+ if ($expected === '*') {
+ $this->assertNotEmpty($message);
+ } else {
+ $this->assertEquals($expected, $message);
+ }
+ });
$this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
@@ -125,29 +143,26 @@ class SignAppTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['path'],
- ['privateKey'],
- ['certificate'],
- )->willReturnOnConsecutiveCalls(
- 'AppId',
- 'privateKey',
- 'certificate',
- );
+ ->willReturnMap([
+ ['path', 'AppId'],
+ ['privateKey', 'privateKey'],
+ ['certificate', 'certificate'],
+ ]);
$this->fileAccessHelper
->expects($this->any())
->method('file_get_contents')
- ->withConsecutive(['privateKey'])
- ->willReturnOnConsecutiveCalls(false);
+ ->willReturnMap([
+ ['privateKey', false],
+ ]);
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['Private key "privateKey" does not exists.']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('Private key "privateKey" does not exists.', $message);
+ });
$this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
@@ -159,34 +174,26 @@ class SignAppTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['path'],
- ['privateKey'],
- ['certificate'],
- )->willReturnOnConsecutiveCalls(
- 'AppId',
- 'privateKey',
- 'certificate',
- );
+ ->willReturnMap([
+ ['path', 'AppId'],
+ ['privateKey', 'privateKey'],
+ ['certificate', 'certificate'],
+ ]);
$this->fileAccessHelper
->expects($this->any())
->method('file_get_contents')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- )
- ->willReturnOnConsecutiveCalls(
- \OC::$SERVERROOT . '/tests/data/integritycheck/core.key',
- false
- );
+ ->willReturnMap([
+ ['privateKey', file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')],
+ ['certificate', false],
+ ]);
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['Certificate "certificate" does not exists.']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('Certificate "certificate" does not exists.', $message);
+ });
$this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
@@ -198,27 +205,19 @@ class SignAppTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['path'],
- ['privateKey'],
- ['certificate'],
- )->willReturnOnConsecutiveCalls(
- 'AppId',
- 'privateKey',
- 'certificate',
- );
+ ->willReturnMap([
+ ['path', 'AppId'],
+ ['privateKey', 'privateKey'],
+ ['certificate', 'certificate'],
+ ]);
$this->fileAccessHelper
->expects($this->any())
->method('file_get_contents')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- )
- ->willReturnOnConsecutiveCalls(
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'),
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'),
- );
+ ->willReturnMap([
+ ['privateKey', file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')],
+ ['certificate', \OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'],
+ ]);
$this->checker
->expects($this->once())
@@ -228,9 +227,9 @@ class SignAppTest extends TestCase {
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['Error: My error message']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('Error: My error message', $message);
+ });
$this->assertSame(1, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
@@ -242,27 +241,19 @@ class SignAppTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['path'],
- ['privateKey'],
- ['certificate'],
- )->willReturnOnConsecutiveCalls(
- 'AppId',
- 'privateKey',
- 'certificate',
- );
+ ->willReturnMap([
+ ['path', 'AppId'],
+ ['privateKey', 'privateKey'],
+ ['certificate', 'certificate'],
+ ]);
$this->fileAccessHelper
->expects($this->any())
->method('file_get_contents')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- )
- ->willReturnOnConsecutiveCalls(
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'),
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'),
- );
+ ->willReturnMap([
+ ['privateKey', file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')],
+ ['certificate', \OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'],
+ ]);
$this->checker
->expects($this->once())
@@ -271,9 +262,9 @@ class SignAppTest extends TestCase {
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['Successfully signed "AppId"']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('Successfully signed "AppId"', $message);
+ });
$this->assertSame(0, self::invokePrivate($this->signApp, 'execute', [$inputInterface, $outputInterface]));
}
diff --git a/tests/lib/Command/Integrity/SignCoreTest.php b/tests/lib/Command/Integrity/SignCoreTest.php
index bbb68e00a84..66227322dda 100644
--- a/tests/lib/Command/Integrity/SignCoreTest.php
+++ b/tests/lib/Command/Integrity/SignCoreTest.php
@@ -39,22 +39,18 @@ class SignCoreTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- ['path'],
- )->willReturnOnConsecutiveCalls(
- null,
- 'certificate',
- 'certificate',
- );
+ ->willReturnMap([
+ ['privateKey', null],
+ ['certificate', 'certificate'],
+ ['path', 'certificate'],
+ ]);
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['--privateKey, --certificate and --path are required.']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('--privateKey, --certificate and --path are required.', $message);
+ });
$this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -66,22 +62,18 @@ class SignCoreTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- ['path'],
- )->willReturnOnConsecutiveCalls(
- 'privateKey',
- null,
- 'certificate',
- );
+ ->willReturnMap([
+ ['privateKey', 'privateKey'],
+ ['certificate', null],
+ ['path', 'certificate'],
+ ]);
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['--privateKey, --certificate and --path are required.']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('--privateKey, --certificate and --path are required.', $message);
+ });
$this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -93,32 +85,24 @@ class SignCoreTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- ['path'],
- )->willReturnOnConsecutiveCalls(
- 'privateKey',
- 'certificate',
- 'certificate',
- );
+ ->willReturnMap([
+ ['privateKey', 'privateKey'],
+ ['certificate', 'certificate'],
+ ['path', 'certificate'],
+ ]);
$this->fileAccessHelper
- ->expects($this->any())
->method('file_get_contents')
- ->withConsecutive(
- ['privateKey'],
- )
- ->willReturnOnConsecutiveCalls(
- false,
- );
+ ->willReturnMap([
+ ['privateKey', false],
+ ]);
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['Private key "privateKey" does not exists.']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('Private key "privateKey" does not exists.', $message);
+ });
$this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -130,34 +114,26 @@ class SignCoreTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- ['path'],
- )->willReturnOnConsecutiveCalls(
- 'privateKey',
- 'certificate',
- 'certificate',
- );
+ ->willReturnMap([
+ ['privateKey', 'privateKey'],
+ ['certificate', 'certificate'],
+ ['path', 'certificate'],
+ ]);
$this->fileAccessHelper
->expects($this->any())
->method('file_get_contents')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- )
- ->willReturnOnConsecutiveCalls(
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'),
- false,
- );
+ ->willReturnMap([
+ ['privateKey', file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')],
+ ['certificate', false],
+ ]);
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['Certificate "certificate" does not exists.']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('Certificate "certificate" does not exists.', $message);
+ });
$this->assertSame(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -169,27 +145,19 @@ class SignCoreTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- ['path'],
- )->willReturnOnConsecutiveCalls(
- 'privateKey',
- 'certificate',
- 'certificate',
- );
+ ->willReturnMap([
+ ['privateKey', 'privateKey'],
+ ['certificate', 'certificate'],
+ ['path', 'certificate'],
+ ]);
$this->fileAccessHelper
->expects($this->any())
->method('file_get_contents')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- )
- ->willReturnOnConsecutiveCalls(
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'),
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'),
- );
+ ->willReturnMap([
+ ['privateKey', file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')],
+ ['certificate', file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt')],
+ ]);
$this->checker
->expects($this->once())
@@ -199,9 +167,9 @@ class SignCoreTest extends TestCase {
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['Error: My exception message']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('Error: My exception message', $message);
+ });
$this->assertEquals(1, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
@@ -213,27 +181,19 @@ class SignCoreTest extends TestCase {
$inputInterface
->expects($this->exactly(3))
->method('getOption')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- ['path'],
- )->willReturnOnConsecutiveCalls(
- 'privateKey',
- 'certificate',
- 'certificate',
- );
+ ->willReturnMap([
+ ['privateKey', 'privateKey'],
+ ['certificate', 'certificate'],
+ ['path', 'certificate'],
+ ]);
$this->fileAccessHelper
->expects($this->any())
->method('file_get_contents')
- ->withConsecutive(
- ['privateKey'],
- ['certificate'],
- )
- ->willReturnOnConsecutiveCalls(
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'),
- file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'),
- );
+ ->willReturnMap([
+ ['privateKey', file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')],
+ ['certificate', file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt')],
+ ]);
$this->checker
->expects($this->once())
@@ -242,9 +202,9 @@ class SignCoreTest extends TestCase {
$outputInterface
->expects($this->any())
->method('writeln')
- ->withConsecutive(
- ['Successfully signed "core"']
- );
+ ->willReturnCallback(function (string $message) {
+ $this->assertEquals('Successfully signed "core"', $message);
+ });
$this->assertEquals(0, self::invokePrivate($this->signCore, 'execute', [$inputInterface, $outputInterface]));
}
diff --git a/tests/lib/Comments/CommentTest.php b/tests/lib/Comments/CommentTest.php
index 3cfc897b28e..988ffbe0e0b 100644
--- a/tests/lib/Comments/CommentTest.php
+++ b/tests/lib/Comments/CommentTest.php
@@ -81,7 +81,7 @@ class CommentTest extends TestCase {
$this->assertSame('', $comment->getId());
}
- public function simpleSetterProvider() {
+ public static function simpleSetterProvider(): array {
return [
['Id', true],
['TopmostParentId', true],
@@ -105,7 +105,7 @@ class CommentTest extends TestCase {
$comment->$setter($input);
}
- public function roleSetterProvider() {
+ public static function roleSetterProvider(): array {
return [
['Actor', true, true],
['Actor', 'users', true],
@@ -138,7 +138,7 @@ class CommentTest extends TestCase {
$comment->setMessage($msg);
}
- public function mentionsProvider(): array {
+ public static function mentionsProvider(): array {
return [
[
'@alice @bob look look, a cook!',
diff --git a/tests/lib/Config/UserConfigTest.php b/tests/lib/Config/UserConfigTest.php
index f9a9b5c5272..7bd1e06e297 100644
--- a/tests/lib/Config/UserConfigTest.php
+++ b/tests/lib/Config/UserConfigTest.php
@@ -333,10 +333,7 @@ class UserConfigTest extends TestCase {
);
}
- /**
- * @return array[]
- */
- public function providerHasKey(): array {
+ public static function providerHasKey(): array {
return [
['user1', 'app1', 'key1', false, true],
['user0', 'app1', 'key1', false, false],
@@ -358,10 +355,7 @@ class UserConfigTest extends TestCase {
$this->assertEquals($result, $userConfig->hasKey($userId, $appId, $key, $lazy));
}
- /**
- * @return array[]
- */
- public function providerIsSensitive(): array {
+ public static function providerIsSensitive(): array {
return [
['user1', 'app1', 'key1', false, false, false],
['user0', 'app1', 'key1', false, false, true],
@@ -399,10 +393,7 @@ class UserConfigTest extends TestCase {
$this->assertEquals($result, $userConfig->isSensitive($userId, $appId, $key, $lazy));
}
- /**
- * @return array[]
- */
- public function providerIsLazy(): array {
+ public static function providerIsLazy(): array {
return [
['user1', 'app1', 'key1', false, false],
['user0', 'app1', 'key1', false, true],
@@ -432,7 +423,7 @@ class UserConfigTest extends TestCase {
$this->assertEquals($result, $userConfig->isLazy($userId, $appId, $key));
}
- public function providerGetValues(): array {
+ public static function providerGetValues(): array {
return [
[
'user1', 'app1', '', true,
@@ -565,7 +556,7 @@ class UserConfigTest extends TestCase {
);
}
- public function providerGetAllValues(): array {
+ public static function providerGetAllValues(): array {
return [
[
'user2', false,
@@ -662,7 +653,7 @@ class UserConfigTest extends TestCase {
$this->assertEqualsCanonicalizing($result, $userConfig->getAllValues($userId, $filtered));
}
- public function providerSearchValuesByApps(): array {
+ public static function providerSearchValuesByApps(): array {
return [
[
'user1', 'key1', false, null,
@@ -708,7 +699,7 @@ class UserConfigTest extends TestCase {
$this->assertEquals($result, $userConfig->getValuesByApps($userId, $key, $lazy, $typedAs));
}
- public function providerSearchValuesByUsers(): array {
+ public static function providerSearchValuesByUsers(): array {
return [
[
'app2', 'key2', null, null,
@@ -760,7 +751,7 @@ class UserConfigTest extends TestCase {
);
}
- public function providerSearchValuesByValueString(): array {
+ public static function providerSearchValuesByValueString(): array {
return [
['app2', 'key2', 'value2a', false, ['user1']],
['app2', 'key2', 'value2A', false, ['user4']],
@@ -782,7 +773,7 @@ class UserConfigTest extends TestCase {
$this->assertEqualsCanonicalizing($result, iterator_to_array($userConfig->searchUsersByValueString($app, $key, $value, $ci)));
}
- public function providerSearchValuesByValueInt(): array {
+ public static function providerSearchValuesByValueInt(): array {
return [
['app3', 'key8', 12, []], // sensitive value, cannot search
['app2', 'key8', 12, ['user2', 'user5']], // sensitive value, cannot search
@@ -803,7 +794,7 @@ class UserConfigTest extends TestCase {
$this->assertEqualsCanonicalizing($result, iterator_to_array($userConfig->searchUsersByValueInt($app, $key, $value)));
}
- public function providerSearchValuesByValues(): array {
+ public static function providerSearchValuesByValues(): array {
return [
['app2', 'key2', ['value2a', 'value2b'], ['user1', 'user2']],
['app2', 'key2', ['value2a', 'value2c'], ['user1', 'user3']],
@@ -823,7 +814,7 @@ class UserConfigTest extends TestCase {
$this->assertEqualsCanonicalizing($result, iterator_to_array($userConfig->searchUsersByValues($app, $key, $values)));
}
- public function providerSearchValuesByValueBool(): array {
+ public static function providerSearchValuesByValueBool(): array {
return [
['app3', 'key10', true, ['user1', 'user4']],
['app3', 'key10', false, ['user2']],
@@ -843,7 +834,7 @@ class UserConfigTest extends TestCase {
$this->assertEqualsCanonicalizing($result, iterator_to_array($userConfig->searchUsersByValueBool($app, $key, $value)));
}
- public function providerGetValueMixed(): array {
+ public static function providerGetValueMixed(): array {
return [
[
['user1'], 'user1', 'app1', 'key0', 'default_because_unknown_key', true,
@@ -943,7 +934,7 @@ class UserConfigTest extends TestCase {
$this->assertEquals($result, $userConfig->getValueString($userId, $app, $key, $default, $lazy));
}
- public function providerGetValueInt(): array {
+ public static function providerGetValueInt(): array {
return [
[['user1'], 'user1', 'app1', 'key0', 54321, true, 54321],
[null, 'user1', 'app1', 'key0', 54321, true, 54321],
@@ -985,7 +976,7 @@ class UserConfigTest extends TestCase {
$this->assertEquals($result, $userConfig->getValueInt($userId, $app, $key, $default, $lazy));
}
- public function providerGetValueFloat(): array {
+ public static function providerGetValueFloat(): array {
return [
[['user1'], 'user1', 'app1', 'key0', 54.321, true, 54.321],
[null, 'user1', 'app1', 'key0', 54.321, true, 54.321],
@@ -1026,7 +1017,7 @@ class UserConfigTest extends TestCase {
$this->assertEquals($result, $userConfig->getValueFloat($userId, $app, $key, $default, $lazy));
}
- public function providerGetValueBool(): array {
+ public static function providerGetValueBool(): array {
return [
[['user1'], 'user1', 'app1', 'key0', false, true, false],
[null, 'user1', 'app1', 'key0', false, true, false],
@@ -1087,7 +1078,7 @@ class UserConfigTest extends TestCase {
$this->assertEquals($result, $userConfig->getValueBool($userId, $app, $key, $default, $lazy));
}
- public function providerGetValueArray(): array {
+ public static function providerGetValueArray(): array {
return [
[
['user1'], 'user1', 'app1', 'key0', ['default_because_unknown_key'], true,
@@ -1126,7 +1117,7 @@ class UserConfigTest extends TestCase {
);
}
- public function providerGetValueType(): array {
+ public static function providerGetValueType(): array {
return [
[null, 'user1', 'app1', 'key1', false, ValueType::MIXED],
[null, 'user1', 'app1', 'key1', true, null, UnknownKeyException::class],
@@ -1187,7 +1178,7 @@ class UserConfigTest extends TestCase {
}
}
- public function providerSetValueMixed(): array {
+ public static function providerSetValueMixed(): array {
return [
[null, 'user1', 'app1', 'key1', 'value', false, false, true],
[null, 'user1', 'app1', 'key1', '12345', true, false, true],
@@ -1250,7 +1241,7 @@ class UserConfigTest extends TestCase {
}
- public function providerSetValueString(): array {
+ public static function providerSetValueString(): array {
return [
[null, 'user1', 'app1', 'key1', 'value', false, false, true],
[null, 'user1', 'app1', 'key1', '12345', true, false, true],
@@ -1325,7 +1316,7 @@ class UserConfigTest extends TestCase {
}
}
- public function providerSetValueInt(): array {
+ public static function providerSetValueInt(): array {
return [
[null, 'user1', 'app1', 'key1', 12345, false, false, true],
[null, 'user1', 'app1', 'key1', 12345, true, false, true],
@@ -1389,7 +1380,7 @@ class UserConfigTest extends TestCase {
}
}
- public function providerSetValueFloat(): array {
+ public static function providerSetValueFloat(): array {
return [
[null, 'user1', 'app1', 'key1', 12.345, false, false, true],
[null, 'user1', 'app1', 'key1', 12.345, true, false, true],
@@ -1453,7 +1444,7 @@ class UserConfigTest extends TestCase {
}
- public function providerSetValueArray(): array {
+ public static function providerSetValueArray(): array {
return [
[null, 'user1', 'app1', 'key1', [], false, false, true],
[null, 'user1', 'app1', 'key1', [], true, false, true],
@@ -1520,7 +1511,7 @@ class UserConfigTest extends TestCase {
}
}
- public function providerUpdateSensitive(): array {
+ public static function providerUpdateSensitive(): array {
return [
[null, 'user1', 'app1', 'key1', false, false],
[['user1'], 'user1', 'app1', 'key1', false, false],
@@ -1566,7 +1557,7 @@ class UserConfigTest extends TestCase {
}
}
- public function providerUpdateGlobalSensitive(): array {
+ public static function providerUpdateGlobalSensitive(): array {
return [[true], [false]];
}
@@ -1610,7 +1601,7 @@ class UserConfigTest extends TestCase {
}
}
- public function providerUpdateLazy(): array {
+ public static function providerUpdateLazy(): array {
return [
[null, 'user1', 'app1', 'key1', false, false],
[['user1'], 'user1', 'app1', 'key1', false, false],
@@ -1649,7 +1640,7 @@ class UserConfigTest extends TestCase {
}
}
- public function providerUpdateGlobalLazy(): array {
+ public static function providerUpdateGlobalLazy(): array {
return [[true], [false]];
}
@@ -1679,7 +1670,7 @@ class UserConfigTest extends TestCase {
}
}
- public function providerGetDetails(): array {
+ public static function providerGetDetails(): array {
return [
[
'user3', 'app2', 'key2',
@@ -1732,7 +1723,7 @@ class UserConfigTest extends TestCase {
}
- public function providerDeletePreference(): array {
+ public static function providerDeletePreference(): array {
return [
[null, 'user1', 'app1', 'key22'],
[['user1'], 'user1', 'app1', 'fast_string_sensitive'],
@@ -1763,7 +1754,7 @@ class UserConfigTest extends TestCase {
$this->assertEquals(false, $userConfig->hasKey($userId, $app, $key, $lazy));
}
- public function providerDeleteKey(): array {
+ public static function providerDeleteKey(): array {
return [
[null, 'app2', 'key3'],
[['user1'], 'app2', 'key3'],
@@ -1832,7 +1823,7 @@ class UserConfigTest extends TestCase {
'fastCache' => [],
'lazyLoaded' => [],
'lazyCache' => [],
- 'valueTypes' => [],
+ 'valueDetails' => [],
],
$userConfig->statusCache()
);
diff --git a/tests/lib/ContactsManagerTest.php b/tests/lib/ContactsManagerTest.php
index 7586b063883..6fea6b39e92 100644
--- a/tests/lib/ContactsManagerTest.php
+++ b/tests/lib/ContactsManagerTest.php
@@ -17,7 +17,7 @@ class ContactsManagerTest extends \Test\TestCase {
$this->cm = new \OC\ContactsManager();
}
- public function searchProvider() {
+ public static function searchProvider(): array {
$search1 = [
0 => [
'N' => [0 => '', 1 => 'Jan', 2 => 'Jansen', 3 => '', 4 => '',],
diff --git a/tests/lib/DB/ConnectionFactoryTest.php b/tests/lib/DB/ConnectionFactoryTest.php
index 23bde34a8fb..31dd8037964 100644
--- a/tests/lib/DB/ConnectionFactoryTest.php
+++ b/tests/lib/DB/ConnectionFactoryTest.php
@@ -12,7 +12,7 @@ use OCP\ICacheFactory;
use Test\TestCase;
class ConnectionFactoryTest extends TestCase {
- public function splitHostFromPortAndSocketData() {
+ public static function splitHostFromPortAndSocketData(): array {
return [
['127.0.0.1', ['host' => '127.0.0.1']],
['db.example.org', ['host' => 'db.example.org']],
diff --git a/tests/lib/DB/Exception/DbalExceptionTest.php b/tests/lib/DB/Exception/DbalExceptionTest.php
index 470beff9080..c37e65aea0e 100644
--- a/tests/lib/DB/Exception/DbalExceptionTest.php
+++ b/tests/lib/DB/Exception/DbalExceptionTest.php
@@ -44,7 +44,7 @@ class DbalExceptionTest extends \Test\TestCase {
$this->assertSame($reason, $result->getReason());
}
- public function dataDriverException(): array {
+ public static function dataDriverException(): array {
return [
[LockWaitTimeoutException::class, DbalException::REASON_LOCK_WAIT_TIMEOUT],
[ForeignKeyConstraintViolationException::class, DbalException::REASON_FOREIGN_KEY_VIOLATION],
diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php
index 57ffb91e37e..f5379b30be9 100644
--- a/tests/lib/DB/MigrationsTest.php
+++ b/tests/lib/DB/MigrationsTest.php
@@ -175,7 +175,7 @@ class MigrationsTest extends \Test\TestCase {
$this->migrationService->executeStep('20170130180000');
}
- public function dataGetMigration() {
+ public static function dataGetMigration(): array {
return [
['current', '20170130180001'],
['prev', '20170130180000'],
diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php
index c6afe5a053a..46724afee86 100644
--- a/tests/lib/DB/MigratorTest.php
+++ b/tests/lib/DB/MigratorTest.php
@@ -261,7 +261,7 @@ class MigratorTest extends \Test\TestCase {
$this->assertTrue($startSchema->getTable($this->tableNameTmp)->hasForeignKey($fkName));
}
- public function dataNotNullEmptyValuesFailOracle(): array {
+ public static function dataNotNullEmptyValuesFailOracle(): array {
return [
[ParameterType::BOOLEAN, true, Types::BOOLEAN, false],
[ParameterType::BOOLEAN, false, Types::BOOLEAN, true],
diff --git a/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php b/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php
index 392fe9ff937..dc0bca9be95 100644
--- a/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php
+++ b/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php
@@ -11,6 +11,7 @@ use OC\DB\QueryBuilder\Literal;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\Types;
use OCP\IConfig;
+use OCP\IDBConnection;
use OCP\Server;
use Test\TestCase;
@@ -29,8 +30,8 @@ class ExpressionBuilderDBTest extends TestCase {
$this->prepareTestingTable();
}
- public function likeProvider() {
- $connection = \OC::$server->getDatabaseConnection();
+ public static function likeProvider(): array {
+ $connection = \OCP\Server::get(IDBConnection::class);
return [
['foo', 'bar', false],
@@ -65,8 +66,8 @@ class ExpressionBuilderDBTest extends TestCase {
$this->assertEquals($match, $column);
}
- public function ilikeProvider() {
- $connection = \OC::$server->getDatabaseConnection();
+ public static function ilikeProvider(): array {
+ $connection = \OCP\Server::get(IDBConnection::class);
return [
['foo', 'bar', false],
diff --git a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
index c14c55e6d02..ab3d1a5081f 100644
--- a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
@@ -50,8 +50,8 @@ class ExpressionBuilderTest extends TestCase {
$this->doctrineExpressionBuilder = new DoctrineExpressionBuilder($this->internalConnection);
}
- public function dataComparison() {
- $valueSets = $this->dataComparisons();
+ public static function dataComparison(): array {
+ $valueSets = self::dataComparisons();
$comparisonOperators = ['=', '<>', '<', '>', '<=', '>='];
$testSets = [];
@@ -82,7 +82,7 @@ class ExpressionBuilderTest extends TestCase {
);
}
- public function dataComparisons() {
+ public static function dataComparisons(): array {
return [
['value', false, 'value', false],
['value', false, 'value', true],
@@ -213,7 +213,7 @@ class ExpressionBuilderTest extends TestCase {
);
}
- public function dataLike() {
+ public static function dataLike(): array {
return [
['value', false],
['value', true],
@@ -250,7 +250,7 @@ class ExpressionBuilderTest extends TestCase {
);
}
- public function dataIn() {
+ public static function dataIn(): array {
return [
['value', false],
['value', true],
@@ -317,7 +317,7 @@ class ExpressionBuilderTest extends TestCase {
return [$doctrineInput, $ocInput];
}
- public function dataLiteral() {
+ public static function dataLiteral(): array {
return [
['value', null],
['1', null],
@@ -345,7 +345,7 @@ class ExpressionBuilderTest extends TestCase {
);
}
- public function dataClobComparisons() {
+ public static function dataClobComparisons(): array {
return [
['eq', '5', IQueryBuilder::PARAM_STR, false, 3],
['eq', '5', IQueryBuilder::PARAM_STR, true, 1],
diff --git a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
index f3007ace85c..682aedc9ff7 100644
--- a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
@@ -49,7 +49,7 @@ class FunctionBuilderTest extends TestCase {
$this->assertEquals($return, $column);
}
- public function providerTestConcatString(): array {
+ public static function providerTestConcatString(): array {
return [
'1 column: string param unicode' =>
[function ($q) {
@@ -323,7 +323,7 @@ class FunctionBuilderTest extends TestCase {
$this->assertGreaterThan(1, $column);
}
- public function octetLengthProvider() {
+ public static function octetLengthProvider(): array {
return [
['', 0],
['foobar', 6],
@@ -348,7 +348,7 @@ class FunctionBuilderTest extends TestCase {
$this->assertEquals($bytes, $column);
}
- public function charLengthProvider() {
+ public static function charLengthProvider(): array {
return [
['', 0],
['foobar', 6],
diff --git a/tests/lib/DB/QueryBuilder/Partitioned/JoinConditionTest.php b/tests/lib/DB/QueryBuilder/Partitioned/JoinConditionTest.php
index a8ebf11c2c2..3d34ad389bc 100644
--- a/tests/lib/DB/QueryBuilder/Partitioned/JoinConditionTest.php
+++ b/tests/lib/DB/QueryBuilder/Partitioned/JoinConditionTest.php
@@ -22,7 +22,7 @@ class JoinConditionTest extends TestCase {
parent::setUp();
}
- public function platformProvider(): array {
+ public static function platformProvider(): array {
return [
[IDBConnection::PLATFORM_SQLITE],
[IDBConnection::PLATFORM_POSTGRES],
diff --git a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
index 508748f13b2..20086335198 100644
--- a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
@@ -88,7 +88,7 @@ class QueryBuilderTest extends \Test\TestCase {
->execute();
}
- public function dataFirstResult() {
+ public static function dataFirstResult(): array {
return [
[0, [99, 98, 97, 96, 95, 94, 93, 92, 91]],
[0, [99, 98, 97, 96, 95, 94, 93, 92, 91]],
@@ -124,7 +124,7 @@ class QueryBuilderTest extends \Test\TestCase {
$this->deleteTestingRows();
}
- public function dataMaxResults() {
+ public static function dataMaxResults(): array {
return [
[null, [99, 98, 97, 96, 95, 94, 93, 92, 91]],
// Limit 0 gives mixed results: either all entries or none is returned
@@ -161,7 +161,7 @@ class QueryBuilderTest extends \Test\TestCase {
$this->deleteTestingRows();
}
- public function dataSelect() {
+ public function dataSelect(): array {
$config = $this->createMock(SystemConfig::class);
$logger = $this->createMock(LoggerInterface::class);
$queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger);
@@ -229,7 +229,7 @@ class QueryBuilderTest extends \Test\TestCase {
$this->deleteTestingRows();
}
- public function dataSelectAlias() {
+ public function dataSelectAlias(): array {
$config = $this->createMock(SystemConfig::class);
$logger = $this->createMock(LoggerInterface::class);
$queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger);
@@ -338,7 +338,7 @@ class QueryBuilderTest extends \Test\TestCase {
$this->deleteTestingRows('testFirstResult2');
}
- public function dataAddSelect() {
+ public function dataAddSelect(): array {
$config = $this->createMock(SystemConfig::class);
$logger = $this->createMock(LoggerInterface::class);
$queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger);
@@ -408,7 +408,7 @@ class QueryBuilderTest extends \Test\TestCase {
$this->deleteTestingRows();
}
- public function dataDelete() {
+ public static function dataDelete(): array {
return [
['data', null, ['table' => '`*PREFIX*data`', 'alias' => null], '`*PREFIX*data`'],
['data', 't', ['table' => '`*PREFIX*data`', 'alias' => 't'], '`*PREFIX*data` t'],
@@ -437,7 +437,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataUpdate() {
+ public static function dataUpdate(): array {
return [
['data', null, ['table' => '`*PREFIX*data`', 'alias' => null], '`*PREFIX*data`'],
['data', 't', ['table' => '`*PREFIX*data`', 'alias' => 't'], '`*PREFIX*data` t'],
@@ -466,7 +466,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataInsert() {
+ public static function dataInsert(): array {
return [
['data', ['table' => '`*PREFIX*data`'], '`*PREFIX*data`'],
];
@@ -493,7 +493,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataFrom() {
+ public function dataFrom(): array {
$config = $this->createMock(SystemConfig::class);
$logger = $this->createMock(LoggerInterface::class);
$qb = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger);
@@ -541,7 +541,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataJoin() {
+ public static function dataJoin(): array {
return [
[
'd1', 'data2', null, null,
@@ -622,7 +622,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataLeftJoin() {
+ public static function dataLeftJoin(): array {
return [
[
'd1', 'data2', null, null,
@@ -672,7 +672,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataRightJoin() {
+ public static function dataRightJoin(): array {
return [
[
'd1', 'data2', null, null,
@@ -722,7 +722,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataSet() {
+ public static function dataSet(): array {
return [
['column1', new Literal('value'), null, null, ['`column1` = value'], '`column1` = value'],
['column1', new Parameter(':param'), null, null, ['`column1` = :param'], '`column1` = :param'],
@@ -759,7 +759,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataWhere() {
+ public static function dataWhere(): array {
return [
[['where1'], new CompositeExpression('AND', ['where1']), 'where1'],
[['where1', 'where2'], new CompositeExpression('AND', ['where1', 'where2']), '(where1) AND (where2)'],
@@ -816,7 +816,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataOrWhere() {
+ public static function dataOrWhere(): array {
return [
[['where1'], new CompositeExpression('OR', ['where1']), 'where1'],
[['where1', 'where2'], new CompositeExpression('OR', ['where1', 'where2']), '(where1) OR (where2)'],
@@ -848,7 +848,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataGroupBy() {
+ public static function dataGroupBy(): array {
return [
[['column1'], ['`column1`'], '`column1`'],
[['column1', 'column2'], ['`column1`', '`column2`'], '`column1`, `column2`'],
@@ -880,7 +880,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataAddGroupBy() {
+ public static function dataAddGroupBy(): array {
return [
[['column2'], ['`column1`', '`column2`'], '`column1`, `column2`'],
[['column2', 'column3'], ['`column1`', '`column2`', '`column3`'], '`column1`, `column2`, `column3`'],
@@ -913,7 +913,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataSetValue() {
+ public static function dataSetValue(): array {
return [
['column', 'value', ['`column`' => 'value'], '(`column`) VALUES(value)'],
];
@@ -967,7 +967,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataHaving() {
+ public static function dataHaving(): array {
return [
[['condition1'], new CompositeExpression('AND', ['condition1']), 'HAVING condition1'],
[['condition1', 'condition2'], new CompositeExpression('AND', ['condition1', 'condition2']), 'HAVING (condition1) AND (condition2)'],
@@ -1008,7 +1008,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataAndHaving() {
+ public static function dataAndHaving(): array {
return [
[['condition2'], new CompositeExpression('AND', ['condition1', 'condition2']), 'HAVING (condition1) AND (condition2)'],
[['condition2', 'condition3'], new CompositeExpression('AND', ['condition1', 'condition2', 'condition3']), 'HAVING (condition1) AND (condition2) AND (condition3)'],
@@ -1050,7 +1050,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataOrHaving() {
+ public static function dataOrHaving(): array {
return [
[['condition2'], new CompositeExpression('OR', ['condition1', 'condition2']), 'HAVING (condition1) OR (condition2)'],
[['condition2', 'condition3'], new CompositeExpression('OR', ['condition1', 'condition2', 'condition3']), 'HAVING (condition1) OR (condition2) OR (condition3)'],
@@ -1092,7 +1092,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataOrderBy() {
+ public static function dataOrderBy(): array {
return [
['column', null, ['`column` ASC'], 'ORDER BY `column` ASC'],
['column', 'ASC', ['`column` ASC'], 'ORDER BY `column` ASC'],
@@ -1122,7 +1122,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataAddOrderBy() {
+ public static function dataAddOrderBy(): array {
return [
['column2', null, null, ['`column1` ASC', '`column2` ASC'], 'ORDER BY `column1` ASC, `column2` ASC'],
['column2', null, 'ASC', ['`column1` ASC', '`column2` ASC'], 'ORDER BY `column1` ASC, `column2` ASC'],
@@ -1197,7 +1197,7 @@ class QueryBuilderTest extends \Test\TestCase {
}
}
- public function dataGetTableName() {
+ public function dataGetTableName(): array {
$config = $this->createMock(SystemConfig::class);
$logger = $this->createMock(LoggerInterface::class);
$qb = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger);
@@ -1234,7 +1234,7 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
- public function dataGetColumnName() {
+ public static function dataGetColumnName(): array {
return [
['column', '', '`column`'],
['column', 'a', '`a`.`column`'],
diff --git a/tests/lib/DB/QueryBuilder/QuoteHelperTest.php b/tests/lib/DB/QueryBuilder/QuoteHelperTest.php
index 3c2e33c28ea..eb09055033e 100644
--- a/tests/lib/DB/QueryBuilder/QuoteHelperTest.php
+++ b/tests/lib/DB/QueryBuilder/QuoteHelperTest.php
@@ -23,7 +23,7 @@ class QuoteHelperTest extends \Test\TestCase {
$this->helper = new QuoteHelper();
}
- public function dataQuoteColumnName() {
+ public static function dataQuoteColumnName(): array {
return [
['column', '`column`'],
[new Literal('literal'), 'literal'],
@@ -48,7 +48,7 @@ class QuoteHelperTest extends \Test\TestCase {
);
}
- public function dataQuoteColumnNames() {
+ public static function dataQuoteColumnNames(): array {
return [
// Single case
['d.column', '`d`.`column`'],
diff --git a/tests/lib/DateTimeFormatterTest.php b/tests/lib/DateTimeFormatterTest.php
index 924cac9d399..cfab1643beb 100644
--- a/tests/lib/DateTimeFormatterTest.php
+++ b/tests/lib/DateTimeFormatterTest.php
@@ -36,23 +36,23 @@ class DateTimeFormatterTest extends TestCase {
$this->formatter = new \OC\DateTimeFormatter(new \DateTimeZone('UTC'), \OCP\Util::getL10N('lib', 'en'));
}
- protected function getTimestampAgo($time, $seconds = 0, $minutes = 0, $hours = 0, $days = 0, $years = 0) {
+ protected static function getTimestampAgo($time, $seconds = 0, $minutes = 0, $hours = 0, $days = 0, $years = 0) {
return $time - $seconds - $minutes * 60 - $hours * 3600 - $days * 24 * 3600 - $years * 365 * 24 * 3600;
}
- public function formatTimeSpanData() {
+ public static function formatTimeSpanData(): array {
$time = 1416916800; // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo
$deL10N = \OCP\Util::getL10N('lib', 'de');
return [
['seconds ago', $time, $time],
['in a few seconds', $time + 5 , $time],
- ['1 minute ago', $this->getTimestampAgo($time, 30, 1), $time],
- ['15 minutes ago', $this->getTimestampAgo($time, 30, 15), $time],
- ['in 15 minutes', $time, $this->getTimestampAgo($time, 30, 15)],
- ['1 hour ago', $this->getTimestampAgo($time, 30, 15, 1), $time],
- ['3 hours ago', $this->getTimestampAgo($time, 30, 15, 3), $time],
- ['in 3 hours', $time, $this->getTimestampAgo($time, 30, 15, 3)],
- ['4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4), $time],
+ ['1 minute ago', self::getTimestampAgo($time, 30, 1), $time],
+ ['15 minutes ago', self::getTimestampAgo($time, 30, 15), $time],
+ ['in 15 minutes', $time, self::getTimestampAgo($time, 30, 15)],
+ ['1 hour ago', self::getTimestampAgo($time, 30, 15, 1), $time],
+ ['3 hours ago', self::getTimestampAgo($time, 30, 15, 3), $time],
+ ['in 3 hours', $time, self::getTimestampAgo($time, 30, 15, 3)],
+ ['4 days ago', self::getTimestampAgo($time, 30, 15, 3, 4), $time],
['seconds ago', new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')],
['seconds ago', new \DateTime('Wed, 02 Oct 2013 23:59:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')],
@@ -81,29 +81,29 @@ class DateTimeFormatterTest extends TestCase {
$this->assertEquals((string)$expected, (string)$this->formatter->formatTimeSpan($timestamp, $compare, $locale));
}
- public function formatDateSpanData() {
+ public static function formatDateSpanData(): array {
$time = 1416916800; // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo
$deL10N = \OCP\Util::getL10N('lib', 'de');
return [
// Normal testing
- ['today', $this->getTimestampAgo($time, 30, 15), $time],
- ['yesterday', $this->getTimestampAgo($time, 0, 0, 0, 1), $time],
- ['tomorrow', $time, $this->getTimestampAgo($time, 0, 0, 0, 1)],
- ['4 days ago', $this->getTimestampAgo($time, 0, 0, 0, 4), $time],
- ['in 4 days', $time, $this->getTimestampAgo($time, 0, 0, 0, 4)],
- ['5 months ago', $this->getTimestampAgo($time, 0, 0, 0, 155), $time],
- ['next month', $time, $this->getTimestampAgo($time, 0, 0, 0, 32)],
- ['in 5 months', $time, $this->getTimestampAgo($time, 0, 0, 0, 155)],
- ['2 years ago', $this->getTimestampAgo($time, 0, 0, 0, 0, 2), $time],
- ['next year', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 1)],
- ['in 2 years', $time, $this->getTimestampAgo($time, 0, 0, 0, 0, 2)],
+ ['today', self::getTimestampAgo($time, 30, 15), $time],
+ ['yesterday', self::getTimestampAgo($time, 0, 0, 0, 1), $time],
+ ['tomorrow', $time, self::getTimestampAgo($time, 0, 0, 0, 1)],
+ ['4 days ago', self::getTimestampAgo($time, 0, 0, 0, 4), $time],
+ ['in 4 days', $time, self::getTimestampAgo($time, 0, 0, 0, 4)],
+ ['5 months ago', self::getTimestampAgo($time, 0, 0, 0, 155), $time],
+ ['next month', $time, self::getTimestampAgo($time, 0, 0, 0, 32)],
+ ['in 5 months', $time, self::getTimestampAgo($time, 0, 0, 0, 155)],
+ ['2 years ago', self::getTimestampAgo($time, 0, 0, 0, 0, 2), $time],
+ ['next year', $time, self::getTimestampAgo($time, 0, 0, 0, 0, 1)],
+ ['in 2 years', $time, self::getTimestampAgo($time, 0, 0, 0, 0, 2)],
// Test with compare timestamp
- ['today', $this->getTimestampAgo($time, 0, 0, 0, 0, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)],
- ['yesterday', $this->getTimestampAgo($time, 30, 15, 3, 1, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)],
- ['4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)],
- ['5 months ago', $this->getTimestampAgo($time, 30, 15, 3, 155, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)],
- ['2 years ago', $this->getTimestampAgo($time, 30, 15, 3, 35, 3), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)],
+ ['today', self::getTimestampAgo($time, 0, 0, 0, 0, 1), self::getTimestampAgo($time, 0, 0, 0, 0, 1)],
+ ['yesterday', self::getTimestampAgo($time, 30, 15, 3, 1, 1), self::getTimestampAgo($time, 0, 0, 0, 0, 1)],
+ ['4 days ago', self::getTimestampAgo($time, 30, 15, 3, 4, 1), self::getTimestampAgo($time, 0, 0, 0, 0, 1)],
+ ['5 months ago', self::getTimestampAgo($time, 30, 15, 3, 155, 1), self::getTimestampAgo($time, 0, 0, 0, 0, 1)],
+ ['2 years ago', self::getTimestampAgo($time, 30, 15, 3, 35, 3), self::getTimestampAgo($time, 0, 0, 0, 0, 1)],
// Test translations
[$deL10N->t('today'), new \DateTime('Wed, 02 Oct 2013 12:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N],
@@ -147,7 +147,7 @@ class DateTimeFormatterTest extends TestCase {
$this->assertEquals((string)$expected, (string)$this->formatter->formatDateSpan($timestamp, $compare, $locale));
}
- public function formatDateData() {
+ public static function formatDateData(): array {
return [
[1102831200, 'December 12, 2004'],
];
@@ -160,7 +160,7 @@ class DateTimeFormatterTest extends TestCase {
$this->assertEquals($expected, (string)$this->formatter->formatDate($timestamp));
}
- public function formatDateTimeData() {
+ public static function formatDateTimeData(): array {
return [
[1350129205, null, "October 13, 2012, 11:53:25\xE2\x80\xAFAM UTC"],
[1350129205, new \DateTimeZone('Europe/Berlin'), "October 13, 2012, 1:53:25\xE2\x80\xAFPM GMT+2"],
diff --git a/tests/lib/EmojiHelperTest.php b/tests/lib/EmojiHelperTest.php
index 9ad56b32472..517d8655e53 100644
--- a/tests/lib/EmojiHelperTest.php
+++ b/tests/lib/EmojiHelperTest.php
@@ -38,10 +38,7 @@ class EmojiHelperTest extends TestCase {
$this->assertEquals($expected, $this->helper->doesPlatformSupportEmoji());
}
- /**
- * @return array
- */
- public function doesPlatformSupportEmojiDataProvider(): array {
+ public static function doesPlatformSupportEmojiDataProvider(): array {
return [
[true, true],
[false, false],
@@ -60,7 +57,7 @@ class EmojiHelperTest extends TestCase {
$this->assertEquals($expected, $actual);
}
- public function isValidSingleEmojiDataProvider(): array {
+ public static function isValidSingleEmojiDataProvider(): array {
return [
['📱📠', false],
['a', false],
diff --git a/tests/lib/Encryption/EncryptionWrapperTest.php b/tests/lib/Encryption/EncryptionWrapperTest.php
index 1ac7342a3d8..342a7214e44 100644
--- a/tests/lib/Encryption/EncryptionWrapperTest.php
+++ b/tests/lib/Encryption/EncryptionWrapperTest.php
@@ -9,7 +9,10 @@ namespace Test\Encryption;
use OC\Encryption\EncryptionWrapper;
use OC\Encryption\Manager;
+use OC\Files\Storage\Wrapper\Encryption;
use OC\Memcache\ArrayCache;
+use OCA\Files_Trashbin\Storage;
+use OCP\Files\Mount\IMountPoint;
use OCP\Files\Storage\IDisableEncryptionStorage;
use OCP\Files\Storage\IStorage;
use Psr\Log\LoggerInterface;
@@ -55,7 +58,7 @@ class EncryptionWrapperTest extends TestCase {
]);
}
- $mount = $this->getMockBuilder('OCP\Files\Mount\IMountPoint')
+ $mount = $this->getMockBuilder(IMountPoint::class)
->disableOriginalConstructor()
->getMock();
@@ -63,16 +66,16 @@ class EncryptionWrapperTest extends TestCase {
$this->assertEquals(
$expectedWrapped,
- $returnedStorage->instanceOfStorage('OC\Files\Storage\Wrapper\Encryption'),
+ $returnedStorage->instanceOfStorage(Encryption::class),
'Asserted that the storage is (not) wrapped with encryption'
);
}
- public function provideWrapStorage() {
+ public static function provideWrapStorage(): array {
return [
// Wrap when not wrapped or not wrapped with storage
[true, []],
- [true, ['OCA\Files_Trashbin\Storage']],
+ [true, [Storage::class]],
// Do not wrap shared storages
[false, [IDisableEncryptionStorage::class]],
diff --git a/tests/lib/Encryption/UpdateTest.php b/tests/lib/Encryption/UpdateTest.php
index 2627e18601d..4f3de2b495d 100644
--- a/tests/lib/Encryption/UpdateTest.php
+++ b/tests/lib/Encryption/UpdateTest.php
@@ -1,4 +1,7 @@
<?php
+
+declare(strict_types=1);
+
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -10,61 +13,67 @@ namespace Test\Encryption;
use OC\Encryption\File;
use OC\Encryption\Update;
use OC\Encryption\Util;
-use OC\Files\Mount\Manager;
use OC\Files\View;
use OCP\Encryption\IEncryptionModule;
+use OCP\Files\File as OCPFile;
+use OCP\Files\Folder;
+use OCP\IUser;
+use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
class UpdateTest extends TestCase {
- /** @var \OC\Encryption\Update */
- private $update;
-
- /** @var string */
- private $uid;
-
- /** @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject */
- private $view;
-
- /** @var Util | \PHPUnit\Framework\MockObject\MockObject */
- private $util;
-
- /** @var \OC\Files\Mount\Manager | \PHPUnit\Framework\MockObject\MockObject */
- private $mountManager;
-
- /** @var \OC\Encryption\Manager | \PHPUnit\Framework\MockObject\MockObject */
- private $encryptionManager;
-
- /** @var \OCP\Encryption\IEncryptionModule | \PHPUnit\Framework\MockObject\MockObject */
- private $encryptionModule;
-
- /** @var \OC\Encryption\File | \PHPUnit\Framework\MockObject\MockObject */
- private $fileHelper;
-
- /** @var \PHPUnit\Framework\MockObject\MockObject|LoggerInterface */
- private $logger;
+ private string $uid;
+ private View&MockObject $view;
+ private Util&MockObject $util;
+ private \OC\Encryption\Manager&MockObject $encryptionManager;
+ private IEncryptionModule&MockObject $encryptionModule;
+ private File&MockObject $fileHelper;
+ private LoggerInterface&MockObject $logger;
protected function setUp(): void {
parent::setUp();
$this->view = $this->createMock(View::class);
$this->util = $this->createMock(Util::class);
- $this->mountManager = $this->createMock(Manager::class);
$this->encryptionManager = $this->createMock(\OC\Encryption\Manager::class);
$this->fileHelper = $this->createMock(File::class);
$this->encryptionModule = $this->createMock(IEncryptionModule::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->uid = 'testUser1';
+ }
- $this->update = new Update(
- $this->view,
- $this->util,
- $this->mountManager,
- $this->encryptionManager,
- $this->fileHelper,
- $this->logger,
- $this->uid);
+ private function getUserMock(string $uid): IUser&MockObject {
+ $user = $this->createMock(IUser::class);
+ $user->expects(self::any())
+ ->method('getUID')
+ ->willReturn($uid);
+ return $user;
+ }
+
+ private function getFileMock(string $path, string $owner): OCPFile&MockObject {
+ $node = $this->createMock(OCPFile::class);
+ $node->expects(self::atLeastOnce())
+ ->method('getPath')
+ ->willReturn($path);
+ $node->expects(self::any())
+ ->method('getOwner')
+ ->willReturn($this->getUserMock($owner));
+
+ return $node;
+ }
+
+ private function getFolderMock(string $path, string $owner): Folder&MockObject {
+ $node = $this->createMock(Folder::class);
+ $node->expects(self::atLeastOnce())
+ ->method('getPath')
+ ->willReturn($path);
+ $node->expects(self::any())
+ ->method('getOwner')
+ ->willReturn($this->getUserMock($owner));
+
+ return $node;
}
/**
@@ -76,18 +85,21 @@ class UpdateTest extends TestCase {
* @param integer $numberOfFiles
*/
public function testUpdate($path, $isDir, $allFiles, $numberOfFiles): void {
+ $updateMock = $this->getUpdateMock(['getOwnerPath']);
+ $updateMock->expects($this->once())->method('getOwnerPath')
+ ->willReturnCallback(fn (OCPFile|Folder $node) => '/user/' . $node->getPath());
+
$this->encryptionManager->expects($this->once())
->method('getEncryptionModule')
->willReturn($this->encryptionModule);
- $this->view->expects($this->once())
- ->method('is_dir')
- ->willReturn($isDir);
-
if ($isDir) {
$this->util->expects($this->once())
->method('getAllFiles')
->willReturn($allFiles);
+ $node = $this->getFolderMock($path, 'user');
+ } else {
+ $node = $this->getFileMock($path, 'user');
}
$this->fileHelper->expects($this->exactly($numberOfFiles))
@@ -98,15 +110,10 @@ class UpdateTest extends TestCase {
->method('update')
->willReturn(true);
- $this->update->update($path);
+ $updateMock->update($node);
}
- /**
- * data provider for testUpdate()
- *
- * @return array
- */
- public function dataTestUpdate() {
+ public static function dataTestUpdate(): array {
return [
['/user/files/foo', true, ['/user/files/foo/file1.txt', '/user/files/foo/file1.txt'], 2],
['/user/files/test.txt', false, [], 1],
@@ -118,102 +125,66 @@ class UpdateTest extends TestCase {
*
* @param string $source
* @param string $target
- * @param boolean $encryptionEnabled
*/
- public function testPostRename($source, $target, $encryptionEnabled): void {
- $updateMock = $this->getUpdateMock(['update', 'getOwnerPath']);
+ public function testPostRename($source, $target): void {
+ $updateMock = $this->getUpdateMock(['update','getOwnerPath']);
- $this->encryptionManager->expects($this->once())
- ->method('isEnabled')
- ->willReturn($encryptionEnabled);
+ $sourceNode = $this->getFileMock($source, 'user');
+ $targetNode = $this->getFileMock($target, 'user');
- if (dirname($source) === dirname($target) || $encryptionEnabled === false) {
+ if (dirname($source) === dirname($target)) {
$updateMock->expects($this->never())->method('getOwnerPath');
$updateMock->expects($this->never())->method('update');
} else {
- $updateMock->expects($this->once())
- ->method('getOwnerPath')
- ->willReturnCallback(function ($path) use ($target) {
- $this->assertSame(
- $target,
- $path,
- 'update needs to be executed for the target destination');
- return ['owner', $path];
- });
- $updateMock->expects($this->once())->method('update');
+ $updateMock->expects($this->once())->method('update')
+ ->willReturnCallback(fn (OCPFile|Folder $node) => $this->assertSame(
+ $target,
+ $node->getPath(),
+ 'update needs to be executed for the target destination'
+ ));
}
- $updateMock->postRename(['oldpath' => $source, 'newpath' => $target]);
+ $updateMock->postRename($sourceNode, $targetNode);
}
- /**
- * test data for testPostRename()
- *
- * @return array
- */
- public function dataTestPostRename() {
+ public static function dataTestPostRename(): array {
return [
- ['/test.txt', '/testNew.txt', true],
- ['/test.txt', '/testNew.txt', false],
- ['/folder/test.txt', '/testNew.txt', true],
- ['/folder/test.txt', '/testNew.txt', false],
- ['/folder/test.txt', '/testNew.txt', true],
- ['/test.txt', '/folder/testNew.txt', false],
+ ['/test.txt', '/testNew.txt'],
+ ['/folder/test.txt', '/testNew.txt'],
+ ['/test.txt', '/folder/testNew.txt'],
];
}
-
- /**
- * @dataProvider dataTestPostRestore
- *
- * @param boolean $encryptionEnabled
- */
- public function testPostRestore($encryptionEnabled): void {
+ public function testPostRestore(): void {
$updateMock = $this->getUpdateMock(['update']);
- $this->encryptionManager->expects($this->once())
- ->method('isEnabled')
- ->willReturn($encryptionEnabled);
+ $updateMock->expects($this->once())->method('update')
+ ->willReturnCallback(fn (OCPFile|Folder $node) => $this->assertSame(
+ '/folder/test.txt',
+ $node->getPath(),
+ 'update needs to be executed for the target destination'
+ ));
- if ($encryptionEnabled) {
- $updateMock->expects($this->once())->method('update');
- } else {
- $updateMock->expects($this->never())->method('update');
- }
-
- $updateMock->postRestore(['filePath' => '/folder/test.txt']);
- }
-
- /**
- * test data for testPostRestore()
- *
- * @return array
- */
- public function dataTestPostRestore() {
- return [
- [true],
- [false],
- ];
+ $updateMock->postRestore($this->getFileMock('/folder/test.txt', 'user'));
}
/**
* create mock of the update method
*
* @param array $methods methods which should be set
- * @return \OC\Encryption\Update | \PHPUnit\Framework\MockObject\MockObject
*/
- protected function getUpdateMock($methods) {
- return $this->getMockBuilder('\OC\Encryption\Update')
+ protected function getUpdateMock(array $methods): Update&MockObject {
+ return $this->getMockBuilder(Update::class)
->setConstructorArgs(
[
- $this->view,
$this->util,
- $this->mountManager,
$this->encryptionManager,
$this->fileHelper,
$this->logger,
$this->uid
]
- )->setMethods($methods)->getMock();
+ )
+ ->onlyMethods($methods)
+ ->getMock();
}
}
diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php
index 62ef809a867..68989c55fb0 100644
--- a/tests/lib/Encryption/UtilTest.php
+++ b/tests/lib/Encryption/UtilTest.php
@@ -20,7 +20,7 @@ class UtilTest extends TestCase {
*
* @see https://bugs.php.net/bug.php?id=21641
*/
- protected int $headerSize = 8192;
+ protected static int $headerSize = 8192;
/** @var \PHPUnit\Framework\MockObject\MockObject */
protected $view;
@@ -61,7 +61,7 @@ class UtilTest extends TestCase {
$this->assertEquals($expected, $id);
}
- public function providesHeadersForEncryptionModule() {
+ public static function providesHeadersForEncryptionModule(): array {
return [
['', []],
['', ['1']],
@@ -80,11 +80,11 @@ class UtilTest extends TestCase {
$this->assertEquals($expected, $result);
}
- public function providesHeaders() {
+ public static function providesHeaders(): array {
return [
- [str_pad('HBEGIN:oc_encryption_module:0:HEND', $this->headerSize, '-', STR_PAD_RIGHT)
+ [str_pad('HBEGIN:oc_encryption_module:0:HEND', self::$headerSize, '-', STR_PAD_RIGHT)
, [], '0'],
- [str_pad('HBEGIN:oc_encryption_module:0:custom_header:foo:HEND', $this->headerSize, '-', STR_PAD_RIGHT)
+ [str_pad('HBEGIN:oc_encryption_module:0:custom_header:foo:HEND', self::$headerSize, '-', STR_PAD_RIGHT)
, ['custom_header' => 'foo'], '0'],
];
}
@@ -120,7 +120,7 @@ class UtilTest extends TestCase {
);
}
- public function providePathsForTestIsExcluded() {
+ public static function providePathsForTestIsExcluded(): array {
return [
['/files_encryption', '', true],
['files_encryption/foo.txt', '', true],
@@ -152,7 +152,7 @@ class UtilTest extends TestCase {
);
}
- public function dataTestIsFile() {
+ public static function dataTestIsFile(): array {
return [
['/user/files/test.txt', true],
['/user/files', true],
@@ -175,7 +175,7 @@ class UtilTest extends TestCase {
$this->util->stripPartialFileExtension($path));
}
- public function dataTestStripPartialFileExtension() {
+ public static function dataTestStripPartialFileExtension(): array {
return [
['/foo/test.txt', '/foo/test.txt'],
['/foo/test.txt.part', '/foo/test.txt'],
@@ -196,17 +196,17 @@ class UtilTest extends TestCase {
}
}
- public function dataTestParseRawHeader() {
+ public static function dataTestParseRawHeader(): array {
return [
- [str_pad('HBEGIN:oc_encryption_module:0:HEND', $this->headerSize, '-', STR_PAD_RIGHT)
+ [str_pad('HBEGIN:oc_encryption_module:0:HEND', self::$headerSize, '-', STR_PAD_RIGHT)
, [Util::HEADER_ENCRYPTION_MODULE_KEY => '0']],
- [str_pad('HBEGIN:oc_encryption_module:0:custom_header:foo:HEND', $this->headerSize, '-', STR_PAD_RIGHT)
+ [str_pad('HBEGIN:oc_encryption_module:0:custom_header:foo:HEND', self::$headerSize, '-', STR_PAD_RIGHT)
, ['custom_header' => 'foo', Util::HEADER_ENCRYPTION_MODULE_KEY => '0']],
- [str_pad('HelloWorld', $this->headerSize, '-', STR_PAD_RIGHT), []],
+ [str_pad('HelloWorld', self::$headerSize, '-', STR_PAD_RIGHT), []],
['', []],
- [str_pad('HBEGIN:oc_encryption_module:0', $this->headerSize, '-', STR_PAD_RIGHT)
+ [str_pad('HBEGIN:oc_encryption_module:0', self::$headerSize, '-', STR_PAD_RIGHT)
, []],
- [str_pad('oc_encryption_module:0:HEND', $this->headerSize, '-', STR_PAD_RIGHT)
+ [str_pad('oc_encryption_module:0:HEND', self::$headerSize, '-', STR_PAD_RIGHT)
, []],
];
}
@@ -245,7 +245,7 @@ class UtilTest extends TestCase {
);
}
- public function dataTestGetFileKeyDir() {
+ public static function dataTestGetFileKeyDir(): array {
return [
[false, '', '/user1/files_encryption/keys/foo/bar.txt/OC_DEFAULT_MODULE/'],
[true, '', '/files_encryption/keys/foo/bar.txt/OC_DEFAULT_MODULE/'],
diff --git a/tests/lib/ErrorHandlerTest.php b/tests/lib/ErrorHandlerTest.php
index b45525e7962..00cf8e4c8db 100644
--- a/tests/lib/ErrorHandlerTest.php
+++ b/tests/lib/ErrorHandlerTest.php
@@ -16,10 +16,9 @@ use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
class ErrorHandlerTest extends TestCase {
- /** @var MockObject */
- private LoggerInterface $logger;
-
+ private LoggerInterface&MockObject $logger;
private ErrorHandler $errorHandler;
+ private int $errorReporting;
protected function setUp(): void {
parent::setUp();
@@ -28,13 +27,20 @@ class ErrorHandlerTest extends TestCase {
$this->errorHandler = new ErrorHandler(
$this->logger
);
+
+ $this->errorReporting = error_reporting(E_ALL);
+ }
+
+ protected function tearDown(): void {
+ error_reporting($this->errorReporting);
+ parent::tearDown();
}
/**
* provide username, password combinations for testRemovePassword
* @return array
*/
- public function passwordProvider() {
+ public static function passwordProvider(): array {
return [
['us:er', 'pass@word'],
['us:er', 'password'],
diff --git a/tests/lib/Federation/CloudIdManagerTest.php b/tests/lib/Federation/CloudIdManagerTest.php
index 7019cd202db..0bd0659b2f2 100644
--- a/tests/lib/Federation/CloudIdManagerTest.php
+++ b/tests/lib/Federation/CloudIdManagerTest.php
@@ -56,7 +56,7 @@ class CloudIdManagerTest extends TestCase {
$this->overwriteService(ICloudIdManager::class, $this->cloudIdManager);
}
- public function dataGetDisplayNameFromContact(): array {
+ public static function dataGetDisplayNameFromContact(): array {
return [
['test1@example.tld', 'test', 'test'],
['test2@example.tld', null, null],
@@ -84,7 +84,7 @@ class CloudIdManagerTest extends TestCase {
$this->assertEquals($expected, $this->cloudIdManager->getDisplayNameFromContact($cloudId));
}
- public function cloudIdProvider(): array {
+ public static function cloudIdProvider(): array {
return [
['test@example.com', 'test', 'example.com', 'test@example.com'],
['test@example.com/cloud', 'test', 'example.com/cloud', 'test@example.com/cloud'],
@@ -122,7 +122,7 @@ class CloudIdManagerTest extends TestCase {
$this->assertEquals($displayName . '@' . $noProtocolRemote, $cloudId->getDisplayId());
}
- public function invalidCloudIdProvider(): array {
+ public static function invalidCloudIdProvider(): array {
return [
['example.com'],
['test:foo@example.com'],
@@ -142,7 +142,7 @@ class CloudIdManagerTest extends TestCase {
$this->cloudIdManager->resolveCloudId($cloudId);
}
- public function getCloudIdProvider(): array {
+ public static function getCloudIdProvider(): array {
return [
['test', 'example.com', 'test@example.com', null, 'https://example.com', 'https://example.com'],
['test', 'http://example.com', 'test@http://example.com', 'test@example.com'],
diff --git a/tests/lib/Federation/CloudIdTest.php b/tests/lib/Federation/CloudIdTest.php
index ca949d163c7..ec3cc15d6ff 100644
--- a/tests/lib/Federation/CloudIdTest.php
+++ b/tests/lib/Federation/CloudIdTest.php
@@ -28,7 +28,7 @@ class CloudIdTest extends TestCase {
$this->overwriteService(ICloudIdManager::class, $this->cloudIdManager);
}
- public function dataGetDisplayCloudId(): array {
+ public static function dataGetDisplayCloudId(): array {
return [
['test@example.com', 'test', 'example.com', 'test@example.com'],
['test@http://example.com', 'test', 'http://example.com', 'test@example.com'],
diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php
index 204f87d6a18..55b210a1e2d 100644
--- a/tests/lib/Files/Cache/CacheTest.php
+++ b/tests/lib/Files/Cache/CacheTest.php
@@ -49,6 +49,25 @@ class CacheTest extends \Test\TestCase {
*/
protected $cache2;
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->storage = new \OC\Files\Storage\Temporary([]);
+ $this->storage2 = new \OC\Files\Storage\Temporary([]);
+ $this->cache = new \OC\Files\Cache\Cache($this->storage);
+ $this->cache2 = new \OC\Files\Cache\Cache($this->storage2);
+ $this->cache->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
+ $this->cache2->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
+ }
+
+ protected function tearDown(): void {
+ if ($this->cache) {
+ $this->cache->clear();
+ }
+
+ parent::tearDown();
+ }
+
public function testGetNumericId(): void {
$this->assertNotNull($this->cache->getNumericStorageId());
}
@@ -208,7 +227,7 @@ class CacheTest extends \Test\TestCase {
}
}
- public function folderDataProvider() {
+ public static function folderDataProvider(): array {
return [
['folder'],
// that was too easy, try something harder
@@ -301,7 +320,7 @@ class CacheTest extends \Test\TestCase {
$this->assertEquals(\OC\Files\Cache\Cache::COMPLETE, $this->cache->getStatus('foo'));
}
- public function putWithAllKindOfQuotesData() {
+ public static function putWithAllKindOfQuotesData(): array {
return [
['`backtick`'],
['´forward´'],
@@ -437,7 +456,7 @@ class CacheTest extends \Test\TestCase {
new SearchComparison(ISearchComparison::COMPARE_GREATER_THAN_EQUAL, 'size', 100), 10, 0, [], $user)));
}
- public function movePathProvider() {
+ public static function movePathProvider(): array {
return [
['folder/foo', 'folder/foobar', ['1', '2']],
['folder/foo', 'foo', ['1', '2']],
@@ -575,7 +594,7 @@ class CacheTest extends \Test\TestCase {
* @var \OC\Files\Cache\Cache | \PHPUnit\Framework\MockObject\MockObject $cacheMock
*/
$cacheMock = $this->getMockBuilder(Cache::class)
- ->setMethods(['normalize'])
+ ->onlyMethods(['normalize'])
->setConstructorArgs([$this->storage])
->getMock();
@@ -646,7 +665,7 @@ class CacheTest extends \Test\TestCase {
$this->assertEquals(1, count($this->cache->getFolderContents('folder')));
}
- public function bogusPathNamesProvider() {
+ public static function bogusPathNamesProvider(): array {
return [
['/bogus.txt', 'bogus.txt'],
['//bogus.txt', 'bogus.txt'],
@@ -691,7 +710,7 @@ class CacheTest extends \Test\TestCase {
$this->assertNotEquals($fileId, $fileId2);
}
- public function escapingProvider() {
+ public static function escapingProvider(): array {
return [
['foo'],
['o%'],
@@ -807,23 +826,4 @@ class CacheTest extends \Test\TestCase {
$this->cache->remove('sub');
}
-
- protected function tearDown(): void {
- if ($this->cache) {
- $this->cache->clear();
- }
-
- parent::tearDown();
- }
-
- protected function setUp(): void {
- parent::setUp();
-
- $this->storage = new \OC\Files\Storage\Temporary([]);
- $this->storage2 = new \OC\Files\Storage\Temporary([]);
- $this->cache = new \OC\Files\Cache\Cache($this->storage);
- $this->cache2 = new \OC\Files\Cache\Cache($this->storage2);
- $this->cache->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
- $this->cache2->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
- }
}
diff --git a/tests/lib/Files/Cache/ScannerTest.php b/tests/lib/Files/Cache/ScannerTest.php
index d78b7100d43..dc5ba5d3cdf 100644
--- a/tests/lib/Files/Cache/ScannerTest.php
+++ b/tests/lib/Files/Cache/ScannerTest.php
@@ -394,7 +394,7 @@ class ScannerTest extends TestCase {
);
}
- public function dataTestIsPartialFile() {
+ public static function dataTestIsPartialFile(): array {
return [
['foo.txt.part', true],
['/sub/folder/foo.txt.part', true],
diff --git a/tests/lib/Files/Cache/SearchBuilderTest.php b/tests/lib/Files/Cache/SearchBuilderTest.php
index 17285d44209..28af199639a 100644
--- a/tests/lib/Files/Cache/SearchBuilderTest.php
+++ b/tests/lib/Files/Cache/SearchBuilderTest.php
@@ -134,7 +134,7 @@ class SearchBuilderTest extends TestCase {
return $rows;
}
- public function comparisonProvider() {
+ public static function comparisonProvider(): array {
return [
[new SearchComparison(ISearchComparison::COMPARE_GREATER_THAN, 'mtime', 125), [1]],
[new SearchComparison(ISearchComparison::COMPARE_LESS_THAN, 'mtime', 125), [0]],
diff --git a/tests/lib/Files/Cache/UpdaterTest.php b/tests/lib/Files/Cache/UpdaterTest.php
index ab46bdd4141..bc4b39a5dc4 100644
--- a/tests/lib/Files/Cache/UpdaterTest.php
+++ b/tests/lib/Files/Cache/UpdaterTest.php
@@ -305,7 +305,7 @@ class UpdaterTest extends \Test\TestCase {
}
}
- public function changeExtensionProvider(): array {
+ public static function changeExtensionProvider(): array {
return [
[new Temporary()],
[new ObjectStoreStorage(['objectstore' => new StorageObjectStore(new Temporary())])]
diff --git a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
index aed13c41ac0..57024e2eb79 100644
--- a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
+++ b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
@@ -8,6 +8,7 @@
namespace Test\Files\Cache\Wrapper;
use OC\Files\Cache\Wrapper\CacheJail;
+use OC\Files\Cache\Wrapper\CacheWrapper;
use OC\Files\Search\SearchComparison;
use OC\Files\Search\SearchQuery;
use OC\Files\Storage\Wrapper\Jail;
@@ -252,4 +253,14 @@ class CacheJailTest extends CacheTest {
$storage->getWatcher()->update('bar', ['mimetype' => 'text/plain']);
$this->assertTrue($this->cache->inCache('bar'));
}
+
+ public function testUnJailedRoot(): void {
+ $jail1 = new CacheJail($this->sourceCache, 'foo');
+ $jail2 = new CacheJail($jail1, 'bar');
+ $this->assertEquals('foo/bar', $jail2->getGetUnjailedRoot());
+
+ $middleWrapper = new CacheWrapper($jail1);
+ $jail3 = new CacheJail($middleWrapper, 'bar');
+ $this->assertEquals('foo/bar', $jail3->getGetUnjailedRoot());
+ }
}
diff --git a/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php b/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php
index afb5c6a5d4d..9aa1ee5b723 100644
--- a/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php
+++ b/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php
@@ -34,7 +34,7 @@ class CachePermissionsMaskTest extends CacheTest {
return new \OC\Files\Cache\Wrapper\CachePermissionsMask($this->sourceCache, $mask);
}
- public function maskProvider() {
+ public static function maskProvider(): array {
return [
[Constants::PERMISSION_ALL],
[Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE],
diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php
index 1efc56c1908..88b8b7767dd 100644
--- a/tests/lib/Files/Config/UserMountCacheTest.php
+++ b/tests/lib/Files/Config/UserMountCacheTest.php
@@ -9,6 +9,7 @@ namespace Test\Files\Config;
use OC\DB\Exceptions\DbalException;
use OC\DB\QueryBuilder\Literal;
+use OC\Files\Cache\Cache;
use OC\Files\Mount\MountPoint;
use OC\Files\Storage\Storage;
use OC\User\Manager;
@@ -88,25 +89,19 @@ class UserMountCacheTest extends TestCase {
private function getStorage($storageId, $rootInternalPath = '') {
$rootId = $this->createCacheEntry($rootInternalPath, $storageId);
- $storageCache = $this->getMockBuilder('\OC\Files\Cache\Storage')
- ->disableOriginalConstructor()
- ->getMock();
+ $storageCache = $this->createMock(\OC\Files\Cache\Storage::class);
$storageCache->expects($this->any())
->method('getNumericId')
->willReturn($storageId);
- $cache = $this->getMockBuilder('\OC\Files\Cache\Cache')
- ->disableOriginalConstructor()
- ->getMock();
+ $cache = $this->createMock(Cache::class);
$cache->expects($this->any())
->method('getId')
->willReturn($rootId);
$cache->method('getNumericStorageId')
->willReturn($storageId);
- $storage = $this->getMockBuilder('\OC\Files\Storage\Storage')
- ->disableOriginalConstructor()
- ->getMock();
+ $storage = $this->createMock(Storage::class);
$storage->expects($this->any())
->method('getStorageCache')
->willReturn($storageCache);
@@ -427,9 +422,9 @@ class UserMountCacheTest extends TestCase {
$fileId = $this->createCacheEntry('/foo/bar', 2);
- $mount1 = $this->getMockBuilder('\OC\Files\Mount\MountPoint')
+ $mount1 = $this->getMockBuilder(MountPoint::class)
->setConstructorArgs([$storage1, '/'])
- ->setMethods(['getStorageRootId'])
+ ->onlyMethods(['getStorageRootId'])
->getMock();
$mount1->expects($this->any())
@@ -460,9 +455,9 @@ class UserMountCacheTest extends TestCase {
$folderId = $this->createCacheEntry('/foo', 2);
$fileId = $this->createCacheEntry('/bar/asd', 2);
- $mount1 = $this->getMockBuilder('\OC\Files\Mount\MountPoint')
+ $mount1 = $this->getMockBuilder(MountPoint::class)
->setConstructorArgs([$storage1, '/foo/'])
- ->setMethods(['getStorageRootId'])
+ ->onlyMethods(['getStorageRootId'])
->getMock();
$mount1->expects($this->any())
@@ -509,7 +504,7 @@ class UserMountCacheTest extends TestCase {
$mount1 = $this->getMockBuilder(MountPoint::class)
->setConstructorArgs([$storage1, '/u1/'])
- ->setMethods(['getStorageRootId', 'getNumericStorageId'])
+ ->onlyMethods(['getStorageRootId', 'getNumericStorageId'])
->getMock();
$mount1->expects($this->any())
diff --git a/tests/lib/Files/FilenameValidatorTest.php b/tests/lib/Files/FilenameValidatorTest.php
index c5361e2c648..db7874b0bd5 100644
--- a/tests/lib/Files/FilenameValidatorTest.php
+++ b/tests/lib/Files/FilenameValidatorTest.php
@@ -122,7 +122,7 @@ class FilenameValidatorTest extends TestCase {
$this->assertEquals($exception === null, $validator->isFilenameValid($filename));
}
- public function dataValidateFilename(): array {
+ public static function dataValidateFilename(): array {
return [
'valid name' => [
'a: b.txt', ['.htaccess'], [], [], [], null
@@ -202,7 +202,7 @@ class FilenameValidatorTest extends TestCase {
$validator->validateFilename($filename);
}
- public function data4ByteUnicode(): array {
+ public static function data4ByteUnicode(): array {
return [
['plane 1 𐪅'],
['emoji 😶‍🌫️'],
@@ -218,7 +218,7 @@ class FilenameValidatorTest extends TestCase {
$validator->validateFilename($filename);
}
- public function dataInvalidAsciiCharacters(): array {
+ public static function dataInvalidAsciiCharacters(): array {
return [
[\chr(0)],
[\chr(1)],
@@ -271,7 +271,7 @@ class FilenameValidatorTest extends TestCase {
$this->assertEquals($expected, $validator->isForbidden($filename));
}
- public function dataIsForbidden(): array {
+ public static function dataIsForbidden(): array {
return [
'valid name' => [
'a: b.txt', ['.htaccess'], false
diff --git a/tests/lib/Files/FilesystemTest.php b/tests/lib/Files/FilesystemTest.php
index a920dc662da..4a3543474a1 100644
--- a/tests/lib/Files/FilesystemTest.php
+++ b/tests/lib/Files/FilesystemTest.php
@@ -100,7 +100,7 @@ class FilesystemTest extends \Test\TestCase {
$this->assertEquals('folder', $internalPath);
}
- public function normalizePathData() {
+ public static function normalizePathData(): array {
return [
['/', ''],
['/', '/'],
@@ -201,7 +201,7 @@ class FilesystemTest extends \Test\TestCase {
$this->assertEquals($expected, \OC\Files\Filesystem::normalizePath($path, $stripTrailingSlash));
}
- public function normalizePathKeepUnicodeData() {
+ public static function normalizePathKeepUnicodeData(): array {
$nfdName = 'ümlaut';
$nfcName = 'ümlaut';
return [
@@ -227,7 +227,7 @@ class FilesystemTest extends \Test\TestCase {
$this->assertEquals('/' . $nfdName, \OC\Files\Filesystem::normalizePath($nfdName, true, false, true));
}
- public function isValidPathData() {
+ public static function isValidPathData(): array {
return [
['/', true],
['/path', true],
@@ -260,7 +260,7 @@ class FilesystemTest extends \Test\TestCase {
$this->assertSame($expected, \OC\Files\Filesystem::isValidPath($path));
}
- public function isFileBlacklistedData() {
+ public static function isFileBlacklistedData(): array {
return [
['/etc/foo/bar/foo.txt', false],
['\etc\foo/bar\foo.txt', false],
diff --git a/tests/lib/Files/Node/FileTest.php b/tests/lib/Files/Node/FileTest.php
index a67c9433663..74a23520344 100644
--- a/tests/lib/Files/Node/FileTest.php
+++ b/tests/lib/Files/Node/FileTest.php
@@ -7,6 +7,8 @@
namespace Test\Files\Node;
+use OC\Files\Node\Root;
+
/**
* Class FileTest
*
@@ -14,7 +16,7 @@ namespace Test\Files\Node;
*
* @package Test\Files\Node
*/
-class FileTest extends NodeTest {
+class FileTest extends NodeTestCase {
protected function createTestNode($root, $view, $path, array $data = [], $internalPath = '', $storage = null) {
if ($data || $internalPath || $storage) {
return new \OC\Files\Node\File($root, $view, $path, $this->getFileInfo($data, $internalPath, $storage));
@@ -37,7 +39,7 @@ class FileTest extends NodeTest {
public function testGetContent(): void {
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
- $root = $this->getMockBuilder('\OC\Files\Node\Root')
+ $root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
@@ -67,7 +69,7 @@ class FileTest extends NodeTest {
$this->expectException(\OCP\Files\NotPermittedException::class);
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
- $root = $this->getMockBuilder('\OC\Files\Node\Root')
+ $root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
@@ -86,7 +88,7 @@ class FileTest extends NodeTest {
public function testPutContent(): void {
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
- $root = $this->getMockBuilder('\OC\Files\Node\Root')
+ $root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
@@ -113,7 +115,7 @@ class FileTest extends NodeTest {
$this->expectException(\OCP\Files\NotPermittedException::class);
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
- $root = $this->getMockBuilder('\OC\Files\Node\Root')
+ $root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
@@ -128,7 +130,7 @@ class FileTest extends NodeTest {
public function testGetMimeType(): void {
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
- $root = $this->getMockBuilder('\OC\Files\Node\Root')
+ $root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php
index e3edf202f8e..25f555e7068 100644
--- a/tests/lib/Files/Node/FolderTest.php
+++ b/tests/lib/Files/Node/FolderTest.php
@@ -40,7 +40,7 @@ use PHPUnit\Framework\MockObject\MockObject;
*
* @package Test\Files\Node
*/
-class FolderTest extends NodeTest {
+class FolderTest extends NodeTestCase {
protected function createTestNode($root, $view, $path, array $data = [], $internalPath = '', $storage = null) {
$view->expects($this->any())
->method('getRoot')
@@ -337,7 +337,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
@@ -499,7 +499,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getMountsIn', 'getMount'])
+ ->onlyMethods(['getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
@@ -548,7 +548,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getMountsIn', 'getMount'])
+ ->onlyMethods(['getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
@@ -593,7 +593,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getMountsIn', 'getMount'])
+ ->onlyMethods(['getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
@@ -637,7 +637,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getMountsIn', 'getMount'])
+ ->onlyMethods(['getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
@@ -681,7 +681,7 @@ class FolderTest extends NodeTest {
$this->assertEquals('/bar/foo/asd/foo/qwerty', $result[1]->getPath());
}
- public function uniqueNameProvider() {
+ public static function uniqueNameProvider(): array {
return [
// input, existing, expected
['foo', [], 'foo'],
@@ -698,7 +698,7 @@ class FolderTest extends NodeTest {
$folderPath = '/bar/foo';
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
@@ -723,7 +723,7 @@ class FolderTest extends NodeTest {
$view = $this->getRootViewMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\FileInfo $folderInfo */
@@ -792,7 +792,7 @@ class FolderTest extends NodeTest {
$view = $this->getRootViewMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\FileInfo $folderInfo */
@@ -859,7 +859,7 @@ class FolderTest extends NodeTest {
$view = $this->getRootViewMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\FileInfo $folderInfo */
@@ -910,7 +910,7 @@ class FolderTest extends NodeTest {
$this->assertEquals([$id1], $ids);
}
- public function offsetLimitProvider() {
+ public static function offsetLimitProvider(): array {
return [
[0, 10, ['/bar/foo/foo1', '/bar/foo/foo2', '/bar/foo/foo3', '/bar/foo/foo4', '/bar/foo/sub1/foo5', '/bar/foo/sub1/foo6', '/bar/foo/sub2/foo7', '/bar/foo/sub2/foo8'], []],
[0, 5, ['/bar/foo/foo1', '/bar/foo/foo2', '/bar/foo/foo3', '/bar/foo/foo4', '/bar/foo/sub1/foo5'], []],
diff --git a/tests/lib/Files/Node/HookConnectorTest.php b/tests/lib/Files/Node/HookConnectorTest.php
index 1a3337b9ddc..b9e16299dd0 100644
--- a/tests/lib/Files/Node/HookConnectorTest.php
+++ b/tests/lib/Files/Node/HookConnectorTest.php
@@ -96,7 +96,7 @@ class HookConnectorTest extends TestCase {
\OC_Util::tearDownFS();
}
- public function viewToNodeProvider() {
+ public static function viewToNodeProvider(): array {
return [
[function () {
Filesystem::file_put_contents('test.txt', 'asd');
@@ -195,7 +195,7 @@ class HookConnectorTest extends TestCase {
$this->assertEquals('/' . $this->userId . '/files/test.txt', $newDispatcherNode->getPath());
}
- public function viewToNodeProviderCopyRename() {
+ public static function viewToNodeProviderCopyRename(): array {
return [
[function () {
Filesystem::file_put_contents('source', 'asd');
diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTestCase.php
index db87aa925d3..a2b8a3ddffe 100644
--- a/tests/lib/Files/Node/NodeTest.php
+++ b/tests/lib/Files/Node/NodeTestCase.php
@@ -9,6 +9,7 @@ namespace Test\Files\Node;
use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
+use OC\Files\Node\Root;
use OC\Files\View;
use OC\Memcache\ArrayCache;
use OCP\EventDispatcher\IEventDispatcher;
@@ -27,7 +28,7 @@ use Psr\Log\LoggerInterface;
*
* @package Test\Files\Node
*/
-abstract class NodeTest extends \Test\TestCase {
+abstract class NodeTestCase extends \Test\TestCase {
/** @var \OC\User\User */
protected $user;
/** @var \OC\Files\Mount\Manager */
@@ -71,7 +72,7 @@ abstract class NodeTest extends \Test\TestCase {
->willReturnCallback(function () {
return new ArrayCache();
});
- $this->root = $this->getMockBuilder('\OC\Files\Node\Root')
+ $this->root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
}
@@ -592,7 +593,7 @@ abstract class NodeTest extends \Test\TestCase {
$this->assertEquals('/bar/asd', $node->getPath());
}
- public function moveOrCopyProvider() {
+ public static function moveOrCopyProvider(): array {
return [
['move', 'rename', 'preRename', 'postRename'],
['copy', 'copy', 'preCopy', 'postCopy'],
@@ -608,9 +609,9 @@ abstract class NodeTest extends \Test\TestCase {
*/
public function testMoveCopyHooks($operationMethod, $viewMethod, $preHookName, $postHookName): void {
/** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject $root */
- $root = $this->getMockBuilder('\OC\Files\Node\Root')
+ $root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
- ->setMethods(['get'])
+ ->onlyMethods(['get'])
->getMock();
$this->view->expects($this->any())
diff --git a/tests/lib/Files/ObjectStore/AzureTest.php b/tests/lib/Files/ObjectStore/AzureTest.php
index c82ed988434..1103b15ecd2 100644
--- a/tests/lib/Files/ObjectStore/AzureTest.php
+++ b/tests/lib/Files/ObjectStore/AzureTest.php
@@ -11,7 +11,7 @@ use OC\Files\ObjectStore\Azure;
/**
* @group PRIMARY-azure
*/
-class AzureTest extends ObjectStoreTest {
+class AzureTest extends ObjectStoreTestCase {
protected function getInstance() {
$config = \OC::$server->getConfig()->getSystemValue('objectstore');
if (!is_array($config) || $config['class'] !== 'OC\\Files\\ObjectStore\\Azure') {
diff --git a/tests/lib/Files/ObjectStore/LocalTest.php b/tests/lib/Files/ObjectStore/LocalTest.php
index 99c5b61534f..3b561c01049 100644
--- a/tests/lib/Files/ObjectStore/LocalTest.php
+++ b/tests/lib/Files/ObjectStore/LocalTest.php
@@ -9,7 +9,7 @@ namespace Test\Files\ObjectStore;
use OC\Files\ObjectStore\StorageObjectStore;
use OC\Files\Storage\Temporary;
-class LocalTest extends ObjectStoreTest {
+class LocalTest extends ObjectStoreTestCase {
/**
* @return \OCP\Files\ObjectStore\IObjectStore
*/
diff --git a/tests/lib/Files/ObjectStore/MapperTest.php b/tests/lib/Files/ObjectStore/MapperTest.php
index 15a2d497fc3..77416eae09a 100644
--- a/tests/lib/Files/ObjectStore/MapperTest.php
+++ b/tests/lib/Files/ObjectStore/MapperTest.php
@@ -29,7 +29,7 @@ class MapperTest extends \Test\TestCase {
$this->mapper = new Mapper($this->user, $this->config);
}
- public function dataGetBucket() {
+ public static function dataGetBucket(): array {
return [
['user', 64, 0, '17'],
['USER', 64, 0, '0'],
diff --git a/tests/lib/Files/ObjectStore/ObjectStoreStoragesDifferentBucketTest.php b/tests/lib/Files/ObjectStore/ObjectStoreStoragesDifferentBucketTest.php
index a0e18a5557b..a1befd4e79d 100644
--- a/tests/lib/Files/ObjectStore/ObjectStoreStoragesDifferentBucketTest.php
+++ b/tests/lib/Files/ObjectStore/ObjectStoreStoragesDifferentBucketTest.php
@@ -9,12 +9,12 @@ namespace Test\Files\ObjectStore;
use OC\Files\ObjectStore\StorageObjectStore;
use OC\Files\Storage\Temporary;
-use Test\Files\Storage\StoragesTest;
+use Test\Files\Storage\StoragesTestCase;
/**
* @group DB
*/
-class ObjectStoreStoragesDifferentBucketTest extends StoragesTest {
+class ObjectStoreStoragesDifferentBucketTest extends StoragesTestCase {
/**
* @var \OCP\Files\ObjectStore\IObjectStore
*/
diff --git a/tests/lib/Files/ObjectStore/ObjectStoreStoragesSameBucketTest.php b/tests/lib/Files/ObjectStore/ObjectStoreStoragesSameBucketTest.php
index 19a1f4b7bc5..5505ee1dac1 100644
--- a/tests/lib/Files/ObjectStore/ObjectStoreStoragesSameBucketTest.php
+++ b/tests/lib/Files/ObjectStore/ObjectStoreStoragesSameBucketTest.php
@@ -9,12 +9,12 @@ namespace Test\Files\ObjectStore;
use OC\Files\ObjectStore\StorageObjectStore;
use OC\Files\Storage\Temporary;
-use Test\Files\Storage\StoragesTest;
+use Test\Files\Storage\StoragesTestCase;
/**
* @group DB
*/
-class ObjectStoreStoragesSameBucketTest extends StoragesTest {
+class ObjectStoreStoragesSameBucketTest extends StoragesTestCase {
/**
* @var \OCP\Files\ObjectStore\IObjectStore
*/
diff --git a/tests/lib/Files/ObjectStore/ObjectStoreTest.php b/tests/lib/Files/ObjectStore/ObjectStoreTestCase.php
index 4a4f85dfb91..ecbfd9a37e6 100644
--- a/tests/lib/Files/ObjectStore/ObjectStoreTest.php
+++ b/tests/lib/Files/ObjectStore/ObjectStoreTestCase.php
@@ -9,10 +9,12 @@ namespace Test\Files\ObjectStore;
use Test\TestCase;
-abstract class ObjectStoreTest extends TestCase {
+abstract class ObjectStoreTestCase extends TestCase {
/** @var string[] */
private $cleanup = [];
+ private $instance = null;
+
/**
* @return \OCP\Files\ObjectStore\IObjectStore
*/
@@ -22,13 +24,20 @@ abstract class ObjectStoreTest extends TestCase {
$this->cleanup[] = $urn;
}
- public function tearDown(): void {
- parent::tearDown();
+ public function setUp(): void {
+ parent::setUp();
- $instance = $this->getInstance();
- foreach ($this->cleanup as $urn) {
- $instance->deleteObject($urn);
+ $this->instance = $this->getInstance();
+ }
+
+ public function tearDown(): void {
+ if ($this->instance) {
+ foreach ($this->cleanup as $urn) {
+ $this->instance->deleteObject($urn);
+ }
}
+
+ parent::tearDown();
}
protected function stringToStream($data) {
diff --git a/tests/lib/Files/ObjectStore/S3Test.php b/tests/lib/Files/ObjectStore/S3Test.php
index 1501f575f9a..76fc80c975f 100644
--- a/tests/lib/Files/ObjectStore/S3Test.php
+++ b/tests/lib/Files/ObjectStore/S3Test.php
@@ -44,7 +44,7 @@ class NonSeekableStream extends Wrapper {
/**
* @group PRIMARY-s3
*/
-class S3Test extends ObjectStoreTest {
+class S3Test extends ObjectStoreTestCase {
public function setUp(): void {
parent::setUp();
$s3 = $this->getInstance();
@@ -126,7 +126,7 @@ class S3Test extends ObjectStoreTest {
}
/** File size to upload in bytes */
- public function dataFileSizes() {
+ public static function dataFileSizes(): array {
return [
[1000000], [2000000], [5242879], [5242880], [5242881], [10000000]
];
diff --git a/tests/lib/Files/ObjectStore/SwiftTest.php b/tests/lib/Files/ObjectStore/SwiftTest.php
index 8a34d25e57b..9fb8c9bb68e 100644
--- a/tests/lib/Files/ObjectStore/SwiftTest.php
+++ b/tests/lib/Files/ObjectStore/SwiftTest.php
@@ -12,7 +12,7 @@ use OC\Files\ObjectStore\Swift;
/**
* @group PRIMARY-swift
*/
-class SwiftTest extends ObjectStoreTest {
+class SwiftTest extends ObjectStoreTestCase {
/**
* @return \OCP\Files\ObjectStore\IObjectStore
*/
diff --git a/tests/lib/Files/PathVerificationTest.php b/tests/lib/Files/PathVerificationTest.php
index fcbe0a6957f..d6dff445c0f 100644
--- a/tests/lib/Files/PathVerificationTest.php
+++ b/tests/lib/Files/PathVerificationTest.php
@@ -49,7 +49,7 @@ class PathVerificationTest extends \Test\TestCase {
$this->view->verifyPath('', $fileName);
}
- public function providesEmptyFiles() {
+ public static function providesEmptyFiles(): array {
return [
[''],
[' '],
@@ -66,7 +66,7 @@ class PathVerificationTest extends \Test\TestCase {
$this->view->verifyPath('', $fileName);
}
- public function providesDotFiles() {
+ public static function providesDotFiles(): array {
return [
['.'],
['..'],
@@ -95,7 +95,7 @@ class PathVerificationTest extends \Test\TestCase {
$this->view->verifyPath('', $fileName);
}
- public function providesAstralPlane() {
+ public static function providesAstralPlane(): array {
return [
// this is the monkey emoji - http://en.wikipedia.org/w/index.php?title=%F0%9F%90%B5&redirect=no
['🐵'],
@@ -117,7 +117,7 @@ class PathVerificationTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- public function providesValidPosixPaths() {
+ public static function providesValidPosixPaths(): array {
return [
['simple'],
['simple.txt'],
diff --git a/tests/lib/Files/Storage/Storage.php b/tests/lib/Files/Storage/Storage.php
index 36d70965848..c6f051fb7e1 100644
--- a/tests/lib/Files/Storage/Storage.php
+++ b/tests/lib/Files/Storage/Storage.php
@@ -108,7 +108,7 @@ abstract class Storage extends \Test\TestCase {
$this->assertEquals([], $content);
}
- public function fileNameProvider() {
+ public static function fileNameProvider(): array {
return [
['file.txt'],
[' file.txt'],
@@ -119,7 +119,7 @@ abstract class Storage extends \Test\TestCase {
];
}
- public function directoryProvider() {
+ public static function directoryProvider(): array {
return [
['folder'],
[' folder'],
@@ -130,7 +130,7 @@ abstract class Storage extends \Test\TestCase {
];
}
- public function loremFileProvider() {
+ public static function loremFileProvider(): array {
$root = \OC::$SERVERROOT . '/tests/data/';
return [
// small file
@@ -179,7 +179,7 @@ abstract class Storage extends \Test\TestCase {
}
- public function copyAndMoveProvider() {
+ public static function copyAndMoveProvider(): array {
return [
['/source.txt', '/target.txt'],
['/source.txt', '/target with space.txt'],
@@ -414,7 +414,7 @@ abstract class Storage extends \Test\TestCase {
$this->assertFalse($this->instance->file_exists('folder'));
}
- public function hashProvider() {
+ public static function hashProvider(): array {
return [
['Foobar', 'md5'],
['Foobar', 'sha1'],
diff --git a/tests/lib/Files/Storage/StoragesTest.php b/tests/lib/Files/Storage/StoragesTestCase.php
index 3f8198d331d..18fe78a93d1 100644
--- a/tests/lib/Files/Storage/StoragesTest.php
+++ b/tests/lib/Files/Storage/StoragesTestCase.php
@@ -9,7 +9,7 @@ namespace Test\Files\Storage;
use Test\TestCase;
-abstract class StoragesTest extends TestCase {
+abstract class StoragesTestCase extends TestCase {
/**
* @var \OC\Files\Storage\Storage
*/
diff --git a/tests/lib/Files/Storage/Wrapper/EncodingTest.php b/tests/lib/Files/Storage/Wrapper/EncodingTest.php
index d8b03a891c2..9d8a1e16145 100644
--- a/tests/lib/Files/Storage/Wrapper/EncodingTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncodingTest.php
@@ -29,25 +29,25 @@ class EncodingTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- public function directoryProvider() {
+ public static function directoryProvider(): array {
$a = parent::directoryProvider();
$a[] = [self::NFC_NAME];
return $a;
}
- public function fileNameProvider() {
+ public static function fileNameProvider(): array {
$a = parent::fileNameProvider();
$a[] = [self::NFD_NAME . '.txt'];
return $a;
}
- public function copyAndMoveProvider() {
+ public static function copyAndMoveProvider(): array {
$a = parent::copyAndMoveProvider();
$a[] = [self::NFD_NAME . '.txt', self::NFC_NAME . '-renamed.txt'];
return $a;
}
- public function accessNameProvider() {
+ public static function accessNameProvider(): array {
return [
[self::NFD_NAME],
[self::NFC_NAME],
@@ -110,7 +110,7 @@ class EncodingTest extends \Test\Files\Storage\Storage {
$this->assertEquals('nfc', $this->instance->file_get_contents(self::NFC_NAME));
}
- public function encodedDirectoriesProvider() {
+ public static function encodedDirectoriesProvider(): array {
return [
[self::NFD_NAME, self::NFC_NAME],
[self::NFD_NAME . '/' . self::NFD_NAME, self::NFC_NAME . '/' . self::NFC_NAME],
@@ -150,7 +150,7 @@ class EncodingTest extends \Test\Files\Storage\Storage {
$this->assertEquals('barbaric', $this->instance->file_get_contents('//' . self::NFC_NAME));
}
- public function sourceAndTargetDirectoryProvider() {
+ public static function sourceAndTargetDirectoryProvider(): array {
return [
[self::NFC_NAME . '1', self::NFC_NAME . '2'],
[self::NFD_NAME . '1', self::NFC_NAME . '2'],
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index bb3df36dec2..1c299fa989f 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -11,7 +11,6 @@ use Exception;
use OC;
use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
use OC\Encryption\File;
-use OC\Encryption\Update;
use OC\Encryption\Util;
use OC\Files\Cache\Cache;
use OC\Files\Cache\CacheEntry;
@@ -46,7 +45,6 @@ class EncryptionTest extends Storage {
private Util&MockObject $util;
private \OC\Encryption\Manager&MockObject $encryptionManager;
private IEncryptionModule&MockObject $encryptionModule;
- private Update&MockObject $update;
private Cache&MockObject $cache;
private LoggerInterface&MockObject $logger;
private File&MockObject $file;
@@ -62,9 +60,9 @@ class EncryptionTest extends Storage {
parent::setUp();
$mockModule = $this->buildMockModule();
- $this->encryptionManager = $this->getMockBuilder('\OC\Encryption\Manager')
+ $this->encryptionManager = $this->getMockBuilder(\OC\Encryption\Manager::class)
->disableOriginalConstructor()
- ->setMethods(['getEncryptionModule', 'isEnabled'])
+ ->onlyMethods(['getEncryptionModule', 'isEnabled'])
->getMock();
$this->encryptionManager->expects($this->any())
->method('getEncryptionModule')
@@ -78,8 +76,8 @@ class EncryptionTest extends Storage {
->disableOriginalConstructor()
->getMock();
- $this->util = $this->getMockBuilder('\OC\Encryption\Util')
- ->setMethods(['getUidAndFilename', 'isFile', 'isExcluded', 'stripPartialFileExtension'])
+ $this->util = $this->getMockBuilder(Util::class)
+ ->onlyMethods(['getUidAndFilename', 'isFile', 'isExcluded', 'stripPartialFileExtension'])
->setConstructorArgs([new View(), new Manager(
$this->config,
$this->createMock(ICacheFactory::class),
@@ -98,9 +96,9 @@ class EncryptionTest extends Storage {
return $path;
});
- $this->file = $this->getMockBuilder('\OC\Encryption\File')
+ $this->file = $this->getMockBuilder(File::class)
->disableOriginalConstructor()
- ->setMethods(['getAccessList'])
+ ->onlyMethods(['getAccessList'])
->getMock();
$this->file->expects($this->any())->method('getAccessList')->willReturn([]);
@@ -108,15 +106,11 @@ class EncryptionTest extends Storage {
$this->sourceStorage = new Temporary([]);
- $this->keyStore = $this->getMockBuilder('\OC\Encryption\Keys\Storage')
- ->disableOriginalConstructor()->getMock();
-
- $this->update = $this->getMockBuilder('\OC\Encryption\Update')
- ->disableOriginalConstructor()->getMock();
+ $this->keyStore = $this->createMock(\OC\Encryption\Keys\Storage::class);
- $this->mount = $this->getMockBuilder('\OC\Files\Mount\MountPoint')
+ $this->mount = $this->getMockBuilder(MountPoint::class)
->disableOriginalConstructor()
- ->setMethods(['getOption'])
+ ->onlyMethods(['getOption'])
->getMock();
$this->mount->expects($this->any())->method('getOption')->willReturnCallback(function ($option, $default) {
if ($option === 'encrypt' && $default === true) {
@@ -155,12 +149,11 @@ class EncryptionTest extends Storage {
$this->file,
null,
$this->keyStore,
- $this->update,
$this->mountManager,
$this->arrayCache
]
)
- ->setMethods(['getMetaData', 'getCache', 'getEncryptionModule'])
+ ->onlyMethods(['getMetaData', 'getCache', 'getEncryptionModule'])
->getMock();
$this->instance->expects($this->any())
@@ -181,7 +174,7 @@ class EncryptionTest extends Storage {
protected function buildMockModule(): IEncryptionModule&MockObject {
$this->encryptionModule = $this->getMockBuilder('\OCP\Encryption\IEncryptionModule')
->disableOriginalConstructor()
- ->setMethods(['getId', 'getDisplayName', 'begin', 'end', 'encrypt', 'decrypt', 'update', 'shouldEncrypt', 'getUnencryptedBlockSize', 'isReadable', 'encryptAll', 'prepareDecryptAll', 'isReadyForUser', 'needDetailedAccessList'])
+ ->onlyMethods(['getId', 'getDisplayName', 'begin', 'end', 'encrypt', 'decrypt', 'update', 'shouldEncrypt', 'getUnencryptedBlockSize', 'isReadable', 'encryptAll', 'prepareDecryptAll', 'isReadyForUser', 'needDetailedAccessList'])
->getMock();
$this->encryptionModule->expects($this->any())->method('getId')->willReturn('UNIT_TEST_MODULE');
@@ -237,12 +230,11 @@ class EncryptionTest extends Storage {
$this->file,
null,
$this->keyStore,
- $this->update,
$this->mountManager,
$this->arrayCache,
]
)
- ->setMethods(['getCache', 'verifyUnencryptedSize'])
+ ->onlyMethods(['getCache', 'verifyUnencryptedSize'])
->getMock();
if ($unencryptedSizeSet) {
@@ -285,7 +277,7 @@ class EncryptionTest extends Storage {
}
}
- public function dataTestGetMetaData() {
+ public static function dataTestGetMetaData(): array {
return [
['/test.txt', ['size' => 42, 'encrypted' => 2, 'encryptedVersion' => 2, 'fileid' => 1], true, true, 12, ['size' => 12, 'encrypted' => true, 'encryptedVersion' => 2]],
['/test.txt', null, true, true, 12, null],
@@ -316,12 +308,11 @@ class EncryptionTest extends Storage {
$this->file,
null,
$this->keyStore,
- $this->update,
$this->mountManager,
$this->arrayCache,
]
)
- ->setMethods(['getCache', 'verifyUnencryptedSize'])
+ ->onlyMethods(['getCache', 'verifyUnencryptedSize'])
->getMock();
$this->instance->expects($this->any())->method('getCache')->willReturn($cache);
@@ -361,12 +352,11 @@ class EncryptionTest extends Storage {
$this->file,
null,
$this->keyStore,
- $this->update,
$this->mountManager,
$this->arrayCache,
]
)
- ->setMethods(['fixUnencryptedSize'])
+ ->onlyMethods(['fixUnencryptedSize'])
->getMock();
$sourceStorage->expects($this->once())->method('filesize')->willReturn($encryptedSize);
@@ -389,7 +379,7 @@ class EncryptionTest extends Storage {
);
}
- public function dataTestVerifyUnencryptedSize() {
+ public static function dataTestVerifyUnencryptedSize(): array {
return [
[120, 80, false, 80],
[120, 120, false, 80],
@@ -444,7 +434,7 @@ class EncryptionTest extends Storage {
*
* @return array
*/
- public function dataTestCopyAndRename() {
+ public static function dataTestCopyAndRename(): array {
return [
['source', 'target', true, false, false],
['source', 'target', true, true, false],
@@ -491,7 +481,6 @@ class EncryptionTest extends Storage {
$this->file,
null,
$this->keyStore,
- $this->update,
$this->mountManager,
$this->arrayCache,
);
@@ -506,7 +495,7 @@ class EncryptionTest extends Storage {
$encryptionStorage->rmdir($path);
}
- public function dataTestRmdir() {
+ public static function dataTestRmdir(): array {
return [
['/file.txt', true, true, true],
['/file.txt', false, true, true],
@@ -541,7 +530,7 @@ class EncryptionTest extends Storage {
);
}
- public function dataTestCopyKeys() {
+ public static function dataTestCopyKeys(): array {
return [
[true, false],
[false, true],
@@ -598,12 +587,11 @@ class EncryptionTest extends Storage {
$this->file,
null,
$this->keyStore,
- $this->update,
$this->mountManager,
$this->arrayCache,
]
)
- ->setMethods(['getCache', 'readFirstBlock'])
+ ->onlyMethods(['getCache', 'readFirstBlock'])
->getMock();
$instance->method('getCache')->willReturn($cache);
@@ -629,7 +617,7 @@ class EncryptionTest extends Storage {
$this->invokePrivate($instance, 'getHeader', [$path]);
}
- public function dataTestGetHeader() {
+ public static function dataTestGetHeader(): array {
return [
['/foo/bar.txt', false, '/foo/bar.txt'],
['/foo/bar.txt.part', false, '/foo/bar.txt'],
@@ -646,7 +634,7 @@ class EncryptionTest extends Storage {
* @dataProvider dataTestGetHeaderAddLegacyModule
*/
public function testGetHeaderAddLegacyModule($header, $isEncrypted, $strippedPathExists, $expected): void {
- $sourceStorage = $this->getMockBuilder('\OC\Files\Storage\Storage')
+ $sourceStorage = $this->getMockBuilder(\OC\Files\Storage\Storage::class)
->disableOriginalConstructor()->getMock();
$sourceStorage->expects($this->once())
@@ -654,7 +642,7 @@ class EncryptionTest extends Storage {
->with('test.txt')
->willReturn($strippedPathExists);
- $util = $this->getMockBuilder('\OC\Encryption\Util')
+ $util = $this->getMockBuilder(Util::class)
->onlyMethods(['stripPartialFileExtension', 'parseRawHeader'])
->setConstructorArgs([new View(), new Manager(
$this->config,
@@ -669,8 +657,7 @@ class EncryptionTest extends Storage {
return $path;
});
- $cache = $this->getMockBuilder('\OC\Files\Cache\Cache')
- ->disableOriginalConstructor()->getMock();
+ $cache = $this->createMock(Cache::class);
$cache->expects($this->any())
->method('get')
->willReturnCallback(function ($path) use ($isEncrypted) {
@@ -692,12 +679,11 @@ class EncryptionTest extends Storage {
$this->file,
null,
$this->keyStore,
- $this->update,
$this->mountManager,
$this->arrayCache,
]
)
- ->setMethods(['readFirstBlock', 'getCache'])
+ ->onlyMethods(['readFirstBlock', 'getCache'])
->getMock();
$instance->method('readFirstBlock')->willReturn('');
@@ -713,7 +699,7 @@ class EncryptionTest extends Storage {
}
}
- public function dataTestGetHeaderAddLegacyModule() {
+ public static function dataTestGetHeaderAddLegacyModule(): array {
return [
[['cipher' => 'AES-128'], true, true, ['cipher' => 'AES-128', Util::HEADER_ENCRYPTION_MODULE_KEY => 'OC_DEFAULT_MODULE']],
[[], true, false, []],
@@ -722,7 +708,7 @@ class EncryptionTest extends Storage {
];
}
- public function dataCopyBetweenStorage() {
+ public static function dataCopyBetweenStorage(): array {
return [
[true, true, true],
[true, false, false],
@@ -867,12 +853,11 @@ class EncryptionTest extends Storage {
$this->file,
null,
$this->keyStore,
- $this->update,
$this->mountManager,
$this->arrayCache
]
)
- ->setMethods(['updateUnencryptedSize', 'getCache'])
+ ->onlyMethods(['updateUnencryptedSize', 'getCache'])
->getMock();
$targetStorage->expects($this->once())->method('copyFromStorage')
@@ -914,7 +899,7 @@ class EncryptionTest extends Storage {
$this->assertSame($copyResult, $result);
}
- public function dataTestCopyBetweenStorageVersions() {
+ public static function dataTestCopyBetweenStorageVersions(): array {
return [
['/files/foo.txt', '/files_versions/foo.txt.768743', true, true],
['/files/foo.txt', '/files_versions/foo.txt.768743', true, false],
@@ -939,7 +924,7 @@ class EncryptionTest extends Storage {
);
}
- public function dataTestIsVersion() {
+ public static function dataTestIsVersion(): array {
return [
['files_versions/foo', true],
['/files_versions/foo', true],
@@ -968,7 +953,6 @@ class EncryptionTest extends Storage {
$util = $this->createMock(Util::class);
$fileHelper = $this->createMock(IFile::class);
$keyStorage = $this->createMock(IStorage::class);
- $update = $this->createMock(Update::class);
$mountManager = $this->createMock(\OC\Files\Mount\Manager::class);
$mount = $this->createMock(IMountPoint::class);
$arrayCache = $this->createMock(ArrayCache::class);
@@ -986,12 +970,11 @@ class EncryptionTest extends Storage {
$fileHelper,
null,
$keyStorage,
- $update,
$mountManager,
$arrayCache
]
)
- ->setMethods(['getFullPath', 'getEncryptionModule'])
+ ->onlyMethods(['getFullPath', 'getEncryptionModule'])
->getMock();
if ($encryptionModule === true) {
@@ -1033,7 +1016,7 @@ class EncryptionTest extends Storage {
$this->assertSame($expected, $result);
}
- public function dataTestShouldEncrypt() {
+ public static function dataTestShouldEncrypt(): array {
return [
[false, false, false, false],
[true, false, false, false],
diff --git a/tests/lib/Files/Storage/Wrapper/QuotaTest.php b/tests/lib/Files/Storage/Wrapper/QuotaTest.php
index f07e6021e4e..aebae9b3c62 100644
--- a/tests/lib/Files/Storage/Wrapper/QuotaTest.php
+++ b/tests/lib/Files/Storage/Wrapper/QuotaTest.php
@@ -76,7 +76,7 @@ class QuotaTest extends \Test\Files\Storage\Storage {
public function testFreeSpaceWithUnknownDiskSpace(): void {
$storage = $this->getMockBuilder(Local::class)
- ->setMethods(['free_space'])
+ ->onlyMethods(['free_space'])
->setConstructorArgs([['datadir' => $this->tmpDir]])
->getMock();
$storage->expects($this->any())
@@ -132,7 +132,7 @@ class QuotaTest extends \Test\Files\Storage\Storage {
public function testReturnFalseWhenFopenFailed(): void {
$failStorage = $this->getMockBuilder(Local::class)
- ->setMethods(['fopen'])
+ ->onlyMethods(['fopen'])
->setConstructorArgs([['datadir' => $this->tmpDir]])
->getMock();
$failStorage->expects($this->any())
diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php
index 36e72ea764a..c676358ad71 100644
--- a/tests/lib/Files/Stream/EncryptionTest.php
+++ b/tests/lib/Files/Stream/EncryptionTest.php
@@ -9,8 +9,12 @@ declare(strict_types=1);
*/
namespace Test\Files\Stream;
+use OC\Encryption\File;
+use OC\Encryption\Util;
use OC\Files\Cache\CacheEntry;
+use OC\Files\Storage\Storage;
use OC\Files\Storage\Wrapper\Wrapper;
+use OC\Files\Stream\Encryption;
use OC\Files\View;
use OC\Memcache\ArrayCache;
use OCP\Encryption\IEncryptionModule;
@@ -53,11 +57,11 @@ class EncryptionTest extends \Test\TestCase {
->getMock();
$file = $this->getMockBuilder('\OC\Encryption\File')
->disableOriginalConstructor()
- ->setMethods(['getAccessList'])
+ ->onlyMethods(['getAccessList'])
->getMock();
$file->expects($this->any())->method('getAccessList')->willReturn([]);
$util = $this->getMockBuilder('\OC\Encryption\Util')
- ->setMethods(['getUidAndFilename'])
+ ->onlyMethods(['getUidAndFilename'])
->setConstructorArgs([new View(), new \OC\User\Manager(
$config,
$this->createMock(ICacheFactory::class),
@@ -111,20 +115,17 @@ class EncryptionTest extends \Test\TestCase {
$expectedReadOnly,
): void {
// build mocks
- $encryptionModuleMock = $this->getMockBuilder('\OCP\Encryption\IEncryptionModule')
- ->disableOriginalConstructor()->getMock();
+ $encryptionModuleMock = $this->createMock(IEncryptionModule::class);
$encryptionModuleMock->expects($this->any())->method('needDetailedAccessList')->willReturn(!$isMasterKeyUsed);
$encryptionModuleMock->expects($this->once())
->method('getUnencryptedBlockSize')->willReturn(99);
$encryptionModuleMock->expects($this->once())
->method('begin')->willReturn([]);
- $storageMock = $this->getMockBuilder('\OC\Files\Storage\Storage')
- ->disableOriginalConstructor()->getMock();
+ $storageMock = $this->createMock(Storage::class);
$storageMock->expects($this->once())->method('file_exists')->willReturn($fileExists);
- $fileMock = $this->getMockBuilder('\OC\Encryption\File')
- ->disableOriginalConstructor()->getMock();
+ $fileMock = $this->createMock(File::class);
if ($isMasterKeyUsed) {
$fileMock->expects($this->never())->method('getAccessList');
} else {
@@ -134,18 +135,20 @@ class EncryptionTest extends \Test\TestCase {
return [];
});
}
- $utilMock = $this->getMockBuilder('\OC\Encryption\Util')
+ $utilMock = $this->getMockBuilder(Util::class)
->disableOriginalConstructor()->getMock();
$utilMock->expects($this->any())
->method('getHeaderSize')
->willReturn(8192);
// get a instance of the stream wrapper
- $streamWrapper = $this->getMockBuilder('\OC\Files\Stream\Encryption')
- ->setMethods(['loadContext', 'writeHeader', 'skipHeader'])->disableOriginalConstructor()->getMock();
+ $streamWrapper = $this->getMockBuilder(Encryption::class)
+ ->onlyMethods(['loadContext', 'writeHeader', 'skipHeader'])
+ ->disableOriginalConstructor()
+ ->getMock();
// set internal properties of the stream wrapper
- $stream = new \ReflectionClass('\OC\Files\Stream\Encryption');
+ $stream = new \ReflectionClass(Encryption::class);
$encryptionModule = $stream->getProperty('encryptionModule');
$encryptionModule->setAccessible(true);
$encryptionModule->setValue($streamWrapper, $encryptionModuleMock);
@@ -195,7 +198,7 @@ class EncryptionTest extends \Test\TestCase {
$readOnly->setAccessible(false);
}
- public function dataProviderStreamOpen() {
+ public static function dataProviderStreamOpen(): array {
return [
[false, 'r', '/foo/bar/test.txt', true, '/foo/bar/test.txt', null, null, true],
[false, 'r', '/foo/bar/test.txt', false, '/foo/bar', null, null, true],
@@ -266,7 +269,7 @@ class EncryptionTest extends \Test\TestCase {
unlink($fileName);
}
- public function dataFilesProvider() {
+ public static function dataFilesProvider(): array {
return [
['lorem-big.txt'],
['block-aligned.txt'],
@@ -315,9 +318,12 @@ class EncryptionTest extends \Test\TestCase {
* @dataProvider dataFilesProvider
*/
public function testWriteToNonSeekableStorage($testFile): void {
- $wrapper = $this->getMockBuilder('\OC\Files\Stream\Encryption')
- ->setMethods(['parentSeekStream'])->getMock();
- $wrapper->expects($this->any())->method('parentSeekStream')->willReturn(false);
+ $wrapper = $this->getMockBuilder(Encryption::class)
+ ->onlyMethods(['parentStreamSeek'])
+ ->getMock();
+ $wrapper->expects($this->any())
+ ->method('parentStreamSeek')
+ ->willReturn(false);
$expectedData = file_get_contents(\OC::$SERVERROOT . '/tests/data/' . $testFile);
// write it
@@ -351,9 +357,9 @@ class EncryptionTest extends \Test\TestCase {
}
protected function buildMockModule(): IEncryptionModule&MockObject {
- $encryptionModule = $this->getMockBuilder('\OCP\Encryption\IEncryptionModule')
+ $encryptionModule = $this->getMockBuilder(IEncryptionModule::class)
->disableOriginalConstructor()
- ->setMethods(['getId', 'getDisplayName', 'begin', 'end', 'encrypt', 'decrypt', 'update', 'shouldEncrypt', 'getUnencryptedBlockSize', 'isReadable', 'encryptAll', 'prepareDecryptAll', 'isReadyForUser', 'needDetailedAccessList'])
+ ->onlyMethods(['getId', 'getDisplayName', 'begin', 'end', 'encrypt', 'decrypt', 'update', 'shouldEncrypt', 'getUnencryptedBlockSize', 'isReadable', 'encryptAll', 'prepareDecryptAll', 'isReadyForUser', 'needDetailedAccessList'])
->getMock();
$encryptionModule->expects($this->any())->method('getId')->willReturn('UNIT_TEST_MODULE');
diff --git a/tests/lib/Files/Stream/HashWrapperTest.php b/tests/lib/Files/Stream/HashWrapperTest.php
index ee50fe3b13a..1e9bbd8f289 100644
--- a/tests/lib/Files/Stream/HashWrapperTest.php
+++ b/tests/lib/Files/Stream/HashWrapperTest.php
@@ -31,7 +31,7 @@ class HashWrapperTest extends TestCase {
stream_get_contents($wrapper);
}
- public function hashProvider() {
+ public static function hashProvider(): array {
return [
['foo', 'md5', 'acbd18db4cc2f85cedef654fccc4a4d8'],
['foo', 'sha1', '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33'],
diff --git a/tests/lib/Files/Utils/ScannerTest.php b/tests/lib/Files/Utils/ScannerTest.php
index f66bb72e865..51089e5560c 100644
--- a/tests/lib/Files/Utils/ScannerTest.php
+++ b/tests/lib/Files/Utils/ScannerTest.php
@@ -138,10 +138,7 @@ class ScannerTest extends \Test\TestCase {
$this->assertTrue($cache->inCache('folder/bar.txt'));
}
- /**
- * @return array
- */
- public function invalidPathProvider() {
+ public static function invalidPathProvider(): array {
return [
[
'../',
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index 53e5855d0e9..b790c9ed6e8 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -25,6 +25,7 @@ use OCP\Files\ForbiddenException;
use OCP\Files\GenericFileException;
use OCP\Files\Mount\IMountManager;
use OCP\Files\Storage\IStorage;
+use OCP\Files\Storage\IStorageFactory;
use OCP\IDBConnection;
use OCP\IUserManager;
use OCP\Lock\ILockingProvider;
@@ -518,10 +519,10 @@ class ViewTest extends \Test\TestCase {
}
public function moveBetweenStorages($storage1, $storage2) {
- Filesystem::mount($storage1, [], '/');
- Filesystem::mount($storage2, [], '/substorage');
+ Filesystem::mount($storage1, [], '/' . $this->user . '/');
+ Filesystem::mount($storage2, [], '/' . $this->user . '/substorage');
- $rootView = new View('');
+ $rootView = new View('/' . $this->user);
$rootView->rename('foo.txt', 'substorage/folder/foo.txt');
$this->assertFalse($rootView->file_exists('foo.txt'));
$this->assertTrue($rootView->file_exists('substorage/folder/foo.txt'));
@@ -941,14 +942,16 @@ class ViewTest extends \Test\TestCase {
$storage = new Temporary([]);
$scanner = $storage->getScanner();
Filesystem::mount($storage, [], '/test/');
- $storage->file_put_contents('test.part', 'foobar');
+ $sizeWritten = $storage->file_put_contents('test.part', 'foobar');
$scanner->scan('');
$view = new View('/test');
$info = $view->getFileInfo('test.part');
$this->assertInstanceOf('\OCP\Files\FileInfo', $info);
$this->assertNull($info->getId());
+ $this->assertEquals(6, $sizeWritten);
$this->assertEquals(6, $info->getSize());
+ $this->assertEquals('foobar', $view->file_get_contents('test.part'));
}
public static function absolutePathProvider(): array {
@@ -1947,6 +1950,8 @@ class ViewTest extends \Test\TestCase {
/* Pause trash to avoid the trashbin intercepting rmdir and unlink calls */
Server::get(ITrashManager::class)->pauseTrash();
+ /* Same thing with encryption wrapper */
+ Server::get(IStorageFactory::class)->removeStorageWrapper('oc_encryption');
Filesystem::mount($storage, [], $this->user . '/');
@@ -2097,6 +2102,8 @@ class ViewTest extends \Test\TestCase {
/* Pause trash to avoid the trashbin intercepting rmdir and unlink calls */
Server::get(ITrashManager::class)->pauseTrash();
+ /* Same thing with encryption wrapper */
+ Server::get(IStorageFactory::class)->removeStorageWrapper('oc_encryption');
Filesystem::mount($storage, [], $this->user . '/');
@@ -2238,6 +2245,9 @@ class ViewTest extends \Test\TestCase {
$sourcePath = 'original.txt';
$targetPath = 'target.txt';
+ /* Disable encryption wrapper to avoid it intercepting mocked call */
+ Server::get(IStorageFactory::class)->removeStorageWrapper('oc_encryption');
+
Filesystem::mount($storage, [], $this->user . '/');
$storage->mkdir('files');
$view->file_put_contents($sourcePath, 'meh');
@@ -2291,6 +2301,9 @@ class ViewTest extends \Test\TestCase {
$sourcePath = 'original.txt';
$targetPath = 'target.txt';
+ /* Disable encryption wrapper to avoid it intercepting mocked call */
+ Server::get(IStorageFactory::class)->removeStorageWrapper('oc_encryption');
+
Filesystem::mount($storage, [], $this->user . '/');
$storage->mkdir('files');
$view->file_put_contents($sourcePath, 'meh');
@@ -2427,6 +2440,9 @@ class ViewTest extends \Test\TestCase {
$sourcePath = 'original.txt';
$targetPath = 'substorage/target.txt';
+ /* Disable encryption wrapper to avoid it intercepting mocked call */
+ Server::get(IStorageFactory::class)->removeStorageWrapper('oc_encryption');
+
Filesystem::mount($storage, [], $this->user . '/');
Filesystem::mount($storage2, [], $this->user . '/files/substorage');
$storage->mkdir('files');
diff --git a/tests/lib/GlobalScale/ConfigTest.php b/tests/lib/GlobalScale/ConfigTest.php
index aa001268ecd..b6c77c9ddf1 100644
--- a/tests/lib/GlobalScale/ConfigTest.php
+++ b/tests/lib/GlobalScale/ConfigTest.php
@@ -28,7 +28,7 @@ class ConfigTest extends TestCase {
if (!empty($mockMethods)) {
return $this->getMockBuilder(Config::class)
->setConstructorArgs([$this->config])
- ->setMethods($mockMethods)
+ ->onlyMethods($mockMethods)
->getMock();
}
@@ -64,7 +64,7 @@ class ConfigTest extends TestCase {
$this->assertSame($expected, $gsConfig->onlyInternalFederation());
}
- public function dataTestOnlyInternalFederation() {
+ public static function dataTestOnlyInternalFederation(): array {
return [
[true, 'global', false],
[true, 'internal', true],
diff --git a/tests/lib/Group/ManagerTest.php b/tests/lib/Group/ManagerTest.php
index 0f8d7a5ecc3..e52e0733501 100644
--- a/tests/lib/Group/ManagerTest.php
+++ b/tests/lib/Group/ManagerTest.php
@@ -12,6 +12,11 @@ use OC\Group\Database;
use OC\User\Manager;
use OC\User\User;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Group\Backend\ABackend;
+use OCP\Group\Backend\IAddToGroupBackend;
+use OCP\Group\Backend\ICreateGroupBackend;
+use OCP\Group\Backend\IGroupDetailsBackend;
+use OCP\Group\Backend\IRemoveFromGroupBackend;
use OCP\Group\Backend\ISearchableGroupBackend;
use OCP\GroupInterface;
use OCP\ICacheFactory;
@@ -21,7 +26,8 @@ use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
-interface ISearchableGroupInterface extends ISearchableGroupBackend, GroupInterface {
+abstract class TestBackend extends ABackend implements ISearchableGroupBackend, IAddToGroupBackend, ICreateGroupBackend, IGroupDetailsBackend, IRemoveFromGroupBackend, GroupInterface {
+
}
class ManagerTest extends TestCase {
@@ -74,9 +80,9 @@ class ManagerTest extends TestCase {
}
// need to declare it this way due to optional methods
// thanks to the implementsActions logic
- $backend = $this->getMockBuilder(ISearchableGroupInterface::class)
+ $backend = $this->getMockBuilder(TestBackend::class)
->disableOriginalConstructor()
- ->setMethods([
+ ->onlyMethods([
'getGroupDetails',
'implementsActions',
'getUserGroups',
@@ -283,9 +289,10 @@ class ManagerTest extends TestCase {
->with('1')
->willReturn(['group1']);
$backend->expects($this->once())
- ->method('groupExists')
- ->with('group1')
- ->willReturn(true);
+ ->method('getGroupDetails')
+ ->willReturnMap([
+ ['group1', ['displayName' => 'group1']],
+ ]);
$manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache, $this->remoteIpAddress);
$manager->addBackend($backend);
@@ -306,8 +313,11 @@ class ManagerTest extends TestCase {
->with('1')
->willReturn(['group1']);
$backend1->expects($this->any())
- ->method('groupExists')
- ->willReturn(true);
+ ->method('getGroupDetails')
+ ->willReturnMap([
+ ['group1', ['displayName' => 'group1']],
+ ['group12', []],
+ ]);
/**
* @var \PHPUnit\Framework\MockObject\MockObject | \OC\Group\Backend $backend2
@@ -318,8 +328,11 @@ class ManagerTest extends TestCase {
->with('1')
->willReturn(['group12', 'group1']);
$backend2->expects($this->any())
- ->method('groupExists')
- ->willReturn(true);
+ ->method('getGroupDetails')
+ ->willReturnMap([
+ ['group12', ['displayName' => 'group12']],
+ ['group1', ['displayName' => 'group1']],
+ ]);
$manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache, $this->remoteIpAddress);
$manager->addBackend($backend1);
@@ -335,7 +348,7 @@ class ManagerTest extends TestCase {
public function testSearchMultipleBackendsLimitAndOffset(): void {
/**
- * @var \PHPUnit\Framework\MockObject\MockObject | \OC\Group\Backend $backend1
+ * @var \PHPUnit\Framework\MockObject\MockObject|\OC\Group\Backend $backend1
*/
$backend1 = $this->getTestBackend();
$backend1->expects($this->once())
@@ -343,11 +356,16 @@ class ManagerTest extends TestCase {
->with('1', 2, 1)
->willReturn(['group1']);
$backend1->expects($this->any())
- ->method('groupExists')
- ->willReturn(true);
+ ->method('getGroupDetails')
+ ->willReturnMap([
+ [1, []],
+ [2, []],
+ ['group1', ['displayName' => 'group1']],
+ ['group12', []],
+ ]);
/**
- * @var \PHPUnit\Framework\MockObject\MockObject | \OC\Group\Backend $backend2
+ * @var \PHPUnit\Framework\MockObject\MockObject|\OC\Group\Backend $backend2
*/
$backend2 = $this->getTestBackend();
$backend2->expects($this->once())
@@ -355,8 +373,13 @@ class ManagerTest extends TestCase {
->with('1', 2, 1)
->willReturn(['group12']);
$backend2->expects($this->any())
- ->method('groupExists')
- ->willReturn(true);
+ ->method('getGroupDetails')
+ ->willReturnMap([
+ [1, []],
+ [2, []],
+ ['group1', []],
+ ['group12', ['displayName' => 'group12']],
+ ]);
$manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache, $this->remoteIpAddress);
$manager->addBackend($backend1);
diff --git a/tests/lib/HelperStorageTest.php b/tests/lib/HelperStorageTest.php
index 455bd288351..e4e877ab2a8 100644
--- a/tests/lib/HelperStorageTest.php
+++ b/tests/lib/HelperStorageTest.php
@@ -71,13 +71,13 @@ class HelperStorageTest extends \Test\TestCase {
*/
private function getStorageMock($freeSpace = 12) {
$this->storageMock = $this->getMockBuilder(Temporary::class)
- ->setMethods(['free_space'])
+ ->onlyMethods(['free_space'])
->setConstructorArgs([[]])
->getMock();
$this->storageMock->expects($this->once())
->method('free_space')
- ->willReturn(12);
+ ->willReturn($freeSpace);
return $this->storageMock;
}
diff --git a/tests/lib/ImageTest.php b/tests/lib/ImageTest.php
index 5de5435335a..494f616ac9c 100644
--- a/tests/lib/ImageTest.php
+++ b/tests/lib/ImageTest.php
@@ -271,7 +271,7 @@ class ImageTest extends \Test\TestCase {
$this->assertEquals(15, $img->height());
}
- public static function sampleProvider() {
+ public static function sampleProvider(): array {
return [
['testimage.png', [200, 100], [100, 100]],
['testimage.jpg', [840, 840], [840, 525]],
@@ -294,7 +294,7 @@ class ImageTest extends \Test\TestCase {
$this->assertEquals($expected[1], $img->height());
}
- public static function sampleFilenamesProvider() {
+ public static function sampleFilenamesProvider(): array {
return [
['testimage.png'],
['testimage.jpg'],
@@ -328,7 +328,7 @@ class ImageTest extends \Test\TestCase {
);
}
- public static function largeSampleProvider() {
+ public static function largeSampleProvider(): array {
return [
['testimage.png', [200, 100], [100, 100]],
['testimage.jpg', [840, 840], [840, 525]],
@@ -351,7 +351,7 @@ class ImageTest extends \Test\TestCase {
$this->assertEquals($expected[1], $img->height());
}
- public function convertDataProvider() {
+ public static function convertDataProvider(): array {
return [
[ 'image/gif'],
[ 'image/jpeg'],
diff --git a/tests/lib/InfoXmlTest.php b/tests/lib/InfoXmlTest.php
index e579a4b4efd..ffc367d4471 100644
--- a/tests/lib/InfoXmlTest.php
+++ b/tests/lib/InfoXmlTest.php
@@ -23,7 +23,7 @@ class InfoXmlTest extends TestCase {
$this->appManager = Server::get(IAppManager::class);
}
- public function dataApps() {
+ public static function dataApps(): array {
return [
['admin_audit'],
['comments'],
diff --git a/tests/lib/InitialStateServiceTest.php b/tests/lib/InitialStateServiceTest.php
index f58d54cb26b..5e0f7c7b55e 100644
--- a/tests/lib/InitialStateServiceTest.php
+++ b/tests/lib/InitialStateServiceTest.php
@@ -36,7 +36,7 @@ class InitialStateServiceTest extends TestCase {
);
}
- public function staticData(): array {
+ public static function staticData(): array {
return [
['string'],
[23],
diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php
index d27ca6e2159..9e77cb6a4fc 100644
--- a/tests/lib/InstallerTest.php
+++ b/tests/lib/InstallerTest.php
@@ -111,7 +111,7 @@ class InstallerTest extends TestCase {
$installer->removeApp(self::$appid);
}
- public function updateArrayProvider() {
+ public static function updateArrayProvider(): array {
return [
// Update available
[
diff --git a/tests/lib/IntegrityCheck/CheckerTest.php b/tests/lib/IntegrityCheck/CheckerTest.php
index c5a4f255397..8414a531464 100644
--- a/tests/lib/IntegrityCheck/CheckerTest.php
+++ b/tests/lib/IntegrityCheck/CheckerTest.php
@@ -713,7 +713,9 @@ class CheckerTest extends TestCase {
*/
public function testVerifyCoreSignatureWithModifiedMimetypelistSignatureData(): void {
$shippedMimetypeAliases = (array)json_decode(file_get_contents(\OC::$SERVERROOT . '/resources/config/mimetypealiases.dist.json'));
+ $shippedMimetypeNames = (array)json_decode(file_get_contents(\OC::$SERVERROOT . '/resources/config/mimetypenames.dist.json'));
$allAliases = array_merge($shippedMimetypeAliases, ['my-custom/mimetype' => 'custom']);
+ $allMimetypeNames = array_merge($shippedMimetypeNames, ['my-custom/mimetype' => 'Custom Document']);
$this->mimeTypeDetector
->method('getOnlyDefaultAliases')
@@ -723,9 +725,14 @@ class CheckerTest extends TestCase {
->method('getAllAliases')
->willReturn($allAliases);
+ $this->mimeTypeDetector
+ ->method('getAllNamings')
+ ->willReturn($allMimetypeNames);
+
$oldMimetypeList = new GenerateMimetypeFileBuilder();
$all = $this->mimeTypeDetector->getAllAliases();
- $newFile = $oldMimetypeList->generateFile($all);
+ $namings = $this->mimeTypeDetector->getAllNamings();
+ $newFile = $oldMimetypeList->generateFile($all, $namings);
// When updating the mimetype list the test assets need to be updated as well
// 1. Update core/js/mimetypelist.js with the new generated js by running the test with the next line uncommented:
diff --git a/tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php b/tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php
index 14cc8851178..1d0b3e4f24d 100644
--- a/tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php
+++ b/tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php
@@ -17,11 +17,11 @@ class ExcludeFileByNameFilterIteratorTest extends TestCase {
parent::setUp();
$this->filter = $this->getMockBuilder(ExcludeFileByNameFilterIterator::class)
->disableOriginalConstructor()
- ->setMethods(['current'])
+ ->onlyMethods(['current'])
->getMock();
}
- public function fileNameProvider(): array {
+ public static function fileNameProvider(): array {
return [
['a file', true],
['Thumbs.db', false],
@@ -42,7 +42,7 @@ class ExcludeFileByNameFilterIteratorTest extends TestCase {
public function testAcceptForFiles($fileName, $expectedResult): void {
$iteratorMock = $this->getMockBuilder(\RecursiveDirectoryIterator::class)
->disableOriginalConstructor()
- ->setMethods(['getFilename', 'isDir'])
+ ->onlyMethods(['getFilename', 'isDir'])
->getMock();
$iteratorMock->method('getFilename')
@@ -64,7 +64,7 @@ class ExcludeFileByNameFilterIteratorTest extends TestCase {
public function testAcceptForDirs($fileName, $expectedResult): void {
$iteratorMock = $this->getMockBuilder(\RecursiveDirectoryIterator::class)
->disableOriginalConstructor()
- ->setMethods(['getFilename', 'isDir'])
+ ->onlyMethods(['getFilename', 'isDir'])
->getMock();
$iteratorMock->method('getFilename')
diff --git a/tests/lib/L10N/L10nTest.php b/tests/lib/L10N/L10nTest.php
index 32b81cf06a7..a95a1241f4b 100644
--- a/tests/lib/L10N/L10nTest.php
+++ b/tests/lib/L10N/L10nTest.php
@@ -96,7 +96,7 @@ class L10nTest extends TestCase {
$this->assertEquals('5 Dateien', (string)$l->n('%n file', '%n files', 5));
}
- public function dataPlaceholders(): array {
+ public static function dataPlaceholders(): array {
return [
['Ordered placeholders one %s two %s', 'Placeholder one 1 two 2'],
['Reordered placeholders one %s two %s', 'Placeholder two 2 one 1'],
@@ -117,7 +117,7 @@ class L10nTest extends TestCase {
$this->assertEquals($expected, $l->t($string, ['1', '2']));
}
- public function localizationData() {
+ public static function localizationData(): array {
return [
// timestamp as string
["February 13, 2009, 11:31:30\xE2\x80\xAFPM UTC", 'en', 'en_US', 'datetime', '1234567890'],
@@ -161,7 +161,7 @@ class L10nTest extends TestCase {
$this->assertSame($expectedDate, $l->l($type, $value));
}
- public function firstDayData() {
+ public static function firstDayData(): array {
return [
[1, 'de', 'de_DE'],
[0, 'en', 'en_US'],
@@ -179,7 +179,7 @@ class L10nTest extends TestCase {
$this->assertSame($expected, $l->l('firstday', 'firstday'));
}
- public function jsDateData() {
+ public static function jsDateData(): array {
return [
['dd.MM.yy', 'de', 'de_DE'],
['M/d/yy', 'en', 'en_US'],
@@ -224,10 +224,7 @@ class L10nTest extends TestCase {
);
}
- /**
- * @return array
- */
- public function findLanguageFromLocaleData(): array {
+ public static function findLanguageFromLocaleData(): array {
return [
'en_US' => ['en_US', 'en'],
'en_UK' => ['en_UK', 'en'],
diff --git a/tests/lib/L10N/LanguageIteratorTest.php b/tests/lib/L10N/LanguageIteratorTest.php
index 79998c36354..e328941e35d 100644
--- a/tests/lib/L10N/LanguageIteratorTest.php
+++ b/tests/lib/L10N/LanguageIteratorTest.php
@@ -28,7 +28,7 @@ class LanguageIteratorTest extends TestCase {
$this->iterator = new LanguageIterator($this->user, $this->config);
}
- public function languageSettingsProvider() {
+ public static function languageSettingsProvider(): array {
return [
// all language settings set
[ 'de_DE', 'es_CU', 'zh_TW', ['de_DE', 'de', 'es_CU', 'es', 'zh_TW', 'zh', 'en']],
diff --git a/tests/lib/LargeFileHelperGetFileSizeTest.php b/tests/lib/LargeFileHelperGetFileSizeTest.php
index 247886fee6a..7f6604bdb35 100644
--- a/tests/lib/LargeFileHelperGetFileSizeTest.php
+++ b/tests/lib/LargeFileHelperGetFileSizeTest.php
@@ -26,7 +26,7 @@ class LargeFileHelperGetFileSizeTest extends TestCase {
$this->helper = new \OC\LargeFileHelper();
}
- public function dataFileNameProvider() {
+ public static function dataFileNameProvider(): array {
$path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR;
return [
diff --git a/tests/lib/LegacyHelperTest.php b/tests/lib/LegacyHelperTest.php
index ea359d4e50c..15af5ca06e8 100644
--- a/tests/lib/LegacyHelperTest.php
+++ b/tests/lib/LegacyHelperTest.php
@@ -31,7 +31,7 @@ class LegacyHelperTest extends \Test\TestCase {
$this->assertEquals($expected, $result);
}
- public function humanFileSizeProvider() {
+ public static function humanFileSizeProvider(): array {
return [
['0 B', 0],
['1 KB', 1024],
@@ -51,7 +51,7 @@ class LegacyHelperTest extends \Test\TestCase {
$this->assertEquals($expected, $result);
}
- public function providesComputerFileSize() {
+ public static function providesComputerFileSize(): array {
return [
[0.0, '0 B'],
[1024.0, '1 KB'],
@@ -110,95 +110,87 @@ class LegacyHelperTest extends \Test\TestCase {
$viewMock = $this->createMock(View::class);
$viewMock->expects($this->exactly(2))
->method('file_exists')
- ->withConsecutive(
+ ->willReturnMap([
// Conflict on filename.ext
- ['dir/filename.ext'],
- ['dir/filename (2).ext'],
- )
- ->will($this->onConsecutiveCalls(true, false));
+ ['dir/filename.ext', true],
+ ['dir/filename (2).ext', false],
+ ]);
$this->assertEquals('dir/filename (2).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename.ext', $viewMock));
$viewMock = $this->createMock(View::class);
$viewMock->expects($this->exactly(3))
->method('file_exists')
- ->withConsecutive(
- ['dir/filename.ext'],
- ['dir/filename (2).ext'],
- ['dir/filename (3).ext'],
- )
- ->will($this->onConsecutiveCalls(true, true, false));
+ ->willReturnMap([
+ // Conflict on filename.ext
+ ['dir/filename.ext', true],
+ ['dir/filename (2).ext', true],
+ ['dir/filename (3).ext', false],
+ ]);
$this->assertEquals('dir/filename (3).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename.ext', $viewMock));
$viewMock = $this->createMock(View::class);
$viewMock->expects($this->exactly(2))
->method('file_exists')
- ->withConsecutive(
- ['dir/filename (1).ext'],
- ['dir/filename (2).ext'],
- )
- ->will($this->onConsecutiveCalls(true, false));
+ ->willReturnMap([
+ ['dir/filename (1).ext', true],
+ ['dir/filename (2).ext', false],
+ ]);
$this->assertEquals('dir/filename (2).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename (1).ext', $viewMock));
$viewMock = $this->createMock(View::class);
$viewMock->expects($this->exactly(2))
->method('file_exists')
- ->withConsecutive(
- ['dir/filename (2).ext'],
- ['dir/filename (3).ext'],
- )
- ->will($this->onConsecutiveCalls(true, false));
+ ->willReturnMap([
+ ['dir/filename (2).ext', true],
+ ['dir/filename (3).ext', false],
+ ]);
$this->assertEquals('dir/filename (3).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename (2).ext', $viewMock));
$viewMock = $this->createMock(View::class);
$viewMock->expects($this->exactly(3))
->method('file_exists')
- ->withConsecutive(
- ['dir/filename (2).ext'],
- ['dir/filename (3).ext'],
- ['dir/filename (4).ext'],
- )
- ->will($this->onConsecutiveCalls(true, true, false));
+ ->willReturnMap([
+ ['dir/filename (2).ext', true],
+ ['dir/filename (3).ext', true],
+ ['dir/filename (4).ext', false],
+ ]);
$this->assertEquals('dir/filename (4).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename (2).ext', $viewMock));
$viewMock = $this->createMock(View::class);
$viewMock->expects($this->exactly(2))
->method('file_exists')
- ->withConsecutive(
- ['dir/filename(1).ext'],
- ['dir/filename(2).ext'],
- )
- ->will($this->onConsecutiveCalls(true, false));
+ ->willReturnMap([
+ ['dir/filename(1).ext', true],
+ ['dir/filename(2).ext', false],
+ ]);
$this->assertEquals('dir/filename(2).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename(1).ext', $viewMock));
$viewMock = $this->createMock(View::class);
$viewMock->expects($this->exactly(2))
->method('file_exists')
- ->withConsecutive(
- ['dir/filename(1) (1).ext'],
- ['dir/filename(1) (2).ext'],
- )
- ->will($this->onConsecutiveCalls(true, false));
+ ->willReturnMap([
+ ['dir/filename(1) (1).ext', true],
+ ['dir/filename(1) (2).ext', false],
+ ]);
$this->assertEquals('dir/filename(1) (2).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename(1) (1).ext', $viewMock));
$viewMock = $this->createMock(View::class);
$viewMock->expects($this->exactly(3))
->method('file_exists')
- ->withConsecutive(
- ['dir/filename(1) (1).ext'],
- ['dir/filename(1) (2).ext'],
- ['dir/filename(1) (3).ext'],
- )
- ->will($this->onConsecutiveCalls(true, true, false));
+ ->willReturnMap([
+ ['dir/filename(1) (1).ext', true],
+ ['dir/filename(1) (2).ext', true],
+ ['dir/filename(1) (3).ext', false],
+ ]);
$this->assertEquals('dir/filename(1) (3).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename(1) (1).ext', $viewMock));
$viewMock = $this->createMock(View::class);
$viewMock->expects($this->exactly(2))
->method('file_exists')
- ->withConsecutive(
- ['dir/filename(1) (2) (3).ext'],
- ['dir/filename(1) (2) (4).ext'],
- )
- ->will($this->onConsecutiveCalls(true, false));
+ ->willReturnMap([
+ ['dir/filename(1) (2) (3).ext', true],
+ ['dir/filename(1) (2) (4).ext', false],
+ ]);
$this->assertEquals('dir/filename(1) (2) (4).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename(1) (2) (3).ext', $viewMock));
}
@@ -227,7 +219,7 @@ class LegacyHelperTest extends \Test\TestCase {
}
- public function streamCopyDataProvider() {
+ public static function streamCopyDataProvider(): array {
return [
[0, false, false, false],
[0, false, \OC::$SERVERROOT . '/tests/data/lorem.txt', false],
@@ -260,17 +252,4 @@ class LegacyHelperTest extends \Test\TestCase {
\OC_Helper::rmdirr($baseDir);
$this->assertFalse(file_exists($baseDir));
}
-
- /**
- * Allows us to test private methods/properties
- *
- * @param $object
- * @param $methodName
- * @param array $parameters
- * @return mixed
- * @deprecated Please extend \Test\TestCase and use self::invokePrivate() then
- */
- public static function invokePrivate($object, $methodName, array $parameters = []) {
- return parent::invokePrivate($object, $methodName, $parameters);
- }
}
diff --git a/tests/lib/Log/PsrLoggerAdapterTest.php b/tests/lib/Log/PsrLoggerAdapterTest.php
index cc9ddea378a..9a159ba537d 100644
--- a/tests/lib/Log/PsrLoggerAdapterTest.php
+++ b/tests/lib/Log/PsrLoggerAdapterTest.php
@@ -45,7 +45,7 @@ class PsrLoggerAdapterTest extends TestCase {
$this->assertEquals($expectedLevel, PsrLoggerAdapter::logLevelToInt($level));
}
- public function dataPsrLoggingLevels(): array {
+ public static function dataPsrLoggingLevels(): array {
return [
[LogLevel::ALERT, ILogger::ERROR],
[LogLevel::CRITICAL, ILogger::ERROR],
@@ -69,7 +69,7 @@ class PsrLoggerAdapterTest extends TestCase {
$this->loggerAdapter->log($level, 'valid message');
}
- public function dataInvalidLoggingLevel(): array {
+ public static function dataInvalidLoggingLevel(): array {
return [
// invalid string
['this is not a level'],
diff --git a/tests/lib/LoggerTest.php b/tests/lib/LoggerTest.php
index c7c60e892aa..5c8345b392b 100644
--- a/tests/lib/LoggerTest.php
+++ b/tests/lib/LoggerTest.php
@@ -72,7 +72,7 @@ class LoggerTest extends TestCase implements IWriter {
$this->assertEquals($expected, $this->getLogs());
}
- public function dataMatchesCondition(): array {
+ public static function dataMatchesCondition(): array {
return [
[
'user0',
@@ -181,7 +181,7 @@ class LoggerTest extends TestCase implements IWriter {
$this->logs[] = $level . ' ' . $textMessage;
}
- public function userAndPasswordData(): array {
+ public static function userAndPasswordData(): array {
return [
['mySpecialUsername', 'MySuperSecretPassword'],
['my-user', '324324()#ä234'],
diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php
index 02a2605fc77..76a06e58c65 100644
--- a/tests/lib/Mail/MailerTest.php
+++ b/tests/lib/Mail/MailerTest.php
@@ -66,7 +66,7 @@ class MailerTest extends TestCase {
/**
* @return array
*/
- public function sendmailModeProvider(): array {
+ public static function sendmailModeProvider(): array {
return [
'smtp' => ['smtp', ' -bs'],
'pipe' => ['pipe', ' -t -i'],
@@ -170,7 +170,7 @@ class MailerTest extends TestCase {
['mail_smtpport', 25, 25],
]);
$this->mailer = $this->getMockBuilder(Mailer::class)
- ->setMethods(['getInstance'])
+ ->onlyMethods(['getInstance'])
->setConstructorArgs(
[
$this->config,
@@ -227,7 +227,7 @@ class MailerTest extends TestCase {
/**
* @return array
*/
- public function mailAddressProvider() {
+ public static function mailAddressProvider(): array {
return [
['lukas@owncloud.com', true, false],
['lukas@localhost', true, false],
diff --git a/tests/lib/Mail/MessageTest.php b/tests/lib/Mail/MessageTest.php
index 260d3aaff76..79a12f3c355 100644
--- a/tests/lib/Mail/MessageTest.php
+++ b/tests/lib/Mail/MessageTest.php
@@ -27,7 +27,7 @@ class MessageTest extends TestCase {
/**
* @return array
*/
- public function mailAddressProvider() {
+ public static function mailAddressProvider(): array {
return [
[
['lukas@owncloud.com' => 'Lukas Reschke'],
@@ -65,8 +65,7 @@ class MessageTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->symfonyEmail = $this->getMockBuilder(Email::class)
- ->disableOriginalConstructor()->getMock();
+ $this->symfonyEmail = $this->createMock(Email::class);
$this->message = new Message($this->symfonyEmail, false);
}
diff --git a/tests/lib/Memcache/FactoryTest.php b/tests/lib/Memcache/FactoryTest.php
index fa0d80c5153..cbf908e0cc6 100644
--- a/tests/lib/Memcache/FactoryTest.php
+++ b/tests/lib/Memcache/FactoryTest.php
@@ -56,7 +56,7 @@ class FactoryTest extends \Test\TestCase {
public const UNAVAILABLE1 = '\\Test\\Memcache\\Test_Factory_Unavailable_Cache1';
public const UNAVAILABLE2 = '\\Test\\Memcache\\Test_Factory_Unavailable_Cache2';
- public function cacheAvailabilityProvider() {
+ public static function cacheAvailabilityProvider(): array {
return [
[
// local and distributed available
@@ -86,7 +86,7 @@ class FactoryTest extends \Test\TestCase {
];
}
- public function cacheUnavailableProvider() {
+ public static function cacheUnavailableProvider(): array {
return [
[
// local available, distributed unavailable
diff --git a/tests/lib/MemoryInfoTest.php b/tests/lib/MemoryInfoTest.php
index 2477de2d799..a81a5ebcaeb 100644
--- a/tests/lib/MemoryInfoTest.php
+++ b/tests/lib/MemoryInfoTest.php
@@ -37,12 +37,7 @@ class MemoryInfoTest extends TestCase {
ini_set('memory_limit', $this->iniSettingBeforeTest);
}
- /**
- * Provides test data.
- *
- * @return array
- */
- public function getMemoryLimitTestData(): array {
+ public static function getMemoryLimitTestData(): array {
return [
'unlimited' => ['-1', -1,],
'524288000 bytes' => ['524288000', 524288000,],
@@ -65,12 +60,7 @@ class MemoryInfoTest extends TestCase {
self::assertEquals($expected, $memoryInfo->getMemoryLimit());
}
- /**
- * Provides sufficient memory limit test data.
- *
- * @return array
- */
- public function getSufficientMemoryTestData(): array {
+ public static function getSufficientMemoryTestData(): array {
return [
'unlimited' => [-1, true,],
'512M' => [512 * 1024 * 1024, true,],
@@ -85,12 +75,11 @@ class MemoryInfoTest extends TestCase {
* @param int $memoryLimit The memory limit
* @param bool $expected If the memory limit is sufficient.
* @dataProvider getSufficientMemoryTestData
- * @return void
*/
public function testIsMemoryLimitSufficient(int $memoryLimit, bool $expected): void {
/* @var MemoryInfo|MockObject $memoryInfo */
$memoryInfo = $this->getMockBuilder(MemoryInfo::class)
- ->setMethods(['getMemoryLimit',])
+ ->onlyMethods(['getMemoryLimit',])
->getMock();
$memoryInfo
diff --git a/tests/lib/Migration/BackgroundRepairTest.php b/tests/lib/Migration/BackgroundRepairTest.php
index 25ea6088072..b85bd4262e0 100644
--- a/tests/lib/Migration/BackgroundRepairTest.php
+++ b/tests/lib/Migration/BackgroundRepairTest.php
@@ -54,22 +54,15 @@ class BackgroundRepairTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->jobList = $this->getMockBuilder(JobList::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->logger = $this->getMockBuilder(LoggerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->jobList = $this->createMock(JobList::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
$this->dispatcher = $this->createMock(IEventDispatcher::class);
$this->time = $this->createMock(ITimeFactory::class);
$this->time->method('getTime')
->willReturn(999999);
$this->appManager = $this->createMock(IAppManager::class);
$this->repair = new Repair($this->dispatcher, $this->logger);
- $this->job = $this->getMockBuilder(BackgroundRepair::class)
- ->setConstructorArgs([$this->repair, $this->time, $this->logger, $this->jobList, $this->appManager])
- ->setMethods(['loadApp'])
- ->getMock();
+ $this->job = new BackgroundRepair($this->repair, $this->time, $this->logger, $this->jobList, $this->appManager);
}
public function testNoArguments(): void {
diff --git a/tests/lib/NaturalSortTest.php b/tests/lib/NaturalSortTest.php
index 3a07c5ceb66..833e2f5e3be 100644
--- a/tests/lib/NaturalSortTest.php
+++ b/tests/lib/NaturalSortTest.php
@@ -35,7 +35,7 @@ class NaturalSortTest extends \Test\TestCase {
* Must provide the same result as in core/js/tests/specs/coreSpec.js
* @return array test cases
*/
- public function naturalSortDataProvider() {
+ public static function naturalSortDataProvider(): array {
return [
// different casing
[
@@ -189,7 +189,7 @@ class NaturalSortTest extends \Test\TestCase {
* Must provide the same result as in core/js/tests/specs/coreSpec.js
* @return array test cases
*/
- public function defaultCollatorDataProvider() {
+ public static function defaultCollatorDataProvider(): array {
return [
// different casing
[
diff --git a/tests/lib/NavigationManagerTest.php b/tests/lib/NavigationManagerTest.php
index 48cfa972f2b..986d2183a14 100644
--- a/tests/lib/NavigationManagerTest.php
+++ b/tests/lib/NavigationManagerTest.php
@@ -68,10 +68,10 @@ class NavigationManagerTest extends TestCase {
$this->navigationManager->clear(false);
}
- public function addArrayData() {
+ public static function addArrayData(): array {
return [
[
- 'entry id' => [
+ 'entry' => [
'id' => 'entry id',
'name' => 'link text',
'order' => 1,
@@ -81,7 +81,7 @@ class NavigationManagerTest extends TestCase {
'classes' => '',
'unread' => 0
],
- 'entry id2' => [
+ 'expectedEntry' => [
'id' => 'entry id',
'name' => 'link text',
'order' => 1,
@@ -94,7 +94,7 @@ class NavigationManagerTest extends TestCase {
]
],
[
- 'entry id' => [
+ 'entry' => [
'id' => 'entry id',
'name' => 'link text',
'order' => 1,
@@ -103,7 +103,7 @@ class NavigationManagerTest extends TestCase {
'active' => true,
'unread' => 0,
],
- 'entry id2' => [
+ 'expectedEntry' => [
'id' => 'entry id',
'name' => 'link text',
'order' => 1,
@@ -272,7 +272,7 @@ class NavigationManagerTest extends TestCase {
$this->assertEquals($expected, $entries);
}
- public function providesNavigationConfig() {
+ public static function providesNavigationConfig(): array {
$apps = [
'core_apps' => [
'id' => 'core_apps',
diff --git a/tests/lib/Net/HostnameClassifierTest.php b/tests/lib/Net/HostnameClassifierTest.php
index 766246ed8ad..5d80da01e46 100644
--- a/tests/lib/Net/HostnameClassifierTest.php
+++ b/tests/lib/Net/HostnameClassifierTest.php
@@ -21,7 +21,7 @@ class HostnameClassifierTest extends TestCase {
$this->classifier = new HostnameClassifier();
}
- public function localHostnamesData():array {
+ public static function localHostnamesData(): array {
return [
['localhost'],
['localHost'],
@@ -41,7 +41,7 @@ class HostnameClassifierTest extends TestCase {
self::assertTrue($isLocal);
}
- public function publicHostnamesData(): array {
+ public static function publicHostnamesData(): array {
return [
['example.com'],
['example.net'],
diff --git a/tests/lib/Net/IpAddressClassifierTest.php b/tests/lib/Net/IpAddressClassifierTest.php
index 803be00f740..be0b7e52fe0 100644
--- a/tests/lib/Net/IpAddressClassifierTest.php
+++ b/tests/lib/Net/IpAddressClassifierTest.php
@@ -21,7 +21,7 @@ class IpAddressClassifierTest extends TestCase {
$this->classifier = new IpAddressClassifier();
}
- public function publicIpAddressData(): array {
+ public static function publicIpAddressData(): array {
return [
['8.8.8.8'],
['8.8.4.4'],
@@ -39,7 +39,7 @@ class IpAddressClassifierTest extends TestCase {
self::assertFalse($isLocal);
}
- public function localIpAddressData(): array {
+ public static function localIpAddressData(): array {
return [
['192.168.0.1'],
['fe80::200:5aee:feaa:20a2'],
diff --git a/tests/lib/Notification/ActionTest.php b/tests/lib/Notification/ActionTest.php
index 3ae4b1db7e7..241e08048a0 100644
--- a/tests/lib/Notification/ActionTest.php
+++ b/tests/lib/Notification/ActionTest.php
@@ -20,7 +20,7 @@ class ActionTest extends TestCase {
$this->action = new Action();
}
- public function dataSetLabel() {
+ public static function dataSetLabel(): array {
return [
['test1'],
[str_repeat('a', 1)],
@@ -38,7 +38,7 @@ class ActionTest extends TestCase {
$this->assertSame($label, $this->action->getLabel());
}
- public function dataSetLabelInvalid() {
+ public static function dataSetLabelInvalid(): array {
return [
[''],
[str_repeat('a', 33)],
@@ -56,7 +56,7 @@ class ActionTest extends TestCase {
$this->action->setLabel($label);
}
- public function dataSetParsedLabel() {
+ public static function dataSetParsedLabel(): array {
return [
['test1'],
[str_repeat('a', 1)],
@@ -74,7 +74,7 @@ class ActionTest extends TestCase {
$this->assertSame($label, $this->action->getParsedLabel());
}
- public function dataSetParsedLabelInvalid() {
+ public static function dataSetParsedLabelInvalid(): array {
return [
[''],
];
@@ -91,7 +91,7 @@ class ActionTest extends TestCase {
$this->action->setParsedLabel($label);
}
- public function dataSetLink() {
+ public static function dataSetLink(): array {
return [
['test1', 'GET'],
['test2', 'POST'],
@@ -112,7 +112,7 @@ class ActionTest extends TestCase {
$this->assertSame($type, $this->action->getRequestType());
}
- public function dataSetLinkInvalid() {
+ public static function dataSetLinkInvalid(): array {
return [
// Invalid link
['', 'GET'],
@@ -135,7 +135,7 @@ class ActionTest extends TestCase {
$this->action->setLink($link, $type);
}
- public function dataSetPrimary() {
+ public static function dataSetPrimary(): array {
return [
[true],
[false],
diff --git a/tests/lib/Notification/ManagerTest.php b/tests/lib/Notification/ManagerTest.php
index 2a85316d7c4..418d642317e 100644
--- a/tests/lib/Notification/ManagerTest.php
+++ b/tests/lib/Notification/ManagerTest.php
@@ -153,7 +153,7 @@ class ManagerTest extends TestCase {
$this->coordinator,
$this->richTextFormatter,
])
- ->setMethods(['getApps'])
+ ->onlyMethods(['getApps'])
->getMock();
$manager->expects($this->once())
@@ -185,7 +185,7 @@ class ManagerTest extends TestCase {
$this->coordinator,
$this->richTextFormatter,
])
- ->setMethods(['getApps'])
+ ->onlyMethods(['getApps'])
->getMock();
$manager->expects($this->never())
@@ -210,7 +210,7 @@ class ManagerTest extends TestCase {
$this->coordinator,
$this->richTextFormatter,
])
- ->setMethods(['getApps'])
+ ->onlyMethods(['getApps'])
->getMock();
$manager->expects($this->once())
@@ -236,7 +236,7 @@ class ManagerTest extends TestCase {
$this->coordinator,
$this->richTextFormatter,
])
- ->setMethods(['getApps'])
+ ->onlyMethods(['getApps'])
->getMock();
$manager->expects($this->once())
@@ -246,7 +246,7 @@ class ManagerTest extends TestCase {
$manager->getCount($notification);
}
- public function dataIsFairUseOfFreePushService(): array {
+ public static function dataIsFairUseOfFreePushService(): array {
return [
[true, 999, true],
[true, 1000, true],
diff --git a/tests/lib/Notification/NotificationTest.php b/tests/lib/Notification/NotificationTest.php
index 957d74233be..93b1746be3c 100644
--- a/tests/lib/Notification/NotificationTest.php
+++ b/tests/lib/Notification/NotificationTest.php
@@ -30,7 +30,7 @@ class NotificationTest extends TestCase {
$this->notification = new Notification($this->validator, $this->richTextFormatter);
}
- protected function dataValidString($maxLength) {
+ protected static function dataValidString($maxLength): array {
$dataSets = [
['test1'],
['1564'],
@@ -42,7 +42,7 @@ class NotificationTest extends TestCase {
return $dataSets;
}
- protected function dataInvalidString($maxLength) {
+ protected static function dataInvalidString($maxLength): array {
$dataSets = [
['']
];
@@ -52,8 +52,8 @@ class NotificationTest extends TestCase {
return $dataSets;
}
- public function dataSetApp() {
- return $this->dataValidString(32);
+ public static function dataSetApp(): array {
+ return self::dataValidString(32);
}
/**
@@ -66,8 +66,8 @@ class NotificationTest extends TestCase {
$this->assertSame($app, $this->notification->getApp());
}
- public function dataSetAppInvalid() {
- return $this->dataInvalidString(32);
+ public static function dataSetAppInvalid(): array {
+ return self::dataInvalidString(32);
}
/**
@@ -82,8 +82,8 @@ class NotificationTest extends TestCase {
}
- public function dataSetUser() {
- return $this->dataValidString(64);
+ public static function dataSetUser(): array {
+ return self::dataValidString(64);
}
/**
@@ -96,8 +96,8 @@ class NotificationTest extends TestCase {
$this->assertSame($user, $this->notification->getUser());
}
- public function dataSetUserInvalid() {
- return $this->dataInvalidString(64);
+ public static function dataSetUserInvalid(): array {
+ return self::dataInvalidString(64);
}
/**
@@ -111,7 +111,7 @@ class NotificationTest extends TestCase {
$this->notification->setUser($user);
}
- public function dataSetDateTime() {
+ public static function dataSetDateTime(): array {
$past = new \DateTime();
$past->sub(new \DateInterval('P1Y'));
$current = new \DateTime();
@@ -135,7 +135,7 @@ class NotificationTest extends TestCase {
$this->assertSame($dateTime, $this->notification->getDateTime());
}
- public function dataSetDateTimeZero() {
+ public static function dataSetDateTimeZero(): array {
$nineTeenSeventy = new \DateTime();
$nineTeenSeventy->setTimestamp(0);
return [
@@ -155,7 +155,7 @@ class NotificationTest extends TestCase {
$this->notification->setDateTime($dateTime);
}
- public function dataSetObject() {
+ public static function dataSetObject(): array {
return [
['a', '21'],
[str_repeat('a', 64), '42'],
@@ -175,11 +175,11 @@ class NotificationTest extends TestCase {
$this->assertSame($id, $this->notification->getObjectId());
}
- public function dataSetObjectTypeInvalid() {
- return $this->dataInvalidString(64);
+ public static function dataSetObjectTypeInvalid(): array {
+ return self::dataInvalidString(64);
}
- public function dataSetObjectIdInvalid() {
+ public static function dataSetObjectIdInvalid(): array {
return [
[''],
[str_repeat('a', 64 + 1)],
@@ -198,7 +198,7 @@ class NotificationTest extends TestCase {
$this->notification->setObject('object', $id);
}
- public function dataSetSubject() {
+ public static function dataSetSubject(): array {
return [
['a', []],
[str_repeat('a', 64), [str_repeat('a', 160)]],
@@ -219,8 +219,8 @@ class NotificationTest extends TestCase {
$this->assertSame($parameters, $this->notification->getSubjectParameters());
}
- public function dataSetSubjectInvalidSubject() {
- return $this->dataInvalidString(64);
+ public static function dataSetSubjectInvalidSubject(): array {
+ return self::dataInvalidString(64);
}
/**
@@ -234,8 +234,8 @@ class NotificationTest extends TestCase {
$this->notification->setSubject($subject, []);
}
- public function dataSetParsedSubject() {
- return $this->dataValidString(false);
+ public static function dataSetParsedSubject(): array {
+ return self::dataValidString(false);
}
/**
@@ -248,8 +248,8 @@ class NotificationTest extends TestCase {
$this->assertSame($subject, $this->notification->getParsedSubject());
}
- public function dataSetParsedSubjectInvalid() {
- return $this->dataInvalidString(false);
+ public static function dataSetParsedSubjectInvalid(): array {
+ return self::dataInvalidString(false);
}
/**
@@ -263,7 +263,7 @@ class NotificationTest extends TestCase {
$this->notification->setParsedSubject($subject);
}
- public function dataSetMessage() {
+ public static function dataSetMessage(): array {
return [
['a', []],
[str_repeat('a', 64), [str_repeat('a', 160)]],
@@ -284,8 +284,8 @@ class NotificationTest extends TestCase {
$this->assertSame($parameters, $this->notification->getMessageParameters());
}
- public function dataSetMessageInvalidMessage() {
- return $this->dataInvalidString(64);
+ public static function dataSetMessageInvalidMessage(): array {
+ return self::dataInvalidString(64);
}
/**
@@ -299,8 +299,8 @@ class NotificationTest extends TestCase {
$this->notification->setMessage($message, []);
}
- public function dataSetParsedMessage() {
- return $this->dataValidString(false);
+ public static function dataSetParsedMessage(): array {
+ return self::dataValidString(false);
}
/**
@@ -313,8 +313,8 @@ class NotificationTest extends TestCase {
$this->assertSame($message, $this->notification->getParsedMessage());
}
- public function dataSetParsedMessageInvalid() {
- return $this->dataInvalidString(false);
+ public static function dataSetParsedMessageInvalid(): array {
+ return self::dataInvalidString(false);
}
/**
@@ -328,8 +328,8 @@ class NotificationTest extends TestCase {
$this->notification->setParsedMessage($message);
}
- public function dataSetLink() {
- return $this->dataValidString(4000);
+ public static function dataSetLink(): array {
+ return self::dataValidString(4000);
}
/**
@@ -342,8 +342,8 @@ class NotificationTest extends TestCase {
$this->assertSame($link, $this->notification->getLink());
}
- public function dataSetLinkInvalid() {
- return $this->dataInvalidString(4000);
+ public static function dataSetLinkInvalid(): array {
+ return self::dataInvalidString(4000);
}
/**
@@ -357,8 +357,8 @@ class NotificationTest extends TestCase {
$this->notification->setLink($link);
}
- public function dataSetIcon() {
- return $this->dataValidString(4000);
+ public static function dataSetIcon(): array {
+ return self::dataValidString(4000);
}
/**
@@ -371,8 +371,8 @@ class NotificationTest extends TestCase {
$this->assertSame($icon, $this->notification->getIcon());
}
- public function dataSetIconInvalid() {
- return $this->dataInvalidString(4000);
+ public static function dataSetIconInvalid(): array {
+ return self::dataInvalidString(4000);
}
/**
@@ -508,7 +508,7 @@ class NotificationTest extends TestCase {
$this->assertEquals([$action2, $action1, $action1], $this->notification->getParsedActions());
}
- public function dataIsValid() {
+ public static function dataIsValid(): array {
return [
[false, '', false],
[true, '', false],
@@ -527,7 +527,7 @@ class NotificationTest extends TestCase {
public function testIsValid($isValidCommon, $subject, $expected): void {
/** @var \OCP\Notification\INotification|\PHPUnit\Framework\MockObject\MockObject $notification */
$notification = $this->getMockBuilder(Notification::class)
- ->setMethods([
+ ->onlyMethods([
'isValidCommon',
'getSubject',
'getParsedSubject',
@@ -560,7 +560,7 @@ class NotificationTest extends TestCase {
public function testIsParsedValid($isValidCommon, $subject, $expected): void {
/** @var \OCP\Notification\INotification|\PHPUnit\Framework\MockObject\MockObject $notification */
$notification = $this->getMockBuilder(Notification::class)
- ->setMethods([
+ ->onlyMethods([
'isValidCommon',
'getParsedSubject',
'getSubject',
@@ -583,7 +583,7 @@ class NotificationTest extends TestCase {
$this->assertEquals($expected, $notification->isValidParsed());
}
- public function dataIsValidCommon() {
+ public static function dataIsValidCommon(): array {
return [
['', '', 0, '', '', false],
['app', '', 0, '', '', false],
@@ -607,7 +607,7 @@ class NotificationTest extends TestCase {
public function testIsValidCommon($app, $user, $timestamp, $objectType, $objectId, $expected): void {
/** @var \OCP\Notification\INotification|\PHPUnit\Framework\MockObject\MockObject $notification */
$notification = $this->getMockBuilder(Notification::class)
- ->setMethods([
+ ->onlyMethods([
'getApp',
'getUser',
'getDateTime',
diff --git a/tests/lib/OCS/ApiHelperTest.php b/tests/lib/OCS/ApiHelperTest.php
index fdbc1f4c538..93de6b22af7 100644
--- a/tests/lib/OCS/ApiHelperTest.php
+++ b/tests/lib/OCS/ApiHelperTest.php
@@ -14,10 +14,7 @@ use OC\OCS\ApiHelper;
use OCP\IRequest;
class ApiHelperTest extends \Test\TestCase {
- /**
- * @return array
- */
- public function versionDataScriptNameProvider(): array {
+ public static function versionDataScriptNameProvider(): array {
return [
// Valid script name
[
diff --git a/tests/lib/OCS/DiscoveryServiceTest.php b/tests/lib/OCS/DiscoveryServiceTest.php
index 3db3163e11d..2fce12ee3c0 100644
--- a/tests/lib/OCS/DiscoveryServiceTest.php
+++ b/tests/lib/OCS/DiscoveryServiceTest.php
@@ -45,7 +45,7 @@ class DiscoveryServiceTest extends TestCase {
$this->assertSame($expected, $result);
}
- public function dataTestIsSafeUrl() {
+ public static function dataTestIsSafeUrl(): array {
return [
['api/ocs/v1.php/foo', true],
['/api/ocs/v1.php/foo', true],
@@ -69,7 +69,7 @@ class DiscoveryServiceTest extends TestCase {
$this->assertSame($expected, $result);
}
- public function dataTestGetEndpoints() {
+ public static function dataTestGetEndpoints(): array {
return [
[['services' => ['myService' => ['endpoints' => []]]], 'myService', []],
[['services' => ['myService' => ['endpoints' => ['foo' => '/bar']]]], 'myService', ['foo' => '/bar']],
diff --git a/tests/lib/Preview/GeneratorTest.php b/tests/lib/Preview/GeneratorTest.php
index 607127a6495..84ffe6662c7 100644
--- a/tests/lib/Preview/GeneratorTest.php
+++ b/tests/lib/Preview/GeneratorTest.php
@@ -343,7 +343,7 @@ class GeneratorTest extends \Test\TestCase {
return $image;
}
- public function dataSize() {
+ public static function dataSize(): array {
return [
[1024, 2048, 512, 512, false, IPreview::MODE_FILL, 256, 512],
[1024, 2048, 512, 512, false, IPreview::MODE_COVER, 512, 1024],
diff --git a/tests/lib/Preview/SVGTest.php b/tests/lib/Preview/SVGTest.php
index 6a0e93e5f79..14730bc8034 100644
--- a/tests/lib/Preview/SVGTest.php
+++ b/tests/lib/Preview/SVGTest.php
@@ -30,7 +30,7 @@ class SVGTest extends Provider {
}
}
- public function dataGetThumbnailSVGHref(): array {
+ public static function dataGetThumbnailSVGHref(): array {
return [
['href'],
[' href'],
diff --git a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php b/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php
index 810fa1fe4e8..88fc24b40ad 100644
--- a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php
+++ b/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php
@@ -30,7 +30,7 @@ class ClearGeneratedAvatarCacheTest extends \Test\TestCase {
$this->repair = new ClearGeneratedAvatarCache($this->config, $this->avatarManager, $this->jobList);
}
- public function shouldRunDataProvider() {
+ public static function shouldRunDataProvider(): array {
return [
['11.0.0.0', true],
['15.0.0.3', true],
diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php
index dfcdce3801a..7c49d74e2ef 100644
--- a/tests/lib/Repair/RepairInvalidSharesTest.php
+++ b/tests/lib/Repair/RepairInvalidSharesTest.php
@@ -122,7 +122,7 @@ class RepairInvalidSharesTest extends TestCase {
$result->closeCursor();
}
- public function fileSharePermissionsProvider() {
+ public static function fileSharePermissionsProvider(): array {
return [
// unchanged for folder
[
diff --git a/tests/lib/RichObjectStrings/DefinitionsTest.php b/tests/lib/RichObjectStrings/DefinitionsTest.php
index 9299a556972..cc964aff50f 100644
--- a/tests/lib/RichObjectStrings/DefinitionsTest.php
+++ b/tests/lib/RichObjectStrings/DefinitionsTest.php
@@ -10,7 +10,7 @@ use OCP\RichObjectStrings\Definitions;
use Test\TestCase;
class DefinitionsTest extends TestCase {
- public function dataGetDefinition() {
+ public static function dataGetDefinition() {
$definitions = new Definitions();
$testsuite = [];
foreach ($definitions->definitions as $type => $definition) {
@@ -19,7 +19,7 @@ class DefinitionsTest extends TestCase {
return $testsuite;
}
-
+
public function testGetDefinitionNotExisting(): void {
$this->expectException(\OCP\RichObjectStrings\InvalidObjectExeption::class);
$this->expectExceptionMessage('Object type is undefined');
diff --git a/tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php b/tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php
index 82bffb74e01..ac679238617 100644
--- a/tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php
+++ b/tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php
@@ -36,7 +36,7 @@ class MemoryCacheBackendTest extends TestCase {
$this->cacheFactory
->expects($this->once())
->method('createDistributed')
- ->with('OC\Security\Bruteforce\Backend\MemoryCacheBackend')
+ ->with(MemoryCacheBackend::class)
->willReturn($this->cache);
$this->backend = new MemoryCacheBackend(
@@ -55,7 +55,7 @@ class MemoryCacheBackendTest extends TestCase {
$this->assertSame(0, $this->backend->getAttempts('10.10.10.10/32', 0));
}
- public function dataGetAttempts(): array {
+ public static function dataGetAttempts(): array {
return [
[0, null, null, 4],
[100, null, null, 2],
diff --git a/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php b/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php
index f8386124626..fcc776ade8e 100644
--- a/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php
+++ b/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php
@@ -28,7 +28,7 @@ class SessionStorageTest extends \Test\TestCase {
/**
* @return array
*/
- public function getTokenDataProvider() {
+ public static function getTokenDataProvider(): array {
return [
[
'',
diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php
index 1c168228b6a..a0cb133ec3b 100644
--- a/tests/lib/Security/CertificateManagerTest.php
+++ b/tests/lib/Security/CertificateManagerTest.php
@@ -100,10 +100,7 @@ class CertificateManagerTest extends \Test\TestCase {
$this->certificateManager->addCertificate('InvalidCertificate', 'invalidCertificate');
}
- /**
- * @return array
- */
- public function dangerousFileProvider() {
+ public static function dangerousFileProvider(): array {
return [
['.htaccess'],
['../../foo.txt'],
@@ -153,7 +150,7 @@ class CertificateManagerTest extends \Test\TestCase {
/** @var CertificateManager | \PHPUnit\Framework\MockObject\MockObject $certificateManager */
$certificateManager = $this->getMockBuilder('OC\Security\CertificateManager')
->setConstructorArgs([$view, $config, $this->createMock(LoggerInterface::class), $this->random])
- ->setMethods(['getFilemtimeOfCaBundle', 'getCertificateBundle'])
+ ->onlyMethods(['getFilemtimeOfCaBundle', 'getCertificateBundle'])
->getMock();
$certificateManager->expects($this->any())->method('getFilemtimeOfCaBundle')
@@ -181,7 +178,7 @@ class CertificateManagerTest extends \Test\TestCase {
);
}
- public function dataTestNeedRebundling() {
+ public static function dataTestNeedRebundling(): array {
return [
//values: CaBundleMtime, targetBundleMtime, targetBundleExists, expected
diff --git a/tests/lib/Security/CredentialsManagerTest.php b/tests/lib/Security/CredentialsManagerTest.php
index ce60a2f62a2..d5e7a114667 100644
--- a/tests/lib/Security/CredentialsManagerTest.php
+++ b/tests/lib/Security/CredentialsManagerTest.php
@@ -50,7 +50,7 @@ class CredentialsManagerTest extends \Test\TestCase {
$this->assertSame($secretsRev, $received);
}
- public function credentialsProvider(): array {
+ public static function credentialsProvider(): array {
return [
[
'alice',
diff --git a/tests/lib/Security/CryptoTest.php b/tests/lib/Security/CryptoTest.php
index 79140b34456..64042d0c5a9 100644
--- a/tests/lib/Security/CryptoTest.php
+++ b/tests/lib/Security/CryptoTest.php
@@ -13,7 +13,7 @@ namespace Test\Security;
use OC\Security\Crypto;
class CryptoTest extends \Test\TestCase {
- public function defaultEncryptionProvider() {
+ public static function defaultEncryptionProvider(): array {
return [
['Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.'],
[''],
diff --git a/tests/lib/Security/HasherTest.php b/tests/lib/Security/HasherTest.php
index 41cad7f323f..11b63e8ec88 100644
--- a/tests/lib/Security/HasherTest.php
+++ b/tests/lib/Security/HasherTest.php
@@ -17,10 +17,7 @@ use OCP\IConfig;
* Class HasherTest
*/
class HasherTest extends \Test\TestCase {
- /**
- * @return array
- */
- public function versionHashProvider() {
+ public static function versionHashProvider(): array {
return [
['asf32äà$$a.|3', null],
['asf32äà$$a.|3|5', null],
@@ -30,7 +27,7 @@ class HasherTest extends \Test\TestCase {
];
}
- public function hashProviders70_71(): array {
+ public static function hashProviders70_71(): array {
return [
// Valid SHA1 strings
['password', '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8', true],
@@ -66,7 +63,7 @@ class HasherTest extends \Test\TestCase {
];
}
- public function hashProviders72(): array {
+ public static function hashProviders72(): array {
return [
// Valid ARGON2 hashes
['password', '2|$argon2i$v=19$m=1024,t=2,p=2$T3JGcEkxVFNOVktNSjZUcg$4/hyLtSejxNgAuzSFFV/HLM3qRQKBwEtKw61qPN4zWA', true],
@@ -83,7 +80,7 @@ class HasherTest extends \Test\TestCase {
];
}
- public function hashProviders73(): array {
+ public static function hashProviders73(): array {
return [
// Valid ARGON2ID hashes
['password', '2|$argon2id$v=19$m=65536,t=4,p=1$TEtIMnhUczliQzI0Y01WeA$BpMUDrApy25iagIogUAnlc0rNTPJmGs8lOEeVHujJ9Q', true],
diff --git a/tests/lib/Security/Ip/BruteforceAllowListTest.php b/tests/lib/Security/Ip/BruteforceAllowListTest.php
index f7ef9e3df72..efdb7c4034c 100644
--- a/tests/lib/Security/Ip/BruteforceAllowListTest.php
+++ b/tests/lib/Security/Ip/BruteforceAllowListTest.php
@@ -42,7 +42,7 @@ class BruteforceAllowListTest extends TestCase {
);
}
- public function dataIsBypassListed(): array {
+ public static function dataIsBypassListed(): array {
return [
[
'10.10.10.10',
diff --git a/tests/lib/Security/Ip/RemoteAddressTest.php b/tests/lib/Security/Ip/RemoteAddressTest.php
index d1f621796fe..63c1b452294 100644
--- a/tests/lib/Security/Ip/RemoteAddressTest.php
+++ b/tests/lib/Security/Ip/RemoteAddressTest.php
@@ -44,7 +44,7 @@ class RemoteAddressTest extends \Test\TestCase {
/**
* @return array<string, mixed, bool>
*/
- public function dataProvider(): array {
+ public static function dataProvider(): array {
return [
// No IP (ie. CLI)
['', ['192.168.1.2/24'], true],
diff --git a/tests/lib/Security/Normalizer/IpAddressTest.php b/tests/lib/Security/Normalizer/IpAddressTest.php
index 33a8b4d28f1..29067596c98 100644
--- a/tests/lib/Security/Normalizer/IpAddressTest.php
+++ b/tests/lib/Security/Normalizer/IpAddressTest.php
@@ -13,7 +13,7 @@ use OC\Security\Normalizer\IpAddress;
use Test\TestCase;
class IpAddressTest extends TestCase {
- public function subnetDataProvider() {
+ public static function subnetDataProvider(): array {
return [
[
'64.233.191.254',
diff --git a/tests/lib/Security/RateLimiting/LimiterTest.php b/tests/lib/Security/RateLimiting/LimiterTest.php
index 92600e22de8..6f430e85576 100644
--- a/tests/lib/Security/RateLimiting/LimiterTest.php
+++ b/tests/lib/Security/RateLimiting/LimiterTest.php
@@ -12,21 +12,26 @@ namespace Test\Security\RateLimiting;
use OC\Security\RateLimiting\Backend\IBackend;
use OC\Security\RateLimiting\Limiter;
use OCP\IUser;
+use OCP\Security\RateLimiting\ILimiter;
+use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
use Test\TestCase;
class LimiterTest extends TestCase {
- /** @var IBackend|\PHPUnit\Framework\MockObject\MockObject */
- private $backend;
- /** @var Limiter */
- private $limiter;
+
+ private IBackend&MockObject $backend;
+ private ILimiter $limiter;
+ private LoggerInterface $logger;
protected function setUp(): void {
parent::setUp();
$this->backend = $this->createMock(IBackend::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
$this->limiter = new Limiter(
- $this->backend
+ $this->backend,
+ $this->logger,
);
}
@@ -43,6 +48,8 @@ class LimiterTest extends TestCase {
'4664f0d9c88dcb7552be47b37bb52ce35977b2e60e1ac13757cf625f31f87050a41f3da064887fa87d49fd042e4c8eb20de8f10464877d3959677ab011b73a47'
)
->willReturn(101);
+ $this->logger->expects($this->once())
+ ->method('info');
$this->limiter->registerAnonRequest('MyIdentifier', 100, 100, '127.0.0.1');
}
@@ -64,6 +71,8 @@ class LimiterTest extends TestCase {
'4664f0d9c88dcb7552be47b37bb52ce35977b2e60e1ac13757cf625f31f87050a41f3da064887fa87d49fd042e4c8eb20de8f10464877d3959677ab011b73a47',
100
);
+ $this->logger->expects($this->never())
+ ->method('info');
$this->limiter->registerAnonRequest('MyIdentifier', 100, 100, '127.0.0.1');
}
@@ -87,6 +96,8 @@ class LimiterTest extends TestCase {
'ddb2ec50fa973fd49ecf3d816f677c8095143e944ad10485f30fb3dac85c13a346dace4dae2d0a15af91867320957bfd38a43d9eefbb74fe6919e15119b6d805'
)
->willReturn(101);
+ $this->logger->expects($this->once())
+ ->method('info');
$this->limiter->registerUserRequest('MyIdentifier', 100, 100, $user);
}
@@ -115,6 +126,8 @@ class LimiterTest extends TestCase {
'ddb2ec50fa973fd49ecf3d816f677c8095143e944ad10485f30fb3dac85c13a346dace4dae2d0a15af91867320957bfd38a43d9eefbb74fe6919e15119b6d805',
100
);
+ $this->logger->expects($this->never())
+ ->method('info');
$this->limiter->registerUserRequest('MyIdentifier', 100, 100, $user);
}
diff --git a/tests/lib/Security/RemoteHostValidatorIntegrationTest.php b/tests/lib/Security/RemoteHostValidatorIntegrationTest.php
index 6cddb8b4ce9..3d319e828ff 100644
--- a/tests/lib/Security/RemoteHostValidatorIntegrationTest.php
+++ b/tests/lib/Security/RemoteHostValidatorIntegrationTest.php
@@ -37,7 +37,7 @@ class RemoteHostValidatorIntegrationTest extends TestCase {
);
}
- public function localHostsData(): array {
+ public static function localHostsData(): array {
return [
['[::1]'],
['[::]'],
@@ -101,7 +101,7 @@ class RemoteHostValidatorIntegrationTest extends TestCase {
self::assertTrue($isValid);
}
- public function externalAddressesData():array {
+ public static function externalAddressesData():array {
return [
['8.8.8.8'],
['8.8.4.4'],
diff --git a/tests/lib/Security/RemoteHostValidatorTest.php b/tests/lib/Security/RemoteHostValidatorTest.php
index c698ebbc3c6..46c969d28c1 100644
--- a/tests/lib/Security/RemoteHostValidatorTest.php
+++ b/tests/lib/Security/RemoteHostValidatorTest.php
@@ -44,7 +44,7 @@ class RemoteHostValidatorTest extends TestCase {
);
}
- public function dataValid(): array {
+ public static function dataValid(): array {
return [
['nextcloud.com', true],
['com.one-.nextcloud-one.com', false],
diff --git a/tests/lib/Security/SecureRandomTest.php b/tests/lib/Security/SecureRandomTest.php
index 8000917579b..98eb0e45df3 100644
--- a/tests/lib/Security/SecureRandomTest.php
+++ b/tests/lib/Security/SecureRandomTest.php
@@ -13,7 +13,7 @@ namespace Test\Security;
use OC\Security\SecureRandom;
class SecureRandomTest extends \Test\TestCase {
- public function stringGenerationProvider() {
+ public static function stringGenerationProvider(): array {
return [
[1, 1],
[128, 128],
@@ -24,7 +24,7 @@ class SecureRandomTest extends \Test\TestCase {
];
}
- public static function charCombinations() {
+ public static function charCombinations(): array {
return [
['CHAR_LOWER', '[a-z]'],
['CHAR_UPPER', '[A-Z]'],
@@ -76,7 +76,7 @@ class SecureRandomTest extends \Test\TestCase {
$this->assertSame(1, $matchesRegex);
}
- public static function invalidLengths() {
+ public static function invalidLengths(): array {
return [
[0],
[-1],
diff --git a/tests/lib/Security/TrustedDomainHelperTest.php b/tests/lib/Security/TrustedDomainHelperTest.php
index 656b7a77206..1b9ba20a906 100644
--- a/tests/lib/Security/TrustedDomainHelperTest.php
+++ b/tests/lib/Security/TrustedDomainHelperTest.php
@@ -63,7 +63,7 @@ class TrustedDomainHelperTest extends \Test\TestCase {
/**
* @return array
*/
- public function trustedDomainDataProvider() {
+ public static function trustedDomainDataProvider(): array {
$trustedHostTestList = [
'host.one.test',
'host.two.test',
diff --git a/tests/lib/ServerTest.php b/tests/lib/ServerTest.php
index eb9b1dab9f5..371bc572b15 100644
--- a/tests/lib/ServerTest.php
+++ b/tests/lib/ServerTest.php
@@ -28,7 +28,7 @@ class ServerTest extends \Test\TestCase {
$this->server = new \OC\Server('', $config);
}
- public function dataTestQuery() {
+ public static function dataTestQuery(): array {
return [
['\OCP\Activity\IManager', '\OC\Activity\Manager'],
['\OCP\IConfig', '\OC\AllConfig'],
diff --git a/tests/lib/SetupTest.php b/tests/lib/SetupTest.php
index b5e1b7000c3..f82060dcfa2 100644
--- a/tests/lib/SetupTest.php
+++ b/tests/lib/SetupTest.php
@@ -42,7 +42,7 @@ class SetupTest extends \Test\TestCase {
$this->random = $this->createMock(ISecureRandom::class);
$this->installer = $this->createMock(Installer::class);
$this->setupClass = $this->getMockBuilder(Setup::class)
- ->setMethods(['class_exists', 'is_callable', 'getAvailableDbDriversForPdo'])
+ ->onlyMethods(['class_exists', 'is_callable', 'getAvailableDbDriversForPdo'])
->setConstructorArgs([$this->config, $this->iniWrapper, $this->l10nFactory, $this->defaults, $this->logger, $this->random, $this->installer])
->getMock();
}
@@ -151,7 +151,7 @@ class SetupTest extends \Test\TestCase {
$this->assertSame($webRoot, $expected);
}
- public function findWebRootProvider(): array {
+ public static function findWebRootProvider(): array {
return [
'https://www.example.com/nextcloud/' => ['https://www.example.com/nextcloud/', '/nextcloud'],
'https://www.example.com/nextcloud' => ['https://www.example.com/nextcloud', '/nextcloud'],
diff --git a/tests/lib/Share/HelperTest.php b/tests/lib/Share/HelperTest.php
index c923bb0480a..c56350358eb 100644
--- a/tests/lib/Share/HelperTest.php
+++ b/tests/lib/Share/HelperTest.php
@@ -12,7 +12,7 @@ namespace Test\Share;
* Class Helper
*/
class HelperTest extends \Test\TestCase {
- public function expireDateProvider() {
+ public static function expireDateProvider(): array {
return [
// no default expire date, we take the users expire date
[['defaultExpireDateSet' => false], 2000000000, 2000010000, 2000010000],
@@ -54,7 +54,7 @@ class HelperTest extends \Test\TestCase {
);
}
- public function dataTestCompareServerAddresses() {
+ public static function dataTestCompareServerAddresses(): array {
return [
['user1', 'http://server1', 'user1', 'http://server1', true],
['user1', 'https://server1', 'user1', 'http://server1', true],
diff --git a/tests/lib/Share/ShareTest.php b/tests/lib/Share/ShareTest.php
index 60891e10ca2..944d0738eb1 100644
--- a/tests/lib/Share/ShareTest.php
+++ b/tests/lib/Share/ShareTest.php
@@ -132,7 +132,7 @@ class ShareTest extends \Test\TestCase {
$this->assertSame($expectedResult, $result);
}
- public function urls() {
+ public static function urls(): array {
return [
['http://owncloud.org', 'owncloud.org'],
['https://owncloud.org', 'owncloud.org'],
@@ -161,7 +161,7 @@ class ShareTest extends \Test\TestCase {
}
}
- public function dataProviderTestGroupItems() {
+ public static function dataProviderTestGroupItems(): array {
return [
// one array with one share
[
diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php
index 75a70d558c1..39560795921 100644
--- a/tests/lib/Share20/DefaultShareProviderTest.php
+++ b/tests/lib/Share20/DefaultShareProviderTest.php
@@ -472,7 +472,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->logger,
$this->shareManager,
])
- ->setMethods(['getShareById'])
+ ->onlyMethods(['getShareById'])
->getMock();
$provider->delete($share);
@@ -569,7 +569,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->logger,
$this->shareManager,
])
- ->setMethods(['getShareById'])
+ ->onlyMethods(['getShareById'])
->getMock();
$provider->delete($share);
@@ -968,7 +968,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
return $qb->getLastInsertId();
}
- public function storageAndFileNameProvider() {
+ public static function storageAndFileNameProvider(): array {
return [
// regular file on regular storage
['home::shareOwner', 'files/test.txt', 'files/test2.txt'],
@@ -1281,7 +1281,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertEquals(IShare::TYPE_GROUP, $share->getShareType());
}
- public function shareTypesProvider() {
+ public static function shareTypesProvider(): array {
return [
[IShare::TYPE_USER, false],
[IShare::TYPE_GROUP, false],
@@ -2276,7 +2276,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertSame('/ultraNewTarget', $share->getTarget());
}
- public function dataDeleteUser() {
+ public static function dataDeleteUser(): array {
return [
[IShare::TYPE_USER, 'a', 'b', 'c', 'a', true],
[IShare::TYPE_USER, 'a', 'b', 'c', 'b', false],
@@ -2334,7 +2334,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertCount($rowDeleted ? 0 : 1, $data);
}
- public function dataDeleteUserGroup() {
+ public static function dataDeleteUserGroup(): array {
return [
['a', 'b', 'c', 'a', true, true],
['a', 'b', 'c', 'b', false, false],
@@ -2403,7 +2403,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertCount($groupShareDeleted ? 0 : 1, $data);
}
- public function dataGroupDeleted() {
+ public static function dataGroupDeleted(): array {
return [
[
[
@@ -2497,7 +2497,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertCount($shouldBeDeleted ? 0 : count($ids), $data);
}
- public function dataUserDeletedFromGroup() {
+ public static function dataUserDeletedFromGroup(): array {
return [
['group1', 'user1', true],
['group1', 'user2', false],
diff --git a/tests/lib/Share20/LegacyHooksTest.php b/tests/lib/Share20/LegacyHooksTest.php
index 0761eed592b..4a3d3a4310b 100644
--- a/tests/lib/Share20/LegacyHooksTest.php
+++ b/tests/lib/Share20/LegacyHooksTest.php
@@ -23,6 +23,19 @@ use OCP\Share\IShare;
use Psr\Log\LoggerInterface;
use Test\TestCase;
+class Dummy {
+ public function postShare() {
+ }
+ public function preShare() {
+ }
+ public function postFromSelf() {
+ }
+ public function post() {
+ }
+ public function pre() {
+ }
+}
+
class LegacyHooksTest extends TestCase {
/** @var LegacyHooks */
private $hooks;
@@ -60,7 +73,7 @@ class LegacyHooksTest extends TestCase {
->setTarget('myTarget')
->setNodeCacheEntry($info);
- $hookListner = $this->getMockBuilder('Dummy')->setMethods(['pre'])->getMock();
+ $hookListner = $this->getMockBuilder(Dummy::class)->onlyMethods(['pre'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'pre_unshare', $hookListner, 'pre');
$hookListnerExpectsPre = [
@@ -101,7 +114,7 @@ class LegacyHooksTest extends TestCase {
->setTarget('myTarget')
->setNodeCacheEntry($info);
- $hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
+ $hookListner = $this->getMockBuilder(Dummy::class)->onlyMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_unshare', $hookListner, 'post');
$hookListnerExpectsPost = [
@@ -155,7 +168,7 @@ class LegacyHooksTest extends TestCase {
->setTarget('myTarget')
->setNodeCacheEntry($info);
- $hookListner = $this->getMockBuilder('Dummy')->setMethods(['postFromSelf'])->getMock();
+ $hookListner = $this->getMockBuilder(Dummy::class)->onlyMethods(['postFromSelf'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_unshareFromSelf', $hookListner, 'postFromSelf');
$hookListnerExpectsPostFromSelf = [
@@ -212,7 +225,7 @@ class LegacyHooksTest extends TestCase {
->setToken('token');
- $hookListner = $this->getMockBuilder('Dummy')->setMethods(['preShare'])->getMock();
+ $hookListner = $this->getMockBuilder(Dummy::class)->onlyMethods(['preShare'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'pre_shared', $hookListner, 'preShare');
$run = true;
@@ -260,7 +273,7 @@ class LegacyHooksTest extends TestCase {
->setToken('token');
- $hookListner = $this->getMockBuilder('Dummy')->setMethods(['preShare'])->getMock();
+ $hookListner = $this->getMockBuilder(Dummy::class)->onlyMethods(['preShare'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'pre_shared', $hookListner, 'preShare');
$run = true;
@@ -316,7 +329,7 @@ class LegacyHooksTest extends TestCase {
->setToken('token');
- $hookListner = $this->getMockBuilder('Dummy')->setMethods(['postShare'])->getMock();
+ $hookListner = $this->getMockBuilder(Dummy::class)->onlyMethods(['postShare'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_shared', $hookListner, 'postShare');
$expected = [
diff --git a/tests/lib/Share20/ShareHelperTest.php b/tests/lib/Share20/ShareHelperTest.php
index 8aaa8350ea9..9027704bb32 100644
--- a/tests/lib/Share20/ShareHelperTest.php
+++ b/tests/lib/Share20/ShareHelperTest.php
@@ -27,7 +27,7 @@ class ShareHelperTest extends TestCase {
$this->helper = new ShareHelper($this->manager);
}
- public function dataGetPathsForAccessList() {
+ public static function dataGetPathsForAccessList(): array {
return [
[[], [], false, [], [], false, [
'users' => [],
@@ -64,7 +64,7 @@ class ShareHelperTest extends TestCase {
/** @var ShareHelper|\PHPUnit\Framework\MockObject\MockObject $helper */
$helper = $this->getMockBuilder(ShareHelper::class)
->setConstructorArgs([$this->manager])
- ->setMethods(['getPathsForUsers', 'getPathsForRemotes'])
+ ->onlyMethods(['getPathsForUsers', 'getPathsForRemotes'])
->getMock();
$helper->expects($resolveUsers ? $this->once() : $this->never())
@@ -80,7 +80,7 @@ class ShareHelperTest extends TestCase {
$this->assertSame($expected, $helper->getPathsForAccessList($node));
}
- public function dataGetPathsForUsers() {
+ public static function dataGetPathsForUsers(): array {
return [
[[], [23 => 'TwentyThree', 42 => 'FortyTwo'], []],
[
@@ -133,7 +133,7 @@ class ShareHelperTest extends TestCase {
$this->assertEquals($expected, self::invokePrivate($this->helper, 'getPathsForUsers', [$lastNode, $users]));
}
- public function dataGetPathsForRemotes() {
+ public static function dataGetPathsForRemotes(): array {
return [
[[], [23 => 'TwentyThree', 42 => 'FortyTwo'], []],
[
@@ -190,7 +190,7 @@ class ShareHelperTest extends TestCase {
$this->assertEquals($expected, self::invokePrivate($this->helper, 'getPathsForRemotes', [$lastNode, $remotes]));
}
- public function dataGetMountedPath() {
+ public static function dataGetMountedPath(): array {
return [
['/admin/files/foobar', '/foobar'],
['/admin/files/foo/bar', '/foo/bar'],
diff --git a/tests/lib/Support/Subscription/RegistryTest.php b/tests/lib/Support/Subscription/RegistryTest.php
index b3a0f8e603e..08a216294d6 100644
--- a/tests/lib/Support/Subscription/RegistryTest.php
+++ b/tests/lib/Support/Subscription/RegistryTest.php
@@ -157,7 +157,7 @@ class RegistryTest extends TestCase {
$this->assertSame(false, $this->registry->delegateIsHardUserLimitReached($this->notificationManager));
}
- public function dataForUserLimitCheck() {
+ public static function dataForUserLimitCheck(): array {
return [
// $userLimit, $userCount, $disabledUsers, $expectedResult
[35, 15, 2, false],
diff --git a/tests/lib/SystemTag/SystemTagManagerTest.php b/tests/lib/SystemTag/SystemTagManagerTest.php
index 94103c52cb1..4627ebbf546 100644
--- a/tests/lib/SystemTag/SystemTagManagerTest.php
+++ b/tests/lib/SystemTag/SystemTagManagerTest.php
@@ -66,7 +66,7 @@ class SystemTagManagerTest extends TestCase {
$query->delete(SystemTagManager::TAG_TABLE)->execute();
}
- public static function getAllTagsDataProvider() {
+ public static function getAllTagsDataProvider(): array {
return [
[
// no tags at all
@@ -113,7 +113,7 @@ class SystemTagManagerTest extends TestCase {
}
}
- public static function getAllTagsFilteredDataProvider() {
+ public static function getAllTagsFilteredDataProvider(): array {
return [
[
[
@@ -226,7 +226,7 @@ class SystemTagManagerTest extends TestCase {
}
}
- public static function oneTagMultipleFlagsProvider() {
+ public static function oneTagMultipleFlagsProvider(): array {
return [
['one', false, false],
['one', true, false],
@@ -299,7 +299,7 @@ class SystemTagManagerTest extends TestCase {
$this->tagManager->getTagsByIds([$tag1->getId() . 'suffix']);
}
- public static function updateTagProvider() {
+ public static function updateTagProvider(): array {
return [
[
// update name
@@ -424,7 +424,7 @@ class SystemTagManagerTest extends TestCase {
], $tagIdMapping);
}
- public static function visibilityCheckProvider() {
+ public static function visibilityCheckProvider(): array {
return [
[false, false, false, false],
[true, false, false, true],
@@ -451,7 +451,7 @@ class SystemTagManagerTest extends TestCase {
$this->assertEquals($expectedResult, $this->tagManager->canUserSeeTag($tag1, $user));
}
- public static function assignabilityCheckProvider() {
+ public static function assignabilityCheckProvider(): array {
return [
// no groups
[false, false, false, false],
@@ -529,7 +529,7 @@ class SystemTagManagerTest extends TestCase {
$this->assertEquals([], $this->tagManager->getTagGroups($tag1));
}
- private function allowedToCreateProvider(): array {
+ public static function allowedToCreateProvider(): array {
return [
[true, null, true],
[true, null, false],
@@ -570,7 +570,7 @@ class SystemTagManagerTest extends TestCase {
\OC::$CLI = $oldCli;
}
- private function disallowedToCreateProvider(): array {
+ public static function disallowedToCreateProvider(): array {
return [
[false],
[null],
diff --git a/tests/lib/Updater/ReleaseMetadataTest.php b/tests/lib/Updater/ReleaseMetadataTest.php
index 72c6da5064d..335425b7672 100644
--- a/tests/lib/Updater/ReleaseMetadataTest.php
+++ b/tests/lib/Updater/ReleaseMetadataTest.php
@@ -17,9 +17,7 @@ class ReleaseMetadataTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();
- $this->clientService = $this->getMockBuilder(IClientService::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->clientService = $this->createMock(IClientService::class);
}
public function testDownloadMetadata(): void {
@@ -39,7 +37,7 @@ class ReleaseMetadataTest extends \Test\TestCase {
$releaseMetadata = new ReleaseMetadata($this->clientService);
- $this->assertSame($this->resultRequestArray(), $releaseMetadata->downloadMetadata('ouila'));
+ $this->assertSame(self::resultRequestArray(), $releaseMetadata->downloadMetadata('ouila'));
}
/**
@@ -72,7 +70,7 @@ class ReleaseMetadataTest extends \Test\TestCase {
/**
* @return array
*/
- public function getMetadataUrlProvider(): array {
+ public static function getMetadataUrlProvider(): array {
return [
[
'30.0.0',
@@ -89,11 +87,11 @@ class ReleaseMetadataTest extends \Test\TestCase {
];
}
- private function resultRequest(): string {
- return json_encode($this->resultRequestArray());
+ private static function resultRequest(): string {
+ return json_encode(self::resultRequestArray());
}
- private function resultRequestArray(): array {
+ private static function resultRequestArray(): array {
return [
'migrations' => [
'core' => [],
diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php
index 51d1625ea4d..4ee75c767a2 100644
--- a/tests/lib/Updater/VersionCheckTest.php
+++ b/tests/lib/Updater/VersionCheckTest.php
@@ -45,7 +45,7 @@ class VersionCheckTest extends \Test\TestCase {
->willReturn(false);
$this->logger = $this->createMock(LoggerInterface::class);
$this->updater = $this->getMockBuilder(VersionCheck::class)
- ->setMethods(['getUrlContent'])
+ ->onlyMethods(['getUrlContent'])
->setConstructorArgs([
$this->serverVersion,
$clientService,
diff --git a/tests/lib/UpdaterTest.php b/tests/lib/UpdaterTest.php
index 81babee7029..291aaf807e5 100644
--- a/tests/lib/UpdaterTest.php
+++ b/tests/lib/UpdaterTest.php
@@ -54,7 +54,7 @@ class UpdaterTest extends TestCase {
/**
* @return array
*/
- public function versionCompatibilityTestData() {
+ public static function versionCompatibilityTestData(): array {
return [
// Upgrade with invalid version
['9.1.1.13', '11.0.2.25', ['nextcloud' => ['11.0' => true]], false],
diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php
index ed7b797d809..7006c3948f6 100644
--- a/tests/lib/UrlGeneratorTest.php
+++ b/tests/lib/UrlGeneratorTest.php
@@ -107,14 +107,14 @@ class UrlGeneratorTest extends \Test\TestCase {
$this->assertEquals($expected, $result);
}
- public static function provideRoutes() {
+ public static function provideRoutes(): array {
return [
['core.Preview.getPreview', 'http://localhost/nextcloud/index.php/core/preview.png'],
['cloud_federation_api.requesthandlercontroller.addShare', 'http://localhost/nextcloud/index.php/ocm/shares'],
];
}
- public static function provideDocRootAppUrlParts() {
+ public static function provideDocRootAppUrlParts(): array {
return [
['files_external', 'ajax/oauth2.php', [], '/index.php/apps/files_external/ajax/oauth2.php'],
['files_external', 'ajax/oauth2.php', ['trut' => 'trat', 'dut' => 'dat'], '/index.php/apps/files_external/ajax/oauth2.php?trut=trat&dut=dat'],
@@ -122,7 +122,7 @@ class UrlGeneratorTest extends \Test\TestCase {
];
}
- public static function provideSubDirAppUrlParts() {
+ public static function provideSubDirAppUrlParts(): array {
return [
['files_external', 'ajax/oauth2.php', [], '/nextcloud/index.php/apps/files_external/ajax/oauth2.php'],
['files_external', 'ajax/oauth2.php', ['trut' => 'trat', 'dut' => 'dat'], '/nextcloud/index.php/apps/files_external/ajax/oauth2.php?trut=trat&dut=dat'],
@@ -154,7 +154,7 @@ class UrlGeneratorTest extends \Test\TestCase {
$this->assertEquals($expectedResult, $result);
}
- public function provideDocRootURLs() {
+ public static function provideDocRootURLs(): array {
return [
['index.php', 'http://localhost/index.php'],
['/index.php', 'http://localhost/index.php'],
@@ -163,7 +163,7 @@ class UrlGeneratorTest extends \Test\TestCase {
];
}
- public function provideSubDirURLs() {
+ public static function provideSubDirURLs(): array {
return [
['', 'http://localhost/nextcloud/'],
['/', 'http://localhost/nextcloud/'],
@@ -213,7 +213,7 @@ class UrlGeneratorTest extends \Test\TestCase {
$this->assertEquals($expected, $result);
}
- public function provideOCSRoutes(): array {
+ public static function provideOCSRoutes(): array {
return [
['core.OCS.getCapabilities', false, 'http://localhost/nextcloud/ocs/v2.php/cloud/capabilities'],
['core.OCS.getCapabilities', true, 'http://localhost/nextcloud/ocs/v2.php/cloud/capabilities'],
@@ -268,7 +268,7 @@ class UrlGeneratorTest extends \Test\TestCase {
$this->assertSame('http://localhost' . \OC::$WEBROOT . '/apps/dashboard/', $this->urlGenerator->linkToDefaultPageUrl());
}
- public function imagePathProvider(): array {
+ public static function imagePathProvider(): array {
return [
['core', 'favicon-mask.svg', \OC::$WEBROOT . '/core/img/favicon-mask.svg'],
['files', 'folder.svg', \OC::$WEBROOT . '/apps/files/img/folder.svg'],
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php
index 7ed02571460..a10a0e87b81 100644
--- a/tests/lib/User/SessionTest.php
+++ b/tests/lib/User/SessionTest.php
@@ -96,7 +96,7 @@ class SessionTest extends \Test\TestCase {
$this->logger,
$this->dispatcher
])
- ->setMethods([
+ ->onlyMethods([
'setMagicInCookie',
])
->getMock();
@@ -104,7 +104,7 @@ class SessionTest extends \Test\TestCase {
\OC_User::setIncognitoMode(false);
}
- public function isLoggedInData() {
+ public static function isLoggedInData(): array {
return [
[true],
[false],
@@ -121,7 +121,7 @@ class SessionTest extends \Test\TestCase {
$userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
- ->setMethods([
+ ->onlyMethods([
'getUser'
])
->getMock();
@@ -177,7 +177,7 @@ class SessionTest extends \Test\TestCase {
//keep following methods intact in order to ensure hooks are working
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']);
$manager = $this->getMockBuilder(Manager::class)
- ->setMethods($mockedManagerMethods)
+ ->onlyMethods($mockedManagerMethods)
->setConstructorArgs([
$this->config,
$this->createMock(ICacheFactory::class),
@@ -205,7 +205,7 @@ class SessionTest extends \Test\TestCase {
$userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
- ->setMethods([
+ ->onlyMethods([
'prepareUserLogin'
])
->getMock();
@@ -244,7 +244,7 @@ class SessionTest extends \Test\TestCase {
//keep following methods intact in order to ensure hooks are working
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']);
$manager = $this->getMockBuilder(Manager::class)
- ->setMethods($mockedManagerMethods)
+ ->onlyMethods($mockedManagerMethods)
->setConstructorArgs([
$this->config,
$this->createMock(ICacheFactory::class),
@@ -278,7 +278,7 @@ class SessionTest extends \Test\TestCase {
//keep following methods intact in order to ensure hooks are working
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']);
$manager = $this->getMockBuilder(Manager::class)
- ->setMethods($mockedManagerMethods)
+ ->onlyMethods($mockedManagerMethods)
->setConstructorArgs([
$this->config,
$this->createMock(ICacheFactory::class),
@@ -322,7 +322,7 @@ class SessionTest extends \Test\TestCase {
// Keep following methods intact in order to ensure hooks are working
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']);
$manager = $this->getMockBuilder(Manager::class)
- ->setMethods($mockedManagerMethods)
+ ->onlyMethods($mockedManagerMethods)
->setConstructorArgs([
$this->config,
$this->createMock(ICacheFactory::class),
@@ -360,7 +360,7 @@ class SessionTest extends \Test\TestCase {
// Keep following methods intact in order to ensure hooks are working
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']);
$manager = $this->getMockBuilder(Manager::class)
- ->setMethods($mockedManagerMethods)
+ ->onlyMethods($mockedManagerMethods)
->setConstructorArgs([
$this->config,
$this->createMock(ICacheFactory::class),
@@ -424,7 +424,7 @@ class SessionTest extends \Test\TestCase {
/** @var Session $userSession */
$userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
- ->setMethods(['login', 'supportsCookies', 'createSessionToken', 'getUser'])
+ ->onlyMethods(['login', 'supportsCookies', 'createSessionToken', 'getUser'])
->getMock();
$this->tokenProvider->expects($this->once())
@@ -460,7 +460,7 @@ class SessionTest extends \Test\TestCase {
/** @var Session $userSession */
$userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
- ->setMethods(['login', 'supportsCookies', 'createSessionToken', 'getUser'])
+ ->onlyMethods(['login', 'supportsCookies', 'createSessionToken', 'getUser'])
->getMock();
$this->tokenProvider->expects($this->once())
@@ -486,7 +486,7 @@ class SessionTest extends \Test\TestCase {
/** @var Session $userSession */
$userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
- ->setMethods(['isTokenPassword', 'login', 'supportsCookies', 'createSessionToken', 'getUser'])
+ ->onlyMethods(['isTokenPassword', 'login', 'supportsCookies', 'createSessionToken', 'getUser'])
->getMock();
$userSession->expects($this->once())
@@ -528,7 +528,7 @@ class SessionTest extends \Test\TestCase {
/** @var Session $userSession */
$userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
- ->setMethods(['login', 'isTwoFactorEnforced'])
+ ->onlyMethods(['login', 'isTwoFactorEnforced'])
->getMock();
$this->tokenProvider->expects($this->once())
@@ -657,7 +657,7 @@ class SessionTest extends \Test\TestCase {
//keep following methods intact in order to ensure hooks are working
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']);
$manager = $this->getMockBuilder(Manager::class)
- ->setMethods($mockedManagerMethods)
+ ->onlyMethods($mockedManagerMethods)
->setConstructorArgs([
$this->config,
$this->createMock(ICacheFactory::class),
@@ -667,7 +667,7 @@ class SessionTest extends \Test\TestCase {
->getMock();
$userSession = $this->getMockBuilder(Session::class)
//override, otherwise tests will fail because of setcookie()
- ->setMethods(['setMagicInCookie', 'setLoginName'])
+ ->onlyMethods(['setMagicInCookie', 'setLoginName'])
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
->getMock();
@@ -747,7 +747,7 @@ class SessionTest extends \Test\TestCase {
//keep following methods intact in order to ensure hooks are working
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']);
$manager = $this->getMockBuilder(Manager::class)
- ->setMethods($mockedManagerMethods)
+ ->onlyMethods($mockedManagerMethods)
->setConstructorArgs([
$this->config,
$this->createMock(ICacheFactory::class),
@@ -757,7 +757,7 @@ class SessionTest extends \Test\TestCase {
->getMock();
$userSession = $this->getMockBuilder(Session::class)
//override, otherwise tests will fail because of setcookie()
- ->setMethods(['setMagicInCookie'])
+ ->onlyMethods(['setMagicInCookie'])
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
->getMock();
@@ -812,7 +812,7 @@ class SessionTest extends \Test\TestCase {
//keep following methods intact in order to ensure hooks are working
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']);
$manager = $this->getMockBuilder(Manager::class)
- ->setMethods($mockedManagerMethods)
+ ->onlyMethods($mockedManagerMethods)
->setConstructorArgs([
$this->config,
$this->createMock(ICacheFactory::class),
@@ -822,7 +822,7 @@ class SessionTest extends \Test\TestCase {
->getMock();
$userSession = $this->getMockBuilder(Session::class)
//override, otherwise tests will fail because of setcookie()
- ->setMethods(['setMagicInCookie'])
+ ->onlyMethods(['setMagicInCookie'])
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
->getMock();
@@ -865,7 +865,7 @@ class SessionTest extends \Test\TestCase {
//keep following methods intact in order to ensure hooks are working
$mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']);
$manager = $this->getMockBuilder(Manager::class)
- ->setMethods($mockedManagerMethods)
+ ->onlyMethods($mockedManagerMethods)
->setConstructorArgs([
$this->config,
$this->createMock(ICacheFactory::class),
@@ -875,7 +875,7 @@ class SessionTest extends \Test\TestCase {
->getMock();
$userSession = $this->getMockBuilder(Session::class)
//override, otherwise tests will fail because of setcookie()
- ->setMethods(['setMagicInCookie'])
+ ->onlyMethods(['setMagicInCookie'])
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
->getMock();
$token = 'goodToken';
@@ -925,7 +925,7 @@ class SessionTest extends \Test\TestCase {
$session->set('user_id', 'foo');
$userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
- ->setMethods([
+ ->onlyMethods([
'validateSession'
])
->getMock();
@@ -1155,7 +1155,7 @@ class SessionTest extends \Test\TestCase {
$this->logger,
$this->dispatcher
])
- ->setMethods([
+ ->onlyMethods([
'logClientIn',
'getUser',
])
@@ -1207,7 +1207,7 @@ class SessionTest extends \Test\TestCase {
$this->logger,
$this->dispatcher
])
- ->setMethods([
+ ->onlyMethods([
'logClientIn',
])
->getMock();
@@ -1235,7 +1235,7 @@ class SessionTest extends \Test\TestCase {
/** @var Session $userSession */
$userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
- ->setMethods(['isTokenPassword', 'login', 'supportsCookies', 'createSessionToken', 'getUser'])
+ ->onlyMethods(['isTokenPassword', 'login', 'supportsCookies', 'createSessionToken', 'getUser'])
->getMock();
$userSession->expects($this->once())
@@ -1281,7 +1281,7 @@ class SessionTest extends \Test\TestCase {
/** @var Session $userSession */
$userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
- ->setMethods(['isTokenPassword', 'login', 'supportsCookies', 'createSessionToken', 'getUser'])
+ ->onlyMethods(['isTokenPassword', 'login', 'supportsCookies', 'createSessionToken', 'getUser'])
->getMock();
$userSession->expects($this->once())
diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php
index 44d28481ed5..694c1e757cb 100644
--- a/tests/lib/User/UserTest.php
+++ b/tests/lib/User/UserTest.php
@@ -496,7 +496,7 @@ class UserTest extends TestCase {
$this->assertEquals(2, $hooksCalled);
}
- public function dataDeleteHooks() {
+ public static function dataDeleteHooks(): array {
return [
[true, 2],
[false, 1],
@@ -632,7 +632,7 @@ class UserTest extends TestCase {
->onlyMethods(['getHome'])
->setConstructorArgs(['foo', $backend, $this->dispatcher, null, $config])
->getMock();
-
+
$user->expects(self::atLeastOnce())
->method('getHome')
->willReturn('/home/path');
@@ -650,7 +650,7 @@ class UserTest extends TestCase {
$this->restoreService(\OCP\Comments\ICommentsManager::class);
}
- public function dataGetCloudId(): array {
+ public static function dataGetCloudId(): array {
return [
['https://localhost:8888/nextcloud', 'foo@localhost:8888/nextcloud'],
['http://localhost:8888/nextcloud', 'foo@http://localhost:8888/nextcloud'],
@@ -964,7 +964,7 @@ class UserTest extends TestCase {
null,
$config,
])
- ->setMethods(['isEnabled', 'triggerChange'])
+ ->onlyMethods(['isEnabled', 'triggerChange'])
->getMock();
$user->expects($this->once())
@@ -998,7 +998,7 @@ class UserTest extends TestCase {
null,
$config,
])
- ->setMethods(['isEnabled', 'triggerChange'])
+ ->onlyMethods(['isEnabled', 'triggerChange'])
->getMock();
$user->expects($this->once())