aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-05-30 14:19:51 +0200
committerGitHub <noreply@github.com>2024-05-30 14:19:51 +0200
commit99af78cd66cb489b52f985e9a5b7d165b60b0e82 (patch)
treee0ea396f5eefcd8a5a4b6f7ec35769d42cb32a7f /tests
parentf80282a5ed1891224e3fa71c69ca2d60412c4c63 (diff)
parent31b0a44cf65b6625636ea0fa15fb1a1122b525e1 (diff)
downloadnextcloud-server-99af78cd66cb489b52f985e9a5b7d165b60b0e82.tar.gz
nextcloud-server-99af78cd66cb489b52f985e9a5b7d165b60b0e82.zip
Merge branch 'master' into refactor/OC-Server-getL10NFactory
Signed-off-by: John Molakvoæ <skjnldsv@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Core/Command/Apps/AppsDisableTest.php19
-rw-r--r--tests/Core/Command/Apps/AppsEnableTest.php19
-rw-r--r--tests/Core/Command/Config/App/DeleteConfigTest.php20
-rw-r--r--tests/Core/Command/Config/App/GetConfigTest.php43
-rw-r--r--tests/Core/Command/Config/App/SetConfigTest.php64
-rw-r--r--tests/Core/Command/Config/ImportTest.php20
-rw-r--r--tests/Core/Command/Config/ListConfigsTest.php20
-rw-r--r--tests/Core/Command/Config/System/DeleteConfigTest.php20
-rw-r--r--tests/Core/Command/Config/System/GetConfigTest.php20
-rw-r--r--tests/Core/Command/Config/System/SetConfigTest.php20
-rw-r--r--tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php26
-rw-r--r--tests/Core/Command/Encryption/DecryptAllTest.php54
-rw-r--r--tests/Core/Command/Encryption/DisableTest.php20
-rw-r--r--tests/Core/Command/Encryption/EnableTest.php62
-rw-r--r--tests/Core/Command/Encryption/EncryptAllTest.php28
-rw-r--r--tests/Core/Command/Encryption/SetDefaultModuleTest.php31
-rw-r--r--tests/Core/Command/Group/AddTest.php21
-rw-r--r--tests/Core/Command/Group/AddUserTest.php21
-rw-r--r--tests/Core/Command/Group/DeleteTest.php21
-rw-r--r--tests/Core/Command/Group/InfoTest.php21
-rw-r--r--tests/Core/Command/Group/ListCommandTest.php21
-rw-r--r--tests/Core/Command/Group/RemoveUserTest.php21
-rw-r--r--tests/Core/Command/Log/FileTest.php34
-rw-r--r--tests/Core/Command/Log/ManageTest.php57
-rw-r--r--tests/Core/Command/Maintenance/DataFingerprintTest.php20
-rw-r--r--tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php64
-rw-r--r--tests/Core/Command/Maintenance/ModeTest.php5
-rw-r--r--tests/Core/Command/Maintenance/UpdateTheme.php21
-rw-r--r--tests/Core/Command/Preview/RepairTest.php9
-rw-r--r--tests/Core/Command/SystemTag/AddTest.php21
-rw-r--r--tests/Core/Command/SystemTag/DeleteTest.php21
-rw-r--r--tests/Core/Command/SystemTag/EditTest.php21
-rw-r--r--tests/Core/Command/SystemTag/ListCommandTest.php21
-rw-r--r--tests/Core/Command/TwoFactorAuth/CleanupTest.php21
-rw-r--r--tests/Core/Command/TwoFactorAuth/DisableTest.php21
-rw-r--r--tests/Core/Command/TwoFactorAuth/EnableTest.php21
-rw-r--r--tests/Core/Command/TwoFactorAuth/EnforceTest.php21
-rw-r--r--tests/Core/Command/TwoFactorAuth/StateTest.php21
-rw-r--r--tests/Core/Command/User/AddTest.php153
-rw-r--r--tests/Core/Command/User/AuthTokens/DeleteTest.php23
-rw-r--r--tests/Core/Command/User/DeleteTest.php20
-rw-r--r--tests/Core/Command/User/DisableTest.php21
-rw-r--r--tests/Core/Command/User/EnableTest.php21
-rw-r--r--tests/Core/Command/User/LastSeenTest.php20
-rw-r--r--tests/Core/Command/User/SettingTest.php20
-rw-r--r--tests/Core/Controller/AppPasswordControllerTest.php41
-rw-r--r--tests/Core/Controller/AutoCompleteControllerTest.php21
-rw-r--r--tests/Core/Controller/AvatarControllerTest.php20
-rw-r--r--tests/Core/Controller/CSRFTokenControllerTest.php21
-rw-r--r--tests/Core/Controller/ChangePasswordControllerTest.php20
-rw-r--r--tests/Core/Controller/ClientFlowLoginControllerTest.php27
-rw-r--r--tests/Core/Controller/ClientFlowLoginV2ControllerTest.php21
-rw-r--r--tests/Core/Controller/ContactsMenuControllerTest.php21
-rw-r--r--tests/Core/Controller/CssControllerTest.php24
-rw-r--r--tests/Core/Controller/GuestAvatarControllerTest.php5
-rw-r--r--tests/Core/Controller/JsControllerTest.php24
-rw-r--r--tests/Core/Controller/LoginControllerTest.php91
-rw-r--r--tests/Core/Controller/LostControllerTest.php21
-rw-r--r--tests/Core/Controller/NavigationControllerTest.php21
-rw-r--r--tests/Core/Controller/OCSControllerTest.php24
-rw-r--r--tests/Core/Controller/PreviewControllerTest.php21
-rw-r--r--tests/Core/Controller/TwoFactorChallengeControllerTest.php29
-rw-r--r--tests/Core/Controller/UserControllerTest.php21
-rw-r--r--tests/Core/Controller/WellKnownControllerTest.php22
-rw-r--r--tests/Core/Controller/WipeControllerTest.php21
-rw-r--r--tests/Core/Data/LoginFlowV2CredentialsTest.php19
-rw-r--r--tests/Core/Middleware/TwoFactorMiddlewareTest.php20
-rw-r--r--tests/Core/Service/LoginFlowV2ServiceUnitTest.php23
-rw-r--r--tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php21
-rw-r--r--tests/Test/Repair/Owncloud/CleanPreviewsTest.php21
-rw-r--r--tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php21
-rw-r--r--tests/acceptance/composer.json19
-rw-r--r--tests/acceptance/composer.lock4203
-rw-r--r--tests/acceptance/config/behat.yml105
-rw-r--r--tests/acceptance/config/firefox-profiles/css-grid-enabled.zipbin192 -> 0 bytes
-rw-r--r--tests/acceptance/features/access-levels.feature23
-rw-r--r--tests/acceptance/features/app-comments.feature325
-rw-r--r--tests/acceptance/features/apps.feature92
-rw-r--r--tests/acceptance/features/bootstrap/AppNavigationContext.php154
-rw-r--r--tests/acceptance/features/bootstrap/AppSettingsContext.php99
-rw-r--r--tests/acceptance/features/bootstrap/AppsManagementContext.php283
-rw-r--r--tests/acceptance/features/bootstrap/CommentsAppContext.php113
-rw-r--r--tests/acceptance/features/bootstrap/ContactsMenuContext.php145
-rw-r--r--tests/acceptance/features/bootstrap/DialogContext.php77
-rw-r--r--tests/acceptance/features/bootstrap/FeatureContext.php35
-rw-r--r--tests/acceptance/features/bootstrap/FileListAncestorSetter.php64
-rw-r--r--tests/acceptance/features/bootstrap/FileListContext.php595
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppContext.php416
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppSharingContext.php811
-rw-r--r--tests/acceptance/features/bootstrap/LoginPageContext.php149
-rw-r--r--tests/acceptance/features/bootstrap/NotificationsContext.php96
-rw-r--r--tests/acceptance/features/bootstrap/PublicShareContext.php253
-rw-r--r--tests/acceptance/features/bootstrap/SearchContext.php114
-rw-r--r--tests/acceptance/features/bootstrap/SettingsContext.php283
-rw-r--r--tests/acceptance/features/bootstrap/SettingsMenuContext.php228
-rw-r--r--tests/acceptance/features/bootstrap/ThemingAppContext.php186
-rw-r--r--tests/acceptance/features/bootstrap/ToastContext.php54
-rw-r--r--tests/acceptance/features/bootstrap/UsersSettingsContext.php379
-rw-r--r--tests/acceptance/features/bootstrap/WaitFor.php76
-rw-r--r--tests/acceptance/features/core/Actor.php214
-rw-r--r--tests/acceptance/features/core/ActorAware.php36
-rw-r--r--tests/acceptance/features/core/ActorAwareInterface.php29
-rw-r--r--tests/acceptance/features/core/ActorContext.php194
-rw-r--r--tests/acceptance/features/core/ElementFinder.php203
-rw-r--r--tests/acceptance/features/core/ElementWrapper.php358
-rw-r--r--tests/acceptance/features/core/Locator.php313
-rw-r--r--tests/acceptance/features/core/NextcloudTestServerContext.php126
-rw-r--r--tests/acceptance/features/core/NextcloudTestServerHelper.php71
-rw-r--r--tests/acceptance/features/core/NextcloudTestServerLocalApacheHelper.php128
-rw-r--r--tests/acceptance/features/core/NextcloudTestServerLocalBuiltInHelper.php142
-rw-r--r--tests/acceptance/features/core/NoSuchElementException.php35
-rw-r--r--tests/acceptance/features/core/Utils.php88
-rw-r--r--tests/acceptance/features/header.feature86
-rw-r--r--tests/acceptance/features/login.feature55
-rw-r--r--tests/acceptance/features/users.feature77
-rwxr-xr-xtests/acceptance/installAndConfigureServer.sh51
-rwxr-xr-xtests/acceptance/run-local.sh229
-rwxr-xr-xtests/acceptance/run.sh254
-rw-r--r--tests/apps.php37
-rw-r--r--tests/apps/testapp_dependency_missing/appinfo/info.xml4
-rw-r--r--tests/apps/testapp_infoxml/appinfo/info.xml4
-rw-r--r--tests/apps/testapp_name_missing/appinfo/info.xml4
-rw-r--r--tests/apps/testapp_version/appinfo/info.xml4
-rw-r--r--tests/blueprints/basic.toml2
-rw-r--r--tests/bootstrap.php12
-rw-r--r--tests/data/app/description-multi-lang.xml4
-rw-r--r--tests/data/app/description-single-lang.xml4
-rw-r--r--tests/data/app/expected-info.json.license3
-rw-r--r--tests/data/app/invalid-info.xml5
-rw-r--r--tests/data/app/navigation-one-item.json.license2
-rw-r--r--tests/data/app/navigation-one-item.xml4
-rw-r--r--tests/data/app/navigation-two-items.json.license2
-rw-r--r--tests/data/app/navigation-two-items.xml4
-rw-r--r--tests/data/app/valid-info.xml5
-rw-r--r--tests/data/integritycheck/SomeApp.crt.license2
-rw-r--r--tests/data/integritycheck/SomeApp.key.license2
-rw-r--r--tests/data/integritycheck/core.crt.license3
-rw-r--r--tests/data/integritycheck/core.key.license2
-rw-r--r--tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js2
-rw-r--r--tests/data/integritycheck/mimetypeListModified/core/signature.json4
-rw-r--r--tests/data/integritycheck/root.crt.license2
-rw-r--r--tests/data/integritycheck/root.key.license2
-rw-r--r--tests/data/scss/styles-error.scss4
-rw-r--r--tests/data/scss/styles-success.scss6
-rw-r--r--tests/data/svg/files-app-red.svg4
-rw-r--r--tests/data/svg/mixed-red.svg4
-rw-r--r--tests/data/svg/mixed-source.svg4
-rw-r--r--tests/data/svg/rect-black.svg4
-rw-r--r--tests/data/svg/rect-red.svg4
-rw-r--r--tests/data/svg/settings-admin-red.svg6
-rw-r--r--tests/data/testimage.webpbin2428 -> 3854 bytes
-rw-r--r--tests/docker/mysqlmb4.config.php6
-rwxr-xr-xtests/drone-run-integration-tests.sh3
-rwxr-xr-xtests/drone-run-php-tests.sh3
-rwxr-xr-xtests/drone-wait-objectstore.sh3
-rw-r--r--tests/enable_all.php7
-rw-r--r--tests/karma.config.js29
-rw-r--r--tests/lib/APITest.php7
-rw-r--r--tests/lib/Accounts/AccountManagerTest.php41
-rw-r--r--tests/lib/Accounts/AccountPropertyCollectionTest.php21
-rw-r--r--tests/lib/Accounts/AccountPropertyTest.php21
-rw-r--r--tests/lib/Accounts/AccountTest.php21
-rw-r--r--tests/lib/Accounts/HooksTest.php19
-rw-r--r--tests/lib/Activity/ManagerTest.php30
-rw-r--r--tests/lib/AllConfigTest.php32
-rw-r--r--tests/lib/App/AppManagerTest.php278
-rw-r--r--tests/lib/App/AppStore/Bundles/BundleBase.php19
-rw-r--r--tests/lib/App/AppStore/Bundles/BundleFetcherTest.php21
-rw-r--r--tests/lib/App/AppStore/Bundles/EducationBundleTest.php19
-rw-r--r--tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php19
-rw-r--r--tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php19
-rw-r--r--tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php19
-rw-r--r--tests/lib/App/AppStore/Fetcher/AppDiscoverFetcherTest.php116
-rw-r--r--tests/lib/App/AppStore/Fetcher/AppFetcherTest.php114
-rw-r--r--tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php24
-rw-r--r--tests/lib/App/AppStore/Fetcher/FetcherBase.php28
-rw-r--r--tests/lib/App/AppStore/Version/VersionParserTest.php21
-rw-r--r--tests/lib/App/AppStore/Version/VersionTest.php19
-rw-r--r--tests/lib/App/CompareVersionTest.php21
-rw-r--r--tests/lib/App/DependencyAnalyzerTest.php10
-rw-r--r--tests/lib/App/InfoParserTest.php10
-rw-r--r--tests/lib/App/PlatformRepositoryTest.php9
-rw-r--r--tests/lib/AppConfigTest.php1595
-rw-r--r--tests/lib/AppFramework/AppTest.php21
-rw-r--r--tests/lib/AppFramework/Bootstrap/BootContextTest.php20
-rw-r--r--tests/lib/AppFramework/Bootstrap/CoordinatorTest.php23
-rw-r--r--tests/lib/AppFramework/Bootstrap/FunctionInjectorTest.php20
-rw-r--r--tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php20
-rw-r--r--tests/lib/AppFramework/Controller/ApiControllerTest.php21
-rw-r--r--tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php21
-rw-r--r--tests/lib/AppFramework/Controller/ControllerTest.php23
-rw-r--r--tests/lib/AppFramework/Controller/OCSControllerTest.php21
-rw-r--r--tests/lib/AppFramework/Controller/PublicShareControllerTest.php21
-rw-r--r--tests/lib/AppFramework/Db/EntityTest.php21
-rw-r--r--tests/lib/AppFramework/Db/QBMapperTest.php21
-rw-r--r--tests/lib/AppFramework/Db/TransactionalTest.php22
-rw-r--r--tests/lib/AppFramework/DependencyInjection/DIContainerTest.php23
-rw-r--r--tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php21
-rw-r--r--tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php41
-rw-r--r--tests/lib/AppFramework/Http/DataResponseTest.php21
-rw-r--r--tests/lib/AppFramework/Http/DispatcherTest.php71
-rw-r--r--tests/lib/AppFramework/Http/DownloadResponseTest.php21
-rw-r--r--tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php43
-rw-r--r--tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php21
-rw-r--r--tests/lib/AppFramework/Http/FeaturePolicyTest.php21
-rw-r--r--tests/lib/AppFramework/Http/FileDisplayResponseTest.php21
-rw-r--r--tests/lib/AppFramework/Http/HttpTest.php21
-rw-r--r--tests/lib/AppFramework/Http/JSONResponseTest.php23
-rw-r--r--tests/lib/AppFramework/Http/OutputTest.php6
-rw-r--r--tests/lib/AppFramework/Http/PublicTemplateResponseTest.php21
-rw-r--r--tests/lib/AppFramework/Http/RedirectResponseTest.php21
-rw-r--r--tests/lib/AppFramework/Http/RequestIdTest.php19
-rw-r--r--tests/lib/AppFramework/Http/RequestStream.php5
-rw-r--r--tests/lib/AppFramework/Http/RequestTest.php409
-rw-r--r--tests/lib/AppFramework/Http/ResponseTest.php23
-rw-r--r--tests/lib/AppFramework/Http/StreamResponseTest.php21
-rw-r--r--tests/lib/AppFramework/Http/TemplateResponseTest.php21
-rw-r--r--tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php21
-rw-r--r--tests/lib/AppFramework/Middleware/CompressionMiddlewareTest.php21
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php21
-rw-r--r--tests/lib/AppFramework/Middleware/MiddlewareTest.php23
-rw-r--r--tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php21
-rw-r--r--tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php20
-rw-r--r--tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php21
-rw-r--r--tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php20
-rw-r--r--tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php11
-rw-r--r--tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php21
-rw-r--r--tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php21
-rw-r--r--tests/lib/AppFramework/Middleware/Security/Mock/CORSMiddlewareController.php20
-rw-r--r--tests/lib/AppFramework/Middleware/Security/Mock/NormalController.php20
-rw-r--r--tests/lib/AppFramework/Middleware/Security/Mock/OCSController.php20
-rw-r--r--tests/lib/AppFramework/Middleware/Security/Mock/PasswordConfirmationMiddlewareController.php20
-rw-r--r--tests/lib/AppFramework/Middleware/Security/Mock/SecurityMiddlewareController.php20
-rw-r--r--tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php21
-rw-r--r--tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php28
-rw-r--r--tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php21
-rw-r--r--tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php21
-rw-r--r--tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php12
-rw-r--r--tests/lib/AppFramework/OCS/BaseResponseTest.php60
-rw-r--r--tests/lib/AppFramework/Routing/RoutingTest.php41
-rw-r--r--tests/lib/AppFramework/Services/AppConfigTest.php675
-rw-r--r--tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php42
-rw-r--r--tests/lib/AppFramework/Utility/SimpleContainerTest.php45
-rw-r--r--tests/lib/AppFramework/Utility/TimeFactoryTest.php37
-rw-r--r--tests/lib/AppScriptSortTest.php7
-rw-r--r--tests/lib/AppTest.php15
-rw-r--r--tests/lib/Archive/TARTest.php7
-rw-r--r--tests/lib/Archive/TestBase.php7
-rw-r--r--tests/lib/Archive/ZIPTest.php7
-rw-r--r--tests/lib/Authentication/Events/RemoteWipeFinishedTest.php20
-rw-r--r--tests/lib/Authentication/Events/RemoteWipeStartedTest.php20
-rw-r--r--tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php20
-rw-r--r--tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php20
-rw-r--r--tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php20
-rw-r--r--tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php20
-rw-r--r--tests/lib/Authentication/Login/ALoginCommandTest.php20
-rw-r--r--tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php20
-rw-r--r--tests/lib/Authentication/Login/CompleteLoginCommandTest.php20
-rw-r--r--tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php20
-rw-r--r--tests/lib/Authentication/Login/EmailLoginCommandTest.php20
-rw-r--r--tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php20
-rw-r--r--tests/lib/Authentication/Login/LoggedInCheckCommandTest.php20
-rw-r--r--tests/lib/Authentication/Login/PreLoginHookCommandTest.php20
-rw-r--r--tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php20
-rw-r--r--tests/lib/Authentication/Login/TwoFactorCommandTest.php20
-rw-r--r--tests/lib/Authentication/Login/UidLoginCommandTest.php20
-rw-r--r--tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php20
-rw-r--r--tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php20
-rw-r--r--tests/lib/Authentication/LoginCredentials/CredentialsTest.php21
-rw-r--r--tests/lib/Authentication/LoginCredentials/StoreTest.php21
-rw-r--r--tests/lib/Authentication/Token/ManagerTest.php21
-rw-r--r--tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php38
-rw-r--r--tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php36
-rw-r--r--tests/lib/Authentication/Token/PublicKeyTokenTest.php21
-rw-r--r--tests/lib/Authentication/Token/RemoteWipeTest.php20
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php21
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php20
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/ManagerTest.php45
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php21
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php21
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php21
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/ProviderSetTest.php21
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/RegistryTest.php21
-rw-r--r--tests/lib/AutoLoaderTest.php7
-rw-r--r--tests/lib/Avatar/AvatarManagerTest.php41
-rw-r--r--tests/lib/Avatar/GuestAvatarTest.php19
-rw-r--r--tests/lib/Avatar/UserAvatarTest.php7
-rw-r--r--tests/lib/BackgroundJob/DummyJobList.php17
-rw-r--r--tests/lib/BackgroundJob/JobListTest.php7
-rw-r--r--tests/lib/BackgroundJob/JobTest.php29
-rw-r--r--tests/lib/BackgroundJob/QueuedJobTest.php41
-rw-r--r--tests/lib/BackgroundJob/TestJob.php11
-rw-r--r--tests/lib/BackgroundJob/TestParallelAwareJob.php8
-rw-r--r--tests/lib/BackgroundJob/TimedJobTest.php74
-rw-r--r--tests/lib/Cache/CappedMemoryCacheTest.php21
-rw-r--r--tests/lib/Cache/FileCacheTest.php21
-rw-r--r--tests/lib/Cache/TestCache.php7
-rw-r--r--tests/lib/Calendar/ManagerTest.php21
-rw-r--r--tests/lib/Calendar/Resource/ManagerTest.php21
-rw-r--r--tests/lib/Calendar/Room/ManagerTest.php21
-rw-r--r--tests/lib/CapabilitiesManagerTest.php20
-rw-r--r--tests/lib/Collaboration/Collaborators/GroupPluginTest.php21
-rw-r--r--tests/lib/Collaboration/Collaborators/LookupPluginTest.php21
-rw-r--r--tests/lib/Collaboration/Collaborators/MailPluginTest.php23
-rw-r--r--tests/lib/Collaboration/Collaborators/RemotePluginTest.php21
-rw-r--r--tests/lib/Collaboration/Collaborators/SearchResultTest.php21
-rw-r--r--tests/lib/Collaboration/Collaborators/SearchTest.php21
-rw-r--r--tests/lib/Collaboration/Collaborators/UserPluginTest.php27
-rw-r--r--tests/lib/Collaboration/Resources/ManagerTest.php19
-rw-r--r--tests/lib/Collaboration/Resources/ProviderManagerTest.php19
-rw-r--r--tests/lib/Command/AsyncBusTest.php7
-rw-r--r--tests/lib/Command/BackgroundJobsTest.php25
-rw-r--r--tests/lib/Command/CronBusTest.php28
-rw-r--r--tests/lib/Command/Integrity/SignAppTest.php20
-rw-r--r--tests/lib/Command/Integrity/SignCoreTest.php20
-rw-r--r--tests/lib/Comments/CommentTest.php81
-rw-r--r--tests/lib/Comments/FakeFactory.php6
-rw-r--r--tests/lib/Comments/FakeManager.php10
-rw-r--r--tests/lib/Comments/ManagerTest.php60
-rw-r--r--tests/lib/ConfigTest.php7
-rw-r--r--tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php21
-rw-r--r--tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php21
-rw-r--r--tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php21
-rw-r--r--tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php152
-rw-r--r--tests/lib/Contacts/ContactsMenu/EntryTest.php27
-rw-r--r--tests/lib/Contacts/ContactsMenu/ManagerTest.php25
-rw-r--r--tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php21
-rw-r--r--tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php21
-rw-r--r--tests/lib/ContactsManagerTest.php33
-rw-r--r--tests/lib/DB/ConnectionFactoryTest.php19
-rw-r--r--tests/lib/DB/ConnectionTest.php101
-rw-r--r--tests/lib/DB/Exception/DbalExceptionTest.php20
-rw-r--r--tests/lib/DB/MigrationsTest.php7
-rw-r--r--tests/lib/DB/MigratorTest.php23
-rw-r--r--tests/lib/DB/OCPostgreSqlPlatformTest.php20
-rw-r--r--tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php105
-rw-r--r--tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php20
-rw-r--r--tests/lib/DB/QueryBuilder/FunctionBuilderTest.php19
-rw-r--r--tests/lib/DB/QueryBuilder/QueryBuilderTest.php22
-rw-r--r--tests/lib/DB/QueryBuilder/QuoteHelperTest.php20
-rw-r--r--tests/lib/DateTimeFormatterTest.php13
-rw-r--r--tests/lib/Diagnostics/EventLoggerTest.php22
-rw-r--r--tests/lib/Diagnostics/QueryLoggerTest.php20
-rw-r--r--tests/lib/DirectEditing/ManagerTest.php5
-rw-r--r--tests/lib/EmojiHelperTest.php21
-rw-r--r--tests/lib/Encryption/DecryptAllTest.php20
-rw-r--r--tests/lib/Encryption/EncryptionWrapperTest.php20
-rw-r--r--tests/lib/Encryption/Keys/StorageTest.php55
-rw-r--r--tests/lib/Encryption/ManagerTest.php120
-rw-r--r--tests/lib/Encryption/UpdateTest.php24
-rw-r--r--tests/lib/Encryption/UtilTest.php77
-rw-r--r--tests/lib/ErrorHandlerTest.php21
-rw-r--r--tests/lib/EventSourceFactoryTest.php20
-rw-r--r--tests/lib/Federation/CloudIdManagerTest.php41
-rw-r--r--tests/lib/Federation/CloudIdTest.php19
-rw-r--r--tests/lib/FileChunkingTest.php20
-rw-r--r--tests/lib/Files/AppData/AppDataTest.php21
-rw-r--r--tests/lib/Files/AppData/FactoryTest.php21
-rw-r--r--tests/lib/Files/Cache/CacheTest.php7
-rw-r--r--tests/lib/Files/Cache/HomeCacheTest.php7
-rw-r--r--tests/lib/Files/Cache/LocalRootScannerTest.php19
-rw-r--r--tests/lib/Files/Cache/MoveFromCacheTraitTest.php7
-rw-r--r--tests/lib/Files/Cache/PropagatorTest.php7
-rw-r--r--tests/lib/Files/Cache/ScannerTest.php51
-rw-r--r--tests/lib/Files/Cache/SearchBuilderTest.php20
-rw-r--r--tests/lib/Files/Cache/UpdaterLegacyTest.php11
-rw-r--r--tests/lib/Files/Cache/UpdaterTest.php7
-rw-r--r--tests/lib/Files/Cache/WatcherTest.php7
-rw-r--r--tests/lib/Files/Cache/Wrapper/CacheJailTest.php37
-rw-r--r--tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php7
-rw-r--r--tests/lib/Files/Config/UserMountCacheTest.php69
-rw-r--r--tests/lib/Files/EtagTest.php9
-rw-r--r--tests/lib/Files/FileInfoTest.php24
-rw-r--r--tests/lib/Files/FilesystemTest.php27
-rw-r--r--tests/lib/Files/Mount/CacheMountProviderTest.php92
-rw-r--r--tests/lib/Files/Mount/ManagerTest.php7
-rw-r--r--tests/lib/Files/Mount/MountPointTest.php7
-rw-r--r--tests/lib/Files/Mount/MountTest.php7
-rw-r--r--tests/lib/Files/Mount/ObjectHomeMountProviderTest.php6
-rw-r--r--tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php21
-rw-r--r--tests/lib/Files/Mount/RootMountProviderTest.php19
-rw-r--r--tests/lib/Files/Node/FileTest.php32
-rw-r--r--tests/lib/Files/Node/FolderTest.php53
-rw-r--r--tests/lib/Files/Node/HookConnectorTest.php26
-rw-r--r--tests/lib/Files/Node/IntegrationTest.php17
-rw-r--r--tests/lib/Files/Node/NodeTest.php29
-rw-r--r--tests/lib/Files/Node/RootTest.php36
-rw-r--r--tests/lib/Files/ObjectStore/AzureTest.php19
-rw-r--r--tests/lib/Files/ObjectStore/FailDeleteObjectStore.php21
-rw-r--r--tests/lib/Files/ObjectStore/FailWriteObjectStore.php21
-rw-r--r--tests/lib/Files/ObjectStore/LocalTest.php19
-rw-r--r--tests/lib/Files/ObjectStore/MapperTest.php20
-rw-r--r--tests/lib/Files/ObjectStore/ObjectStoreScannerTest.php10
-rw-r--r--tests/lib/Files/ObjectStore/ObjectStoreStorageOverwrite.php23
-rw-r--r--tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php57
-rw-r--r--tests/lib/Files/ObjectStore/ObjectStoreTest.php19
-rw-r--r--tests/lib/Files/ObjectStore/S3Test.php40
-rw-r--r--tests/lib/Files/ObjectStore/SwiftTest.php24
-rw-r--r--tests/lib/Files/PathVerificationTest.php8
-rw-r--r--tests/lib/Files/Search/QueryOptimizer/CombinedTests.php194
-rw-r--r--tests/lib/Files/Search/QueryOptimizer/FlattenNestedBoolTest.php45
-rw-r--r--tests/lib/Files/Search/QueryOptimizer/MergeDistributiveOperationsTest.php163
-rw-r--r--tests/lib/Files/Search/QueryOptimizer/OrEqualsToInTest.php123
-rw-r--r--tests/lib/Files/Search/SearchIntegrationTest.php47
-rw-r--r--tests/lib/Files/SimpleFS/InMemoryFileTest.php19
-rw-r--r--tests/lib/Files/SimpleFS/SimpleFileTest.php21
-rw-r--r--tests/lib/Files/SimpleFS/SimpleFolderTest.php21
-rw-r--r--tests/lib/Files/Storage/CommonTest.php72
-rw-r--r--tests/lib/Files/Storage/CopyDirectoryTest.php20
-rw-r--r--tests/lib/Files/Storage/HomeTest.php21
-rw-r--r--tests/lib/Files/Storage/LocalTest.php32
-rw-r--r--tests/lib/Files/Storage/Storage.php26
-rw-r--r--tests/lib/Files/Storage/StorageFactoryTest.php7
-rw-r--r--tests/lib/Files/Storage/Wrapper/AvailabilityTest.php20
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncodingTest.php7
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php76
-rw-r--r--tests/lib/Files/Storage/Wrapper/JailTest.php7
-rw-r--r--tests/lib/Files/Storage/Wrapper/KnownMtimeTest.php68
-rw-r--r--tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php7
-rw-r--r--tests/lib/Files/Storage/Wrapper/QuotaTest.php7
-rw-r--r--tests/lib/Files/Storage/Wrapper/WrapperTest.php7
-rw-r--r--tests/lib/Files/Stream/DummyEncryptionWrapper.php20
-rw-r--r--tests/lib/Files/Stream/EncryptionTest.php20
-rw-r--r--tests/lib/Files/Stream/HashWrapperTest.php19
-rw-r--r--tests/lib/Files/Stream/QuotaTest.php7
-rw-r--r--tests/lib/Files/Type/DetectionTest.php20
-rw-r--r--tests/lib/Files/Type/LoaderTest.php31
-rw-r--r--tests/lib/Files/Utils/ScannerTest.php7
-rw-r--r--tests/lib/Files/ViewTest.php26
-rw-r--r--tests/lib/GlobalScale/ConfigTest.php19
-rw-r--r--tests/lib/Group/Backend.php25
-rw-r--r--tests/lib/Group/DatabaseTest.php42
-rw-r--r--tests/lib/Group/Dummy.php21
-rw-r--r--tests/lib/Group/GroupTest.php7
-rw-r--r--tests/lib/Group/ManagerTest.php58
-rw-r--r--tests/lib/Group/MetaDataTest.php21
-rw-r--r--tests/lib/HelperStorageTest.php7
-rw-r--r--tests/lib/HookHelper.php7
-rw-r--r--tests/lib/Hooks/BasicEmitterTest.php7
-rw-r--r--tests/lib/Http/Client/ClientServiceTest.php60
-rw-r--r--tests/lib/Http/Client/ClientTest.php8
-rw-r--r--tests/lib/Http/Client/DnsPinMiddlewareTest.php546
-rw-r--r--tests/lib/Http/Client/NegativeDnsCacheTest.php21
-rw-r--r--tests/lib/Http/Client/ResponseTest.php7
-rw-r--r--tests/lib/Http/WellKnown/GenericResponseTest.php22
-rw-r--r--tests/lib/Http/WellKnown/JrdResponseTest.php22
-rw-r--r--tests/lib/Http/WellKnown/RequestManagerTest.php22
-rw-r--r--tests/lib/ImageTest.php10
-rw-r--r--tests/lib/InfoXmlTest.php19
-rw-r--r--tests/lib/InitialStateServiceTest.php26
-rw-r--r--tests/lib/InstallerTest.php46
-rw-r--r--tests/lib/IntegrityCheck/CheckerTest.php30
-rw-r--r--tests/lib/IntegrityCheck/Helpers/AppLocatorTest.php20
-rw-r--r--tests/lib/IntegrityCheck/Helpers/EnvironmentHelperTest.php20
-rw-r--r--tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php20
-rw-r--r--tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php21
-rw-r--r--tests/lib/L10N/FactoryTest.php48
-rw-r--r--tests/lib/L10N/L10nTest.php15
-rw-r--r--tests/lib/L10N/LanguageIteratorTest.php21
-rw-r--r--tests/lib/LargeFileHelperGetFileSizeTest.php7
-rw-r--r--tests/lib/LargeFileHelperTest.php7
-rw-r--r--tests/lib/LegacyHelperTest.php7
-rw-r--r--tests/lib/Lock/DBLockingProviderTest.php20
-rw-r--r--tests/lib/Lock/LockingProvider.php20
-rw-r--r--tests/lib/Lock/MemcacheLockingProviderTest.php24
-rw-r--r--tests/lib/Lock/NonCachingDBLockingProviderTest.php19
-rw-r--r--tests/lib/Lockdown/Filesystem/NoFSTest.php25
-rw-r--r--tests/lib/Lockdown/Filesystem/NullCacheTest.php21
-rw-r--r--tests/lib/Lockdown/Filesystem/NullStorageTest.php21
-rw-r--r--tests/lib/Lockdown/LockdownManagerTest.php19
-rw-r--r--tests/lib/Log/ExceptionSerializerTest.php21
-rw-r--r--tests/lib/Log/FileTest.php16
-rw-r--r--tests/lib/Log/LogFactoryTest.php22
-rw-r--r--tests/lib/LoggerTest.php10
-rw-r--r--tests/lib/Mail/EMailTemplateTest.php21
-rw-r--r--tests/lib/Mail/MailerTest.php20
-rw-r--r--tests/lib/Mail/MessageTest.php9
-rw-r--r--tests/lib/Memcache/APCuTest.php7
-rw-r--r--tests/lib/Memcache/ArrayCacheTest.php7
-rw-r--r--tests/lib/Memcache/Cache.php7
-rw-r--r--tests/lib/Memcache/CasTraitTest.php20
-rw-r--r--tests/lib/Memcache/FactoryTest.php33
-rw-r--r--tests/lib/Memcache/MemcachedTest.php7
-rw-r--r--tests/lib/Memcache/RedisTest.php28
-rw-r--r--tests/lib/MemoryInfoTest.php19
-rw-r--r--tests/lib/Metadata/FileMetadataMapperTest.php87
-rw-r--r--tests/lib/Migration/BackgroundRepairTest.php53
-rw-r--r--tests/lib/NaturalSortTest.php7
-rw-r--r--tests/lib/NavigationManagerTest.php190
-rw-r--r--tests/lib/Net/HostnameClassifierTest.php22
-rw-r--r--tests/lib/Net/IpAddressClassifierTest.php22
-rw-r--r--tests/lib/Notification/ActionTest.php20
-rw-r--r--tests/lib/Notification/DummyApp.php19
-rw-r--r--tests/lib/Notification/DummyNotifier.php19
-rw-r--r--tests/lib/Notification/ManagerTest.php20
-rw-r--r--tests/lib/Notification/NotificationTest.php20
-rw-r--r--tests/lib/OCS/DiscoveryServiceTest.php19
-rw-r--r--tests/lib/OCS/MapStatusCodeTest.php20
-rw-r--r--tests/lib/OCS/ProviderTest.php20
-rw-r--r--tests/lib/Preview/BackgroundCleanupJobTest.php24
-rw-r--r--tests/lib/Preview/BitmapTest.php20
-rw-r--r--tests/lib/Preview/GeneratorTest.php21
-rw-r--r--tests/lib/Preview/HEICTest.php19
-rw-r--r--tests/lib/Preview/ImageTest.php20
-rw-r--r--tests/lib/Preview/MP3Test.php20
-rw-r--r--tests/lib/Preview/MovieTest.php20
-rw-r--r--tests/lib/Preview/OfficeTest.php20
-rw-r--r--tests/lib/Preview/Provider.php23
-rw-r--r--tests/lib/Preview/SVGTest.php49
-rw-r--r--tests/lib/Preview/TXTTest.php20
-rw-r--r--tests/lib/PublicNamespace/UtilTest.php20
-rw-r--r--tests/lib/Remote/Api/OCSTest.php19
-rw-r--r--tests/lib/Remote/InstanceTest.php19
-rw-r--r--tests/lib/Repair/CleanTagsTest.php7
-rw-r--r--tests/lib/Repair/ClearFrontendCachesTest.php21
-rw-r--r--tests/lib/Repair/ClearGeneratedAvatarCacheTest.php21
-rw-r--r--tests/lib/Repair/NC11/FixMountStoragesTest.php21
-rw-r--r--tests/lib/Repair/OldGroupMembershipSharesTest.php7
-rw-r--r--tests/lib/Repair/RepairCollationTest.php7
-rw-r--r--tests/lib/Repair/RepairDavSharesTest.php23
-rw-r--r--tests/lib/Repair/RepairInvalidSharesTest.php7
-rw-r--r--tests/lib/Repair/RepairMimeTypesTest.php8
-rw-r--r--tests/lib/Repair/RepairSqliteAutoincrementTest.php90
-rw-r--r--tests/lib/RepairTest.php15
-rw-r--r--tests/lib/RichObjectStrings/DefinitionsTest.php19
-rw-r--r--tests/lib/RichObjectStrings/ValidatorTest.php19
-rw-r--r--tests/lib/Route/RouterTest.php21
-rw-r--r--tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php21
-rw-r--r--tests/lib/Security/Bruteforce/CapabilitiesTest.php19
-rw-r--r--tests/lib/Security/Bruteforce/ThrottlerTest.php33
-rw-r--r--tests/lib/Security/CSP/AddContentSecurityPolicyEventTest.php21
-rw-r--r--tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php20
-rw-r--r--tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php19
-rw-r--r--tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php20
-rw-r--r--tests/lib/Security/CSRF/CsrfTokenManagerTest.php20
-rw-r--r--tests/lib/Security/CSRF/CsrfTokenTest.php20
-rw-r--r--tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php20
-rw-r--r--tests/lib/Security/CertificateManagerTest.php13
-rw-r--r--tests/lib/Security/CertificateTest.php20
-rw-r--r--tests/lib/Security/CredentialsManagerTest.php20
-rw-r--r--tests/lib/Security/CryptoTest.php7
-rw-r--r--tests/lib/Security/FeaturePolicy/AddFeaturePolicyEventTest.php21
-rw-r--r--tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php21
-rw-r--r--tests/lib/Security/HasherTest.php7
-rw-r--r--tests/lib/Security/IdentityProof/KeyTest.php21
-rw-r--r--tests/lib/Security/IdentityProof/ManagerTest.php19
-rw-r--r--tests/lib/Security/IdentityProof/SignerTest.php21
-rw-r--r--tests/lib/Security/Normalizer/IpAddressTest.php19
-rw-r--r--tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php19
-rw-r--r--tests/lib/Security/RateLimiting/LimiterTest.php19
-rw-r--r--tests/lib/Security/RemoteHostValidatorIntegrationTest.php22
-rw-r--r--tests/lib/Security/RemoteHostValidatorTest.php37
-rw-r--r--tests/lib/Security/SecureRandomTest.php7
-rw-r--r--tests/lib/Security/TrustedDomainHelperTest.php7
-rw-r--r--tests/lib/Security/VerificationToken/VerificationTokenTest.php23
-rw-r--r--tests/lib/ServerTest.php26
-rw-r--r--tests/lib/Session/CryptoSessionDataTest.php20
-rw-r--r--tests/lib/Session/CryptoWrappingTest.php20
-rw-r--r--tests/lib/Session/MemoryTest.php7
-rw-r--r--tests/lib/Session/Session.php7
-rw-r--r--tests/lib/Settings/DeclarativeManagerTest.php521
-rw-r--r--tests/lib/Settings/ManagerTest.php23
-rw-r--r--tests/lib/Settings/SectionTest.php21
-rw-r--r--tests/lib/SetupTest.php39
-rw-r--r--tests/lib/Share/Backend.php30
-rw-r--r--tests/lib/Share/HelperTest.php20
-rw-r--r--tests/lib/Share/ShareTest.php126
-rw-r--r--tests/lib/Share20/DefaultShareProviderTest.php175
-rw-r--r--tests/lib/Share20/LegacyHooksTest.php24
-rw-r--r--tests/lib/Share20/ManagerTest.php347
-rw-r--r--tests/lib/Share20/ShareByMailProviderTest.php30
-rw-r--r--tests/lib/Share20/ShareHelperTest.php21
-rw-r--r--tests/lib/Share20/ShareTest.php20
-rw-r--r--tests/lib/SubAdminTest.php20
-rw-r--r--tests/lib/Support/CrashReport/RegistryTest.php21
-rw-r--r--tests/lib/Support/Subscription/DummySubscription.php19
-rw-r--r--tests/lib/Support/Subscription/RegistryTest.php19
-rw-r--r--tests/lib/SystemTag/SystemTagManagerTest.php8
-rw-r--r--tests/lib/SystemTag/SystemTagObjectMapperTest.php8
-rw-r--r--tests/lib/TagsTest.php21
-rw-r--r--tests/lib/Talk/BrokerTest.php22
-rw-r--r--tests/lib/Talk/ConversationOptionsTest.php22
-rw-r--r--tests/lib/TaskProcessing/TaskProcessingTest.php762
-rw-r--r--tests/lib/TempManagerTest.php7
-rw-r--r--tests/lib/Template/CSSResourceLocatorTest.php21
-rw-r--r--tests/lib/Template/JSCombinerTest.php21
-rw-r--r--tests/lib/Template/JSResourceLocatorTest.php29
-rw-r--r--tests/lib/Template/ResourceLocatorTest.php7
-rw-r--r--tests/lib/Template/data/1.js.license2
-rw-r--r--tests/lib/Template/data/2.js.license2
-rw-r--r--tests/lib/Template/data/combine.json.license2
-rw-r--r--tests/lib/TemplateFunctionsTest.php21
-rw-r--r--tests/lib/TestCase.php77
-rw-r--r--tests/lib/TestMoveableMountPoint.php20
-rw-r--r--tests/lib/TextProcessing/TextProcessingTest.php8
-rw-r--r--tests/lib/Traits/ClientServiceTrait.php19
-rw-r--r--tests/lib/Traits/EncryptionTrait.php7
-rw-r--r--tests/lib/Traits/MountProviderTrait.php7
-rw-r--r--tests/lib/Traits/UserTrait.php7
-rw-r--r--tests/lib/Updater/ChangesCheckTest.php25
-rw-r--r--tests/lib/Updater/VersionCheckTest.php227
-rw-r--r--tests/lib/UpdaterTest.php32
-rw-r--r--tests/lib/UrlGeneratorTest.php29
-rw-r--r--tests/lib/User/AvailabilityCoordinatorTest.php201
-rw-r--r--tests/lib/User/AvatarUserDummy.php21
-rw-r--r--tests/lib/User/Backend.php21
-rw-r--r--tests/lib/User/DatabaseTest.php21
-rw-r--r--tests/lib/User/Dummy.php21
-rw-r--r--tests/lib/User/ManagerTest.php9
-rw-r--r--tests/lib/User/SessionTest.php139
-rw-r--r--tests/lib/User/UserTest.php7
-rw-r--r--tests/lib/Util/Group/Dummy.php36
-rw-r--r--tests/lib/Util/User/Dummy.php28
-rw-r--r--tests/lib/UtilCheckServerTest.php9
-rw-r--r--tests/lib/UtilTest.php7
-rwxr-xr-xtests/objectstore/start-swift-ceph.sh4
-rwxr-xr-xtests/objectstore/stop-swift-ceph.sh3
-rwxr-xr-xtests/objectstore/wait-for-connection5
-rw-r--r--tests/phpunit-autotest-external.xml4
-rw-r--r--tests/phpunit-autotest.xml9
-rw-r--r--tests/preseed-config.php95
-rw-r--r--tests/redis-cluster.config.php5
-rw-r--r--tests/redis.config.php7
-rw-r--r--tests/startsessionlistener.php7
-rw-r--r--tests/travis/before_install.sh3
-rwxr-xr-xtests/travis/changed_app.sh3
-rw-r--r--tests/travis/custom.ini2
-rwxr-xr-xtests/travis/install.sh4
628 files changed, 9693 insertions, 21553 deletions
diff --git a/tests/Core/Command/Apps/AppsDisableTest.php b/tests/Core/Command/Apps/AppsDisableTest.php
index 2b276948b04..8d23ecd1c61 100644
--- a/tests/Core/Command/Apps/AppsDisableTest.php
+++ b/tests/Core/Command/Apps/AppsDisableTest.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Daniel Kesselberg (mail@danielkesselberg.de)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Command\Config;
diff --git a/tests/Core/Command/Apps/AppsEnableTest.php b/tests/Core/Command/Apps/AppsEnableTest.php
index 6e577464103..228c09364bf 100644
--- a/tests/Core/Command/Apps/AppsEnableTest.php
+++ b/tests/Core/Command/Apps/AppsEnableTest.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Daniel Kesselberg (mail@danielkesselberg.de)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Command\Config;
diff --git a/tests/Core/Command/Config/App/DeleteConfigTest.php b/tests/Core/Command/Config/App/DeleteConfigTest.php
index 2c9482b57f6..643c7ca3ca1 100644
--- a/tests/Core/Command/Config/App/DeleteConfigTest.php
+++ b/tests/Core/Command/Config/App/DeleteConfigTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Config\App;
diff --git a/tests/Core/Command/Config/App/GetConfigTest.php b/tests/Core/Command/Config/App/GetConfigTest.php
index 521ecfbfb40..79b79ea5576 100644
--- a/tests/Core/Command/Config/App/GetConfigTest.php
+++ b/tests/Core/Command/Config/App/GetConfigTest.php
@@ -1,28 +1,15 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Config\App;
+use OC\AppConfig;
use OC\Core\Command\Config\App\GetConfig;
-use OCP\IConfig;
+use OCP\Exceptions\AppConfigUnknownKeyException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
@@ -42,13 +29,13 @@ class GetConfigTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $config = $this->config = $this->getMockBuilder(IConfig::class)
+ $config = $this->config = $this->getMockBuilder(AppConfig::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
- /** @var \OCP\IConfig $config */
+ /** @var \OCP\IAppConfig $config */
$this->command = new GetConfig($config);
}
@@ -108,20 +95,22 @@ class GetConfigTest extends TestCase {
* @param string $expectedMessage
*/
public function testGet($configName, $value, $configExists, $defaultValue, $hasDefault, $outputFormat, $expectedReturn, $expectedMessage) {
- $this->config->expects($this->atLeastOnce())
- ->method('getAppKeys')
- ->with('app-name')
- ->willReturn($configExists ? [$configName] : []);
-
if (!$expectedReturn) {
if ($configExists) {
$this->config->expects($this->once())
- ->method('getAppValue')
+ ->method('getDetails')
->with('app-name', $configName)
- ->willReturn($value);
+ ->willReturn(['value' => $value]);
}
}
+ if (!$configExists) {
+ $this->config->expects($this->once())
+ ->method('getDetails')
+ ->with('app-name', $configName)
+ ->willThrowException(new AppConfigUnknownKeyException());
+ }
+
$this->consoleInput->expects($this->exactly(2))
->method('getArgument')
->willReturnMap([
diff --git a/tests/Core/Command/Config/App/SetConfigTest.php b/tests/Core/Command/Config/App/SetConfigTest.php
index 88053f8c189..5c7e856f6fa 100644
--- a/tests/Core/Command/Config/App/SetConfigTest.php
+++ b/tests/Core/Command/Config/App/SetConfigTest.php
@@ -1,28 +1,16 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Config\App;
+use OC\AppConfig;
use OC\Core\Command\Config\App\SetConfig;
-use OCP\IConfig;
+use OCP\Exceptions\AppConfigUnknownKeyException;
+use OCP\IAppConfig;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
@@ -42,13 +30,13 @@ class SetConfigTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $config = $this->config = $this->getMockBuilder(IConfig::class)
+ $config = $this->config = $this->getMockBuilder(AppConfig::class)
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
- /** @var \OCP\IConfig $config */
+ /** @var \OCP\IAppConfig $config */
$this->command = new SetConfig($config);
}
@@ -85,14 +73,24 @@ class SetConfigTest extends TestCase {
* @param string $expectedMessage
*/
public function testSet($configName, $newValue, $configExists, $updateOnly, $updated, $expectedMessage) {
- $this->config->expects($this->once())
- ->method('getAppKeys')
- ->with('app-name')
- ->willReturn($configExists ? [$configName] : []);
+ $this->config->expects($this->any())
+ ->method('hasKey')
+ ->with('app-name', $configName)
+ ->willReturn($configExists);
+
+ if (!$configExists) {
+ $this->config->expects($this->any())
+ ->method('getValueType')
+ ->willThrowException(new AppConfigUnknownKeyException());
+ } else {
+ $this->config->expects($this->any())
+ ->method('getValueType')
+ ->willReturn(IAppConfig::VALUE_MIXED);
+ }
if ($updated) {
$this->config->expects($this->once())
- ->method('setAppValue')
+ ->method('setValueMixed')
->with('app-name', $configName, $newValue);
}
@@ -104,13 +102,19 @@ class SetConfigTest extends TestCase {
]);
$this->consoleInput->expects($this->any())
->method('getOption')
- ->with('value')
- ->willReturn($newValue);
+ ->willReturnMap([
+ ['value', $newValue],
+ ['lazy', null],
+ ['sensitive', null],
+ ['no-interaction', true],
+ ]);
$this->consoleInput->expects($this->any())
->method('hasParameterOption')
- ->with('--update-only')
- ->willReturn($updateOnly);
-
+ ->willReturnMap([
+ ['--type', false, false],
+ ['--value', false, true],
+ ['--update-only', false, $updateOnly]
+ ]);
$this->consoleOutput->expects($this->any())
->method('writeln')
->with($this->stringContains($expectedMessage));
diff --git a/tests/Core/Command/Config/ImportTest.php b/tests/Core/Command/Config/ImportTest.php
index c9cc256bea9..91485955e60 100644
--- a/tests/Core/Command/Config/ImportTest.php
+++ b/tests/Core/Command/Config/ImportTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Config;
diff --git a/tests/Core/Command/Config/ListConfigsTest.php b/tests/Core/Command/Config/ListConfigsTest.php
index 01d5f512494..8b6fdf39192 100644
--- a/tests/Core/Command/Config/ListConfigsTest.php
+++ b/tests/Core/Command/Config/ListConfigsTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Config;
diff --git a/tests/Core/Command/Config/System/DeleteConfigTest.php b/tests/Core/Command/Config/System/DeleteConfigTest.php
index b72f06b35bf..9b5b018687e 100644
--- a/tests/Core/Command/Config/System/DeleteConfigTest.php
+++ b/tests/Core/Command/Config/System/DeleteConfigTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Config\System;
diff --git a/tests/Core/Command/Config/System/GetConfigTest.php b/tests/Core/Command/Config/System/GetConfigTest.php
index 3a6bb1acb50..db96331680b 100644
--- a/tests/Core/Command/Config/System/GetConfigTest.php
+++ b/tests/Core/Command/Config/System/GetConfigTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Config\System;
diff --git a/tests/Core/Command/Config/System/SetConfigTest.php b/tests/Core/Command/Config/System/SetConfigTest.php
index a53607e8a39..d5c54a5e720 100644
--- a/tests/Core/Command/Config/System/SetConfigTest.php
+++ b/tests/Core/Command/Config/System/SetConfigTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Config\System;
diff --git a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
index ecb3faaa25d..4334994e8d3 100644
--- a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
+++ b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Björn Schießle <schiessle@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Encryption;
@@ -159,9 +145,9 @@ class ChangeKeyStorageRootTest extends TestCase {
]
)->setMethods(['prepareNewRoot', 'moveSystemKeys', 'moveUserKeys'])->getMock();
- $changeKeyStorageRoot->expects($this->at(0))->method('prepareNewRoot')->with('newRoot');
- $changeKeyStorageRoot->expects($this->at(1))->method('moveSystemKeys')->with('oldRoot', 'newRoot');
- $changeKeyStorageRoot->expects($this->at(2))->method('moveUserKeys')->with('oldRoot', 'newRoot', $this->outputInterface);
+ $changeKeyStorageRoot->expects($this->once())->method('prepareNewRoot')->with('newRoot');
+ $changeKeyStorageRoot->expects($this->once())->method('moveSystemKeys')->with('oldRoot', 'newRoot');
+ $changeKeyStorageRoot->expects($this->once())->method('moveUserKeys')->with('oldRoot', 'newRoot', $this->outputInterface);
$this->invokePrivate($changeKeyStorageRoot, 'moveAllKeys', ['oldRoot', 'newRoot', $this->outputInterface]);
}
diff --git a/tests/Core/Command/Encryption/DecryptAllTest.php b/tests/Core/Command/Encryption/DecryptAllTest.php
index c78500fd9d8..3ae14a3e12d 100644
--- a/tests/Core/Command/Encryption/DecryptAllTest.php
+++ b/tests/Core/Command/Encryption/DecryptAllTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Björn Schießle <schiessle@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Encryption;
@@ -86,17 +72,16 @@ class DecryptAllTest extends TestCase {
public function testMaintenanceAndTrashbin() {
// on construct we enable single-user-mode and disable the trash bin
- $this->config->expects($this->at(1))
+ // on destruct we disable single-user-mode again and enable the trash bin
+ $this->config->expects($this->exactly(2))
->method('setSystemValue')
- ->with('maintenance', true);
+ ->withConsecutive(
+ ['maintenance', true],
+ ['maintenance', false],
+ );
$this->appManager->expects($this->once())
->method('disableApp')
->with('files_trashbin');
-
- // on destruct wi disable single-user-mode again and enable the trash bin
- $this->config->expects($this->at(2))
- ->method('setSystemValue')
- ->with('maintenance', false);
$this->appManager->expects($this->once())
->method('enableApp')
->with('files_trashbin');
@@ -142,9 +127,12 @@ class DecryptAllTest extends TestCase {
->willReturn('user1');
if ($encryptionEnabled) {
- $this->config->expects($this->at(1))
+ $this->config->expects($this->exactly(2))
->method('setAppValue')
- ->with('core', 'encryption_enabled', 'no');
+ ->withConsecutive(
+ ['core', 'encryption_enabled', 'no'],
+ ['core', 'encryption_enabled', 'yes'],
+ );
$this->questionHelper->expects($this->once())
->method('ask')
->willReturn($continue);
@@ -154,9 +142,6 @@ class DecryptAllTest extends TestCase {
->with($this->consoleInput, $this->consoleOutput, 'user1');
} else {
$this->decryptAll->expects($this->never())->method('decryptAll');
- $this->config->expects($this->at(2))
- ->method('setAppValue')
- ->with('core', 'encryption_enabled', 'yes');
}
} else {
$this->config->expects($this->never())->method('setAppValue');
@@ -188,14 +173,13 @@ class DecryptAllTest extends TestCase {
$this->questionHelper
);
- $this->config->expects($this->at(1))
- ->method('setAppValue')
- ->with('core', 'encryption_enabled', 'no');
-
// make sure that we enable encryption again after a exception was thrown
- $this->config->expects($this->at(4))
+ $this->config->expects($this->exactly(2))
->method('setAppValue')
- ->with('core', 'encryption_enabled', 'yes');
+ ->withConsecutive(
+ ['core', 'encryption_enabled', 'no'],
+ ['core', 'encryption_enabled', 'yes'],
+ );
$this->encryptionManager->expects($this->once())
->method('isEnabled')
diff --git a/tests/Core/Command/Encryption/DisableTest.php b/tests/Core/Command/Encryption/DisableTest.php
index bd29caafec3..6c962399e11 100644
--- a/tests/Core/Command/Encryption/DisableTest.php
+++ b/tests/Core/Command/Encryption/DisableTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Encryption;
diff --git a/tests/Core/Command/Encryption/EnableTest.php b/tests/Core/Command/Encryption/EnableTest.php
index c1656054ecd..b535c80b0a8 100644
--- a/tests/Core/Command/Encryption/EnableTest.php
+++ b/tests/Core/Command/Encryption/EnableTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Encryption;
@@ -80,42 +66,40 @@ class EnableTest extends TestCase {
* @param string $expectedDefaultModuleString
*/
public function testEnable($oldStatus, $defaultModule, $availableModules, $isUpdating, $expectedString, $expectedDefaultModuleString) {
- $invokeCount = 0;
- $this->config->expects($this->at($invokeCount))
- ->method('getAppValue')
- ->with('core', 'encryption_enabled', $this->anything())
- ->willReturn($oldStatus);
- $invokeCount++;
-
if ($isUpdating) {
$this->config->expects($this->once())
->method('setAppValue')
->with('core', 'encryption_enabled', 'yes');
- $invokeCount++;
}
$this->manager->expects($this->atLeastOnce())
->method('getEncryptionModules')
->willReturn($availableModules);
- if (!empty($availableModules)) {
- $this->config->expects($this->at($invokeCount))
+ if (empty($availableModules)) {
+ $this->config->expects($this->once())
->method('getAppValue')
- ->with('core', 'default_encryption_module', $this->anything())
- ->willReturn($defaultModule);
+ ->with('core', 'encryption_enabled', $this->anything())
+ ->willReturn($oldStatus);
+ } else {
+ $this->config->expects($this->exactly(2))
+ ->method('getAppValue')
+ ->withConsecutive(
+ ['core', 'encryption_enabled', $this->anything()],
+ ['core', 'default_encryption_module', $this->anything()],
+ )->willReturnOnConsecutiveCalls(
+ $oldStatus,
+ $defaultModule,
+ );
}
- $this->consoleOutput->expects($this->at(0))
- ->method('writeln')
- ->with($this->stringContains($expectedString));
-
- $this->consoleOutput->expects($this->at(1))
- ->method('writeln')
- ->with('');
-
- $this->consoleOutput->expects($this->at(2))
+ $this->consoleOutput->expects($this->exactly(3))
->method('writeln')
- ->with($this->stringContains($expectedDefaultModuleString));
+ ->withConsecutive(
+ [$this->stringContains($expectedString)],
+ [''],
+ [$this->stringContains($expectedDefaultModuleString)],
+ );
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
diff --git a/tests/Core/Command/Encryption/EncryptAllTest.php b/tests/Core/Command/Encryption/EncryptAllTest.php
index 1190a98843f..83eeb5abdaa 100644
--- a/tests/Core/Command/Encryption/EncryptAllTest.php
+++ b/tests/Core/Command/Encryption/EncryptAllTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Björn Schießle <schiessle@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Encryption;
@@ -88,8 +74,12 @@ class EncryptAllTest extends TestCase {
// enable single user mode to avoid that other user login during encryption
// destructor should disable the single user mode again
$this->config->expects($this->once())->method('getSystemValueBool')->with('maintenance', false)->willReturn(false);
- $this->config->expects($this->at(1))->method('setSystemValue')->with('maintenance', true);
- $this->config->expects($this->at(2))->method('setSystemValue')->with('maintenance', false);
+ $this->config->expects($this->exactly(2))
+ ->method('setSystemValue')
+ ->withConsecutive(
+ ['maintenance', true],
+ ['maintenance', false],
+ );
$instance = new EncryptAll($this->encryptionManager, $this->appManager, $this->config, $this->questionHelper);
$this->invokePrivate($instance, 'forceMaintenanceAndTrashbin');
diff --git a/tests/Core/Command/Encryption/SetDefaultModuleTest.php b/tests/Core/Command/Encryption/SetDefaultModuleTest.php
index 015964e1357..9c4259fb04e 100644
--- a/tests/Core/Command/Encryption/SetDefaultModuleTest.php
+++ b/tests/Core/Command/Encryption/SetDefaultModuleTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Encryption;
@@ -127,13 +113,12 @@ class SetDefaultModuleTest extends TestCase {
->with('maintenance', false)
->willReturn(true);
- $this->consoleOutput->expects($this->at(0))
+ $this->consoleOutput->expects($this->exactly(2))
->method('writeln')
- ->with($this->stringContains('Maintenance mode must be disabled when setting default module,'));
-
- $this->consoleOutput->expects($this->at(1))
- ->method('writeln')
- ->with($this->stringContains('in order to load the relevant encryption modules correctly.'));
+ ->withConsecutive(
+ [$this->stringContains('Maintenance mode must be disabled when setting default module,')],
+ [$this->stringContains('in order to load the relevant encryption modules correctly.')],
+ );
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
diff --git a/tests/Core/Command/Group/AddTest.php b/tests/Core/Command/Group/AddTest.php
index bfddee468a4..76ef4a74f6a 100644
--- a/tests/Core/Command/Group/AddTest.php
+++ b/tests/Core/Command/Group/AddTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2018, Denis Mosolov <denismosolov@gmail.com>
- *
- * @author Denis Mosolov <denismosolov@gmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Afferoq General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\Group;
diff --git a/tests/Core/Command/Group/AddUserTest.php b/tests/Core/Command/Group/AddUserTest.php
index c885365f8c6..8c8f4902a16 100644
--- a/tests/Core/Command/Group/AddUserTest.php
+++ b/tests/Core/Command/Group/AddUserTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\Group;
diff --git a/tests/Core/Command/Group/DeleteTest.php b/tests/Core/Command/Group/DeleteTest.php
index 393f33aea98..fe1aaff64bc 100644
--- a/tests/Core/Command/Group/DeleteTest.php
+++ b/tests/Core/Command/Group/DeleteTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2018, Denis Mosolov <denismosolov@gmail.com>
- *
- * @author Denis Mosolov <denismosolov@gmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Afferoq General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\Group;
diff --git a/tests/Core/Command/Group/InfoTest.php b/tests/Core/Command/Group/InfoTest.php
index 3f1cc359799..6f5a9cce02b 100644
--- a/tests/Core/Command/Group/InfoTest.php
+++ b/tests/Core/Command/Group/InfoTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2021, hosting.de, Johannes Leuker <developers@hosting.de>
- *
- * @author Johannes Leuker <developers@hosting.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Afferoq General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\Group;
diff --git a/tests/Core/Command/Group/ListCommandTest.php b/tests/Core/Command/Group/ListCommandTest.php
index f8e750bbe65..e4e91ce1458 100644
--- a/tests/Core/Command/Group/ListCommandTest.php
+++ b/tests/Core/Command/Group/ListCommandTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\Group;
diff --git a/tests/Core/Command/Group/RemoveUserTest.php b/tests/Core/Command/Group/RemoveUserTest.php
index 470d5965333..47c782b6f44 100644
--- a/tests/Core/Command/Group/RemoveUserTest.php
+++ b/tests/Core/Command/Group/RemoveUserTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\Group;
diff --git a/tests/Core/Command/Log/FileTest.php b/tests/Core/Command/Log/FileTest.php
index 103888de287..35db7c6d718 100644
--- a/tests/Core/Command/Log/FileTest.php
+++ b/tests/Core/Command/Log/FileTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Robin McCorkell <rmccorkell@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Log;
@@ -110,15 +96,13 @@ class FileTest extends TestCase {
['log_rotate_size', 100 * 1024 * 1024, 5 * 1024 * 1024],
]);
- $this->consoleOutput->expects($this->at(0))
+ $this->consoleOutput->expects($this->exactly(3))
->method('writeln')
- ->with('Log backend file: disabled');
- $this->consoleOutput->expects($this->at(1))
- ->method('writeln')
- ->with('Log file: /var/log/nextcloud.log');
- $this->consoleOutput->expects($this->at(2))
- ->method('writeln')
- ->with('Rotate at: 5 MB');
+ ->withConsecutive(
+ ['Log backend file: disabled'],
+ ['Log file: /var/log/nextcloud.log'],
+ ['Rotate at: 5 MB'],
+ );
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
diff --git a/tests/Core/Command/Log/ManageTest.php b/tests/Core/Command/Log/ManageTest.php
index 6683291a9b8..5cba6dd626f 100644
--- a/tests/Core/Command/Log/ManageTest.php
+++ b/tests/Core/Command/Log/ManageTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Robin McCorkell <rmccorkell@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Log;
@@ -156,28 +142,25 @@ class ManageTest extends TestCase {
}
public function testGetConfiguration() {
- $this->config->expects($this->at(0))
+ $this->config->expects($this->exactly(3))
->method('getSystemValue')
- ->with('log_type', 'file')
- ->willReturn('log_type_value');
- $this->config->expects($this->at(1))
- ->method('getSystemValue')
- ->with('loglevel', 2)
- ->willReturn(0);
- $this->config->expects($this->at(2))
- ->method('getSystemValue')
- ->with('logtimezone', 'UTC')
- ->willReturn('logtimezone_value');
-
- $this->consoleOutput->expects($this->at(0))
- ->method('writeln')
- ->with('Enabled logging backend: log_type_value');
- $this->consoleOutput->expects($this->at(1))
- ->method('writeln')
- ->with('Log level: Debug (0)');
- $this->consoleOutput->expects($this->at(2))
+ ->withConsecutive(
+ ['log_type', 'file'],
+ ['loglevel', 2],
+ ['logtimezone', 'UTC'],
+ )->willReturnOnConsecutiveCalls(
+ 'log_type_value',
+ 0,
+ 'logtimezone_value'
+ );
+
+ $this->consoleOutput->expects($this->exactly(3))
->method('writeln')
- ->with('Log timezone: logtimezone_value');
+ ->withConsecutive(
+ ['Enabled logging backend: log_type_value'],
+ ['Log level: Debug (0)'],
+ ['Log timezone: logtimezone_value'],
+ );
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
diff --git a/tests/Core/Command/Maintenance/DataFingerprintTest.php b/tests/Core/Command/Maintenance/DataFingerprintTest.php
index 185a8d1576a..03cf37b8f48 100644
--- a/tests/Core/Command/Maintenance/DataFingerprintTest.php
+++ b/tests/Core/Command/Maintenance/DataFingerprintTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Maintenance;
diff --git a/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php b/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php
index bd08a5348a2..a4169907167 100644
--- a/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php
+++ b/tests/Core/Command/Maintenance/Mimetype/UpdateDBTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Robin McCorkell <rmccorkell@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\Maintenance\Mimetype;
@@ -78,12 +64,12 @@ class UpdateDBTest extends TestCase {
$this->loader->expects($this->never())
->method('updateFilecache');
- $this->consoleOutput->expects($this->at(0))
+ $this->consoleOutput->expects($this->exactly(2))
->method('writeln')
- ->with('Added 0 new mimetypes');
- $this->consoleOutput->expects($this->at(1))
- ->method('writeln')
- ->with('Updated 0 filecache rows');
+ ->withConsecutive(
+ ['Added 0 new mimetypes'],
+ ['Updated 0 filecache rows'],
+ );
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
@@ -117,19 +103,14 @@ class UpdateDBTest extends TestCase {
->with('new', 2)
->willReturn(3);
- $this->consoleOutput->expects($this->at(0))
- ->method('writeln')
- ->with('Added mimetype "testing/newmimetype" to database');
- $this->consoleOutput->expects($this->at(1))
- ->method('writeln')
- ->with('Updated 3 filecache rows for mimetype "testing/newmimetype"');
-
- $this->consoleOutput->expects($this->at(2))
+ $this->consoleOutput->expects($this->exactly(4))
->method('writeln')
- ->with('Added 1 new mimetypes');
- $this->consoleOutput->expects($this->at(3))
- ->method('writeln')
- ->with('Updated 3 filecache rows');
+ ->withConsecutive(
+ ['Added mimetype "testing/newmimetype" to database'],
+ ['Updated 3 filecache rows for mimetype "testing/newmimetype"'],
+ ['Added 1 new mimetypes'],
+ ['Updated 3 filecache rows'],
+ );
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
@@ -172,16 +153,13 @@ class UpdateDBTest extends TestCase {
->with('ext', 1)
->willReturn(3);
- $this->consoleOutput->expects($this->at(0))
- ->method('writeln')
- ->with('Updated 3 filecache rows for mimetype "testing/existingmimetype"');
-
- $this->consoleOutput->expects($this->at(1))
- ->method('writeln')
- ->with('Added 0 new mimetypes');
- $this->consoleOutput->expects($this->at(2))
+ $this->consoleOutput->expects($this->exactly(3))
->method('writeln')
- ->with('Updated 3 filecache rows');
+ ->withConsecutive(
+ ['Updated 3 filecache rows for mimetype "testing/existingmimetype"'],
+ ['Added 0 new mimetypes'],
+ ['Updated 3 filecache rows'],
+ );
self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
diff --git a/tests/Core/Command/Maintenance/ModeTest.php b/tests/Core/Command/Maintenance/ModeTest.php
index 1e8af354d50..458699649b2 100644
--- a/tests/Core/Command/Maintenance/ModeTest.php
+++ b/tests/Core/Command/Maintenance/ModeTest.php
@@ -1,5 +1,8 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
namespace Tests\Core\Command\Maintenance;
use OC\Core\Command\Maintenance\Mode;
diff --git a/tests/Core/Command/Maintenance/UpdateTheme.php b/tests/Core/Command/Maintenance/UpdateTheme.php
index bf460b44d4e..25229b8997a 100644
--- a/tests/Core/Command/Maintenance/UpdateTheme.php
+++ b/tests/Core/Command/Maintenance/UpdateTheme.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Command\Maintenance;
diff --git a/tests/Core/Command/Preview/RepairTest.php b/tests/Core/Command/Preview/RepairTest.php
index 090e9cc0bd0..b257c59d9d2 100644
--- a/tests/Core/Command/Preview/RepairTest.php
+++ b/tests/Core/Command/Preview/RepairTest.php
@@ -1,5 +1,8 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
namespace Tests\Core\Command\Preview;
use bantu\IniGetWrapper\IniGetWrapper;
@@ -10,11 +13,11 @@ use OCP\Files\Node;
use OCP\IConfig;
use OCP\Lock\ILockingProvider;
use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
-use Psr\Log\LoggerInterface;
class RepairTest extends TestCase {
/** @var IConfig|MockObject */
@@ -142,7 +145,7 @@ class RepairTest extends TestCase {
$previewFolder->expects($this->once())
->method('getDirectoryListing')
->willReturn($directories);
- $this->rootFolder->expects($this->at(0))
+ $this->rootFolder->expects($this->once())
->method('get')
->with("appdata_/preview")
->willReturn($previewFolder);
diff --git a/tests/Core/Command/SystemTag/AddTest.php b/tests/Core/Command/SystemTag/AddTest.php
index 93a79e1e1a9..921b875dc4e 100644
--- a/tests/Core/Command/SystemTag/AddTest.php
+++ b/tests/Core/Command/SystemTag/AddTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2021, hosting.de, Johannes Leuker <developers@hosting.de>
- *
- * @author Johannes Leuker <developers@hosting.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\SystemTag;
diff --git a/tests/Core/Command/SystemTag/DeleteTest.php b/tests/Core/Command/SystemTag/DeleteTest.php
index 16c0c9e7b04..a2ec3767272 100644
--- a/tests/Core/Command/SystemTag/DeleteTest.php
+++ b/tests/Core/Command/SystemTag/DeleteTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2021, hosting.de, Johannes Leuker <developers@hosting.de>
- *
- * @author Johannes Leuker <developers@hosting.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\SystemTag;
diff --git a/tests/Core/Command/SystemTag/EditTest.php b/tests/Core/Command/SystemTag/EditTest.php
index a5340cf6b53..4273d666ff5 100644
--- a/tests/Core/Command/SystemTag/EditTest.php
+++ b/tests/Core/Command/SystemTag/EditTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2021, hosting.de, Johannes Leuker <developers@hosting.de>
- *
- * @author Johannes Leuker <developers@hosting.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\SystemTag;
diff --git a/tests/Core/Command/SystemTag/ListCommandTest.php b/tests/Core/Command/SystemTag/ListCommandTest.php
index 6488e130947..c7e213a782c 100644
--- a/tests/Core/Command/SystemTag/ListCommandTest.php
+++ b/tests/Core/Command/SystemTag/ListCommandTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2021, hosting.de, Johannes Leuker <developers@hosting.de>
- *
- * @author Johannes Leuker <developers@hosting.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\SystemTag;
diff --git a/tests/Core/Command/TwoFactorAuth/CleanupTest.php b/tests/Core/Command/TwoFactorAuth/CleanupTest.php
index 23461ebd784..8f082d76856 100644
--- a/tests/Core/Command/TwoFactorAuth/CleanupTest.php
+++ b/tests/Core/Command/TwoFactorAuth/CleanupTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Core\Command\TwoFactorAuth;
diff --git a/tests/Core/Command/TwoFactorAuth/DisableTest.php b/tests/Core/Command/TwoFactorAuth/DisableTest.php
index 35b810c637f..4c1db3b1dc2 100644
--- a/tests/Core/Command/TwoFactorAuth/DisableTest.php
+++ b/tests/Core/Command/TwoFactorAuth/DisableTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\TwoFactorAuth;
diff --git a/tests/Core/Command/TwoFactorAuth/EnableTest.php b/tests/Core/Command/TwoFactorAuth/EnableTest.php
index 0e26bcb9578..79755b9984d 100644
--- a/tests/Core/Command/TwoFactorAuth/EnableTest.php
+++ b/tests/Core/Command/TwoFactorAuth/EnableTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Command\TwoFactorAuth;
diff --git a/tests/Core/Command/TwoFactorAuth/EnforceTest.php b/tests/Core/Command/TwoFactorAuth/EnforceTest.php
index 194e16e8699..073ea7dede8 100644
--- a/tests/Core/Command/TwoFactorAuth/EnforceTest.php
+++ b/tests/Core/Command/TwoFactorAuth/EnforceTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Command\TwoFactorAuth;
diff --git a/tests/Core/Command/TwoFactorAuth/StateTest.php b/tests/Core/Command/TwoFactorAuth/StateTest.php
index bc683c11886..23cb21f75d6 100644
--- a/tests/Core/Command/TwoFactorAuth/StateTest.php
+++ b/tests/Core/Command/TwoFactorAuth/StateTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Core\Command\TwoFactorAuth;
diff --git a/tests/Core/Command/User/AddTest.php b/tests/Core/Command/User/AddTest.php
new file mode 100644
index 00000000000..7a956c173c1
--- /dev/null
+++ b/tests/Core/Command/User/AddTest.php
@@ -0,0 +1,153 @@
+<?php
+/**
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+declare(strict_types=1);
+
+namespace Core\Command\User;
+
+use OC\Core\Command\User\Add;
+use OCA\Settings\Mailer\NewUserMailHelper;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\IAppConfig;
+use OCP\IGroupManager;
+use OCP\IUser;
+use OCP\IUserManager;
+use OCP\Mail\IEMailTemplate;
+use OCP\mail\IMailer;
+use OCP\Security\ISecureRandom;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Test\TestCase;
+
+class AddTest extends TestCase {
+ /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
+ private $userManager;
+
+ /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
+ private $groupManager;
+
+ /** @var IMailer|\PHPUnit\Framework\MockObject\MockObject */
+ private $mailer;
+
+ /** @var IAppConfig|\PHPUnit\Framework\MockObject\MockObject */
+ private $appConfig;
+
+ /** @var NewUserMailHelper|\PHPUnit\Framework\MockObject\MockObject */
+ private $mailHelper;
+
+ /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
+ private $eventDispatcher;
+
+ /** @var ISecureRandom|\PHPUnit\Framework\MockObject\MockObject */
+ private $secureRandom;
+
+ /** @var IUser|\PHPUnit\Framework\MockObject\MockObject */
+ private $user;
+
+ /** @var InputInterface|\PHPUnit\Framework\MockObject\MockObject */
+ private $consoleInput;
+
+ /** @var OutputInterface|\PHPUnit\Framework\MockObject\MockObject */
+ private $consoleOutput;
+
+ /** @var Add */
+ private $addCommand;
+
+ public function setUp(): void {
+ parent::setUp();
+
+ $this->userManager = static::createMock(IUserManager::class);
+ $this->groupManager = static::createStub(IGroupManager::class);
+ $this->mailer = static::createMock(IMailer::class);
+ $this->appConfig = static::createMock(IAppConfig::class);
+ $this->mailHelper = static::createMock(NewUserMailHelper::class);
+ $this->eventDispatcher = static::createStub(IEventDispatcher::class);
+ $this->secureRandom = static::createStub(ISecureRandom::class);
+
+ $this->user = static::createMock(IUser::class);
+
+ $this->consoleInput = static::createMock(InputInterface::class);
+ $this->consoleOutput = static::createMock(OutputInterface::class);
+
+ $this->addCommand = new Add(
+ $this->userManager,
+ $this->groupManager,
+ $this->mailer,
+ $this->appConfig,
+ $this->mailHelper,
+ $this->eventDispatcher,
+ $this->secureRandom
+ );
+ }
+
+ /**
+ * @dataProvider addEmailDataProvider
+ */
+ public function testAddEmail(
+ ?string $email,
+ bool $isEmailValid,
+ bool $shouldSendEmail,
+ ): void {
+ $this->user->expects($isEmailValid ? static::once() : static::never())
+ ->method('setSystemEMailAddress')
+ ->with(static::equalTo($email));
+
+ $this->userManager->method('createUser')
+ ->willReturn($this->user);
+
+ $this->appConfig->method('getValueString')
+ ->willReturn($shouldSendEmail ? 'yes' : 'no');
+
+ $this->mailer->method('validateMailAddress')
+ ->willReturn($isEmailValid);
+
+ $this->mailHelper->method('generateTemplate')
+ ->willReturn(static::createMock(IEMailTemplate::class));
+
+ $this->mailHelper->expects($isEmailValid && $shouldSendEmail ? static::once() : static::never())
+ ->method('sendMail');
+
+ $this->consoleInput->method('getOption')
+ ->will(static::returnValueMap([
+ ['generate-password', 'true'],
+ ['email', $email],
+ ['group', []],
+ ]));
+
+ $this->invokePrivate($this->addCommand, 'execute', [
+ $this->consoleInput,
+ $this->consoleOutput
+ ]);
+ }
+
+ /**
+ * @return array
+ */
+ public function addEmailDataProvider(): array {
+ return [
+ 'Valid E-Mail' => [
+ 'info@example.com',
+ true,
+ true,
+ ],
+ 'Invalid E-Mail' => [
+ 'info@@example.com',
+ false,
+ false,
+ ],
+ 'No E-Mail' => [
+ '',
+ false,
+ false,
+ ],
+ 'Valid E-Mail, but no mail should be sent' => [
+ 'info@example.com',
+ true,
+ false,
+ ],
+ ];
+ }
+}
diff --git a/tests/Core/Command/User/AuthTokens/DeleteTest.php b/tests/Core/Command/User/AuthTokens/DeleteTest.php
index 528d4c6869b..bd82475b206 100644
--- a/tests/Core/Command/User/AuthTokens/DeleteTest.php
+++ b/tests/Core/Command/User/AuthTokens/DeleteTest.php
@@ -1,29 +1,12 @@
<?php
/**
- * @copyright Copyright (c) 2023 Lucas Azevedo <lhs_azevedo@hotmail.com>
- *
- * @author Lucas Azevedo <lhs_azevedo@hotmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Command\User\AuthTokens;
-use OC\Core\Command\User\AuthTokens\Delete;
use OC\Authentication\Token\IProvider;
+use OC\Core\Command\User\AuthTokens\Delete;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputInterface;
diff --git a/tests/Core/Command/User/DeleteTest.php b/tests/Core/Command/User/DeleteTest.php
index 6ac0ed0353c..74b98b0246a 100644
--- a/tests/Core/Command/User/DeleteTest.php
+++ b/tests/Core/Command/User/DeleteTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\User;
diff --git a/tests/Core/Command/User/DisableTest.php b/tests/Core/Command/User/DisableTest.php
index 0e1d1b72ac4..a080eb9379a 100644
--- a/tests/Core/Command/User/DisableTest.php
+++ b/tests/Core/Command/User/DisableTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Command\User;
diff --git a/tests/Core/Command/User/EnableTest.php b/tests/Core/Command/User/EnableTest.php
index 6ff82aac673..39af10f2ef3 100644
--- a/tests/Core/Command/User/EnableTest.php
+++ b/tests/Core/Command/User/EnableTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Command\User;
diff --git a/tests/Core/Command/User/LastSeenTest.php b/tests/Core/Command/User/LastSeenTest.php
index f861c2e5f77..1146c0664d4 100644
--- a/tests/Core/Command/User/LastSeenTest.php
+++ b/tests/Core/Command/User/LastSeenTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\User;
diff --git a/tests/Core/Command/User/SettingTest.php b/tests/Core/Command/User/SettingTest.php
index 964a707bf38..7be9bd27ecb 100644
--- a/tests/Core/Command/User/SettingTest.php
+++ b/tests/Core/Command/User/SettingTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Command\User;
diff --git a/tests/Core/Controller/AppPasswordControllerTest.php b/tests/Core/Controller/AppPasswordControllerTest.php
index 47220fcf5ab..6b7b023ab2e 100644
--- a/tests/Core/Controller/AppPasswordControllerTest.php
+++ b/tests/Core/Controller/AppPasswordControllerTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Controller;
@@ -29,6 +12,7 @@ use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
use OC\Core\Controller\AppPasswordController;
+use OC\User\Session;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\Authentication\Exceptions\CredentialsUnavailableException;
@@ -38,6 +22,8 @@ use OCP\Authentication\LoginCredentials\IStore;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IRequest;
use OCP\ISession;
+use OCP\IUserManager;
+use OCP\Security\Bruteforce\IThrottler;
use OCP\Security\ISecureRandom;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -61,6 +47,15 @@ class AppPasswordControllerTest extends TestCase {
/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
private $eventDispatcher;
+ /** @var Session|MockObject */
+ private $userSession;
+
+ /** @var IUserManager|MockObject */
+ private $userManager;
+
+ /** @var IThrottler|MockObject */
+ private $throttler;
+
/** @var AppPasswordController */
private $controller;
@@ -73,6 +68,9 @@ class AppPasswordControllerTest extends TestCase {
$this->credentialStore = $this->createMock(IStore::class);
$this->request = $this->createMock(IRequest::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
+ $this->userSession = $this->createMock(Session::class);
+ $this->userManager = $this->createMock(IUserManager::class);
+ $this->throttler = $this->createMock(IThrottler::class);
$this->controller = new AppPasswordController(
'core',
@@ -81,7 +79,10 @@ class AppPasswordControllerTest extends TestCase {
$this->random,
$this->tokenProvider,
$this->credentialStore,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->userSession,
+ $this->userManager,
+ $this->throttler
);
}
diff --git a/tests/Core/Controller/AutoCompleteControllerTest.php b/tests/Core/Controller/AutoCompleteControllerTest.php
index 6b2f9a4f163..e2797181097 100644
--- a/tests/Core/Controller/AutoCompleteControllerTest.php
+++ b/tests/Core/Controller/AutoCompleteControllerTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Controller;
diff --git a/tests/Core/Controller/AvatarControllerTest.php b/tests/Core/Controller/AvatarControllerTest.php
index 256f5665795..5de042886fd 100644
--- a/tests/Core/Controller/AvatarControllerTest.php
+++ b/tests/Core/Controller/AvatarControllerTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Core\Controller;
diff --git a/tests/Core/Controller/CSRFTokenControllerTest.php b/tests/Core/Controller/CSRFTokenControllerTest.php
index ba01675e978..a401788be8d 100644
--- a/tests/Core/Controller/CSRFTokenControllerTest.php
+++ b/tests/Core/Controller/CSRFTokenControllerTest.php
@@ -1,25 +1,8 @@
<?php
/**
- * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Controller;
diff --git a/tests/Core/Controller/ChangePasswordControllerTest.php b/tests/Core/Controller/ChangePasswordControllerTest.php
index 2d7292f6801..93fb4196d35 100644
--- a/tests/Core/Controller/ChangePasswordControllerTest.php
+++ b/tests/Core/Controller/ChangePasswordControllerTest.php
@@ -1,23 +1,7 @@
<?php
/**
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Controller;
diff --git a/tests/Core/Controller/ClientFlowLoginControllerTest.php b/tests/Core/Controller/ClientFlowLoginControllerTest.php
index dfd3e629dcd..98f09f0f18c 100644
--- a/tests/Core/Controller/ClientFlowLoginControllerTest.php
+++ b/tests/Core/Controller/ClientFlowLoginControllerTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Controller;
@@ -31,6 +16,7 @@ use OCA\OAuth2\Db\Client;
use OCA\OAuth2\Db\ClientMapper;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\StandaloneTemplateResponse;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IL10N;
@@ -69,7 +55,8 @@ class ClientFlowLoginControllerTest extends TestCase {
private $crypto;
/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
private $eventDispatcher;
-
+ /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
+ private $timeFactory;
/** @var ClientFlowLoginController */
private $clientFlowLoginController;
@@ -95,6 +82,7 @@ class ClientFlowLoginControllerTest extends TestCase {
$this->accessTokenMapper = $this->createMock(AccessTokenMapper::class);
$this->crypto = $this->createMock(ICrypto::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
+ $this->timeFactory = $this->createMock(ITimeFactory::class);
$this->clientFlowLoginController = new ClientFlowLoginController(
'core',
@@ -109,7 +97,8 @@ class ClientFlowLoginControllerTest extends TestCase {
$this->clientMapper,
$this->accessTokenMapper,
$this->crypto,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->timeFactory
);
}
diff --git a/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php b/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php
index fac060262ed..eefa2982c74 100644
--- a/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php
+++ b/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Controller;
diff --git a/tests/Core/Controller/ContactsMenuControllerTest.php b/tests/Core/Controller/ContactsMenuControllerTest.php
index f51bab0f006..d688ea6682f 100644
--- a/tests/Core/Controller/ContactsMenuControllerTest.php
+++ b/tests/Core/Controller/ContactsMenuControllerTest.php
@@ -1,25 +1,8 @@
<?php
/**
- * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Controller;
diff --git a/tests/Core/Controller/CssControllerTest.php b/tests/Core/Controller/CssControllerTest.php
index 9659d76a7cb..8064f36cddb 100644
--- a/tests/Core/Controller/CssControllerTest.php
+++ b/tests/Core/Controller/CssControllerTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2017, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Controller;
@@ -117,7 +100,6 @@ class CssControllerTest extends TestCase {
$expires->setTimestamp(1337);
$expires->add(new \DateInterval('PT31536000S'));
$expected->addHeader('Expires', $expires->format(\DateTime::RFC1123));
- $expected->addHeader('Pragma', 'cache');
$result = $this->controller->getCss('file.css', 'myapp');
$this->assertEquals($expected, $result);
@@ -147,7 +129,6 @@ class CssControllerTest extends TestCase {
$expires->setTimestamp(1337);
$expires->add(new \DateInterval('PT31536000S'));
$expected->addHeader('Expires', $expires->format(\DateTime::RFC1123));
- $expected->addHeader('Pragma', 'cache');
$result = $this->controller->getCss('file.css', 'myapp');
$this->assertEquals($expected, $result);
@@ -182,7 +163,6 @@ class CssControllerTest extends TestCase {
$expires->setTimestamp(1337);
$expires->add(new \DateInterval('PT31536000S'));
$expected->addHeader('Expires', $expires->format(\DateTime::RFC1123));
- $expected->addHeader('Pragma', 'cache');
$result = $this->controller->getCss('file.css', 'myapp');
$this->assertEquals($expected, $result);
diff --git a/tests/Core/Controller/GuestAvatarControllerTest.php b/tests/Core/Controller/GuestAvatarControllerTest.php
index 42a00e1618c..b2f60665948 100644
--- a/tests/Core/Controller/GuestAvatarControllerTest.php
+++ b/tests/Core/Controller/GuestAvatarControllerTest.php
@@ -1,5 +1,8 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
namespace Core\Controller;
use OC\Core\Controller\GuestAvatarController;
diff --git a/tests/Core/Controller/JsControllerTest.php b/tests/Core/Controller/JsControllerTest.php
index 6561d22f264..5aa853e4ed0 100644
--- a/tests/Core/Controller/JsControllerTest.php
+++ b/tests/Core/Controller/JsControllerTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2017, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Controller;
@@ -117,7 +100,6 @@ class JsControllerTest extends TestCase {
$expires->setTimestamp(1337);
$expires->add(new \DateInterval('PT31536000S'));
$expected->addHeader('Expires', $expires->format(\DateTime::RFC1123));
- $expected->addHeader('Pragma', 'cache');
$result = $this->controller->getJs('file.js', 'myapp');
$this->assertEquals($expected, $result);
@@ -147,7 +129,6 @@ class JsControllerTest extends TestCase {
$expires->setTimestamp(1337);
$expires->add(new \DateInterval('PT31536000S'));
$expected->addHeader('Expires', $expires->format(\DateTime::RFC1123));
- $expected->addHeader('Pragma', 'cache');
$result = $this->controller->getJs('file.js', 'myapp');
$this->assertEquals($expected, $result);
@@ -182,7 +163,6 @@ class JsControllerTest extends TestCase {
$expires->setTimestamp(1337);
$expires->add(new \DateInterval('PT31536000S'));
$expected->addHeader('Expires', $expires->format(\DateTime::RFC1123));
- $expected->addHeader('Pragma', 'cache');
$result = $this->controller->getJs('file.js', 'myapp');
$this->assertEquals($expected, $result);
diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php
index 333baf0aa86..8fe24f156f6 100644
--- a/tests/Core/Controller/LoginControllerTest.php
+++ b/tests/Core/Controller/LoginControllerTest.php
@@ -3,23 +3,9 @@
declare(strict_types=1);
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Controller;
@@ -30,11 +16,12 @@ use OC\Authentication\Login\LoginResult;
use OC\Authentication\TwoFactorAuth\Manager;
use OC\Core\Controller\LoginController;
use OC\User\Session;
+use OCP\App\IAppManager;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\Services\IInitialState;
use OCP\Defaults;
use OCP\IConfig;
-use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\IRequest;
use OCP\ISession;
@@ -77,8 +64,8 @@ class LoginControllerTest extends TestCase {
/** @var IThrottler|MockObject */
private $throttler;
- /** @var IInitialStateService|MockObject */
- private $initialStateService;
+ /** @var IInitialState|MockObject */
+ private $initialState;
/** @var \OC\Authentication\WebAuthn\Manager|MockObject */
private $webAuthnManager;
@@ -89,6 +76,9 @@ class LoginControllerTest extends TestCase {
/** @var IL10N|MockObject */
private $l;
+ /** @var IAppManager|MockObject */
+ private $appManager;
+
protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
@@ -100,10 +90,12 @@ class LoginControllerTest extends TestCase {
$this->twoFactorManager = $this->createMock(Manager::class);
$this->defaults = $this->createMock(Defaults::class);
$this->throttler = $this->createMock(IThrottler::class);
- $this->initialStateService = $this->createMock(IInitialStateService::class);
+ $this->initialState = $this->createMock(IInitialState::class);
$this->webAuthnManager = $this->createMock(\OC\Authentication\WebAuthn\Manager::class);
$this->notificationManager = $this->createMock(IManager::class);
$this->l = $this->createMock(IL10N::class);
+ $this->appManager = $this->createMock(IAppManager::class);
+
$this->l->expects($this->any())
->method('t')
->willReturnCallback(function ($text, $parameters = []) {
@@ -129,10 +121,11 @@ class LoginControllerTest extends TestCase {
$this->urlGenerator,
$this->defaults,
$this->throttler,
- $this->initialStateService,
+ $this->initialState,
$this->webAuthnManager,
$this->notificationManager,
- $this->l
+ $this->l,
+ $this->appManager,
);
}
@@ -145,6 +138,10 @@ class LoginControllerTest extends TestCase {
$this->request
->method('getServerProtocol')
->willReturn('https');
+ $this->request
+ ->expects($this->once())
+ ->method('isUserAgent')
+ ->willReturn(false);
$this->config
->expects($this->never())
->method('deleteUserValue');
@@ -159,6 +156,29 @@ class LoginControllerTest extends TestCase {
$this->assertEquals($expected, $this->loginController->logout());
}
+ public function testLogoutNoClearSiteData() {
+ $this->request
+ ->expects($this->once())
+ ->method('getCookie')
+ ->with('nc_token')
+ ->willReturn(null);
+ $this->request
+ ->method('getServerProtocol')
+ ->willReturn('https');
+ $this->request
+ ->expects($this->once())
+ ->method('isUserAgent')
+ ->willReturn(true);
+ $this->urlGenerator
+ ->expects($this->once())
+ ->method('linkToRouteAbsolute')
+ ->with('core.login.showLoginForm')
+ ->willReturn('/login');
+
+ $expected = new RedirectResponse('/login');
+ $this->assertEquals($expected, $this->loginController->logout());
+ }
+
public function testLogoutWithToken() {
$this->request
->expects($this->once())
@@ -166,9 +186,12 @@ class LoginControllerTest extends TestCase {
->with('nc_token')
->willReturn('MyLoginToken');
$this->request
- ->expects($this->once())
->method('getServerProtocol')
->willReturn('https');
+ $this->request
+ ->expects($this->once())
+ ->method('isUserAgent')
+ ->willReturn(false);
$user = $this->createMock(IUser::class);
$user
->expects($this->once())
@@ -228,10 +251,9 @@ class LoginControllerTest extends TestCase {
],
]
);
- $this->initialStateService->expects($this->exactly(11))
+ $this->initialState->expects($this->exactly(13))
->method('provideInitialState')
->withConsecutive([
- 'core',
'loginMessages',
[
'MessageArray1',
@@ -240,7 +262,6 @@ class LoginControllerTest extends TestCase {
],
],
[
- 'core',
'loginErrors',
[
'ErrorArray1',
@@ -248,7 +269,6 @@ class LoginControllerTest extends TestCase {
],
],
[
- 'core',
'loginUsername',
'',
]);
@@ -270,14 +290,12 @@ class LoginControllerTest extends TestCase {
->expects($this->once())
->method('isLoggedIn')
->willReturn(false);
- $this->initialStateService->expects($this->exactly(12))
+ $this->initialState->expects($this->exactly(14))
->method('provideInitialState')
->withConsecutive([], [], [], [
- 'core',
'loginAutocomplete',
false
], [
- 'core',
'loginRedirectUrl',
'login/flow'
]);
@@ -314,7 +332,7 @@ class LoginControllerTest extends TestCase {
* @dataProvider passwordResetDataProvider
*/
public function testShowLoginFormWithPasswordResetOption($canChangePassword,
- $expectedResult) {
+ $expectedResult) {
$this->userSession
->expects($this->once())
->method('isLoggedIn')
@@ -341,14 +359,12 @@ class LoginControllerTest extends TestCase {
->method('get')
->with('LdapUser')
->willReturn($user);
- $this->initialStateService->expects($this->exactly(11))
+ $this->initialState->expects($this->exactly(13))
->method('provideInitialState')
->withConsecutive([], [], [
- 'core',
'loginUsername',
'LdapUser'
], [], [], [], [
- 'core',
'loginCanResetPassword',
$expectedResult
]);
@@ -391,18 +407,15 @@ class LoginControllerTest extends TestCase {
->method('get')
->with('0')
->willReturn($user);
- $this->initialStateService->expects($this->exactly(11))
+ $this->initialState->expects($this->exactly(13))
->method('provideInitialState')
->withConsecutive([], [], [], [
- 'core',
'loginAutocomplete',
true
], [], [
- 'core',
'loginResetPasswordLink',
false
], [
- 'core',
'loginCanResetPassword',
false
]);
diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php
index 84ec450943e..1e1771f7a15 100644
--- a/tests/Core/Controller/LostControllerTest.php
+++ b/tests/Core/Controller/LostControllerTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- * @author Joshua Trees <me@jtrees.io>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @copyright Copyright (c) 2023, Joshua Trees <me@jtrees.io>
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Controller;
diff --git a/tests/Core/Controller/NavigationControllerTest.php b/tests/Core/Controller/NavigationControllerTest.php
index ddf307ec06d..0d7c91d3034 100644
--- a/tests/Core/Controller/NavigationControllerTest.php
+++ b/tests/Core/Controller/NavigationControllerTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Controller;
diff --git a/tests/Core/Controller/OCSControllerTest.php b/tests/Core/Controller/OCSControllerTest.php
index 61ed4a50d62..19b87a97359 100644
--- a/tests/Core/Controller/OCSControllerTest.php
+++ b/tests/Core/Controller/OCSControllerTest.php
@@ -1,24 +1,8 @@
<?php
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Core\Controller;
@@ -196,7 +180,7 @@ class OCSControllerTest extends TestCase {
->with('NotExistingUser')
->willReturn(null);
- $expected = new DataResponse(['User not found'], 404);
+ $expected = new DataResponse(['Account not found'], 404);
$this->assertEquals($expected, $this->controller->getIdentityProof('NotExistingUser'));
}
diff --git a/tests/Core/Controller/PreviewControllerTest.php b/tests/Core/Controller/PreviewControllerTest.php
index 1f8cfff1172..d330c1d5209 100644
--- a/tests/Core/Controller/PreviewControllerTest.php
+++ b/tests/Core/Controller/PreviewControllerTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Controller;
diff --git a/tests/Core/Controller/TwoFactorChallengeControllerTest.php b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
index baf7feaa068..f003975b359 100644
--- a/tests/Core/Controller/TwoFactorChallengeControllerTest.php
+++ b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
@@ -1,23 +1,9 @@
<?php
/**
- * @author Christoph Wurst <christoph@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Core\Controller;
@@ -337,7 +323,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
$this->assertEquals($expected, $this->controller->solveChallenge('myprovider', 'token', '/url'));
}
- public function testSetUpProviders() {
+ public function testSetUpProviders(): void {
$user = $this->createMock(IUser::class);
$this->userSession->expects($this->once())
->method('getUser')
@@ -357,6 +343,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
$provider,
],
'logout_url' => 'logoutAttribute',
+ 'redirect_url' => null,
],
'guest'
);
@@ -392,7 +379,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
$this->assertEquals($expected, $response);
}
- public function testSetUpProvider() {
+ public function testSetUpProvider(): void {
$user = $this->createMock(IUser::class);
$this->userSession->expects($this->once())
->method('getUser')
@@ -426,6 +413,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
'provider' => $provider,
'logout_url' => 'logoutAttribute',
'template' => 'tmpl',
+ 'redirect_url' => null,
],
'guest'
);
@@ -435,13 +423,14 @@ class TwoFactorChallengeControllerTest extends TestCase {
$this->assertEquals($expected, $response);
}
- public function testConfirmProviderSetup() {
+ public function testConfirmProviderSetup(): void {
$this->urlGenerator->expects($this->once())
->method('linkToRoute')
->with(
'core.TwoFactorChallenge.showChallenge',
[
'challengeProviderId' => 'totp',
+ 'redirect_url' => null,
])
->willReturn('2fa/select/page');
$expected = new RedirectResponse('2fa/select/page');
diff --git a/tests/Core/Controller/UserControllerTest.php b/tests/Core/Controller/UserControllerTest.php
index b7b6e0c69f6..09a22913fdc 100644
--- a/tests/Core/Controller/UserControllerTest.php
+++ b/tests/Core/Controller/UserControllerTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Core\Controller;
diff --git a/tests/Core/Controller/WellKnownControllerTest.php b/tests/Core/Controller/WellKnownControllerTest.php
index 08af2a214ae..99c693c78b7 100644
--- a/tests/Core/Controller/WellKnownControllerTest.php
+++ b/tests/Core/Controller/WellKnownControllerTest.php
@@ -2,25 +2,9 @@
declare(strict_types=1);
-/*
- * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Controller;
diff --git a/tests/Core/Controller/WipeControllerTest.php b/tests/Core/Controller/WipeControllerTest.php
index 5c06a867b79..f07fe4c9282 100644
--- a/tests/Core/Controller/WipeControllerTest.php
+++ b/tests/Core/Controller/WipeControllerTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Core\Controller;
diff --git a/tests/Core/Data/LoginFlowV2CredentialsTest.php b/tests/Core/Data/LoginFlowV2CredentialsTest.php
index c56a11594aa..0bb32f1c967 100644
--- a/tests/Core/Data/LoginFlowV2CredentialsTest.php
+++ b/tests/Core/Data/LoginFlowV2CredentialsTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @author Konrad Abicht <hi@inspirito.de>
- *
- * @copyright Copyright (c) 2021, Konrad Abicht <hi@inspirito.de>
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Data;
diff --git a/tests/Core/Middleware/TwoFactorMiddlewareTest.php b/tests/Core/Middleware/TwoFactorMiddlewareTest.php
index fe1b53e3fa5..a245845a674 100644
--- a/tests/Core/Middleware/TwoFactorMiddlewareTest.php
+++ b/tests/Core/Middleware/TwoFactorMiddlewareTest.php
@@ -1,23 +1,9 @@
<?php
/**
- * @author Christoph Wurst <christoph@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Core\Middleware;
diff --git a/tests/Core/Service/LoginFlowV2ServiceUnitTest.php b/tests/Core/Service/LoginFlowV2ServiceUnitTest.php
index 57443ca1328..2e6407d4c00 100644
--- a/tests/Core/Service/LoginFlowV2ServiceUnitTest.php
+++ b/tests/Core/Service/LoginFlowV2ServiceUnitTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @author Konrad Abicht <hi@inspirito.de>
- *
- * @copyright Copyright (c) 2021, Konrad Abicht <hi@inspirito.de>
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Tests\Core\Data;
@@ -27,8 +12,8 @@ use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
use OC\Core\Data\LoginFlowV2Credentials;
use OC\Core\Data\LoginFlowV2Tokens;
-use OC\Core\Db\LoginFlowV2Mapper;
use OC\Core\Db\LoginFlowV2;
+use OC\Core\Db\LoginFlowV2Mapper;
use OC\Core\Exception\LoginFlowV2NotFoundException;
use OC\Core\Service\LoginFlowV2Service;
use OCP\AppFramework\Db\DoesNotExistException;
@@ -392,7 +377,7 @@ class LoginFlowV2ServiceUnitTest extends TestCase {
->method('getSystemValue')
->willReturn($this->returnCallback(function ($key) {
// Note: \OCP\IConfig::getSystemValue returns either an array or string.
- return 'openssl' == $key ? [] : '';
+ return $key == 'openssl' ? [] : '';
}));
$this->mapper->expects($this->once())
diff --git a/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php b/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php
index 3c15d51fd61..3d102c8f279 100644
--- a/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php
+++ b/tests/Test/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Repair\Owncloud;
diff --git a/tests/Test/Repair/Owncloud/CleanPreviewsTest.php b/tests/Test/Repair/Owncloud/CleanPreviewsTest.php
index b291b4d86d1..10d2e5d216c 100644
--- a/tests/Test/Repair/Owncloud/CleanPreviewsTest.php
+++ b/tests/Test/Repair/Owncloud/CleanPreviewsTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Repair\Owncloud;
diff --git a/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php b/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php
index 6d34babe76a..856adde5c95 100644
--- a/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php
+++ b/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Morris Jobke <hey@morrisjobke.de>
- *
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Repair\Owncloud;
diff --git a/tests/acceptance/composer.json b/tests/acceptance/composer.json
deleted file mode 100644
index 142e791ced3..00000000000
--- a/tests/acceptance/composer.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "config": {
- "platform": {
- "php": "7.4"
- }
- },
- "require-dev": {
- "behat/behat": "3.11.*",
- "behat/mink": "1.10.*",
- "behat/mink-extension": "2.3.*",
- "behat/mink-selenium2-driver": "1.6.*",
- "phpunit/phpunit": "9.5.19"
- },
- "autoload": {
- "psr-4": {
- "": ["features/bootstrap", "features/core"]
- }
- }
-}
diff --git a/tests/acceptance/composer.lock b/tests/acceptance/composer.lock
deleted file mode 100644
index ef855cdf227..00000000000
--- a/tests/acceptance/composer.lock
+++ /dev/null
@@ -1,4203 +0,0 @@
-{
- "_readme": [
- "This file locks the dependencies of your project to a known state",
- "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
- "This file is @generated automatically"
- ],
- "content-hash": "ec049b32a215727464f8fa17889df43f",
- "packages": [],
- "packages-dev": [
- {
- "name": "behat/behat",
- "version": "v3.11.0",
- "source": {
- "type": "git",
- "url": "https://github.com/Behat/Behat.git",
- "reference": "a19c72c78eb0cdf7b7c4dabfeec9eb3a282728fc"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/Behat/Behat/zipball/a19c72c78eb0cdf7b7c4dabfeec9eb3a282728fc",
- "reference": "a19c72c78eb0cdf7b7c4dabfeec9eb3a282728fc",
- "shasum": ""
- },
- "require": {
- "behat/gherkin": "^4.9.0",
- "behat/transliterator": "^1.2",
- "ext-mbstring": "*",
- "php": "^7.2 || ^8.0",
- "psr/container": "^1.0 || ^2.0",
- "symfony/config": "^4.4 || ^5.0 || ^6.0",
- "symfony/console": "^4.4 || ^5.0 || ^6.0",
- "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
- "symfony/event-dispatcher": "^4.4 || ^5.0 || ^6.0",
- "symfony/translation": "^4.4 || ^5.0 || ^6.0",
- "symfony/yaml": "^4.4 || ^5.0 || ^6.0"
- },
- "require-dev": {
- "herrera-io/box": "~1.6.1",
- "phpunit/phpunit": "^8.5 || ^9.0",
- "symfony/process": "^4.4 || ^5.0 || ^6.0",
- "vimeo/psalm": "^4.8"
- },
- "suggest": {
- "ext-dom": "Needed to output test results in JUnit format."
- },
- "bin": [
- "bin/behat"
- ],
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Behat\\Hook\\": "src/Behat/Hook/",
- "Behat\\Step\\": "src/Behat/Step/",
- "Behat\\Behat\\": "src/Behat/Behat/",
- "Behat\\Testwork\\": "src/Behat/Testwork/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Konstantin Kudryashov",
- "email": "ever.zet@gmail.com",
- "homepage": "http://everzet.com"
- }
- ],
- "description": "Scenario-oriented BDD framework for PHP",
- "homepage": "http://behat.org/",
- "keywords": [
- "Agile",
- "BDD",
- "ScenarioBDD",
- "Scrum",
- "StoryBDD",
- "User story",
- "business",
- "development",
- "documentation",
- "examples",
- "symfony",
- "testing"
- ],
- "support": {
- "issues": "https://github.com/Behat/Behat/issues",
- "source": "https://github.com/Behat/Behat/tree/v3.11.0"
- },
- "time": "2022-07-07T09:49:27+00:00"
- },
- {
- "name": "behat/gherkin",
- "version": "v4.9.0",
- "source": {
- "type": "git",
- "url": "https://github.com/Behat/Gherkin.git",
- "reference": "0bc8d1e30e96183e4f36db9dc79caead300beff4"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/Behat/Gherkin/zipball/0bc8d1e30e96183e4f36db9dc79caead300beff4",
- "reference": "0bc8d1e30e96183e4f36db9dc79caead300beff4",
- "shasum": ""
- },
- "require": {
- "php": "~7.2|~8.0"
- },
- "require-dev": {
- "cucumber/cucumber": "dev-gherkin-22.0.0",
- "phpunit/phpunit": "~8|~9",
- "symfony/yaml": "~3|~4|~5"
- },
- "suggest": {
- "symfony/yaml": "If you want to parse features, represented in YAML files"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.x-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Behat\\Gherkin": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Konstantin Kudryashov",
- "email": "ever.zet@gmail.com",
- "homepage": "http://everzet.com"
- }
- ],
- "description": "Gherkin DSL parser for PHP",
- "homepage": "http://behat.org/",
- "keywords": [
- "BDD",
- "Behat",
- "Cucumber",
- "DSL",
- "gherkin",
- "parser"
- ],
- "support": {
- "issues": "https://github.com/Behat/Gherkin/issues",
- "source": "https://github.com/Behat/Gherkin/tree/v4.9.0"
- },
- "time": "2021-10-12T13:05:09+00:00"
- },
- {
- "name": "behat/mink",
- "version": "v1.10.0",
- "source": {
- "type": "git",
- "url": "https://github.com/minkphp/Mink.git",
- "reference": "19e58905632e7cfdc5b2bafb9b950a3521af32c5"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/minkphp/Mink/zipball/19e58905632e7cfdc5b2bafb9b950a3521af32c5",
- "reference": "19e58905632e7cfdc5b2bafb9b950a3521af32c5",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2",
- "symfony/css-selector": "^4.4 || ^5.0 || ^6.0"
- },
- "require-dev": {
- "phpunit/phpunit": "^8.5.22 || ^9.5.11",
- "symfony/error-handler": "^4.4 || ^5.0 || ^6.0",
- "symfony/phpunit-bridge": "^5.4 || ^6.0"
- },
- "suggest": {
- "behat/mink-browserkit-driver": "fast headless driver for any app without JS emulation",
- "behat/mink-selenium2-driver": "slow, but JS-enabled driver for any app (requires Selenium2)",
- "behat/mink-zombie-driver": "fast and JS-enabled headless driver for any app (requires node.js)",
- "dmore/chrome-mink-driver": "fast and JS-enabled driver for any app (requires chromium or google chrome)"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Behat\\Mink\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Konstantin Kudryashov",
- "email": "ever.zet@gmail.com",
- "homepage": "http://everzet.com"
- }
- ],
- "description": "Browser controller/emulator abstraction for PHP",
- "homepage": "https://mink.behat.org/",
- "keywords": [
- "browser",
- "testing",
- "web"
- ],
- "support": {
- "issues": "https://github.com/minkphp/Mink/issues",
- "source": "https://github.com/minkphp/Mink/tree/v1.10.0"
- },
- "time": "2022-03-28T14:22:43+00:00"
- },
- {
- "name": "behat/mink-extension",
- "version": "2.3.1",
- "source": {
- "type": "git",
- "url": "https://github.com/Behat/MinkExtension.git",
- "reference": "80f7849ba53867181b7e412df9210e12fba50177"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/Behat/MinkExtension/zipball/80f7849ba53867181b7e412df9210e12fba50177",
- "reference": "80f7849ba53867181b7e412df9210e12fba50177",
- "shasum": ""
- },
- "require": {
- "behat/behat": "^3.0.5",
- "behat/mink": "^1.5",
- "php": ">=5.3.2",
- "symfony/config": "^2.7|^3.0|^4.0"
- },
- "require-dev": {
- "behat/mink-goutte-driver": "^1.1",
- "phpspec/phpspec": "^2.0"
- },
- "type": "behat-extension",
- "extra": {
- "branch-alias": {
- "dev-master": "2.1.x-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Behat\\MinkExtension": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Christophe Coevoet",
- "email": "stof@notk.org"
- },
- {
- "name": "Konstantin Kudryashov",
- "email": "ever.zet@gmail.com"
- }
- ],
- "description": "Mink extension for Behat",
- "homepage": "http://extensions.behat.org/mink",
- "keywords": [
- "browser",
- "gui",
- "test",
- "web"
- ],
- "support": {
- "issues": "https://github.com/Behat/MinkExtension/issues",
- "source": "https://github.com/Behat/MinkExtension/tree/master"
- },
- "time": "2018-02-06T15:36:30+00:00"
- },
- {
- "name": "behat/mink-selenium2-driver",
- "version": "v1.6.0",
- "source": {
- "type": "git",
- "url": "https://github.com/minkphp/MinkSelenium2Driver.git",
- "reference": "e5f8421654930da725499fb92983e6948c6f973e"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/minkphp/MinkSelenium2Driver/zipball/e5f8421654930da725499fb92983e6948c6f973e",
- "reference": "e5f8421654930da725499fb92983e6948c6f973e",
- "shasum": ""
- },
- "require": {
- "behat/mink": "^1.9@dev",
- "ext-json": "*",
- "instaclick/php-webdriver": "^1.4",
- "php": ">=7.2"
- },
- "require-dev": {
- "mink/driver-testsuite": "dev-master",
- "phpunit/phpunit": "^8.5.22 || ^9.5.11",
- "symfony/error-handler": "^4.4 || ^5.0"
- },
- "type": "mink-driver",
- "extra": {
- "branch-alias": {
- "dev-master": "1.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Behat\\Mink\\Driver\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Pete Otaqui",
- "email": "pete@otaqui.com",
- "homepage": "https://github.com/pete-otaqui"
- },
- {
- "name": "Konstantin Kudryashov",
- "email": "ever.zet@gmail.com",
- "homepage": "http://everzet.com"
- }
- ],
- "description": "Selenium2 (WebDriver) driver for Mink framework",
- "homepage": "https://mink.behat.org/",
- "keywords": [
- "ajax",
- "browser",
- "javascript",
- "selenium",
- "testing",
- "webdriver"
- ],
- "support": {
- "issues": "https://github.com/minkphp/MinkSelenium2Driver/issues",
- "source": "https://github.com/minkphp/MinkSelenium2Driver/tree/v1.6.0"
- },
- "time": "2022-03-28T14:55:17+00:00"
- },
- {
- "name": "behat/transliterator",
- "version": "v1.5.0",
- "source": {
- "type": "git",
- "url": "https://github.com/Behat/Transliterator.git",
- "reference": "baac5873bac3749887d28ab68e2f74db3a4408af"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/Behat/Transliterator/zipball/baac5873bac3749887d28ab68e2f74db3a4408af",
- "reference": "baac5873bac3749887d28ab68e2f74db3a4408af",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2"
- },
- "require-dev": {
- "chuyskywalker/rolling-curl": "^3.1",
- "php-yaoi/php-yaoi": "^1.0",
- "phpunit/phpunit": "^8.5.25 || ^9.5.19"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Behat\\Transliterator\\": "src/Behat/Transliterator"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "Artistic-1.0"
- ],
- "description": "String transliterator",
- "keywords": [
- "i18n",
- "slug",
- "transliterator"
- ],
- "support": {
- "issues": "https://github.com/Behat/Transliterator/issues",
- "source": "https://github.com/Behat/Transliterator/tree/v1.5.0"
- },
- "time": "2022-03-30T09:27:43+00:00"
- },
- {
- "name": "doctrine/instantiator",
- "version": "1.4.1",
- "source": {
- "type": "git",
- "url": "https://github.com/doctrine/instantiator.git",
- "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc",
- "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc",
- "shasum": ""
- },
- "require": {
- "php": "^7.1 || ^8.0"
- },
- "require-dev": {
- "doctrine/coding-standard": "^9",
- "ext-pdo": "*",
- "ext-phar": "*",
- "phpbench/phpbench": "^0.16 || ^1",
- "phpstan/phpstan": "^1.4",
- "phpstan/phpstan-phpunit": "^1",
- "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
- "vimeo/psalm": "^4.22"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Marco Pivetta",
- "email": "ocramius@gmail.com",
- "homepage": "https://ocramius.github.io/"
- }
- ],
- "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
- "homepage": "https://www.doctrine-project.org/projects/instantiator.html",
- "keywords": [
- "constructor",
- "instantiate"
- ],
- "support": {
- "issues": "https://github.com/doctrine/instantiator/issues",
- "source": "https://github.com/doctrine/instantiator/tree/1.4.1"
- },
- "funding": [
- {
- "url": "https://www.doctrine-project.org/sponsorship.html",
- "type": "custom"
- },
- {
- "url": "https://www.patreon.com/phpdoctrine",
- "type": "patreon"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator",
- "type": "tidelift"
- }
- ],
- "time": "2022-03-03T08:28:38+00:00"
- },
- {
- "name": "instaclick/php-webdriver",
- "version": "1.4.15",
- "source": {
- "type": "git",
- "url": "https://github.com/instaclick/php-webdriver.git",
- "reference": "ed8f7741a0952db42686aae0780a0935138a7cf8"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/instaclick/php-webdriver/zipball/ed8f7741a0952db42686aae0780a0935138a7cf8",
- "reference": "ed8f7741a0952db42686aae0780a0935138a7cf8",
- "shasum": ""
- },
- "require": {
- "ext-curl": "*",
- "php": ">=5.3.2"
- },
- "require-dev": {
- "phpunit/phpunit": "^8.5 || ^9.5",
- "satooshi/php-coveralls": "^1.0 || ^2.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.4.x-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "WebDriver": "lib/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "Apache-2.0"
- ],
- "authors": [
- {
- "name": "Justin Bishop",
- "email": "jubishop@gmail.com",
- "role": "Developer"
- },
- {
- "name": "Anthon Pang",
- "email": "apang@softwaredevelopment.ca",
- "role": "Fork Maintainer"
- }
- ],
- "description": "PHP WebDriver for Selenium 2",
- "homepage": "http://instaclick.com/",
- "keywords": [
- "browser",
- "selenium",
- "webdriver",
- "webtest"
- ],
- "support": {
- "issues": "https://github.com/instaclick/php-webdriver/issues",
- "source": "https://github.com/instaclick/php-webdriver/tree/1.4.15"
- },
- "time": "2022-08-09T14:26:29+00:00"
- },
- {
- "name": "myclabs/deep-copy",
- "version": "1.11.0",
- "source": {
- "type": "git",
- "url": "https://github.com/myclabs/DeepCopy.git",
- "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614",
- "reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614",
- "shasum": ""
- },
- "require": {
- "php": "^7.1 || ^8.0"
- },
- "conflict": {
- "doctrine/collections": "<1.6.8",
- "doctrine/common": "<2.13.3 || >=3,<3.2.2"
- },
- "require-dev": {
- "doctrine/collections": "^1.6.8",
- "doctrine/common": "^2.13.3 || ^3.2.2",
- "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13"
- },
- "type": "library",
- "autoload": {
- "files": [
- "src/DeepCopy/deep_copy.php"
- ],
- "psr-4": {
- "DeepCopy\\": "src/DeepCopy/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "description": "Create deep copies (clones) of your objects",
- "keywords": [
- "clone",
- "copy",
- "duplicate",
- "object",
- "object graph"
- ],
- "support": {
- "issues": "https://github.com/myclabs/DeepCopy/issues",
- "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0"
- },
- "funding": [
- {
- "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy",
- "type": "tidelift"
- }
- ],
- "time": "2022-03-03T13:19:32+00:00"
- },
- {
- "name": "nikic/php-parser",
- "version": "v4.15.1",
- "source": {
- "type": "git",
- "url": "https://github.com/nikic/PHP-Parser.git",
- "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0ef6c55a3f47f89d7a374e6f835197a0b5fcf900",
- "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900",
- "shasum": ""
- },
- "require": {
- "ext-tokenizer": "*",
- "php": ">=7.0"
- },
- "require-dev": {
- "ircmaxell/php-yacc": "^0.0.7",
- "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
- },
- "bin": [
- "bin/php-parse"
- ],
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.9-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "PhpParser\\": "lib/PhpParser"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Nikita Popov"
- }
- ],
- "description": "A PHP parser written in PHP",
- "keywords": [
- "parser",
- "php"
- ],
- "support": {
- "issues": "https://github.com/nikic/PHP-Parser/issues",
- "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.1"
- },
- "time": "2022-09-04T07:30:47+00:00"
- },
- {
- "name": "phar-io/manifest",
- "version": "2.0.3",
- "source": {
- "type": "git",
- "url": "https://github.com/phar-io/manifest.git",
- "reference": "97803eca37d319dfa7826cc2437fc020857acb53"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53",
- "reference": "97803eca37d319dfa7826cc2437fc020857acb53",
- "shasum": ""
- },
- "require": {
- "ext-dom": "*",
- "ext-phar": "*",
- "ext-xmlwriter": "*",
- "phar-io/version": "^3.0.1",
- "php": "^7.2 || ^8.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Arne Blankerts",
- "email": "arne@blankerts.de",
- "role": "Developer"
- },
- {
- "name": "Sebastian Heuer",
- "email": "sebastian@phpeople.de",
- "role": "Developer"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "Developer"
- }
- ],
- "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
- "support": {
- "issues": "https://github.com/phar-io/manifest/issues",
- "source": "https://github.com/phar-io/manifest/tree/2.0.3"
- },
- "time": "2021-07-20T11:28:43+00:00"
- },
- {
- "name": "phar-io/version",
- "version": "3.2.1",
- "source": {
- "type": "git",
- "url": "https://github.com/phar-io/version.git",
- "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
- "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74",
- "shasum": ""
- },
- "require": {
- "php": "^7.2 || ^8.0"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Arne Blankerts",
- "email": "arne@blankerts.de",
- "role": "Developer"
- },
- {
- "name": "Sebastian Heuer",
- "email": "sebastian@phpeople.de",
- "role": "Developer"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "Developer"
- }
- ],
- "description": "Library for handling version information and constraints",
- "support": {
- "issues": "https://github.com/phar-io/version/issues",
- "source": "https://github.com/phar-io/version/tree/3.2.1"
- },
- "time": "2022-02-21T01:04:05+00:00"
- },
- {
- "name": "phpdocumentor/reflection-common",
- "version": "2.2.0",
- "source": {
- "type": "git",
- "url": "https://github.com/phpDocumentor/ReflectionCommon.git",
- "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b",
- "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b",
- "shasum": ""
- },
- "require": {
- "php": "^7.2 || ^8.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-2.x": "2.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "phpDocumentor\\Reflection\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Jaap van Otterdijk",
- "email": "opensource@ijaap.nl"
- }
- ],
- "description": "Common reflection classes used by phpdocumentor to reflect the code structure",
- "homepage": "http://www.phpdoc.org",
- "keywords": [
- "FQSEN",
- "phpDocumentor",
- "phpdoc",
- "reflection",
- "static analysis"
- ],
- "support": {
- "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
- "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
- },
- "time": "2020-06-27T09:03:43+00:00"
- },
- {
- "name": "phpdocumentor/reflection-docblock",
- "version": "5.3.0",
- "source": {
- "type": "git",
- "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
- "reference": "622548b623e81ca6d78b721c5e029f4ce664f170"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170",
- "reference": "622548b623e81ca6d78b721c5e029f4ce664f170",
- "shasum": ""
- },
- "require": {
- "ext-filter": "*",
- "php": "^7.2 || ^8.0",
- "phpdocumentor/reflection-common": "^2.2",
- "phpdocumentor/type-resolver": "^1.3",
- "webmozart/assert": "^1.9.1"
- },
- "require-dev": {
- "mockery/mockery": "~1.3.2",
- "psalm/phar": "^4.8"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "5.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "phpDocumentor\\Reflection\\": "src"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Mike van Riel",
- "email": "me@mikevanriel.com"
- },
- {
- "name": "Jaap van Otterdijk",
- "email": "account@ijaap.nl"
- }
- ],
- "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
- "support": {
- "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
- "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0"
- },
- "time": "2021-10-19T17:43:47+00:00"
- },
- {
- "name": "phpdocumentor/type-resolver",
- "version": "1.6.2",
- "source": {
- "type": "git",
- "url": "https://github.com/phpDocumentor/TypeResolver.git",
- "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
- "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
- "shasum": ""
- },
- "require": {
- "php": "^7.4 || ^8.0",
- "phpdocumentor/reflection-common": "^2.0"
- },
- "require-dev": {
- "ext-tokenizer": "*",
- "phpstan/extension-installer": "^1.1",
- "phpstan/phpstan": "^1.8",
- "phpstan/phpstan-phpunit": "^1.1",
- "phpunit/phpunit": "^9.5",
- "rector/rector": "^0.13.9",
- "vimeo/psalm": "^4.25"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-1.x": "1.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "phpDocumentor\\Reflection\\": "src"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Mike van Riel",
- "email": "me@mikevanriel.com"
- }
- ],
- "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
- "support": {
- "issues": "https://github.com/phpDocumentor/TypeResolver/issues",
- "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2"
- },
- "time": "2022-10-14T12:47:21+00:00"
- },
- {
- "name": "phpspec/prophecy",
- "version": "v1.15.0",
- "source": {
- "type": "git",
- "url": "https://github.com/phpspec/prophecy.git",
- "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13",
- "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13",
- "shasum": ""
- },
- "require": {
- "doctrine/instantiator": "^1.2",
- "php": "^7.2 || ~8.0, <8.2",
- "phpdocumentor/reflection-docblock": "^5.2",
- "sebastian/comparator": "^3.0 || ^4.0",
- "sebastian/recursion-context": "^3.0 || ^4.0"
- },
- "require-dev": {
- "phpspec/phpspec": "^6.0 || ^7.0",
- "phpunit/phpunit": "^8.0 || ^9.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Prophecy\\": "src/Prophecy"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Konstantin Kudryashov",
- "email": "ever.zet@gmail.com",
- "homepage": "http://everzet.com"
- },
- {
- "name": "Marcello Duarte",
- "email": "marcello.duarte@gmail.com"
- }
- ],
- "description": "Highly opinionated mocking framework for PHP 5.3+",
- "homepage": "https://github.com/phpspec/prophecy",
- "keywords": [
- "Double",
- "Dummy",
- "fake",
- "mock",
- "spy",
- "stub"
- ],
- "support": {
- "issues": "https://github.com/phpspec/prophecy/issues",
- "source": "https://github.com/phpspec/prophecy/tree/v1.15.0"
- },
- "time": "2021-12-08T12:19:24+00:00"
- },
- {
- "name": "phpunit/php-code-coverage",
- "version": "9.2.17",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8",
- "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8",
- "shasum": ""
- },
- "require": {
- "ext-dom": "*",
- "ext-libxml": "*",
- "ext-xmlwriter": "*",
- "nikic/php-parser": "^4.14",
- "php": ">=7.3",
- "phpunit/php-file-iterator": "^3.0.3",
- "phpunit/php-text-template": "^2.0.2",
- "sebastian/code-unit-reverse-lookup": "^2.0.2",
- "sebastian/complexity": "^2.0",
- "sebastian/environment": "^5.1.2",
- "sebastian/lines-of-code": "^1.0.3",
- "sebastian/version": "^3.0.1",
- "theseer/tokenizer": "^1.2.0"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "suggest": {
- "ext-pcov": "*",
- "ext-xdebug": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "9.2-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
- "homepage": "https://github.com/sebastianbergmann/php-code-coverage",
- "keywords": [
- "coverage",
- "testing",
- "xunit"
- ],
- "support": {
- "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
- "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.17"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2022-08-30T12:24:04+00:00"
- },
- {
- "name": "phpunit/php-file-iterator",
- "version": "3.0.6",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
- "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
- "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "FilterIterator implementation that filters files based on a list of suffixes.",
- "homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
- "keywords": [
- "filesystem",
- "iterator"
- ],
- "support": {
- "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
- "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2021-12-02T12:48:52+00:00"
- },
- {
- "name": "phpunit/php-invoker",
- "version": "3.1.1",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-invoker.git",
- "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67",
- "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "require-dev": {
- "ext-pcntl": "*",
- "phpunit/phpunit": "^9.3"
- },
- "suggest": {
- "ext-pcntl": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.1-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Invoke callables with a timeout",
- "homepage": "https://github.com/sebastianbergmann/php-invoker/",
- "keywords": [
- "process"
- ],
- "support": {
- "issues": "https://github.com/sebastianbergmann/php-invoker/issues",
- "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-09-28T05:58:55+00:00"
- },
- {
- "name": "phpunit/php-text-template",
- "version": "2.0.4",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-text-template.git",
- "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28",
- "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Simple template engine.",
- "homepage": "https://github.com/sebastianbergmann/php-text-template/",
- "keywords": [
- "template"
- ],
- "support": {
- "issues": "https://github.com/sebastianbergmann/php-text-template/issues",
- "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-10-26T05:33:50+00:00"
- },
- {
- "name": "phpunit/php-timer",
- "version": "5.0.3",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-timer.git",
- "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2",
- "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "5.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Utility class for timing",
- "homepage": "https://github.com/sebastianbergmann/php-timer/",
- "keywords": [
- "timer"
- ],
- "support": {
- "issues": "https://github.com/sebastianbergmann/php-timer/issues",
- "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-10-26T13:16:10+00:00"
- },
- {
- "name": "phpunit/phpunit",
- "version": "9.5.19",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "35ea4b7f3acabb26f4bb640f8c30866c401da807"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/35ea4b7f3acabb26f4bb640f8c30866c401da807",
- "reference": "35ea4b7f3acabb26f4bb640f8c30866c401da807",
- "shasum": ""
- },
- "require": {
- "doctrine/instantiator": "^1.3.1",
- "ext-dom": "*",
- "ext-json": "*",
- "ext-libxml": "*",
- "ext-mbstring": "*",
- "ext-xml": "*",
- "ext-xmlwriter": "*",
- "myclabs/deep-copy": "^1.10.1",
- "phar-io/manifest": "^2.0.3",
- "phar-io/version": "^3.0.2",
- "php": ">=7.3",
- "phpspec/prophecy": "^1.12.1",
- "phpunit/php-code-coverage": "^9.2.13",
- "phpunit/php-file-iterator": "^3.0.5",
- "phpunit/php-invoker": "^3.1.1",
- "phpunit/php-text-template": "^2.0.3",
- "phpunit/php-timer": "^5.0.2",
- "sebastian/cli-parser": "^1.0.1",
- "sebastian/code-unit": "^1.0.6",
- "sebastian/comparator": "^4.0.5",
- "sebastian/diff": "^4.0.3",
- "sebastian/environment": "^5.1.3",
- "sebastian/exporter": "^4.0.3",
- "sebastian/global-state": "^5.0.1",
- "sebastian/object-enumerator": "^4.0.3",
- "sebastian/resource-operations": "^3.0.3",
- "sebastian/type": "^3.0",
- "sebastian/version": "^3.0.2"
- },
- "require-dev": {
- "ext-pdo": "*",
- "phpspec/prophecy-phpunit": "^2.0.1"
- },
- "suggest": {
- "ext-soap": "*",
- "ext-xdebug": "*"
- },
- "bin": [
- "phpunit"
- ],
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "9.5-dev"
- }
- },
- "autoload": {
- "files": [
- "src/Framework/Assert/Functions.php"
- ],
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "The PHP Unit Testing framework.",
- "homepage": "https://phpunit.de/",
- "keywords": [
- "phpunit",
- "testing",
- "xunit"
- ],
- "support": {
- "issues": "https://github.com/sebastianbergmann/phpunit/issues",
- "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.19"
- },
- "funding": [
- {
- "url": "https://phpunit.de/sponsors.html",
- "type": "custom"
- },
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2022-03-15T09:57:31+00:00"
- },
- {
- "name": "psr/container",
- "version": "1.1.2",
- "source": {
- "type": "git",
- "url": "https://github.com/php-fig/container.git",
- "reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea",
- "reference": "513e0666f7216c7459170d56df27dfcefe1689ea",
- "shasum": ""
- },
- "require": {
- "php": ">=7.4.0"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Psr\\Container\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "PHP-FIG",
- "homepage": "https://www.php-fig.org/"
- }
- ],
- "description": "Common Container Interface (PHP FIG PSR-11)",
- "homepage": "https://github.com/php-fig/container",
- "keywords": [
- "PSR-11",
- "container",
- "container-interface",
- "container-interop",
- "psr"
- ],
- "support": {
- "issues": "https://github.com/php-fig/container/issues",
- "source": "https://github.com/php-fig/container/tree/1.1.2"
- },
- "time": "2021-11-05T16:50:12+00:00"
- },
- {
- "name": "psr/event-dispatcher",
- "version": "1.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/php-fig/event-dispatcher.git",
- "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0",
- "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Psr\\EventDispatcher\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "PHP-FIG",
- "homepage": "http://www.php-fig.org/"
- }
- ],
- "description": "Standard interfaces for event handling.",
- "keywords": [
- "events",
- "psr",
- "psr-14"
- ],
- "support": {
- "issues": "https://github.com/php-fig/event-dispatcher/issues",
- "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0"
- },
- "time": "2019-01-08T18:20:26+00:00"
- },
- {
- "name": "sebastian/cli-parser",
- "version": "1.0.1",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/cli-parser.git",
- "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2",
- "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Library for parsing CLI options",
- "homepage": "https://github.com/sebastianbergmann/cli-parser",
- "support": {
- "issues": "https://github.com/sebastianbergmann/cli-parser/issues",
- "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-09-28T06:08:49+00:00"
- },
- {
- "name": "sebastian/code-unit",
- "version": "1.0.8",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/code-unit.git",
- "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120",
- "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Collection of value objects that represent the PHP code units",
- "homepage": "https://github.com/sebastianbergmann/code-unit",
- "support": {
- "issues": "https://github.com/sebastianbergmann/code-unit/issues",
- "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-10-26T13:08:54+00:00"
- },
- {
- "name": "sebastian/code-unit-reverse-lookup",
- "version": "2.0.3",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git",
- "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5",
- "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Looks up which function or method a line of code belongs to",
- "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
- "support": {
- "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues",
- "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-09-28T05:30:19+00:00"
- },
- {
- "name": "sebastian/comparator",
- "version": "4.0.8",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/comparator.git",
- "reference": "fa0f136dd2334583309d32b62544682ee972b51a"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a",
- "reference": "fa0f136dd2334583309d32b62544682ee972b51a",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3",
- "sebastian/diff": "^4.0",
- "sebastian/exporter": "^4.0"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- },
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Volker Dusch",
- "email": "github@wallbash.com"
- },
- {
- "name": "Bernhard Schussek",
- "email": "bschussek@2bepublished.at"
- }
- ],
- "description": "Provides the functionality to compare PHP values for equality",
- "homepage": "https://github.com/sebastianbergmann/comparator",
- "keywords": [
- "comparator",
- "compare",
- "equality"
- ],
- "support": {
- "issues": "https://github.com/sebastianbergmann/comparator/issues",
- "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2022-09-14T12:41:17+00:00"
- },
- {
- "name": "sebastian/complexity",
- "version": "2.0.2",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/complexity.git",
- "reference": "739b35e53379900cc9ac327b2147867b8b6efd88"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88",
- "reference": "739b35e53379900cc9ac327b2147867b8b6efd88",
- "shasum": ""
- },
- "require": {
- "nikic/php-parser": "^4.7",
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Library for calculating the complexity of PHP code units",
- "homepage": "https://github.com/sebastianbergmann/complexity",
- "support": {
- "issues": "https://github.com/sebastianbergmann/complexity/issues",
- "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-10-26T15:52:27+00:00"
- },
- {
- "name": "sebastian/diff",
- "version": "4.0.4",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/diff.git",
- "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d",
- "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3",
- "symfony/process": "^4.2 || ^5"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- },
- {
- "name": "Kore Nordmann",
- "email": "mail@kore-nordmann.de"
- }
- ],
- "description": "Diff implementation",
- "homepage": "https://github.com/sebastianbergmann/diff",
- "keywords": [
- "diff",
- "udiff",
- "unidiff",
- "unified diff"
- ],
- "support": {
- "issues": "https://github.com/sebastianbergmann/diff/issues",
- "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-10-26T13:10:38+00:00"
- },
- {
- "name": "sebastian/environment",
- "version": "5.1.4",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/environment.git",
- "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7",
- "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "suggest": {
- "ext-posix": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "5.1-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Provides functionality to handle HHVM/PHP environments",
- "homepage": "http://www.github.com/sebastianbergmann/environment",
- "keywords": [
- "Xdebug",
- "environment",
- "hhvm"
- ],
- "support": {
- "issues": "https://github.com/sebastianbergmann/environment/issues",
- "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2022-04-03T09:37:03+00:00"
- },
- {
- "name": "sebastian/exporter",
- "version": "4.0.5",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/exporter.git",
- "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d",
- "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3",
- "sebastian/recursion-context": "^4.0"
- },
- "require-dev": {
- "ext-mbstring": "*",
- "phpunit/phpunit": "^9.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- },
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Volker Dusch",
- "email": "github@wallbash.com"
- },
- {
- "name": "Adam Harvey",
- "email": "aharvey@php.net"
- },
- {
- "name": "Bernhard Schussek",
- "email": "bschussek@gmail.com"
- }
- ],
- "description": "Provides the functionality to export PHP variables for visualization",
- "homepage": "https://www.github.com/sebastianbergmann/exporter",
- "keywords": [
- "export",
- "exporter"
- ],
- "support": {
- "issues": "https://github.com/sebastianbergmann/exporter/issues",
- "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2022-09-14T06:03:37+00:00"
- },
- {
- "name": "sebastian/global-state",
- "version": "5.0.5",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/global-state.git",
- "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2",
- "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3",
- "sebastian/object-reflector": "^2.0",
- "sebastian/recursion-context": "^4.0"
- },
- "require-dev": {
- "ext-dom": "*",
- "phpunit/phpunit": "^9.3"
- },
- "suggest": {
- "ext-uopz": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "5.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Snapshotting of global state",
- "homepage": "http://www.github.com/sebastianbergmann/global-state",
- "keywords": [
- "global state"
- ],
- "support": {
- "issues": "https://github.com/sebastianbergmann/global-state/issues",
- "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2022-02-14T08:28:10+00:00"
- },
- {
- "name": "sebastian/lines-of-code",
- "version": "1.0.3",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/lines-of-code.git",
- "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc",
- "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc",
- "shasum": ""
- },
- "require": {
- "nikic/php-parser": "^4.6",
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Library for counting the lines of code in PHP source code",
- "homepage": "https://github.com/sebastianbergmann/lines-of-code",
- "support": {
- "issues": "https://github.com/sebastianbergmann/lines-of-code/issues",
- "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-11-28T06:42:11+00:00"
- },
- {
- "name": "sebastian/object-enumerator",
- "version": "4.0.4",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/object-enumerator.git",
- "reference": "5c9eeac41b290a3712d88851518825ad78f45c71"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71",
- "reference": "5c9eeac41b290a3712d88851518825ad78f45c71",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3",
- "sebastian/object-reflector": "^2.0",
- "sebastian/recursion-context": "^4.0"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Traverses array structures and object graphs to enumerate all referenced objects",
- "homepage": "https://github.com/sebastianbergmann/object-enumerator/",
- "support": {
- "issues": "https://github.com/sebastianbergmann/object-enumerator/issues",
- "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-10-26T13:12:34+00:00"
- },
- {
- "name": "sebastian/object-reflector",
- "version": "2.0.4",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/object-reflector.git",
- "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7",
- "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Allows reflection of object attributes, including inherited and non-public ones",
- "homepage": "https://github.com/sebastianbergmann/object-reflector/",
- "support": {
- "issues": "https://github.com/sebastianbergmann/object-reflector/issues",
- "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-10-26T13:14:26+00:00"
- },
- {
- "name": "sebastian/recursion-context",
- "version": "4.0.4",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/recursion-context.git",
- "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172",
- "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- },
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Adam Harvey",
- "email": "aharvey@php.net"
- }
- ],
- "description": "Provides functionality to recursively process PHP variables",
- "homepage": "http://www.github.com/sebastianbergmann/recursion-context",
- "support": {
- "issues": "https://github.com/sebastianbergmann/recursion-context/issues",
- "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-10-26T13:17:30+00:00"
- },
- {
- "name": "sebastian/resource-operations",
- "version": "3.0.3",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/resource-operations.git",
- "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8",
- "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Provides a list of PHP built-in functions that operate on resources",
- "homepage": "https://www.github.com/sebastianbergmann/resource-operations",
- "support": {
- "issues": "https://github.com/sebastianbergmann/resource-operations/issues",
- "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-09-28T06:45:17+00:00"
- },
- {
- "name": "sebastian/type",
- "version": "3.2.0",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/type.git",
- "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e",
- "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "require-dev": {
- "phpunit/phpunit": "^9.5"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.2-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Collection of value objects that represent the types of the PHP type system",
- "homepage": "https://github.com/sebastianbergmann/type",
- "support": {
- "issues": "https://github.com/sebastianbergmann/type/issues",
- "source": "https://github.com/sebastianbergmann/type/tree/3.2.0"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2022-09-12T14:47:03+00:00"
- },
- {
- "name": "sebastian/version",
- "version": "3.0.2",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/version.git",
- "reference": "c6c1022351a901512170118436c764e473f6de8c"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c",
- "reference": "c6c1022351a901512170118436c764e473f6de8c",
- "shasum": ""
- },
- "require": {
- "php": ">=7.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Library that helps with managing the version number of Git-hosted PHP projects",
- "homepage": "https://github.com/sebastianbergmann/version",
- "support": {
- "issues": "https://github.com/sebastianbergmann/version/issues",
- "source": "https://github.com/sebastianbergmann/version/tree/3.0.2"
- },
- "funding": [
- {
- "url": "https://github.com/sebastianbergmann",
- "type": "github"
- }
- ],
- "time": "2020-09-28T06:39:44+00:00"
- },
- {
- "name": "symfony/config",
- "version": "v4.4.44",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/config.git",
- "reference": "ed42f8f9da528d2c6cae36fe1f380b0c1d8f0658"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/config/zipball/ed42f8f9da528d2c6cae36fe1f380b0c1d8f0658",
- "reference": "ed42f8f9da528d2c6cae36fe1f380b0c1d8f0658",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1.3",
- "symfony/filesystem": "^3.4|^4.0|^5.0",
- "symfony/polyfill-ctype": "~1.8",
- "symfony/polyfill-php80": "^1.16",
- "symfony/polyfill-php81": "^1.22"
- },
- "conflict": {
- "symfony/finder": "<3.4"
- },
- "require-dev": {
- "symfony/event-dispatcher": "^3.4|^4.0|^5.0",
- "symfony/finder": "^3.4|^4.0|^5.0",
- "symfony/messenger": "^4.1|^5.0",
- "symfony/service-contracts": "^1.1|^2",
- "symfony/yaml": "^3.4|^4.0|^5.0"
- },
- "suggest": {
- "symfony/yaml": "To use the yaml reference dumper"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\Config\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Helps you find, load, combine, autofill and validate configuration values of any kind",
- "homepage": "https://symfony.com",
- "support": {
- "source": "https://github.com/symfony/config/tree/v4.4.44"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-07-20T09:59:04+00:00"
- },
- {
- "name": "symfony/console",
- "version": "v5.4.14",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/console.git",
- "reference": "984ea2c0f45f42dfed01d2f3987b187467c4b16d"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/984ea2c0f45f42dfed01d2f3987b187467c4b16d",
- "reference": "984ea2c0f45f42dfed01d2f3987b187467c4b16d",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1|^3",
- "symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php73": "^1.9",
- "symfony/polyfill-php80": "^1.16",
- "symfony/service-contracts": "^1.1|^2|^3",
- "symfony/string": "^5.1|^6.0"
- },
- "conflict": {
- "psr/log": ">=3",
- "symfony/dependency-injection": "<4.4",
- "symfony/dotenv": "<5.1",
- "symfony/event-dispatcher": "<4.4",
- "symfony/lock": "<4.4",
- "symfony/process": "<4.4"
- },
- "provide": {
- "psr/log-implementation": "1.0|2.0"
- },
- "require-dev": {
- "psr/log": "^1|^2",
- "symfony/config": "^4.4|^5.0|^6.0",
- "symfony/dependency-injection": "^4.4|^5.0|^6.0",
- "symfony/event-dispatcher": "^4.4|^5.0|^6.0",
- "symfony/lock": "^4.4|^5.0|^6.0",
- "symfony/process": "^4.4|^5.0|^6.0",
- "symfony/var-dumper": "^4.4|^5.0|^6.0"
- },
- "suggest": {
- "psr/log": "For using the console logger",
- "symfony/event-dispatcher": "",
- "symfony/lock": "",
- "symfony/process": ""
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\Console\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Eases the creation of beautiful and testable command line interfaces",
- "homepage": "https://symfony.com",
- "keywords": [
- "cli",
- "command line",
- "console",
- "terminal"
- ],
- "support": {
- "source": "https://github.com/symfony/console/tree/v5.4.14"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-10-07T08:01:20+00:00"
- },
- {
- "name": "symfony/css-selector",
- "version": "v5.4.11",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/css-selector.git",
- "reference": "c1681789f059ab756001052164726ae88512ae3d"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/css-selector/zipball/c1681789f059ab756001052164726ae88512ae3d",
- "reference": "c1681789f059ab756001052164726ae88512ae3d",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.5",
- "symfony/polyfill-php80": "^1.16"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\CssSelector\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Jean-François Simon",
- "email": "jeanfrancois.simon@sensiolabs.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Converts CSS selectors to XPath expressions",
- "homepage": "https://symfony.com",
- "support": {
- "source": "https://github.com/symfony/css-selector/tree/v5.4.11"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-06-27T16:58:25+00:00"
- },
- {
- "name": "symfony/dependency-injection",
- "version": "v4.4.44",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/dependency-injection.git",
- "reference": "25502a57182ba1e15da0afd64c975cae4d0a1471"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/25502a57182ba1e15da0afd64c975cae4d0a1471",
- "reference": "25502a57182ba1e15da0afd64c975cae4d0a1471",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1.3",
- "psr/container": "^1.0",
- "symfony/polyfill-php80": "^1.16",
- "symfony/service-contracts": "^1.1.6|^2"
- },
- "conflict": {
- "symfony/config": "<4.3|>=5.0",
- "symfony/finder": "<3.4",
- "symfony/proxy-manager-bridge": "<3.4",
- "symfony/yaml": "<4.4.26"
- },
- "provide": {
- "psr/container-implementation": "1.0",
- "symfony/service-implementation": "1.0|2.0"
- },
- "require-dev": {
- "symfony/config": "^4.3",
- "symfony/expression-language": "^3.4|^4.0|^5.0",
- "symfony/yaml": "^4.4.26|^5.0"
- },
- "suggest": {
- "symfony/config": "",
- "symfony/expression-language": "For using expressions in service container configuration",
- "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required",
- "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them",
- "symfony/yaml": ""
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\DependencyInjection\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Allows you to standardize and centralize the way objects are constructed in your application",
- "homepage": "https://symfony.com",
- "support": {
- "source": "https://github.com/symfony/dependency-injection/tree/v4.4.44"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-07-20T09:59:04+00:00"
- },
- {
- "name": "symfony/deprecation-contracts",
- "version": "v2.5.2",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/deprecation-contracts.git",
- "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
- "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "2.5-dev"
- },
- "thanks": {
- "name": "symfony/contracts",
- "url": "https://github.com/symfony/contracts"
- }
- },
- "autoload": {
- "files": [
- "function.php"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "A generic function and convention to trigger deprecation notices",
- "homepage": "https://symfony.com",
- "support": {
- "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-01-02T09:53:40+00:00"
- },
- {
- "name": "symfony/event-dispatcher",
- "version": "v5.4.9",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/event-dispatcher.git",
- "reference": "8e6ce1cc0279e3ff3c8ff0f43813bc88d21ca1bc"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/8e6ce1cc0279e3ff3c8ff0f43813bc88d21ca1bc",
- "reference": "8e6ce1cc0279e3ff3c8ff0f43813bc88d21ca1bc",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1|^3",
- "symfony/event-dispatcher-contracts": "^2|^3",
- "symfony/polyfill-php80": "^1.16"
- },
- "conflict": {
- "symfony/dependency-injection": "<4.4"
- },
- "provide": {
- "psr/event-dispatcher-implementation": "1.0",
- "symfony/event-dispatcher-implementation": "2.0"
- },
- "require-dev": {
- "psr/log": "^1|^2|^3",
- "symfony/config": "^4.4|^5.0|^6.0",
- "symfony/dependency-injection": "^4.4|^5.0|^6.0",
- "symfony/error-handler": "^4.4|^5.0|^6.0",
- "symfony/expression-language": "^4.4|^5.0|^6.0",
- "symfony/http-foundation": "^4.4|^5.0|^6.0",
- "symfony/service-contracts": "^1.1|^2|^3",
- "symfony/stopwatch": "^4.4|^5.0|^6.0"
- },
- "suggest": {
- "symfony/dependency-injection": "",
- "symfony/http-kernel": ""
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\EventDispatcher\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
- "homepage": "https://symfony.com",
- "support": {
- "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.9"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-05-05T16:45:39+00:00"
- },
- {
- "name": "symfony/event-dispatcher-contracts",
- "version": "v2.5.2",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/event-dispatcher-contracts.git",
- "reference": "f98b54df6ad059855739db6fcbc2d36995283fe1"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/f98b54df6ad059855739db6fcbc2d36995283fe1",
- "reference": "f98b54df6ad059855739db6fcbc2d36995283fe1",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.5",
- "psr/event-dispatcher": "^1"
- },
- "suggest": {
- "symfony/event-dispatcher-implementation": ""
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "2.5-dev"
- },
- "thanks": {
- "name": "symfony/contracts",
- "url": "https://github.com/symfony/contracts"
- }
- },
- "autoload": {
- "psr-4": {
- "Symfony\\Contracts\\EventDispatcher\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Generic abstractions related to dispatching event",
- "homepage": "https://symfony.com",
- "keywords": [
- "abstractions",
- "contracts",
- "decoupling",
- "interfaces",
- "interoperability",
- "standards"
- ],
- "support": {
- "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.2"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-01-02T09:53:40+00:00"
- },
- {
- "name": "symfony/filesystem",
- "version": "v5.4.13",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/filesystem.git",
- "reference": "ac09569844a9109a5966b9438fc29113ce77cf51"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/filesystem/zipball/ac09569844a9109a5966b9438fc29113ce77cf51",
- "reference": "ac09569844a9109a5966b9438fc29113ce77cf51",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.5",
- "symfony/polyfill-ctype": "~1.8",
- "symfony/polyfill-mbstring": "~1.8",
- "symfony/polyfill-php80": "^1.16"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\Filesystem\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Provides basic utilities for the filesystem",
- "homepage": "https://symfony.com",
- "support": {
- "source": "https://github.com/symfony/filesystem/tree/v5.4.13"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-09-21T19:53:16+00:00"
- },
- {
- "name": "symfony/polyfill-ctype",
- "version": "v1.26.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-ctype.git",
- "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4",
- "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "provide": {
- "ext-ctype": "*"
- },
- "suggest": {
- "ext-ctype": "For best performance"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "1.26-dev"
- },
- "thanks": {
- "name": "symfony/polyfill",
- "url": "https://github.com/symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Ctype\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Gert de Pagter",
- "email": "BackEndTea@gmail.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill for ctype functions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "ctype",
- "polyfill",
- "portable"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-05-24T11:49:31+00:00"
- },
- {
- "name": "symfony/polyfill-intl-grapheme",
- "version": "v1.26.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-intl-grapheme.git",
- "reference": "433d05519ce6990bf3530fba6957499d327395c2"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/433d05519ce6990bf3530fba6957499d327395c2",
- "reference": "433d05519ce6990bf3530fba6957499d327395c2",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "suggest": {
- "ext-intl": "For best performance"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "1.26-dev"
- },
- "thanks": {
- "name": "symfony/polyfill",
- "url": "https://github.com/symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Intl\\Grapheme\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill for intl's grapheme_* functions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "grapheme",
- "intl",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.26.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-05-24T11:49:31+00:00"
- },
- {
- "name": "symfony/polyfill-intl-normalizer",
- "version": "v1.26.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-intl-normalizer.git",
- "reference": "219aa369ceff116e673852dce47c3a41794c14bd"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/219aa369ceff116e673852dce47c3a41794c14bd",
- "reference": "219aa369ceff116e673852dce47c3a41794c14bd",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "suggest": {
- "ext-intl": "For best performance"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "1.26-dev"
- },
- "thanks": {
- "name": "symfony/polyfill",
- "url": "https://github.com/symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
- },
- "classmap": [
- "Resources/stubs"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill for intl's Normalizer class and related functions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "intl",
- "normalizer",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.26.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-05-24T11:49:31+00:00"
- },
- {
- "name": "symfony/polyfill-mbstring",
- "version": "v1.26.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-mbstring.git",
- "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e",
- "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "provide": {
- "ext-mbstring": "*"
- },
- "suggest": {
- "ext-mbstring": "For best performance"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "1.26-dev"
- },
- "thanks": {
- "name": "symfony/polyfill",
- "url": "https://github.com/symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Mbstring\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill for the Mbstring extension",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "mbstring",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-05-24T11:49:31+00:00"
- },
- {
- "name": "symfony/polyfill-php73",
- "version": "v1.26.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-php73.git",
- "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/e440d35fa0286f77fb45b79a03fedbeda9307e85",
- "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "1.26-dev"
- },
- "thanks": {
- "name": "symfony/polyfill",
- "url": "https://github.com/symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Php73\\": ""
- },
- "classmap": [
- "Resources/stubs"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-php73/tree/v1.26.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-05-24T11:49:31+00:00"
- },
- {
- "name": "symfony/polyfill-php80",
- "version": "v1.26.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-php80.git",
- "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace",
- "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "1.26-dev"
- },
- "thanks": {
- "name": "symfony/polyfill",
- "url": "https://github.com/symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Php80\\": ""
- },
- "classmap": [
- "Resources/stubs"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Ion Bazan",
- "email": "ion.bazan@gmail.com"
- },
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-05-10T07:21:04+00:00"
- },
- {
- "name": "symfony/polyfill-php81",
- "version": "v1.26.0",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/polyfill-php81.git",
- "reference": "13f6d1271c663dc5ae9fb843a8f16521db7687a1"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/13f6d1271c663dc5ae9fb843a8f16521db7687a1",
- "reference": "13f6d1271c663dc5ae9fb843a8f16521db7687a1",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "1.26-dev"
- },
- "thanks": {
- "name": "symfony/polyfill",
- "url": "https://github.com/symfony/polyfill"
- }
- },
- "autoload": {
- "files": [
- "bootstrap.php"
- ],
- "psr-4": {
- "Symfony\\Polyfill\\Php81\\": ""
- },
- "classmap": [
- "Resources/stubs"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions",
- "homepage": "https://symfony.com",
- "keywords": [
- "compatibility",
- "polyfill",
- "portable",
- "shim"
- ],
- "support": {
- "source": "https://github.com/symfony/polyfill-php81/tree/v1.26.0"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-05-24T11:49:31+00:00"
- },
- {
- "name": "symfony/service-contracts",
- "version": "v2.5.2",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/service-contracts.git",
- "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/service-contracts/zipball/4b426aac47d6427cc1a1d0f7e2ac724627f5966c",
- "reference": "4b426aac47d6427cc1a1d0f7e2ac724627f5966c",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.5",
- "psr/container": "^1.1",
- "symfony/deprecation-contracts": "^2.1|^3"
- },
- "conflict": {
- "ext-psr": "<1.1|>=2"
- },
- "suggest": {
- "symfony/service-implementation": ""
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "2.5-dev"
- },
- "thanks": {
- "name": "symfony/contracts",
- "url": "https://github.com/symfony/contracts"
- }
- },
- "autoload": {
- "psr-4": {
- "Symfony\\Contracts\\Service\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Generic abstractions related to writing services",
- "homepage": "https://symfony.com",
- "keywords": [
- "abstractions",
- "contracts",
- "decoupling",
- "interfaces",
- "interoperability",
- "standards"
- ],
- "support": {
- "source": "https://github.com/symfony/service-contracts/tree/v2.5.2"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-05-30T19:17:29+00:00"
- },
- {
- "name": "symfony/string",
- "version": "v5.4.14",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/string.git",
- "reference": "089e7237497fae7a9c404d0c3aeb8db3254733e4"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/string/zipball/089e7237497fae7a9c404d0c3aeb8db3254733e4",
- "reference": "089e7237497fae7a9c404d0c3aeb8db3254733e4",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.5",
- "symfony/polyfill-ctype": "~1.8",
- "symfony/polyfill-intl-grapheme": "~1.0",
- "symfony/polyfill-intl-normalizer": "~1.0",
- "symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php80": "~1.15"
- },
- "conflict": {
- "symfony/translation-contracts": ">=3.0"
- },
- "require-dev": {
- "symfony/error-handler": "^4.4|^5.0|^6.0",
- "symfony/http-client": "^4.4|^5.0|^6.0",
- "symfony/translation-contracts": "^1.1|^2",
- "symfony/var-exporter": "^4.4|^5.0|^6.0"
- },
- "type": "library",
- "autoload": {
- "files": [
- "Resources/functions.php"
- ],
- "psr-4": {
- "Symfony\\Component\\String\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way",
- "homepage": "https://symfony.com",
- "keywords": [
- "grapheme",
- "i18n",
- "string",
- "unicode",
- "utf-8",
- "utf8"
- ],
- "support": {
- "source": "https://github.com/symfony/string/tree/v5.4.14"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-10-05T15:16:54+00:00"
- },
- {
- "name": "symfony/translation",
- "version": "v4.4.47",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/translation.git",
- "reference": "45036b1d53accc48fe9bab71ccd86d57eba0dd94"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/translation/zipball/45036b1d53accc48fe9bab71ccd86d57eba0dd94",
- "reference": "45036b1d53accc48fe9bab71ccd86d57eba0dd94",
- "shasum": ""
- },
- "require": {
- "php": ">=7.1.3",
- "symfony/polyfill-mbstring": "~1.0",
- "symfony/polyfill-php80": "^1.16",
- "symfony/translation-contracts": "^1.1.6|^2"
- },
- "conflict": {
- "symfony/config": "<3.4",
- "symfony/dependency-injection": "<3.4",
- "symfony/http-kernel": "<4.4",
- "symfony/yaml": "<3.4"
- },
- "provide": {
- "symfony/translation-implementation": "1.0|2.0"
- },
- "require-dev": {
- "psr/log": "^1|^2|^3",
- "symfony/config": "^3.4|^4.0|^5.0",
- "symfony/console": "^3.4|^4.0|^5.0",
- "symfony/dependency-injection": "^3.4|^4.0|^5.0",
- "symfony/finder": "~2.8|~3.0|~4.0|^5.0",
- "symfony/http-kernel": "^4.4",
- "symfony/intl": "^3.4|^4.0|^5.0",
- "symfony/service-contracts": "^1.1.2|^2",
- "symfony/yaml": "^3.4|^4.0|^5.0"
- },
- "suggest": {
- "psr/log-implementation": "To use logging capability in translator",
- "symfony/config": "",
- "symfony/yaml": ""
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\Translation\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Provides tools to internationalize your application",
- "homepage": "https://symfony.com",
- "support": {
- "source": "https://github.com/symfony/translation/tree/v4.4.47"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-10-03T15:15:11+00:00"
- },
- {
- "name": "symfony/translation-contracts",
- "version": "v2.5.2",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/translation-contracts.git",
- "reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/136b19dd05cdf0709db6537d058bcab6dd6e2dbe",
- "reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.5"
- },
- "suggest": {
- "symfony/translation-implementation": ""
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-main": "2.5-dev"
- },
- "thanks": {
- "name": "symfony/contracts",
- "url": "https://github.com/symfony/contracts"
- }
- },
- "autoload": {
- "psr-4": {
- "Symfony\\Contracts\\Translation\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Nicolas Grekas",
- "email": "p@tchwork.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Generic abstractions related to translation",
- "homepage": "https://symfony.com",
- "keywords": [
- "abstractions",
- "contracts",
- "decoupling",
- "interfaces",
- "interoperability",
- "standards"
- ],
- "support": {
- "source": "https://github.com/symfony/translation-contracts/tree/v2.5.2"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-06-27T16:58:25+00:00"
- },
- {
- "name": "symfony/yaml",
- "version": "v5.4.14",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/yaml.git",
- "reference": "e83fe9a72011f07c662da46a05603d66deeeb487"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/yaml/zipball/e83fe9a72011f07c662da46a05603d66deeeb487",
- "reference": "e83fe9a72011f07c662da46a05603d66deeeb487",
- "shasum": ""
- },
- "require": {
- "php": ">=7.2.5",
- "symfony/deprecation-contracts": "^2.1|^3",
- "symfony/polyfill-ctype": "^1.8"
- },
- "conflict": {
- "symfony/console": "<5.3"
- },
- "require-dev": {
- "symfony/console": "^5.3|^6.0"
- },
- "suggest": {
- "symfony/console": "For validating YAML files using the lint command"
- },
- "bin": [
- "Resources/bin/yaml-lint"
- ],
- "type": "library",
- "autoload": {
- "psr-4": {
- "Symfony\\Component\\Yaml\\": ""
- },
- "exclude-from-classmap": [
- "/Tests/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- },
- {
- "name": "Symfony Community",
- "homepage": "https://symfony.com/contributors"
- }
- ],
- "description": "Loads and dumps YAML files",
- "homepage": "https://symfony.com",
- "support": {
- "source": "https://github.com/symfony/yaml/tree/v5.4.14"
- },
- "funding": [
- {
- "url": "https://symfony.com/sponsor",
- "type": "custom"
- },
- {
- "url": "https://github.com/fabpot",
- "type": "github"
- },
- {
- "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
- "type": "tidelift"
- }
- ],
- "time": "2022-10-03T15:15:50+00:00"
- },
- {
- "name": "theseer/tokenizer",
- "version": "1.2.1",
- "source": {
- "type": "git",
- "url": "https://github.com/theseer/tokenizer.git",
- "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e",
- "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e",
- "shasum": ""
- },
- "require": {
- "ext-dom": "*",
- "ext-tokenizer": "*",
- "ext-xmlwriter": "*",
- "php": "^7.2 || ^8.0"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Arne Blankerts",
- "email": "arne@blankerts.de",
- "role": "Developer"
- }
- ],
- "description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
- "support": {
- "issues": "https://github.com/theseer/tokenizer/issues",
- "source": "https://github.com/theseer/tokenizer/tree/1.2.1"
- },
- "funding": [
- {
- "url": "https://github.com/theseer",
- "type": "github"
- }
- ],
- "time": "2021-07-28T10:34:58+00:00"
- },
- {
- "name": "webmozart/assert",
- "version": "1.11.0",
- "source": {
- "type": "git",
- "url": "https://github.com/webmozarts/assert.git",
- "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991",
- "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991",
- "shasum": ""
- },
- "require": {
- "ext-ctype": "*",
- "php": "^7.2 || ^8.0"
- },
- "conflict": {
- "phpstan/phpstan": "<0.12.20",
- "vimeo/psalm": "<4.6.1 || 4.6.2"
- },
- "require-dev": {
- "phpunit/phpunit": "^8.5.13"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.10-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "Webmozart\\Assert\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Bernhard Schussek",
- "email": "bschussek@gmail.com"
- }
- ],
- "description": "Assertions to validate method input/output with nice error messages.",
- "keywords": [
- "assert",
- "check",
- "validate"
- ],
- "support": {
- "issues": "https://github.com/webmozarts/assert/issues",
- "source": "https://github.com/webmozarts/assert/tree/1.11.0"
- },
- "time": "2022-06-03T18:03:27+00:00"
- }
- ],
- "aliases": [],
- "minimum-stability": "stable",
- "stability-flags": [],
- "prefer-stable": false,
- "prefer-lowest": false,
- "platform": [],
- "platform-dev": [],
- "platform-overrides": {
- "php": "7.4"
- },
- "plugin-api-version": "2.3.0"
-}
diff --git a/tests/acceptance/config/behat.yml b/tests/acceptance/config/behat.yml
deleted file mode 100644
index a0aff969bae..00000000000
--- a/tests/acceptance/config/behat.yml
+++ /dev/null
@@ -1,105 +0,0 @@
-default:
- suites:
- default:
- paths:
- - "%paths.base%/../features"
- contexts:
- - ActorContext
- - NextcloudTestServerContext
-
- - AppNavigationContext
- - AppSettingsContext
- - AppsManagementContext
- - CommentsAppContext
- - ContactsMenuContext
- - DialogContext
- - FeatureContext
- - FileListContext
- - FilesAppContext
- - FilesAppSharingContext
- - LoginPageContext
- - NotificationsContext
- - PublicShareContext
- - SearchContext
- - SettingsContext
- - SettingsMenuContext
- - ThemingAppContext
- - ToastContext
- - UsersSettingsContext
- filters:
- tags: "~@apache"
- apache:
- paths:
- - "%paths.base%/../features"
- contexts:
- - ActorContext
- - NextcloudTestServerContext:
- nextcloudTestServerHelper: NextcloudTestServerLocalApacheHelper
-
- - AppNavigationContext
- - AppSettingsContext
- - AppsManagementContext
- - CommentsAppContext
- - ContactsMenuContext
- - DialogContext
- - FeatureContext
- - FileListContext
- - FilesAppContext
- - FilesAppSharingContext
- - LoginPageContext
- - NotificationsContext
- - PublicShareContext
- - SearchContext
- - SettingsContext
- - SettingsMenuContext
- - ThemingAppContext
- - ToastContext
- - UsersSettingsContext
- filters:
- tags: "@apache"
- extensions:
- Behat\MinkExtension:
- sessions:
- default:
- selenium2:
- wd_host: %selenium.server%
- browser: "chrome"
- capabilities:
- extra_capabilities:
- goog:chromeOptions:
- args: ["disable-dev-shm-usage"]
- w3c: false
- John:
- selenium2:
- wd_host: %selenium.server%
- browser: "chrome"
- capabilities:
- extra_capabilities:
- goog:chromeOptions:
- args: ["disable-dev-shm-usage"]
- w3c: false
- Jane:
- selenium2:
- wd_host: %selenium.server%
- browser: "chrome"
- capabilities:
- extra_capabilities:
- goog:chromeOptions:
- args: ["disable-dev-shm-usage"]
- w3c: false
- Jim:
- selenium2:
- wd_host: %selenium.server%
- browser: "chrome"
- capabilities:
- extra_capabilities:
- goog:chromeOptions:
- args: ["disable-dev-shm-usage"]
- w3c: false
- Rubeus:
- # Rubeus uses a browser that has CSS grid support.
- selenium2:
- wd_host: %selenium.server%
- capabilities:
- firefox:
- profile: %paths.base%/firefox-profiles/css-grid-enabled.zip
diff --git a/tests/acceptance/config/firefox-profiles/css-grid-enabled.zip b/tests/acceptance/config/firefox-profiles/css-grid-enabled.zip
deleted file mode 100644
index 8f061806d0a..00000000000
--- a/tests/acceptance/config/firefox-profiles/css-grid-enabled.zip
+++ /dev/null
Binary files differ
diff --git a/tests/acceptance/features/access-levels.feature b/tests/acceptance/features/access-levels.feature
deleted file mode 100644
index de34a17baea..00000000000
--- a/tests/acceptance/features/access-levels.feature
+++ /dev/null
@@ -1,23 +0,0 @@
-Feature: access-levels
-
- Scenario: regular users cannot see admin-level items in the Settings menu
- Given I am logged in
- When I open the Settings menu
- Then I see that the Settings menu is shown
- And I see that the "Settings" item in the Settings menu is shown
- And I see that the "Users" item in the Settings menu is not shown
- And I see that the "Help" item in the Settings menu is shown
- And I see that the "Log out" item in the Settings menu is shown
-
- Scenario: regular users cannot see admin-level items on the Settings page
- Given I am logged in
- When I visit the settings page
- Then I see that the "Personal info" entry in the settings panel is shown
- And I see that the "Personal" settings panel is not shown
- And I see that the "Administration" settings panel is not shown
-
- Scenario: admin users can see admin-level items on the Settings page
- Given I am logged in as the admin
- When I visit the admin settings page
- Then I see that the "Personal" settings panel is shown
- And I see that the "Administration" settings panel is shown
diff --git a/tests/acceptance/features/app-comments.feature b/tests/acceptance/features/app-comments.feature
deleted file mode 100644
index b57883d8ba8..00000000000
--- a/tests/acceptance/features/app-comments.feature
+++ /dev/null
@@ -1,325 +0,0 @@
-Feature: app-comments
-
-# Scenario: Writing a comment
-# Given I am logged in
-# And I open the details view for "welcome.txt"
-# And I open the "Comments" tab in the details view
-# When I create a new comment with "Hello world" as message
-# Then I see a comment with "Hello world" as message
-
-# Scenario: open the comments for a different file
-# Given I am logged in
-# And I create a new folder named "Folder"
-# And I open the details view for "welcome.txt"
-# And I open the "Comments" tab in the details view
-# And I create a new comment with "Hello world" as message
-# And I see a comment with "Hello world" as message
-# When I open the details view for "Folder"
- # The "Comments" tab should already be opened
-# Then I see that there are no comments
-
- Scenario: write a comment in a file right after writing a comment in another file
- Given I am logged in
- And I create a new folder named "Folder"
- And I open the details view for "Folder"
- And I open the "Comments" tab in the details view
- And I create a new comment with "Comment in Folder" as message
- And I see a comment with "Comment in Folder" as message
- And I open the details view for "welcome.txt"
- # The "Comments" tab should already be opened
- When I create a new comment with "Comment in welcome.txt" as message
- Then I see a comment with "Comment in welcome.txt" as message
- And I see that there is no comment with "Comment in Folder" as message
-
-
-
- Scenario: read a comment written by the sharer
- Given I act as John
- And I am logged in as the admin
- And I act as Jane
- And I am logged in
- And I act as John
- And I rename "welcome.txt" to "shared.txt"
- And I share "shared.txt" with "user0"
- And I see that the file is shared with "user0"
- # The details view should already be open
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- When I act as Jane
- # The Files app is open again to reload the file list and the comments
- And I open the Files app
- And I open the details view for "shared.txt"
- And I open the "Comments" tab in the details view
- Then I see a comment with "Hello world" as message
-
- Scenario: read a comment written by the sharee
- Given I act as John
- And I am logged in as the admin
- And I act as Jane
- And I am logged in
- And I act as John
- And I rename "welcome.txt" to "shared.txt"
- And I share "shared.txt" with "user0"
- And I see that the file is shared with "user0"
- And I act as Jane
- # The Files app is open again to reload the file list
- And I open the Files app
- And I open the details view for "shared.txt"
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- When I act as John
- # The Files app is open again to reload the file list and the comments
- And I open the Files app
- And I open the details view for "shared.txt"
- And I open the "Comments" tab in the details view
- Then I see a comment with "Hello world" as message
-
-
-
- Scenario: unread comment icon shown for comment written by the sharer in a shared file
- Given I act as John
- And I am logged in as the admin
- And I act as Jane
- And I am logged in
- And I act as John
- And I rename "welcome.txt" to "shared.txt"
- And I share "shared.txt" with "user0"
- And I see that the file is shared with "user0"
- # The details view should already be open
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- When I act as Jane
- # The Files app is open again to reload the file list and the comments
- And I open the Files app
- Then I see that "shared.txt" has unread comments
- And I open the unread comments for "shared.txt"
- And I see that the details view is open
- And I see a comment with "Hello world" as message
-
- Scenario: unread comment icon shown for comment written by the sharee in a shared file
- Given I act as John
- And I am logged in as the admin
- And I act as Jane
- And I am logged in
- And I act as John
- And I rename "welcome.txt" to "shared.txt"
- And I share "shared.txt" with "user0"
- And I see that the file is shared with "user0"
- And I act as Jane
- # The Files app is open again to reload the file list
- And I open the Files app
- And I open the details view for "shared.txt"
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- When I act as John
- # The Files app is open again to reload the file list and the comments
- And I open the Files app
- Then I see that "shared.txt" has unread comments
- And I open the unread comments for "shared.txt"
- And I see that the details view is open
- And I see a comment with "Hello world" as message
-
- Scenario: unread comment icon shown for comment written by the sharer in a shared folder
- Given I act as John
- And I am logged in as the admin
- And I act as Jane
- And I am logged in
- And I act as John
- And I create a new folder named "Folder"
- And I share "Folder" with "user0"
- And I see that the file is shared with "user0"
- # The details view should already be open
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- When I act as Jane
- # The Files app is open again to reload the file list and the comments
- And I open the Files app
- Then I see that "Folder" has unread comments
- And I open the unread comments for "Folder"
- And I see that the details view is open
- And I see a comment with "Hello world" as message
-
- Scenario: unread comment icon shown for comment written by the sharee in a shared folder
- Given I act as John
- And I am logged in as the admin
- And I act as Jane
- And I am logged in
- And I act as John
- And I create a new folder named "Folder"
- And I share "Folder" with "user0"
- And I see that the file is shared with "user0"
- And I act as Jane
- # The Files app is open again to reload the file list
- And I open the Files app
- And I open the details view for "Folder"
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- When I act as John
- # The Files app is open again to reload the file list and the comments
- And I open the Files app
- Then I see that "Folder" has unread comments
- And I open the unread comments for "Folder"
- And I see that the details view is open
- And I see a comment with "Hello world" as message
-
- Scenario: unread comment icon shown for comment written by the sharer in a child folder of a shared folder
- Given I act as John
- And I am logged in as the admin
- And I act as Jane
- And I am logged in
- And I act as John
- And I create a new folder named "Folder"
- And I share "Folder" with "user0"
- And I see that the file is shared with "user0"
- And I enter in the folder named "Folder"
- And I create a new folder named "Child folder"
- # The details view should already be open
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- When I act as Jane
- # The Files app is open again to reload the file list and the comments
- And I open the Files app
- And I enter in the folder named "Folder"
- Then I see that "Child folder" has unread comments
- And I open the unread comments for "Child folder"
- And I see that the details view is open
- And I see a comment with "Hello world" as message
-
- Scenario: unread comment icon shown for comment written by the sharee in a child folder of a shared folder
- Given I act as John
- And I am logged in as the admin
- And I act as Jane
- And I am logged in
- And I act as John
- And I create a new folder named "Folder"
- And I share "Folder" with "user0"
- And I see that the file is shared with "user0"
- And I act as Jane
- # The Files app is open again to reload the file list
- And I open the Files app
- And I enter in the folder named "Folder"
- And I create a new folder named "Child folder"
- # The details view should already be open
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- When I act as John
- And I enter in the folder named "Folder"
- Then I see that "Child folder" has unread comments
- And I open the unread comments for "Child folder"
- And I see that the details view is open
- And I see a comment with "Hello world" as message
-
-
-
- Scenario: search a comment
- Given I am logged in
- And I open the details view for "welcome.txt"
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- When I search for "hello"
- # Search results for comments also include the user that wrote the comment.
- Then I see that the search result 1 is "user0Hello world"
- And I see that the search result 1 was found in "welcome.txt"
-
- Scenario: search a comment in a child folder
- Given I am logged in
- And I create a new folder named "Folder"
- And I enter in the folder named "Folder"
- And I create a new folder named "Child folder"
- And I open the details view for "Child folder"
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- # The Files app is open again to reload the file list
- And I open the Files app
- When I search for "hello"
- # Search results for comments also include the user that wrote the comment.
- Then I see that the search result 1 is "user0Hello world"
- And I see that the search result 1 was found in "Folder/Child folder"
-
- Scenario: search a comment by a another user
- Given I act as John
- And I am logged in as the admin
- And I act as Jane
- And I am logged in
- And I act as John
- And I rename "welcome.txt" to "shared.txt"
- And I share "shared.txt" with "user0"
- And I see that the file is shared with "user0"
- And I act as Jane
- # The Files app is open again to reload the file list
- And I open the Files app
- And I open the details view for "shared.txt"
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- When I act as John
- And I search for "hello"
- # Search results for comments also include the user that wrote the comment.
- Then I see that the search result 1 is "user0Hello world"
- And I see that the search result 1 was found in "shared.txt"
-
- Scenario: open a search result for a comment in a file
- Given I am logged in
- And I open the details view for "welcome.txt"
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- # Force the details view to change to a different file before closing it
- And I create a new folder named "Folder"
- And I close the details view
- When I search for "hello"
- And I open the search result 1
- Then I see that the details view is open
- And I see that the file name shown in the details view is "welcome.txt"
- And I see a comment with "Hello world" as message
- And I see that the file list is currently in "Home"
- And I see that the file list contains a file named "welcome.txt"
-
- Scenario: open a search result for a comment in a folder named like its child folder
- Given I am logged in
- And I create a new folder named "Folder"
- And I open the details view for "Folder"
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- And I enter in the folder named "Folder"
- And I create a new folder named "Folder"
- # The Files app is open again to reload the file list
- And I open the Files app
- When I search for "hello"
- And I open the search result 1
- Then I see that the details view is open
- And I see that the file name shown in the details view is "Folder"
- And I see a comment with "Hello world" as message
- And I see that the file list is currently in "Home"
- And I see that the file list contains a file named "welcome.txt"
- And I see that the file list contains a file named "Folder"
-
- Scenario: open a search result for a comment in a child folder
- Given I am logged in
- And I create a new folder named "Folder"
- And I enter in the folder named "Folder"
- And I create a new folder named "Child folder"
- And I open the details view for "Child folder"
- And I open the "Comments" tab in the details view
- And I create a new comment with "Hello world" as message
- And I see a comment with "Hello world" as message
- # The Files app is open again to reload the file list
- And I open the Files app
- When I search for "hello"
- And I open the search result 1
- Then I see that the details view is open
- And I see that the file name shown in the details view is "Child folder"
- And I see a comment with "Hello world" as message
- And I see that the file list is currently in "Home/Folder"
- And I see that the file list contains a file named "Child folder"
diff --git a/tests/acceptance/features/apps.feature b/tests/acceptance/features/apps.feature
deleted file mode 100644
index 0fc2f2a686d..00000000000
--- a/tests/acceptance/features/apps.feature
+++ /dev/null
@@ -1,92 +0,0 @@
-@apache
-Feature: apps
-
- Scenario: enable an installed app
- Given I act as Jane
- And I am logged in as the admin
- And I open the Apps management
- When I enable the "QA testing" app
- Then I see that the "QA testing" app has been enabled
-
- Scenario: disable a installed app
- Given I act as Jane
- And I am logged in as the admin
- And I open the Apps management
- When I disable the "Update notification" app
- Then I see that the "Update notification" app has been disabled
-
- Scenario: Browse enabled apps
- Given I act as Jane
- And I am logged in as the admin
- And I open the Apps management
- When I open the "Active apps" section
- Then I see that the current section is "Active apps"
- And I see that there are only enabled apps
-
- Scenario: Browse disabled apps
- Given I act as Jane
- And I am logged in as the admin
- And I open the Apps management
- When I open the "Disabled apps" section
- Then I see that the current section is "Disabled apps"
- And I see that there are only disabled apps
-
- Scenario: Browse app bundles
- Given I act as Jane
- And I am logged in as the admin
- And I open the Apps management
- When I open the "App bundles" section
- Then I see that the current section is "App bundles"
- And I see the app bundles
- And I see that the "Enterprise bundle" is disabled
-
-# Enabling an app bundle fails when not all apps have a matching version available
-# Scenario: Enable an app bundle
-# Given I act as Jane
-# And I am logged in as the admin
-# And I open the Apps management
-# And I open the "App bundles" section
-# When I enable all apps from the "Enterprise bundle"
-# Then I see that the "Auditing / Logging" app has been enabled
-# And I see that the "LDAP user and group backend" app has been enabled
-
- Scenario: View app details
- Given I act as Jane
- And I am logged in as the admin
- And I open the Apps management
- When I click on the "QA testing" app
- Then I see that the app details are shown
-
- # TODO: Improve testing with app store as external API
- # The following scenarios require the files_antivirus and calendar app
- # being present in the app store with support for the current server version
- # Ideally we would have either a dummy app store endpoint with some test apps
- # or even an app store instance running somewhere to properly test this.
- # This is also a requirement to properly test updates of apps
-
- Scenario: Show section from app store
- Given I act as Jane
- And I am logged in as the admin
- And I open the Apps management
- And I see that the current section is "Your apps"
- #When I open the "Files" section
- #Then I see that there some apps listed from the app store
- #And I see that the current section is "Files"
-
-# Scenario: View app details for app store apps
-# Given I act as Jane
-# And I am logged in as the admin
-# And I open the Apps management
-# And I open the "Tools" section
-# When I click on the "Antivirus for files" app
-# Then I see that the app details are shown
-
-# Scenario: Install an app from the app store
-# Given I act as Jane
-# And I am logged in as the admin
-# And I open the Apps management
-# And I open the "Tools" section
-# And I click on the "Antivirus for files" app
-# And I see that the app details are shown
-# Then I download and enable the "Antivirus for files" app
-# And I see that the "Antivirus for files" app has been enabled
diff --git a/tests/acceptance/features/bootstrap/AppNavigationContext.php b/tests/acceptance/features/bootstrap/AppNavigationContext.php
deleted file mode 100644
index 49d664e2333..00000000000
--- a/tests/acceptance/features/bootstrap/AppNavigationContext.php
+++ /dev/null
@@ -1,154 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class AppNavigationContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function appNavigation() {
- return Locator::forThe()->xpath("//*[@id=\"app-navigation\" or contains(@class, 'app-navigation')]")->
- describedAs("App navigation");
- }
-
- /**
- * @return Locator
- */
- public static function appNavigationSectionItemFor($sectionText) {
- return Locator::forThe()->xpath("//li/*[contains(normalize-space(), '$sectionText')]/..")->
- descendantOf(self::appNavigation())->
- describedAs($sectionText . " section item in App Navigation");
- }
-
- /**
- * @return Locator
- */
- public static function appNavigationSectionItemInFor($caption, $sectionText) {
- return Locator::forThe()->xpath("//li[normalize-space() = '$caption']/following-sibling::li/a[normalize-space() = '$sectionText']/..")->
- descendantOf(self::appNavigation())->
- describedAs($sectionText . " section item of the $caption group in App Navigation");
- }
-
- /**
- * @return Locator
- */
- public static function appNavigationCurrentSectionItem() {
- return Locator::forThe()->css(".active")->
- descendantOf(self::appNavigation())->
- describedAs("Current section item in App Navigation");
- }
-
- /**
- * @return Locator
- */
- public static function buttonForTheSection($class, $section) {
- return Locator::forThe()->css("." . $class)->
- descendantOf(self::appNavigationSectionItemFor($section))->
- describedAs("The $class button on the $section section in App Navigation");
- }
-
- /**
- * @return Locator
- */
- public static function counterForTheSection($section) {
- return Locator::forThe()->css(".app-navigation-entry-utils-counter")->
- descendantOf(self::appNavigationSectionItemFor($section))->
- describedAs("The counter for the $section section in App Navigation");
- }
-
- /**
- * @Given I open the :section section
- */
- public function iOpenTheSection($section) {
- $this->actor->find(self::appNavigationSectionItemFor($section), 10)->click();
- }
-
- /**
- * @Given I open the :section section of the :caption group
- */
- public function iOpenTheSectionOf($caption, $section) {
- $this->actor->find(self::appNavigationSectionItemInFor($caption, $section), 10)->click();
- }
-
- /**
- * @Given I click the :class button on the :section section
- */
- public function iClickTheButtonInTheSection($class, $section) {
- $this->actor->find(self::buttonForTheSection($class, $section), 10)->click();
- }
-
- /**
- * @Then I see that the current section is :section
- */
- public function iSeeThatTheCurrentSectionIs($section) {
- Assert::assertEquals($this->actor->find(self::appNavigationCurrentSectionItem(), 10)->getText(), $section);
- }
-
- /**
- * @Then I see that the section :section is shown
- */
- public function iSeeThatTheSectionIsShown($section) {
- if (!WaitFor::elementToBeEventuallyShown(
- $this->actor,
- self::appNavigationSectionItemFor($section),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The section $section in the app navigation is not shown yet after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the section :section is not shown
- */
- public function iSeeThatTheSectionIsNotShown($section) {
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::appNavigationSectionItemFor($section),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The section $section in the app navigation is still shown after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the section :section has a count of :count
- */
- public function iSeeThatTheSectionHasACountOf($section, $count) {
- Assert::assertEquals($this->actor->find(self::counterForTheSection($section), 10)->getText(), $count);
- }
-
- /**
- * @Then I see that the section :section does not have a count
- */
- public function iSeeThatTheSectionDoesNotHaveACount($section) {
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::counterForTheSection($section),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The counter for section $section is still shown after $timeout seconds");
- }
- }
-}
diff --git a/tests/acceptance/features/bootstrap/AppSettingsContext.php b/tests/acceptance/features/bootstrap/AppSettingsContext.php
deleted file mode 100644
index 785664fa01c..00000000000
--- a/tests/acceptance/features/bootstrap/AppSettingsContext.php
+++ /dev/null
@@ -1,99 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class AppSettingsContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function appSettings() {
- return Locator::forThe()->id("app-settings")->
- describedAs("App settings");
- }
- /**
- * @return Locator
- */
- public static function appSettingsContent() {
- return Locator::forThe()->xpath("//div[@id = 'app-settings-content' or @id = 'app-settings__content']")->
- descendantOf(self::appSettings())->
- describedAs("App settings");
- }
-
- /**
- * @return Locator
- */
- public static function appSettingsOpenButton() {
- return Locator::forThe()->xpath("//div[@id = 'app-settings-header' or @id = 'app-settings__header']/button")->
- descendantOf(self::appSettings())->
- describedAs("The button to open the app settings");
- }
-
- /**
- * @return Locator
- */
- public static function checkboxInTheSettings($id) {
- return Locator::forThe()->xpath("//input[@id = '$id']")->
- descendantOf(self::appSettingsContent())->
- describedAs("The $id checkbox in the settings");
- }
-
- /**
- * @return Locator
- */
- public static function checkboxLabelInTheSettings($id) {
- return Locator::forThe()->css("[data-test=\"$id\"]")->
- descendantOf(self::appSettingsContent())->
- describedAs("The label for the $id checkbox in the settings");
- }
-
- /**
- * @Given I open the settings
- */
- public function iOpenTheSettings() {
- $this->actor->find(self::appSettingsOpenButton(), 10)->click();
- }
-
- /**
- * @Given I toggle the :id checkbox in the settings
- */
- public function iToggleTheCheckboxInTheSettingsTo($id) {
- $this->actor->find(self::checkboxLabelInTheSettings($id), 10)->click();
- }
-
- /**
- * @Then I see that the settings are opened
- */
- public function iSeeThatTheSettingsAreOpened() {
- if (!WaitFor::elementToBeEventuallyShown(
- $this->actor,
- self::appSettingsContent(),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The app settings are not open yet after $timeout seconds");
- }
- }
-}
diff --git a/tests/acceptance/features/bootstrap/AppsManagementContext.php b/tests/acceptance/features/bootstrap/AppsManagementContext.php
deleted file mode 100644
index fc8a38c867e..00000000000
--- a/tests/acceptance/features/bootstrap/AppsManagementContext.php
+++ /dev/null
@@ -1,283 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class AppsManagementContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function appsList() {
- return Locator::forThe()->xpath("//main[@id='app-content' or contains(@class, 'app-content')]//div[@id='apps-list']")->
- describedAs("Apps list in Apps Management");
- }
-
- /**
- * @return Locator
- */
- public static function enableButtonForApp($app) {
- return Locator::forThe()->button("Enable")->
- descendantOf(self::rowForApp($app))->
- describedAs("Enable button in the app list for $app");
- }
-
- /**
- * @return Locator
- */
- public static function enableButtonForAnyApp() {
- return Locator::forThe()->button("Enable")->
- descendantOf(self::appsList())->
- describedAs("Enable button in the app list for any app");
- }
-
- /**
- * @return Locator
- */
- public static function downloadAndEnableButtonForApp($app) {
- return Locator::forThe()->button("Download and enable")->
- descendantOf(self::rowForApp($app))->
- describedAs("Download & enable button in the app list for $app");
- }
-
- /**
- * @return Locator
- */
- public static function disableButtonForApp($app) {
- return Locator::forThe()->button("Disable")->
- descendantOf(self::rowForApp($app))->
- describedAs("Disable button in the app list for $app");
- }
-
- /**
- * @return Locator
- */
- public static function disableButtonForAnyApp() {
- return Locator::forThe()->button("Disable")->
- descendantOf(self::appsList())->
- describedAs("Disable button in the app list for any app");
- }
-
- /**
- * @return Locator
- */
- public static function enableAllBundleButton($bundle) {
- return Locator::forThe()->xpath("//div[@class='apps-header']/h2[normalize-space() = '$bundle']/input[@value='Download and enable all']")->
- descendantOf(self::appsList())->
- describedAs("Button to enable bundles");
- }
-
- /**
- * @return Locator
- */
- public static function rowForApp($app) {
- return Locator::forThe()->xpath("//div[@class='app-name'][normalize-space() = '$app']/..")->
- descendantOf(self::appsList())->
- describedAs("Row for app $app in Apps Management");
- }
-
- /**
- * @return Locator
- */
- public static function emptyAppList() {
- return Locator::forThe()->xpath("//div[@id='apps-list-empty']")->
- descendantOf(self::appsList())->
- describedAs("Empty apps list view");
- }
-
- /**
- * @return Locator
- */
- public static function appEntries() {
- return Locator::forThe()->xpath("//div[@class='section']")->
- descendantOf(self::appsList())->
- describedAs("Entries in apps list");
- }
-
- /**
- * @return Locator
- */
- public static function disabledAppEntries() {
- return Locator::forThe()->button("Disable")->
- descendantOf(self::appEntries())->
- describedAs("Disable button in the app list");
- }
-
- /**
- * @return Locator
- */
- public static function enabledAppEntries() {
- return Locator::forThe()->button("Enable")->
- descendantOf(self::appEntries())->
- describedAs("Enable button in the app list");
- }
-
- /**
- * @return Locator
- */
- public static function sidebar() {
- return Locator::forThe()->xpath("//*[@id=\"app-sidebar\" or contains(@class, 'app-sidebar')]")->
- describedAs("Sidebar in apps management");
- }
-
-
- /**
- * @When I enable the :app app
- */
- public function iEnableTheApp($app) {
- $this->actor->find(self::enableButtonForApp($app), 10)->click();
- }
-
- /**
- * @When I download and enable the :app app
- */
- public function iDownloadAndEnableTheApp($app) {
- $this->actor->find(self::downloadAndEnableButtonForApp($app), 10)->click();
- }
-
- /**
- * @When I disable the :app app
- */
- public function iDisableTheApp($app) {
- $this->actor->find(self::disableButtonForApp($app), 10)->click();
- }
-
- /**
- * @Then I see that the :app app has been enabled
- */
- public function iSeeThatTheAppHasBeenEnabled($app) {
- // TODO: Find a way to check if the enable button is removed
- Assert::assertTrue(
- $this->actor->find(self::disableButtonForApp($app), 10)->isVisible()
- );
- }
-
- /**
- * @Then I see that the :app app has been disabled
- */
- public function iSeeThatTheAppHasBeenDisabled($app) {
- // TODO: Find a way to check if the disable button is removed
- Assert::assertTrue(
- $this->actor->find(self::enableButtonForApp($app), 10)->isVisible()
- );
- }
-
- /**
- * @Then /^I see that there are no available updates$/
- */
- public function iSeeThatThereAreNoAvailableUpdates() {
- Assert::assertTrue(
- $this->actor->find(self::emptyAppList(), 10)->isVisible()
- );
- }
-
- /**
- * @Then /^I see that there some apps listed from the app store$/
- */
- public function iSeeThatThereSomeAppsListedFromTheAppStore() {
- if (!WaitFor::elementToBeEventuallyShown(
- $this->actor,
- self::appEntries(),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The apps from the app store were not shown yet after $timeout seconds");
- }
- }
-
- /**
- * @When /^I click on the "([^"]*)" app$/
- */
- public function iClickOnTheApp($app) {
- $this->actor->find(self::rowForApp($app), 10)->click();
- }
-
- /**
- * @Given /^I see that there are only disabled apps$/
- */
- public function iSeeThatThereAreOnlyDisabledApps() {
- try {
- $this->actor->find(self::disableButtonForAnyApp(), 2);
-
- Assert::fail("Found enabled apps");
- } catch (NoSuchElementException $exception) {
- }
- }
-
- /**
- * @Given /^I see that there are only enabled apps$/
- */
- public function iSeeThatThereAreOnlyEnabledApps() {
- try {
- $this->actor->find(self::enableButtonForAnyApp(), 2);
-
- Assert::fail("Found disabled apps");
- } catch (NoSuchElementException $exception) {
- }
- }
-
- /**
- * @Given /^I see the app bundles$/
- */
- public function iSeeTheAppBundles() {
- Assert::assertTrue(
- $this->actor->find(self::rowForApp('Auditing / Logging'), 10)->isVisible()
- );
- Assert::assertTrue(
- $this->actor->find(self::rowForApp('LDAP user and group backend'), 2)->isVisible()
- );
- }
-
- /**
- * @When /^I enable all apps from the "([^"]*)"$/
- */
- public function iEnableAllAppsFromThe($bundle) {
- $this->actor->find(self::enableAllBundleButton($bundle), 2)->click();
- }
-
- /**
- * @Given /^I see that the "([^"]*)" is disabled$/
- */
- public function iSeeThatTheIsDisabled($bundle) {
- Assert::assertTrue(
- $this->actor->find(self::enableAllBundleButton($bundle), 2)->isVisible()
- );
- }
-
- /**
- * @Given /^I see that the app details are shown$/
- */
- public function iSeeThatTheAppDetailsAreShown() {
- // The sidebar always exists in the DOM, so it has to be explicitly
- // waited for it to be visible instead of relying on the implicit wait
- // made to find the element.
- if (!WaitFor::elementToBeEventuallyShown(
- $this->actor,
- self::sidebar(),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The sidebar was not shown yet after $timeout seconds");
- }
- }
-}
diff --git a/tests/acceptance/features/bootstrap/CommentsAppContext.php b/tests/acceptance/features/bootstrap/CommentsAppContext.php
deleted file mode 100644
index b193ba9fb33..00000000000
--- a/tests/acceptance/features/bootstrap/CommentsAppContext.php
+++ /dev/null
@@ -1,113 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class CommentsAppContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function newCommentField() {
- return Locator::forThe()->css("div.newCommentRow .message")->
- descendantOf(FilesAppContext::detailsView())->
- describedAs("New comment field in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function submitNewCommentButton() {
- return Locator::forThe()->css("div.newCommentRow .submit")->
- descendantOf(FilesAppContext::detailsView())->
- describedAs("Submit new comment button in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function commentList() {
- return Locator::forThe()->css("ul.comments")->
- descendantOf(FilesAppContext::detailsView())->
- describedAs("Comment list in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function commentWithText($text) {
- return Locator::forThe()->xpath("//div[normalize-space() = '$text']/ancestor::li")->
- descendantOf(self::commentList())->
- describedAs("Comment with text \"$text\" in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function emptyContent() {
- return Locator::forThe()->css(".emptycontent")->
- descendantOf(FilesAppContext::detailsView())->
- describedAs("Empty content in details view in Files app");
- }
-
- /**
- * @When /^I create a new comment with "([^"]*)" as message$/
- */
- public function iCreateANewCommentWithAsMessage($commentText) {
- $this->actor->find(self::newCommentField(), 10)->setValue($commentText);
- $this->actor->find(self::submitNewCommentButton())->click();
- }
-
- /**
- * @Then /^I see that there are no comments$/
- */
- public function iSeeThatThereAreNoComments() {
- if (!WaitFor::elementToBeEventuallyShown(
- $this->actor,
- self::emptyContent(),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The no comments message is not visible yet after $timeout seconds");
- }
- }
-
- /**
- * @Then /^I see a comment with "([^"]*)" as message$/
- */
- public function iSeeACommentWithAsMessage($commentText) {
- Assert::assertTrue(
- $this->actor->find(self::commentWithText($commentText), 10)->isVisible());
- }
-
- /**
- * @Then /^I see that there is no comment with "([^"]*)" as message$/
- */
- public function iSeeThatThereIsNoCommentWithAsMessage($commentText) {
- try {
- Assert::assertFalse(
- $this->actor->find(self::commentWithText($commentText))->isVisible());
- } catch (NoSuchElementException $exception) {
- }
- }
-}
diff --git a/tests/acceptance/features/bootstrap/ContactsMenuContext.php b/tests/acceptance/features/bootstrap/ContactsMenuContext.php
deleted file mode 100644
index 72c33410b28..00000000000
--- a/tests/acceptance/features/bootstrap/ContactsMenuContext.php
+++ /dev/null
@@ -1,145 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv) (skjnldsv@protonmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class ContactsMenuContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function contactsMenuButton() {
- return Locator::forThe()->xpath("//*[@id = 'header']//*[@id = 'contactsmenu']//*[@class = 'header-menu__trigger']")->
- describedAs("Contacts menu button");
- }
-
- /**
- * @return Locator
- */
- public static function contactsMenu() {
- return Locator::forThe()->xpath("//*[@id = 'header']//*[@id = 'contactsmenu']//*[@id = 'contactsmenu-menu']")->
- describedAs("Contacts menu");
- }
-
- /**
- * @return Locator
- */
- public static function contactsMenuSearchInput() {
- return Locator::forThe()->id("contactsmenu-search")->
- descendantOf(self::contactsMenu())->
- describedAs("Contacts menu search input");
- }
-
- /**
- * @return Locator
- */
- public static function noResultsMessage() {
- return Locator::forThe()->xpath("//*[@class = 'emptycontent' and normalize-space() = 'No contacts found']")->
- descendantOf(self::contactsMenu())->
- describedAs("No results message in Contacts menu");
- }
-
- /**
- * @return Locator
- */
- private static function menuItemFor($contactName) {
- return Locator::forThe()->xpath("//*[@class = 'full-name' and normalize-space() = '$contactName']")->
- descendantOf(self::contactsMenu())->
- describedAs($contactName . " contact in Contacts menu");
- }
-
- /**
- * @When I open the Contacts menu
- */
- public function iOpenTheContactsMenu() {
- $this->actor->find(self::contactsMenuButton(), 10)->click();
- }
-
- /**
- * @When I search for the user :user
- */
- public function iSearchForTheUser($user) {
- $this->actor->find(self::contactsMenuSearchInput(), 10)->setValue($user);
- }
-
- /**
- * @Then I see that the Contacts menu is shown
- */
- public function iSeeThatTheContactsMenuIsShown() {
- Assert::assertTrue(
- $this->actor->find(self::contactsMenu(), 10)->isVisible());
- }
-
- /**
- * @Then I see that the Contacts menu search input is shown
- */
- public function iSeeThatTheContactsMenuSearchInputIsShown() {
- Assert::assertTrue(
- $this->actor->find(self::contactsMenuSearchInput(), 10)->isVisible());
- }
-
- /**
- * @Then I see that the no results message in the Contacts menu is shown
- */
- public function iSeeThatTheNoResultsMessageInTheContactsMenuIsShown() {
- Assert::assertTrue(
- $this->actor->find(self::noResultsMessage(), 10)->isVisible());
- }
-
- /**
- * @Then I see that the contact :contactName in the Contacts menu is shown
- */
- public function iSeeThatTheContactInTheContactsMenuIsShown($contactName) {
- Assert::assertTrue(
- $this->actor->find(self::menuItemFor($contactName), 10)->isVisible());
- }
-
- /**
- * @Then I see that the contact :contactName in the Contacts menu is not shown
- */
- public function iSeeThatTheContactInTheContactsMenuIsNotShown($contactName) {
- $this->iSeeThatThecontactsMenuIsShown();
-
- try {
- Assert::assertFalse(
- $this->actor->find(self::menuItemFor($contactName))->isVisible());
- } catch (NoSuchElementException $exception) {
- }
- }
-
- /**
- * @Then I see that the contact :contactName in the Contacts menu is eventually not shown
- */
- public function iSeeThatTheContactInTheContactsMenuIsEventuallyNotShown($contactName) {
- $this->iSeeThatThecontactsMenuIsShown();
-
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::menuItemFor($contactName),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The $contactName contact in Contacts menu is still shown after $timeout seconds");
- }
- }
-}
diff --git a/tests/acceptance/features/bootstrap/DialogContext.php b/tests/acceptance/features/bootstrap/DialogContext.php
deleted file mode 100644
index 3deea2f5ebf..00000000000
--- a/tests/acceptance/features/bootstrap/DialogContext.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class DialogContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function theDialog() {
- return Locator::forThe()->css(".oc-dialog")->
- describedAs("The dialog");
- }
-
- /**
- * @return Locator
- */
- public static function theDialogButton($text) {
- return Locator::forThe()->xpath("//button[normalize-space() = \"$text\"]")->
- descendantOf(self::theDialog())->
- describedAs($text . " button of the dialog");
- }
-
- /**
- * @Given I click the :text button of the confirmation dialog
- */
- public function iClickTheDialogButton($text) {
- $this->actor->find(self::theDialogButton($text), 10)->click();
- }
-
- /**
- * @Then I see that the confirmation dialog is shown
- */
- public function iSeeThatTheConfirmationDialogIsShown() {
- if (!WaitFor::elementToBeEventuallyShown(
- $this->actor,
- self::theDialog(),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The confirmation dialog was not shown yet after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the confirmation dialog is not shown
- */
- public function iSeeThatTheConfirmationDialogIsNotShown() {
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::theDialog(),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The confirmation dialog is still shown after $timeout seconds");
- }
- }
-}
diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php
deleted file mode 100644
index 72798ea98f7..00000000000
--- a/tests/acceptance/features/bootstrap/FeatureContext.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-
-class FeatureContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @When I visit the Home page
- */
- public function iVisitTheHomePage() {
- $this->actor->getSession()->visit($this->actor->locatePath("/"));
- }
-}
diff --git a/tests/acceptance/features/bootstrap/FileListAncestorSetter.php b/tests/acceptance/features/bootstrap/FileListAncestorSetter.php
deleted file mode 100644
index b87d1d7dee3..00000000000
--- a/tests/acceptance/features/bootstrap/FileListAncestorSetter.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Hook\Scope\BeforeScenarioScope;
-
-/**
- * Helper trait to set the ancestor of the file list.
- *
- * The FileListContext provides steps to interact with and check the behaviour
- * of a file list. However, the FileListContext does not know the right file
- * list ancestor that has to be used by the file list steps; this has to be set
- * from other contexts, for example, when the Files app or the public page for a
- * shared folder is opened.
- *
- * Contexts that "know" that certain file list ancestor has to be used by the
- * FileListContext steps should use this trait and call
- * "setFileListAncestorForActor" when needed.
- */
-trait FileListAncestorSetter {
- /**
- * @var FileListContext
- */
- private $fileListContext;
-
- /**
- * @BeforeScenario
- */
- public function getSiblingFileListContext(BeforeScenarioScope $scope) {
- $environment = $scope->getEnvironment();
-
- $this->fileListContext = $environment->getContext("FileListContext");
- }
-
- /**
- * Sets the file list ancestor to be used in the file list steps performed
- * by the given actor.
- *
- * @param null|Locator $fileListAncestor the file list ancestor
- * @param Actor $actor the actor
- */
- private function setFileListAncestorForActor($fileListAncestor, Actor $actor) {
- $this->fileListContext->setFileListAncestorForActor($fileListAncestor, $actor);
- }
-}
diff --git a/tests/acceptance/features/bootstrap/FileListContext.php b/tests/acceptance/features/bootstrap/FileListContext.php
deleted file mode 100644
index 501bad73c06..00000000000
--- a/tests/acceptance/features/bootstrap/FileListContext.php
+++ /dev/null
@@ -1,595 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class FileListContext implements Context, ActorAwareInterface {
- /**
- * @var Actor
- */
- private $actor;
-
- /**
- * @var array
- */
- private $fileListAncestorsByActor;
-
- /**
- * @var Locator
- */
- private $fileListAncestor;
-
- /**
- * @BeforeScenario
- */
- public function initializeFileListAncestors() {
- $this->fileListAncestorsByActor = [];
- $this->fileListAncestor = null;
- }
-
- /**
- * @param Actor $actor
- */
- public function setCurrentActor(Actor $actor) {
- $this->actor = $actor;
-
- if (array_key_exists($actor->getName(), $this->fileListAncestorsByActor)) {
- $this->fileListAncestor = $this->fileListAncestorsByActor[$actor->getName()];
- } else {
- $this->fileListAncestor = null;
- }
- }
-
- /**
- * Sets the file list ancestor to be used in the steps performed by the
- * given actor from that point on (until changed again).
- *
- * This is meant to be called from other contexts, for example, when the
- * Files app or the public page for a shared folder are opened.
- *
- * The FileListAncestorSetter trait can be used to reduce the boilerplate
- * needed to set the file list ancestor from other contexts.
- *
- * @param null|Locator $fileListAncestor the file list ancestor
- * @param Actor $actor the actor
- */
- public function setFileListAncestorForActor($fileListAncestor, Actor $actor) {
- $this->fileListAncestorsByActor[$actor->getName()] = $fileListAncestor;
- }
-
- /**
- * @return Locator
- */
- public static function mainWorkingIcon($fileListAncestor) {
- return Locator::forThe()->css(".mask.icon-loading")->
- descendantOf($fileListAncestor)->
- describedAs("Main working icon in file list");
- }
-
- /**
- * @return Locator
- */
- public static function breadcrumbs($fileListAncestor) {
- return Locator::forThe()->css(".files-controls .breadcrumb")->
- descendantOf($fileListAncestor)->
- describedAs("Breadcrumbs in file list");
- }
-
- /**
- * @return Locator
- */
- public static function createMenuButton($fileListAncestor) {
- return Locator::forThe()->css(".files-controls .button.new")->
- descendantOf($fileListAncestor)->
- describedAs("Create menu button in file list");
- }
-
- /**
- * @return Locator
- */
- private static function createMenuItemFor($fileListAncestor, $newType) {
- return Locator::forThe()->xpath("//div[contains(concat(' ', normalize-space(@class), ' '), ' newFileMenu ')]//span[normalize-space() = '$newType']/ancestor::li")->
- descendantOf($fileListAncestor)->
- describedAs("Create $newType menu item in file list");
- }
-
- /**
- * @return Locator
- */
- public static function createNewFolderMenuItem($fileListAncestor) {
- return self::createMenuItemFor($fileListAncestor, "New folder");
- }
-
- /**
- * @return Locator
- */
- public static function createNewFolderMenuItemNameInput($fileListAncestor) {
- return Locator::forThe()->css(".filenameform input[type=text]")->
- descendantOf(self::createNewFolderMenuItem($fileListAncestor))->
- describedAs("Name input in create new folder menu item in file list");
- }
-
- /**
- * @return Locator
- */
- public static function createNewFolderMenuItemConfirmButton($fileListAncestor) {
- return Locator::forThe()->css(".filenameform input[type=submit]")->
- descendantOf(self::createNewFolderMenuItem($fileListAncestor))->
- describedAs("Confirm button in create new folder menu item in file list");
- }
-
- /**
- * @return Locator
- */
- public static function fileListHeader($fileListAncestor) {
- return Locator::forThe()->css("thead")->
- descendantOf($fileListAncestor)->
- describedAs("Header in file list");
- }
-
- /**
- * @return Locator
- */
- public static function selectedFilesActionsMenuButton($fileListAncestor) {
- return Locator::forThe()->css(".actions-selected")->
- descendantOf(self::fileListHeader($fileListAncestor))->
- describedAs("Selected files actions menu button in file list");
- }
-
- /**
- * @return Locator
- */
- public static function selectedFilesActionsMenu() {
- return Locator::forThe()->css(".filesSelectMenu")->
- describedAs("Selected files actions menu in file list");
- }
-
- /**
- * @return Locator
- */
- private static function selectedFilesActionsMenuItemFor($itemText) {
- return Locator::forThe()->xpath("//a[normalize-space() = '$itemText']")->
- descendantOf(self::selectedFilesActionsMenu())->
- describedAs($itemText . " item in selected files actions menu in file list");
- }
-
- /**
- * @return Locator
- */
- public static function moveOrCopySelectedFilesMenuItem() {
- return self::selectedFilesActionsMenuItemFor("Move or copy");
- }
-
- /**
- * @return Locator
- */
- public static function rowForFile($fileListAncestor, $fileName) {
- return Locator::forThe()->xpath("//*[@class = 'files-fileList']//span[contains(concat(' ', normalize-space(@class), ' '), ' nametext ') and normalize-space() = '$fileName']/ancestor::tr")->
- descendantOf($fileListAncestor)->
- describedAs("Row for file $fileName in file list");
- }
-
- /**
- * @return Locator
- */
- public static function rowForFilePreceding($fileListAncestor, $fileName1, $fileName2) {
- return Locator::forThe()->xpath("//preceding-sibling::tr//span[contains(concat(' ', normalize-space(@class), ' '), ' nametext ') and normalize-space() = '$fileName1']/ancestor::tr")->
- descendantOf(self::rowForFile($fileListAncestor, $fileName2))->
- describedAs("Row for file $fileName1 preceding $fileName2 in file list");
- }
-
- /**
- * @return Locator
- */
- public static function selectionCheckboxForFile($fileListAncestor, $fileName) {
- // Note that the element that the user interacts with is the label, not
- // the checbox itself.
- return Locator::forThe()->css(".selection label")->
- descendantOf(self::rowForFile($fileListAncestor, $fileName))->
- describedAs("Selection checkbox for file $fileName in file list");
- }
-
- /**
- * @return Locator
- */
- public static function selectionCheckboxInputForFile($fileListAncestor, $fileName) {
- return Locator::forThe()->css(".selection input[type=checkbox]")->
- descendantOf(self::rowForFile($fileListAncestor, $fileName))->
- describedAs("Selection checkbox input for file $fileName in file list");
- }
-
- /**
- * @return Locator
- */
- public static function favoriteMarkForFile($fileListAncestor, $fileName) {
- return Locator::forThe()->css(".favorite-mark")->
- descendantOf(self::rowForFile($fileListAncestor, $fileName))->
- describedAs("Favorite mark for file $fileName in file list");
- }
-
- /**
- * @return Locator
- */
- public static function notFavoritedStateIconForFile($fileListAncestor, $fileName) {
- return Locator::forThe()->css(".icon-star")->
- descendantOf(self::favoriteMarkForFile($fileListAncestor, $fileName))->
- describedAs("Not favorited state icon for file $fileName in file list");
- }
-
- /**
- * @return Locator
- */
- public static function favoritedStateIconForFile($fileListAncestor, $fileName) {
- return Locator::forThe()->css(".icon-starred")->
- descendantOf(self::favoriteMarkForFile($fileListAncestor, $fileName))->
- describedAs("Favorited state icon for file $fileName in file list");
- }
-
- /**
- * @return Locator
- */
- public static function mainLinkForFile($fileListAncestor, $fileName) {
- return Locator::forThe()->css(".name")->
- descendantOf(self::rowForFile($fileListAncestor, $fileName))->
- describedAs("Main link for file $fileName in file list");
- }
-
- /**
- * @return Locator
- */
- public static function renameInputForFile($fileListAncestor, $fileName) {
- return Locator::forThe()->css("input.filename")->
- descendantOf(self::rowForFile($fileListAncestor, $fileName))->
- describedAs("Rename input for file $fileName in file list");
- }
-
- /**
- * @return Locator
- */
- public static function commentActionForFile($fileListAncestor, $fileName) {
- return Locator::forThe()->css(".action-comment")->
- descendantOf(self::rowForFile($fileListAncestor, $fileName))->
- describedAs("Comment action for file $fileName in file list");
- }
-
- /**
- * @return Locator
- */
- public static function shareActionForFile($fileListAncestor, $fileName) {
- return Locator::forThe()->css(".action-share")->
- descendantOf(self::rowForFile($fileListAncestor, $fileName))->
- describedAs("Share action for file $fileName in file list");
- }
-
- /**
- * @return Locator
- */
- public static function fileActionsMenuButtonForFile($fileListAncestor, $fileName) {
- return Locator::forThe()->css(".action-menu")->
- descendantOf(self::rowForFile($fileListAncestor, $fileName))->
- describedAs("File actions menu button for file $fileName in file list");
- }
-
- /**
- * @return Locator
- */
- public static function fileActionsMenu() {
- return Locator::forThe()->css(".fileActionsMenu")->
- describedAs("File actions menu in file list");
- }
-
- /**
- * @return Locator
- */
- private static function fileActionsMenuItemFor($itemText) {
- return Locator::forThe()->xpath("//a[normalize-space() = '$itemText']")->
- descendantOf(self::fileActionsMenu())->
- describedAs($itemText . " item in file actions menu in file list");
- }
-
- /**
- * @return Locator
- */
- public static function addToFavoritesMenuItem() {
- return self::fileActionsMenuItemFor("Add to favorites");
- }
-
- /**
- * @return Locator
- */
- public static function removeFromFavoritesMenuItem() {
- return self::fileActionsMenuItemFor("Remove from favorites");
- }
-
- /**
- * @return Locator
- */
- public static function detailsMenuItem() {
- return self::fileActionsMenuItemFor("Details");
- }
-
- /**
- * @return Locator
- */
- public static function renameMenuItem() {
- return self::fileActionsMenuItemFor("Rename");
- }
-
- /**
- * @return Locator
- */
- public static function moveOrCopyMenuItem() {
- return self::fileActionsMenuItemFor("Move or copy");
- }
-
- /**
- * @return Locator
- */
- public static function viewFileInFolderMenuItem() {
- return self::fileActionsMenuItemFor("View in folder");
- }
-
- /**
- * @return Locator
- */
- public static function deleteMenuItem() {
- return self::fileActionsMenuItemFor("Delete");
- }
-
- /**
- * @Given I create a new folder named :folderName
- */
- public function iCreateANewFolderNamed($folderName) {
- $this->actor->find(self::createMenuButton($this->fileListAncestor), 10)->click();
-
- $this->actor->find(self::createNewFolderMenuItem($this->fileListAncestor), 2)->click();
- $this->actor->find(self::createNewFolderMenuItemNameInput($this->fileListAncestor), 2)->setValue($folderName);
- $this->actor->find(self::createNewFolderMenuItemConfirmButton($this->fileListAncestor), 2)->click();
- }
-
- /**
- * @Given I enter in the folder named :folderName
- */
- public function iEnterInTheFolderNamed($folderName) {
- $this->actor->find(self::mainLinkForFile($this->fileListAncestor, $folderName), 10)->click();
- }
-
- /**
- * @Given I select :fileName
- */
- public function iSelect($fileName) {
- $this->iSeeThatIsNotSelected($fileName);
-
- $this->actor->find(self::selectionCheckboxForFile($this->fileListAncestor, $fileName), 10)->click();
- }
-
- /**
- * @Given I start the move or copy operation for the selected files
- */
- public function iStartTheMoveOrCopyOperationForTheSelectedFiles() {
- $this->actor->find(self::selectedFilesActionsMenuButton($this->fileListAncestor), 10)->click();
-
- $this->actor->find(self::moveOrCopySelectedFilesMenuItem(), 2)->click();
- }
-
- /**
- * @Given I open the details view for :fileName
- */
- public function iOpenTheDetailsViewFor($fileName) {
- $this->openFileActionsMenuForFile($fileName);
-
- $this->actor->find(self::detailsMenuItem(), 2)->click();
- }
-
- /**
- * @Given I rename :fileName1 to :fileName2
- */
- public function iRenameTo($fileName1, $fileName2) {
- $this->openFileActionsMenuForFile($fileName1);
-
- $this->actor->find(self::renameMenuItem(), 2)->click();
-
- // For reference, due to a bug in the Firefox driver of Selenium and/or
- // maybe in Firefox itself, as a range is selected in the rename input
- // (the name of the file, without its extension) when the value is set
- // the window must be in the foreground. Otherwise, if the window is in
- // the background, instead of setting the value in the whole field it
- // would be set only in the selected range.
- // This should not be a problem, though, as the default behaviour is to
- // bring the browser window to the foreground when switching to a
- // different actor.
- $this->actor->find(self::renameInputForFile($this->fileListAncestor, $fileName1), 10)->setValue($fileName2);
- }
-
- /**
- * @Given I start the move or copy operation for :fileName
- */
- public function iStartTheMoveOrCopyOperationFor($fileName) {
- $this->openFileActionsMenuForFile($fileName);
-
- $this->actor->find(self::moveOrCopyMenuItem(), 2)->click();
- }
-
- /**
- * @Given I mark :fileName as favorite
- */
- public function iMarkAsFavorite($fileName) {
- $this->iSeeThatIsNotMarkedAsFavorite($fileName);
-
- $this->openFileActionsMenuForFile($fileName);
-
- $this->actor->find(self::addToFavoritesMenuItem(), 2)->click();
- }
-
- /**
- * @Given I unmark :fileName as favorite
- */
- public function iUnmarkAsFavorite($fileName) {
- $this->iSeeThatIsMarkedAsFavorite($fileName);
-
- $this->openFileActionsMenuForFile($fileName);
-
- $this->actor->find(self::removeFromFavoritesMenuItem(), 2)->click();
- }
-
- /**
- * @When I view :fileName in folder
- */
- public function iViewInFolder($fileName) {
- $this->openFileActionsMenuForFile($fileName);
-
- $this->actor->find(self::viewFileInFolderMenuItem(), 2)->click();
- }
-
- /**
- * @When I delete :fileName
- */
- public function iDelete($fileName) {
- $this->openFileActionsMenuForFile($fileName);
-
- $this->actor->find(self::deleteMenuItem(), 2)->click();
- }
-
- /**
- * @When I open the unread comments for :fileName
- */
- public function iOpenTheUnreadCommentsFor($fileName) {
- $this->actor->find(self::commentActionForFile($this->fileListAncestor, $fileName), 10)->click();
- }
-
- /**
- * @Then I see that the file list is eventually loaded
- */
- public function iSeeThatTheFileListIsEventuallyLoaded() {
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::mainWorkingIcon($this->fileListAncestor),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The main working icon for the file list is still shown after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the file list is currently in :path
- */
- public function iSeeThatTheFileListIsCurrentlyIn($path) {
- // The text of the breadcrumbs is the text of all the crumbs separated
- // by white spaces.
- Assert::assertEquals(
- str_replace('/', ' ', $path), $this->actor->find(self::breadcrumbs($this->fileListAncestor), 10)->getText());
- }
-
- /**
- * @Then I see that it is not possible to create new files
- */
- public function iSeeThatItIsNotPossibleToCreateNewFiles() {
- // Once a file list is loaded the "Create" menu button is always in the
- // DOM, so it is checked if it is visible or not.
- Assert::assertFalse($this->actor->find(self::createMenuButton($this->fileListAncestor))->isVisible());
- }
-
- /**
- * @Then I see that the file list contains a file named :fileName
- */
- public function iSeeThatTheFileListContainsAFileNamed($fileName) {
- Assert::assertNotNull($this->actor->find(self::rowForFile($this->fileListAncestor, $fileName), 10));
- }
-
- /**
- * @Then I see that the file list does not contain a file named :fileName
- */
- public function iSeeThatTheFileListDoesNotContainAFileNamed($fileName) {
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::rowForFile($this->fileListAncestor, $fileName),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The file list still contains a file named $fileName after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that :fileName1 precedes :fileName2 in the file list
- */
- public function iSeeThatPrecedesInTheFileList($fileName1, $fileName2) {
- Assert::assertNotNull($this->actor->find(self::rowForFilePreceding($this->fileListAncestor, $fileName1, $fileName2), 10));
- }
-
- /**
- * @Then I see that :fileName is not selected
- */
- public function iSeeThatIsNotSelected($fileName) {
- Assert::assertFalse($this->actor->find(self::selectionCheckboxInputForFile($this->fileListAncestor, $fileName), 10)->isChecked());
- }
-
- /**
- * @Then I see that :fileName is marked as favorite
- */
- public function iSeeThatIsMarkedAsFavorite($fileName) {
- Assert::assertNotNull($this->actor->find(self::favoritedStateIconForFile($this->fileListAncestor, $fileName), 10));
- }
-
- /**
- * @Then I see that :fileName is not marked as favorite
- */
- public function iSeeThatIsNotMarkedAsFavorite($fileName) {
- Assert::assertNotNull($this->actor->find(self::notFavoritedStateIconForFile($this->fileListAncestor, $fileName), 10));
- }
-
- /**
- * @Then I see that :fileName has unread comments
- */
- public function iSeeThatHasUnreadComments($fileName) {
- Assert::assertTrue($this->actor->find(self::commentActionForFile($this->fileListAncestor, $fileName), 10)->isVisible());
- }
-
- private function waitForRowForFileToBeFullyOpaque($fileName) {
- $actor = $this->actor;
- $fileRowXpathExpression = $this->actor->find(self::rowForFile($this->fileListAncestor, $fileName), 10)->getWrappedElement()->getXpath();
-
- $fileRowIsFullyOpaqueCallback = function () use ($actor, $fileRowXpathExpression) {
- $opacity = $actor->getSession()->evaluateScript("return window.getComputedStyle(document.evaluate(\"" . $fileRowXpathExpression . "\", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue).opacity;");
- if ($opacity === "1") {
- return true;
- }
-
- return false;
- };
-
- if (!Utils::waitFor($fileRowIsFullyOpaqueCallback, $timeout = 2 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) {
- Assert::fail("The row for file $fileName in file list is not fully opaque after $timeout seconds");
- }
- }
-
- private function openFileActionsMenuForFile($fileName) {
- // When a row is added to the file list the opacity of the file row is
- // animated from transparent to fully opaque. As the file actions menu
- // is a descendant of the row but overflows it when the row is not fully
- // opaque clicks on the menu entries "fall-through" and are received
- // instead by the rows behind. Therefore it should be waited until the
- // row of the file is fully opaque before using the menu.
- $this->waitForRowForFileToBeFullyOpaque($fileName);
-
- $this->actor->find(self::fileActionsMenuButtonForFile($this->fileListAncestor, $fileName), 10)->click();
- }
-}
diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php
deleted file mode 100644
index b73b8389c49..00000000000
--- a/tests/acceptance/features/bootstrap/FilesAppContext.php
+++ /dev/null
@@ -1,416 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class FilesAppContext implements Context, ActorAwareInterface {
- use ActorAware;
- use FileListAncestorSetter;
-
- /**
- * @return array
- */
- public static function sections() {
- return [ "All files" => "files",
- "Recent" => "recent",
- "Favorites" => "favorites",
- "Shared with you" => "sharingin",
- "Shared with others" => "sharingout",
- "Shared by link" => "sharinglinks",
- "Tags" => "systemtagsfilter",
- "Deleted files" => "trashbin" ];
- }
-
- /**
- * @return Locator
- */
- private static function appMenu() {
- return Locator::forThe()->css("header nav.app-menu")->
- describedAs("App menu in header");
- }
-
- /**
- * @return Locator
- */
- public static function filesItemInAppMenu() {
- return Locator::forThe()->xpath("//li[@data-app-id = 'files']")->
- descendantOf(self::appMenu())->
- describedAs("Files item in app menu in header");
- }
-
- /**
- * @return Locator
- */
- public static function mainViewForSection($section) {
- $sectionId = self::sections()[$section];
-
- return Locator::forThe()->id("app-content-$sectionId")->
- describedAs("Main view for section $section in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function currentSectionMainView() {
- return Locator::forThe()->xpath("//*[starts-with(@id, 'app-content-') and not(@id = 'app-content-vue') and not(contains(concat(' ', normalize-space(@class), ' '), ' hidden '))]")->
- describedAs("Current section main view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function detailsView() {
- return Locator::forThe()->xpath("//*[@id=\"app-sidebar\" or contains(@class, 'app-sidebar')]")->
- describedAs("Details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function closeDetailsViewButton() {
- return Locator::forThe()->css(".app-sidebar__close")->
- descendantOf(self::detailsView())->
- describedAs("Close details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function fileNameInDetailsView() {
- return Locator::forThe()->css(".app-sidebar-header__title")->
- descendantOf(self::detailsView())->
- describedAs("File name in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function favoriteActionInFileDetailsInDetailsView() {
- return Locator::forThe()->css(".app-sidebar-header__star")->
- descendantOf(self::fileDetailsInDetailsView())->
- describedAs("Favorite action in file details in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function notFavoritedStateIconInFileDetailsInDetailsView() {
- return Locator::forThe()->css(".star-outline-icon")->
- descendantOf(self::favoriteActionInFileDetailsInDetailsView())->
- describedAs("Not favorited state icon in file details in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function favoritedStateIconInFileDetailsInDetailsView() {
- return Locator::forThe()->css(".star-icon")->
- descendantOf(self::favoriteActionInFileDetailsInDetailsView())->
- describedAs("Favorited state icon in file details in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function fileDetailsInDetailsViewWithText($fileDetailsText) {
- return Locator::forThe()->xpath("//span[normalize-space() = '$fileDetailsText']")->
- descendantOf(self::fileDetailsInDetailsView())->
- describedAs("File details with text \"$fileDetailsText\" in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- private static function fileDetailsInDetailsView() {
- return Locator::forThe()->css(".app-sidebar-header__desc")->
- descendantOf(self::detailsView())->
- describedAs("File details in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function inputFieldForTagsInDetailsView() {
- return Locator::forThe()->css(".systemTagsInfoView")->
- descendantOf(self::detailsView())->
- describedAs("Input field for tags in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function itemInInputFieldForTagsInDetailsViewForTag($tag) {
- return Locator::forThe()->xpath("//span[normalize-space() = '$tag']")->
- descendantOf(self::inputFieldForTagsInDetailsView())->
- describedAs("Item in input field for tags in details view for tag $tag in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function itemInDropdownForTag($tag) {
- return Locator::forThe()->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' select2-result-label ')]//span[normalize-space() = '$tag']/ancestor::li")->
- descendantOf(self::select2Dropdown())->
- describedAs("Item in dropdown for tag $tag in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function checkmarkInItemInDropdownForTag($tag) {
- return Locator::forThe()->css(".checkmark")->
- descendantOf(self::itemInDropdownForTag($tag))->
- describedAs("Checkmark in item in dropdown for tag $tag in Files app");
- }
-
- /**
- * @return Locator
- */
- private static function select2Dropdown() {
- return Locator::forThe()->css("#select2-drop")->
- describedAs("Select2 dropdown in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function tabHeaderInDetailsViewNamed($tabHeaderName) {
- return Locator::forThe()->xpath("//span[contains(@class, 'app-sidebar-tabs__tab') and normalize-space() = '$tabHeaderName']")->
- descendantOf(self::tabHeadersInDetailsView())->
- describedAs("Tab header named $tabHeaderName in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- private static function tabHeadersInDetailsView() {
- return Locator::forThe()->css(".app-sidebar-tabs__nav")->
- descendantOf(self::detailsView())->
- describedAs("Tab headers in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function tabInDetailsViewNamed($tabName) {
- return Locator::forThe()->xpath("//div[contains(concat(' ', normalize-space(@class), ' '), ' app-sidebar-tabs__content ')]/section[@aria-labelledby = '$tabName' and @role = 'tabpanel']")->
- descendantOf(self::detailsView())->
- describedAs("Tab named $tabName in details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function loadingIconForTabInDetailsViewNamed($tabName) {
- return Locator::forThe()->css(".icon-loading")->
- descendantOf(self::tabInDetailsViewNamed($tabName))->
- describedAs("Loading icon for tab named $tabName in details view in Files app");
- }
-
- /**
- * @Given I open the Files app
- */
- public function iOpenTheFilesApp() {
- $this->actor->find(self::filesItemInAppMenu(), 10)->click();
- }
-
- /**
- * @Given I close the details view
- */
- public function iCloseTheDetailsView() {
- $this->actor->find(self::closeDetailsViewButton(), 10)->click();
- }
-
- /**
- * @Given I open the input field for tags in the details view
- */
- public function iOpenTheInputFieldForTagsInTheDetailsView() {
- $this->actor->find(self::fileDetailsInDetailsViewWithText("Tags"), 10)->click();
- }
-
- /**
- * @Given I open the :tabName tab in the details view
- */
- public function iOpenTheTabInTheDetailsView($tabName) {
- $this->actor->find(self::tabHeaderInDetailsViewNamed($tabName), 10)->click();
- }
-
- /**
- * @When I mark the file as favorite in the details view
- */
- public function iMarkTheFileAsFavoriteInTheDetailsView() {
- $this->iSeeThatTheFileIsNotMarkedAsFavoriteInTheDetailsView();
-
- $this->actor->find(self::favoriteActionInFileDetailsInDetailsView(), 10)->click();
- }
-
- /**
- * @When I unmark the file as favorite in the details view
- */
- public function iUnmarkTheFileAsFavoriteInTheDetailsView() {
- $this->iSeeThatTheFileIsMarkedAsFavoriteInTheDetailsView();
-
- $this->actor->find(self::favoriteActionInFileDetailsInDetailsView(), 10)->click();
- }
-
- /**
- * @When I check the tag :tag in the dropdown for tags in the details view
- */
- public function iCheckTheTagInTheDropdownForTagsInTheDetailsView($tag) {
- $this->iSeeThatTheTagInTheDropdownForTagsInTheDetailsViewIsNotChecked($tag);
-
- $this->actor->find(self::itemInDropdownForTag($tag), 10)->click();
- }
-
- /**
- * @When I uncheck the tag :tag in the dropdown for tags in the details view
- */
- public function iUncheckTheTagInTheDropdownForTagsInTheDetailsView($tag) {
- $this->iSeeThatTheTagInTheDropdownForTagsInTheDetailsViewIsChecked($tag);
-
- $this->actor->find(self::itemInDropdownForTag($tag), 10)->click();
- }
-
- /**
- * @Then I see that the current page is the Files app
- */
- public function iSeeThatTheCurrentPageIsTheFilesApp() {
- Assert::assertStringStartsWith(
- $this->actor->locatePath("/apps/files/"),
- $this->actor->getSession()->getCurrentUrl());
-
- $this->setFileListAncestorForActor(self::currentSectionMainView(), $this->actor);
- }
-
- /**
- * @Then I see that the details view is open
- */
- public function iSeeThatTheDetailsViewIsOpen() {
- // The sidebar always exists in the DOM, so it has to be explicitly
- // waited for it to be visible instead of relying on the implicit wait
- // made to find the element.
- if (!WaitFor::elementToBeEventuallyShown(
- $this->actor,
- self::detailsView(),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The details view is not open yet after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the details view is closed
- */
- public function iSeeThatTheDetailsViewIsClosed() {
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::detailsView(),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The details view is not closed yet after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the file name shown in the details view is :fileName
- */
- public function iSeeThatTheFileNameShownInTheDetailsViewIs($fileName) {
- Assert::assertEquals(
- $this->actor->find(self::fileNameInDetailsView(), 10)->getText(), $fileName);
- }
-
- /**
- * @Then I see that the file is marked as favorite in the details view
- */
- public function iSeeThatTheFileIsMarkedAsFavoriteInTheDetailsView() {
- Assert::assertNotNull(
- $this->actor->find(self::favoritedStateIconInFileDetailsInDetailsView(), 10));
- }
-
- /**
- * @Then I see that the file is not marked as favorite in the details view
- */
- public function iSeeThatTheFileIsNotMarkedAsFavoriteInTheDetailsView() {
- Assert::assertNotNull(
- $this->actor->find(self::notFavoritedStateIconInFileDetailsInDetailsView(), 10));
- }
-
- /**
- * @Then I see that the input field for tags in the details view is shown
- */
- public function iSeeThatTheInputFieldForTagsInTheDetailsViewIsShown() {
- Assert::assertTrue(
- $this->actor->find(self::inputFieldForTagsInDetailsView(), 10)->isVisible());
- }
-
- /**
- * @Then I see that the input field for tags in the details view contains the tag :tag
- */
- public function iSeeThatTheInputFieldForTagsInTheDetailsViewContainsTheTag($tag) {
- Assert::assertTrue(
- $this->actor->find(self::itemInInputFieldForTagsInDetailsViewForTag($tag), 10)->isVisible());
- }
-
- /**
- * @Then I see that the input field for tags in the details view does not contain the tag :tag
- */
- public function iSeeThatTheInputFieldForTagsInTheDetailsViewDoesNotContainTheTag($tag) {
- $this->iSeeThatTheInputFieldForTagsInTheDetailsViewIsShown();
-
- try {
- Assert::assertFalse(
- $this->actor->find(self::itemInInputFieldForTagsInDetailsViewForTag($tag))->isVisible());
- } catch (NoSuchElementException $exception) {
- }
- }
-
- /**
- * @Then I see that the tag :tag in the dropdown for tags in the details view is checked
- */
- public function iSeeThatTheTagInTheDropdownForTagsInTheDetailsViewIsChecked($tag) {
- Assert::assertTrue(
- $this->actor->find(self::checkmarkInItemInDropdownForTag($tag), 10)->isVisible());
- }
-
- /**
- * @Then I see that the tag :tag in the dropdown for tags in the details view is not checked
- */
- public function iSeeThatTheTagInTheDropdownForTagsInTheDetailsViewIsNotChecked($tag) {
- Assert::assertTrue(
- $this->actor->find(self::itemInDropdownForTag($tag), 10)->isVisible());
-
- Assert::assertFalse(
- $this->actor->find(self::checkmarkInItemInDropdownForTag($tag))->isVisible());
- }
-
- /**
- * @When I see that the :tabName tab in the details view is eventually loaded
- */
- public function iSeeThatTheTabInTheDetailsViewIsEventuallyLoaded($tabName) {
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::loadingIconForTabInDetailsViewNamed($tabName),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The $tabName tab in the details view has not been loaded after $timeout seconds");
- }
- }
-}
diff --git a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php
deleted file mode 100644
index 3c2b4a8633f..00000000000
--- a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php
+++ /dev/null
@@ -1,811 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-use WebDriver\Key;
-
-class FilesAppSharingContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function sharedByLabel() {
- return Locator::forThe()->css(".sharing-entry__reshare")->
- descendantOf(FilesAppContext::detailsView())->
- describedAs("Shared by label in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function shareWithInput() {
- return Locator::forThe()->css(".sharing-search__input input")->
- descendantOf(FilesAppContext::detailsView())->
- describedAs("Share with input in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function shareWithInputResults() {
- return Locator::forThe()->css(".vs__dropdown-menu")->
- describedAs("Share with input results list in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function shareWithInputResult($result) {
- return Locator::forThe()->xpath("//li//span[normalize-space() = '$result']/ancestor::li")->
- descendantOf(self::shareWithInputResults())->
- describedAs("Share with input result from the results list in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function shareeList() {
- return Locator::forThe()->css(".sharing-sharee-list")->
- descendantOf(FilesAppContext::detailsView())->
- describedAs("Sharee list in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function sharedWithRow($sharedWithName) {
- // "username" class is used for any type of share, not only for shares
- // with users.
- return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' sharing-entry ')]//span[normalize-space() = '$sharedWithName']/ancestor::li")->
- descendantOf(self::shareeList())->
- describedAs("Shared with $sharedWithName row in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function shareWithMenuTrigger($sharedWithName) {
- return Locator::forThe()->css(".sharing-entry__actions button")->
- descendantOf(self::sharedWithRow($sharedWithName))->
- describedAs("Share with $sharedWithName menu trigger in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function shareWithMenuButton($sharedWithName) {
- return Locator::forThe()->css(".action-item__menutoggle")->
- descendantOf(self::shareWithMenuTrigger($sharedWithName))->
- describedAs("Share with $sharedWithName menu button in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function shareWithMenu($sharedWithName, $shareWithMenuTriggerElement) {
- return Locator::forThe()->xpath("//*[@id = " . $shareWithMenuTriggerElement->getWrappedElement()->getXpath() . "/@aria-describedby]")->
- describedAs("Share with $sharedWithName menu in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function permissionCheckboxFor($sharedWithName, $shareWithMenuTriggerElement, $itemText) {
- // forThe()->checkbox($itemText) can not be used here; that would return
- // the checkbox itself, but the element that the user interacts with is
- // the label.
- return Locator::forThe()->xpath("//label[normalize-space() = '$itemText']")->
- descendantOf(self::shareWithMenu($sharedWithName, $shareWithMenuTriggerElement))->
- describedAs("$itemText checkbox in the share with $sharedWithName menu in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function permissionCheckboxInputFor($sharedWithName, $shareWithMenuTriggerElement, $itemText) {
- return Locator::forThe()->checkbox($itemText)->
- descendantOf(self::shareWithMenu($sharedWithName, $shareWithMenuTriggerElement))->
- describedAs("$itemText checkbox input in the share with $sharedWithName menu in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function canEditCheckbox($sharedWithName, $shareWithMenuTriggerElement) {
- return self::permissionCheckboxFor($sharedWithName, $shareWithMenuTriggerElement, 'Allow editing');
- }
-
- /**
- * @return Locator
- */
- public static function canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement) {
- return self::permissionCheckboxInputFor($sharedWithName, $shareWithMenuTriggerElement, 'Allow editing');
- }
-
- /**
- * @return Locator
- */
- public static function canCreateCheckbox($sharedWithName, $shareWithMenuTriggerElement) {
- return self::permissionCheckboxFor($sharedWithName, $shareWithMenuTriggerElement, 'Allow creating');
- }
-
- /**
- * @return Locator
- */
- public static function canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement) {
- return self::permissionCheckboxInputFor($sharedWithName, $shareWithMenuTriggerElement, 'Allow creating');
- }
-
- /**
- * @return Locator
- */
- public static function canReshareCheckbox($sharedWithName, $shareWithMenuTriggerElement) {
- return self::permissionCheckboxFor($sharedWithName, $shareWithMenuTriggerElement, 'Allow resharing');
- }
-
- /**
- * @return Locator
- */
- public static function canReshareCheckboxInput($sharedWithName, $shareWithMenuTriggerElement) {
- return self::permissionCheckboxInputFor($sharedWithName, $shareWithMenuTriggerElement, 'Allow resharing');
- }
-
- /**
- * @return Locator
- */
- public static function unshareButton($sharedWithName, $shareWithMenuTriggerElement) {
- return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' action ')]//button[normalize-space() = 'Unshare']")->
- descendantOf(self::shareWithMenu($sharedWithName, $shareWithMenuTriggerElement))->
- describedAs("Unshare button in the share with $sharedWithName menu in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function shareLinkRow() {
- return Locator::forThe()->css(".sharing-link-list .sharing-entry__link:first-child")->
- descendantOf(FilesAppContext::detailsView())->
- describedAs("Share link row in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function shareLinkAddNewButton() {
- // When there is no link share the "Add new share" item is shown instead
- // of the menu button as a direct child of ".share-menu".
- return Locator::forThe()->css(".action-item.new-share-link")->
- descendantOf(self::shareLinkRow())->
- describedAs("Add new share link button in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function copyLinkButton() {
- return Locator::forThe()->css("a.sharing-entry__copy")->
- descendantOf(self::shareLinkRow())->
- describedAs("Copy link button in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function shareLinkMenuTrigger() {
- return Locator::forThe()->css(".sharing-entry__actions .action-item__menutoggle")->
- descendantOf(self::shareLinkRow())->
- describedAs("Share link menu trigger in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function shareLinkSingleUnshareAction() {
- return Locator::forThe()->css(".sharing-entry__actions.icon-close")->
- descendantOf(self::shareLinkRow())->
- describedAs("Unshare link single action in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function shareLinkMenuButton() {
- return Locator::forThe()->css(".action-item__menutoggle")->
- descendantOf(self::shareLinkMenuTrigger())->
- describedAs("Share link menu button in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function shareLinkMenu($shareLinkMenuTriggerElement) {
- return Locator::forThe()->xpath("//*[@id = " . $shareLinkMenuTriggerElement->getWrappedElement()->getXpath() . "/@aria-describedby]")->
- describedAs("Share link menu in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function hideDownloadCheckbox($shareLinkMenuTriggerElement) {
- // forThe()->checkbox("Hide download") can not be used here; that would
- // return the checkbox itself, but the element that the user interacts
- // with is the label.
- return Locator::forThe()->xpath("//label[normalize-space() = 'Hide download']")->
- descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))->
- describedAs("Hide download checkbox in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function hideDownloadCheckboxInput($shareLinkMenuTriggerElement) {
- return Locator::forThe()->checkbox("Hide download")->
- descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))->
- describedAs("Hide download checkbox input in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function allowUploadAndEditingRadioButton($shareLinkMenuTriggerElement) {
- // forThe()->radio("Allow upload and editing") can not be used here;
- // that would return the radio button itself, but the element that the
- // user interacts with is the label.
- return Locator::forThe()->xpath("//label[normalize-space() = 'Allow upload and editing']")->
- descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))->
- describedAs("Allow upload and editing radio button in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function passwordProtectCheckbox($shareLinkMenuTriggerElement) {
- // forThe()->checkbox("Password protect") can not be used here; that
- // would return the checkbox itself, but the element that the user
- // interacts with is the label.
- return Locator::forThe()->xpath("//label[normalize-space() = 'Password protect']")->
- descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))->
- describedAs("Password protect checkbox in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function passwordProtectCheckboxInput($shareLinkMenuTriggerElement) {
- return Locator::forThe()->checkbox("Password protect")->
- descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))->
- describedAs("Password protect checkbox input in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function passwordProtectField($shareLinkMenuTriggerElement) {
- return Locator::forThe()->css(".share-link-password input.input-field__input")->descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))->
- describedAs("Password protect field in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function disabledPasswordProtectField($shareLinkMenuTriggerElement) {
- return Locator::forThe()->css(".share-link-password input.input-field__input[disabled]")->descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))->
- describedAs("Disabled password protect field in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function passwordProtectByTalkCheckbox($shareLinkMenuTriggerElement) {
- // forThe()->checkbox("Password protect by Talk") can not be used here;
- // that would return the checkbox itself, but the element that the user
- // interacts with is the label.
- return Locator::forThe()->xpath("//label[normalize-space() = 'Password protect by Talk']")->
- descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))->
- describedAs("Password protect by Talk checkbox in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function passwordProtectByTalkCheckboxInput($shareLinkMenuTriggerElement) {
- return Locator::forThe()->checkbox("Password protect by Talk")->
- descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))->
- describedAs("Password protect by Talk checkbox input in the details view in Files app");
- }
-
- /**
- * @return Locator
- */
- public static function unshareLinkButton($shareLinkMenuTriggerElement) {
- return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' action ')]//button[normalize-space() = 'Unshare']")->
- descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))->
- describedAs("Unshare link button in the details view in Files app");
- }
-
- /**
- * @Given I share the link for :fileName
- */
- public function iShareTheLinkFor($fileName) {
- $this->actor->find(FileListContext::shareActionForFile(FilesAppContext::currentSectionMainView(), $fileName), 10)->click();
-
- $this->actor->find(self::shareLinkAddNewButton(), 5)->click();
- }
-
- /**
- * @Given I share :fileName with :shareWithName
- */
- public function iShareWith($fileName, $shareWithName) {
- $this->actor->find(FileListContext::shareActionForFile(FilesAppContext::currentSectionMainView(), $fileName), 10)->click();
-
- $this->actor->find(self::shareWithInput(), 5)->setValue($shareWithName);
- // "setValue()" ends sending a tab, which unfocuses the input and causes
- // the results to be hidden, so the input needs to be clicked to show
- // the results again.
- $this->actor->find(self::shareWithInput())->click();
- $this->actor->find(self::shareWithInputResult($shareWithName), 5)->click();
- }
-
- /**
- * @Given I write down the shared link
- */
- public function iWriteDownTheSharedLink() {
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
-
- // Close the share link menu if it is open to ensure that it does not
- // cover the copy link button.
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::shareLinkMenu($shareLinkMenuTriggerElement),
- $timeout = 2 * $this->actor->getFindTimeoutMultiplier())) {
- // It may not be possible to click on the menu button (due to the
- // menu itself covering it), so "Enter" key is pressed instead.
- $this->actor->find(self::shareLinkMenuButton(), 2)->getWrappedElement()->keyPress(13);
- }
-
- $this->actor->find(self::copyLinkButton(), 10)->click();
-
- // Clicking on the menu item copies the link to the clipboard, but it is
- // not possible to access that value from the acceptance tests. Due to
- // this the value of the attribute that holds the URL is used instead.
- $this->actor->getSharedNotebook()["shared link"] = $this->actor->find(self::copyLinkButton(), 2)->getWrappedElement()->getAttribute("href");
- }
-
- /**
- * @When I set the download of the shared link as hidden
- */
- public function iSetTheDownloadOfTheSharedLinkAsHidden() {
- $this->showShareLinkMenuIfNeeded();
-
- $this->iSeeThatTheDownloadOfTheLinkShareIsShown();
-
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
- $this->actor->find(self::hideDownloadCheckbox($shareLinkMenuTriggerElement), 2)->click();
- }
-
- /**
- * @When I set the download of the shared link as shown
- */
- public function iSetTheDownloadOfTheSharedLinkAsShown() {
- $this->showShareLinkMenuIfNeeded();
-
- $this->iSeeThatTheDownloadOfTheLinkShareIsHidden();
-
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
- $this->actor->find(self::hideDownloadCheckbox($shareLinkMenuTriggerElement), 2)->click();
- }
-
- /**
- * @When I set the shared link as editable
- */
- public function iSetTheSharedLinkAsEditable() {
- $this->showShareLinkMenuIfNeeded();
-
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
- $this->actor->find(self::allowUploadAndEditingRadioButton($shareLinkMenuTriggerElement), 2)->click();
- }
-
- /**
- * @When I protect the shared link with the password :password
- */
- public function iProtectTheSharedLinkWithThePassword($password) {
- $this->showShareLinkMenuIfNeeded();
-
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
- $this->actor->find(self::passwordProtectCheckbox($shareLinkMenuTriggerElement), 2)->click();
-
- $this->actor->find(self::passwordProtectField($shareLinkMenuTriggerElement), 2)->setValue($password . Key::ENTER);
- }
-
- /**
- * @When I set the password of the shared link as protected by Talk
- */
- public function iSetThePasswordOfTheSharedLinkAsProtectedByTalk() {
- $this->showShareLinkMenuIfNeeded();
-
- $this->iSeeThatThePasswordOfTheLinkShareIsNotProtectedByTalk();
-
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
- $this->actor->find(self::passwordProtectByTalkCheckbox($shareLinkMenuTriggerElement), 2)->click();
- }
-
- /**
- * @When I set the password of the shared link as not protected by Talk
- */
- public function iSetThePasswordOfTheSharedLinkAsNotProtectedByTalk() {
- $this->showShareLinkMenuIfNeeded();
-
- $this->iSeeThatThePasswordOfTheLinkShareIsProtectedByTalk();
-
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
- $this->actor->find(self::passwordProtectByTalkCheckbox($shareLinkMenuTriggerElement), 2)->click();
- }
-
- /**
- * @When I set the share with :shareWithName as not editable
- */
- public function iSetTheShareWithAsNotEditable($shareWithName) {
- $this->showShareWithMenuIfNeeded($shareWithName);
-
- $this->iSeeThatCanEditTheShare($shareWithName);
-
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($shareWithName), 2);
- $this->actor->find(self::canEditCheckbox($shareWithName, $shareWithMenuTriggerElement), 2)->click();
- }
-
- /**
- * @When I set the share with :shareWithName as not creatable
- */
- public function iSetTheShareWithAsNotCreatable($shareWithName) {
- $this->showShareWithMenuIfNeeded($shareWithName);
-
- $this->iSeeThatCanCreateInTheShare($shareWithName);
-
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($shareWithName), 2);
- $this->actor->find(self::canCreateCheckbox($shareWithName, $shareWithMenuTriggerElement), 2)->click();
- }
-
- /**
- * @When I set the share with :shareWithName as not reshareable
- */
- public function iSetTheShareWithAsNotReshareable($shareWithName) {
- $this->showShareWithMenuIfNeeded($shareWithName);
-
- $this->iSeeThatCanReshareTheShare($shareWithName);
-
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($shareWithName), 2);
- $this->actor->find(self::canReshareCheckbox($shareWithName, $shareWithMenuTriggerElement), 2)->click();
- }
-
- /**
- * @When I unshare the share with :shareWithName
- */
- public function iUnshareTheFileWith($shareWithName) {
- $this->showShareWithMenuIfNeeded($shareWithName);
-
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($shareWithName), 2);
- $this->actor->find(self::unshareButton($shareWithName, $shareWithMenuTriggerElement), 2)->click();
- }
-
- /**
- * @When I unshare the link share
- */
- public function iUnshareTheLink() {
- try {
- $this->actor->find(self::shareLinkSingleUnshareAction(), 2)->click();
- } catch (NoSuchElementException $e) {
- $this->showShareLinkMenuIfNeeded();
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
- $this->actor->find(self::unshareLinkButton($shareLinkMenuTriggerElement), 2)->click();
- }
- }
-
- /**
- * @Then I see that the file is shared with me by :sharedByName
- */
- public function iSeeThatTheFileIsSharedWithMeBy($sharedByName) {
- Assert::assertEquals(
- $this->actor->find(self::sharedByLabel(), 10)->getText(), "Shared with you by $sharedByName");
- }
-
- /**
- * @Then I see that the file is shared with :sharedWithName
- */
- public function iSeeThatTheFileIsSharedWith($sharedWithName) {
- Assert::assertTrue(
- $this->actor->find(self::sharedWithRow($sharedWithName), 10)->isVisible());
- }
-
- /**
- * @Then I see that the file is not shared with :sharedWithName
- */
- public function iSeeThatTheFileIsNotSharedWith($sharedWithName) {
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::sharedWithRow($sharedWithName),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The shared with $sharedWithName row is still shown after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that resharing the file is not allowed
- */
- public function iSeeThatResharingTheFileIsNotAllowed() {
- Assert::assertEquals(
- $this->actor->find(self::shareWithInput(), 10)->getWrappedElement()->getAttribute("disabled"), "disabled");
- Assert::assertEquals(
- $this->actor->find(self::shareWithInput(), 10)->getWrappedElement()->getAttribute("placeholder"), "Resharing is not allowed");
- }
-
- /**
- * @Then I see that resharing the file by link is not available
- */
- public function iSeeThatResharingTheFileByLinkIsNotAvailable() {
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::shareLinkAddNewButton(),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The add new share link button is still shown after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that :sharedWithName can not be allowed to edit the share
- */
- public function iSeeThatCanNotBeAllowedToEditTheShare($sharedWithName) {
- $this->showShareWithMenuIfNeeded($sharedWithName);
-
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10);
- Assert::assertEquals(
- $this->actor->find(self::canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->getWrappedElement()->getAttribute("disabled"), "disabled");
- }
-
- /**
- * @Then I see that :sharedWithName can edit the share
- */
- public function iSeeThatCanEditTheShare($sharedWithName) {
- $this->showShareWithMenuIfNeeded($sharedWithName);
-
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10);
- Assert::assertTrue(
- $this->actor->find(self::canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked());
- }
-
- /**
- * @Then I see that :sharedWithName can not edit the share
- */
- public function iSeeThatCanNotEditTheShare($sharedWithName) {
- $this->showShareWithMenuIfNeeded($sharedWithName);
-
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10);
- Assert::assertFalse(
- $this->actor->find(self::canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked());
- }
-
- /**
- * @Then I see that :sharedWithName can not be allowed to create in the share
- */
- public function iSeeThatCanNotBeAllowedToCreateInTheShare($sharedWithName) {
- $this->showShareWithMenuIfNeeded($sharedWithName);
-
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10);
- Assert::assertEquals(
- $this->actor->find(self::canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->getWrappedElement()->getAttribute("disabled"), "disabled");
- }
-
- /**
- * @Then I see that :sharedWithName can create in the share
- */
- public function iSeeThatCanCreateInTheShare($sharedWithName) {
- $this->showShareWithMenuIfNeeded($sharedWithName);
-
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10);
- Assert::assertTrue(
- $this->actor->find(self::canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked());
- }
-
- /**
- * @Then I see that :sharedWithName can not create in the share
- */
- public function iSeeThatCanNotCreateInTheShare($sharedWithName) {
- $this->showShareWithMenuIfNeeded($sharedWithName);
-
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10);
- Assert::assertFalse(
- $this->actor->find(self::canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked());
- }
-
- /**
- * @Then I see that resharing for :sharedWithName is not available
- */
- public function iSeeThatResharingForIsNotAvailable($sharedWithName) {
- $this->showShareWithMenuIfNeeded($sharedWithName);
-
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10);
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::canReshareCheckbox($sharedWithName, $shareWithMenuTriggerElement),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The resharing checkbox for $sharedWithName is still shown after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that :sharedWithName can reshare the share
- */
- public function iSeeThatCanReshareTheShare($sharedWithName) {
- $this->showShareWithMenuIfNeeded($sharedWithName);
-
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10);
- Assert::assertTrue(
- $this->actor->find(self::canReshareCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked());
- }
-
- /**
- * @Then I see that :sharedWithName can not reshare the share
- */
- public function iSeeThatCanNotReshareTheShare($sharedWithName) {
- $this->showShareWithMenuIfNeeded($sharedWithName);
-
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10);
- Assert::assertFalse(
- $this->actor->find(self::canReshareCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked());
- }
-
- /**
- * @Then I see that the download of the link share is hidden
- */
- public function iSeeThatTheDownloadOfTheLinkShareIsHidden() {
- $this->showShareLinkMenuIfNeeded();
-
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10);
- Assert::assertTrue($this->actor->find(self::hideDownloadCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked());
- }
-
- /**
- * @Then I see that the download of the link share is shown
- */
- public function iSeeThatTheDownloadOfTheLinkShareIsShown() {
- $this->showShareLinkMenuIfNeeded();
-
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10);
- Assert::assertFalse($this->actor->find(self::hideDownloadCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked());
- }
-
- /**
- * @Then I see that the password protect is disabled while loading
- */
- public function iSeeThatThePasswordProtectIsDisabledWhileLoading() {
- // Due to the additional time needed to find the menu trigger element it
- // could happen that the request to modify the password protect was
- // completed and the field enabled again even before finding the
- // disabled field started. Therefore, if the disabled field could not be
- // found it is just assumed that it was already enabled again.
- // Nevertheless, this check should be done anyway to ensure that the
- // following scenario steps are not executed before the request to the
- // server was done.
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10);
-
- try {
- $this->actor->find(self::disabledPasswordProtectField($shareLinkMenuTriggerElement), 5);
- } catch (NoSuchElementException $exception) {
- echo "The password protect field was not found disabled after " . (5 * $this->actor->getFindTimeoutMultiplier()) . " seconds, assumming that it was disabled and enabled again before the check started and continuing";
-
- return;
- }
-
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::disabledPasswordProtectField($shareLinkMenuTriggerElement),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The password protect field is still disabled after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the link share is password protected
- */
- public function iSeeThatTheLinkShareIsPasswordProtected() {
- $this->showShareLinkMenuIfNeeded();
-
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10);
- Assert::assertTrue($this->actor->find(self::passwordProtectCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked(), "Password protect checkbox is checked");
- Assert::assertTrue($this->actor->find(self::passwordProtectField($shareLinkMenuTriggerElement), 10)->isVisible(), "Password protect field is visible");
- }
-
- /**
- * @Then I see that the password of the link share is protected by Talk
- */
- public function iSeeThatThePasswordOfTheLinkShareIsProtectedByTalk() {
- $this->showShareLinkMenuIfNeeded();
-
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10);
- Assert::assertTrue($this->actor->find(self::passwordProtectByTalkCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked());
- }
-
- /**
- * @Then I see that the password of the link share is not protected by Talk
- */
- public function iSeeThatThePasswordOfTheLinkShareIsNotProtectedByTalk() {
- $this->showShareLinkMenuIfNeeded();
-
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10);
- Assert::assertFalse($this->actor->find(self::passwordProtectByTalkCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked());
- }
-
- /**
- * @Then I see that the checkbox to protect the password of the link share by Talk is not shown
- */
- public function iSeeThatTheCheckboxToProtectThePasswordOfTheLinkShareByTalkIsNotShown() {
- $this->showShareLinkMenuIfNeeded();
-
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10);
- try {
- Assert::assertFalse(
- $this->actor->find(self::passwordProtectByTalkCheckbox($shareLinkMenuTriggerElement))->isVisible());
- } catch (NoSuchElementException $exception) {
- }
- }
-
- /**
- * @Given I share the link for :fileName protected by the password :password
- */
- public function iShareTheLinkForProtectedByThePassword($fileName, $password) {
- $this->iShareTheLinkFor($fileName);
- $this->iProtectTheSharedLinkWithThePassword($password);
- $this->iSeeThatThePasswordProtectIsDisabledWhileLoading();
- }
-
- private function showShareLinkMenuIfNeeded() {
- $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2);
-
- // In some cases the share menu is hidden after clicking on an action of
- // the menu. Therefore, if the menu is visible, wait a little just in
- // case it is in the process of being hidden due to a previous action,
- // in which case it is shown again.
- if (WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::shareLinkMenu($shareLinkMenuTriggerElement),
- $timeout = 2 * $this->actor->getFindTimeoutMultiplier())) {
- $this->actor->find(self::shareLinkMenuButton(), 10)->click();
- }
- }
-
- private function showShareWithMenuIfNeeded($shareWithName) {
- $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($shareWithName), 2);
-
- // In some cases the share menu is hidden after clicking on an action of
- // the menu. Therefore, if the menu is visible, wait a little just in
- // case it is in the process of being hidden due to a previous action,
- // in which case it is shown again.
- if (WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::shareWithMenu($shareWithName, $shareWithMenuTriggerElement),
- $timeout = 2 * $this->actor->getFindTimeoutMultiplier())) {
- $this->actor->find(self::shareWithMenuButton($shareWithName), 10)->click();
- }
- }
-}
diff --git a/tests/acceptance/features/bootstrap/LoginPageContext.php b/tests/acceptance/features/bootstrap/LoginPageContext.php
deleted file mode 100644
index fc924bbff80..00000000000
--- a/tests/acceptance/features/bootstrap/LoginPageContext.php
+++ /dev/null
@@ -1,149 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use Behat\Behat\Hook\Scope\BeforeScenarioScope;
-use PHPUnit\Framework\Assert;
-
-class LoginPageContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @var FeatureContext
- */
- private $featureContext;
-
- /**
- * @var FilesAppContext
- */
- private $filesAppContext;
-
- public static function userNameField(): Locator {
- return Locator::forThe()->field("user")->
- describedAs("User name field in Login page");
- }
-
- public static function passwordField(): Locator {
- return Locator::forThe()->field("password")->
- describedAs("Password field in Login page");
- }
-
- public static function loginButton(): Locator {
- return Locator::forThe()->css(".button-vue[type='submit']")->
- describedAs("Login button in Login page");
- }
-
- public static function wrongPasswordMessage(): Locator {
- return Locator::forThe()->xpath("//*[@class = 'input-field__helper-text-message input-field__helper-text-message--error' and normalize-space() = 'Wrong username or password.']")->
- describedAs("Wrong password message in Login page");
- }
-
- /**
- * @return Locator
- */
- public static function userDisabledMessage() {
- return Locator::forThe()->xpath("//*[@class = 'input-field__helper-text-message input-field__helper-text-message--error' and normalize-space() = 'User disabled']")->
- describedAs('User disabled message on login page');
- }
-
- /**
- * @When I log in with user :user and password :password
- */
- public function iLogInWithUserAndPassword(string $user, string $password): void {
- $this->actor->find(self::userNameField(), 10)->setValue($user);
- $this->actor->find(self::passwordField())->setValue($password);
- $this->actor->find(self::loginButton())->click();
- }
-
- /**
- * @Then I see that the current page is the Login page
- */
- public function iSeeThatTheCurrentPageIsTheLoginPage() {
- Assert::assertStringStartsWith(
- $this->actor->locatePath("/login"),
- $this->actor->getSession()->getCurrentUrl());
- }
-
- /**
- * @Then I see that a wrong password message is shown
- */
- public function iSeeThatAWrongPasswordMessageIsShown() {
- Assert::assertTrue(
- $this->actor->find(self::wrongPasswordMessage(), 10)->isVisible());
- }
-
- /**
- * @Then I see that the disabled user message is shown
- */
- public function iSeeThatTheDisabledUserMessageIsShown() {
- Assert::assertTrue(
- $this->actor->find(self::userDisabledMessage(), 10)->isVisible());
- }
-
- /**
- * @BeforeScenario
- */
- public function getOtherRequiredSiblingContexts(BeforeScenarioScope $scope) {
- $environment = $scope->getEnvironment();
-
- $this->featureContext = $environment->getContext("FeatureContext");
- $this->filesAppContext = $environment->getContext("FilesAppContext");
- }
-
- /**
- * @Given I am logged in
- */
- public function iAmLoggedIn() {
- $this->featureContext->iVisitTheHomePage();
- $this->iLogInWithUserAndPassword("user0", "123456acb");
- $this->filesAppContext->iSeeThatTheCurrentPageIsTheFilesApp();
- }
-
- /**
- * @Given I am logged in as :userName
- */
- public function iAmLoggedInAs($userName) {
- $this->featureContext->iVisitTheHomePage();
- $this->iLogInWithUserAndPassword($userName, "123456acb");
- $this->filesAppContext->iSeeThatTheCurrentPageIsTheFilesApp();
- }
-
- /**
- * @Given I am logged in as the admin
- */
- public function iAmLoggedInAsTheAdmin() {
- $this->featureContext->iVisitTheHomePage();
- $this->iLogInWithUserAndPassword("admin", "admin");
- $this->filesAppContext->iSeeThatTheCurrentPageIsTheFilesApp();
- }
-
- /**
- * @Given I can not log in with user :user and password :password
- */
- public function iCanNotLogInWithUserAndPassword($user, $password) {
- $this->featureContext->iVisitTheHomePage();
- $this->iLogInWithUserAndPassword($user, $password);
- $this->iSeeThatTheCurrentPageIsTheLoginPage();
- $this->iSeeThatAWrongPasswordMessageIsShown();
- }
-}
diff --git a/tests/acceptance/features/bootstrap/NotificationsContext.php b/tests/acceptance/features/bootstrap/NotificationsContext.php
deleted file mode 100644
index fb8ca2a354f..00000000000
--- a/tests/acceptance/features/bootstrap/NotificationsContext.php
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2019, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-
-class NotificationsContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function notificationsButton() {
- return Locator::forThe()->css("#header #notifications.notifications-button")->
- describedAs("Notifications button in the header");
- }
-
- /**
- * @return Locator
- */
- public static function notificationsContainer() {
- return Locator::forThe()->css("#header #notifications .notification-container")->
- describedAs("Notifications container");
- }
-
- /**
- * @return Locator
- */
- public static function incomingShareNotificationForFile($fileName) {
- return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' notification ') and //div[starts-with(normalize-space(), 'You received $fileName as a share by')]]")->
- descendantOf(self::notificationsContainer())->
- describedAs("Notification of incoming share for file $fileName");
- }
-
- /**
- * @return Locator
- */
- public static function actionsInIncomingShareNotificationForFile($fileName) {
- return Locator::forThe()->css(".notification-actions")->
- descendantOf(self::incomingShareNotificationForFile($fileName))->
- describedAs("Actions in notification of incoming share for file $fileName");
- }
-
- /**
- * @return Locator
- */
- public static function actionInIncomingShareNotificationForFile($fileName, $action) {
- return Locator::forThe()->xpath("//button[normalize-space() = '$action']")->
- descendantOf(self::actionsInIncomingShareNotificationForFile($fileName))->
- describedAs("$action button in notification of incoming share for file $fileName");
- }
-
- /**
- * @return Locator
- */
- public static function acceptButtonInIncomingShareNotificationForFile($fileName) {
- return self::actionInIncomingShareNotificationForFile($fileName, 'Accept');
- }
-
- /**
- * @Given I accept the share for :fileName in the notifications
- */
- public function iAcceptTheShareForInTheNotifications($fileName) {
- $this->actor->find(self::notificationsButton(), 10)->click();
-
- // Notifications are refreshed every 30 seconds, so wait a bit longer.
- // As the waiting is long enough already the find timeout multiplier is
- // capped at 2 when finding notifications.
- $findTimeoutMultiplier = $this->actor->getFindTimeoutMultiplier();
- $this->actor->setFindTimeoutMultiplier(min(2, $findTimeoutMultiplier));
- $this->actor->find(self::acceptButtonInIncomingShareNotificationForFile($fileName), 35)->click();
- $this->actor->setFindTimeoutMultiplier($findTimeoutMultiplier);
-
- // Hide the notifications again
- $this->actor->find(self::notificationsButton(), 10)->click();
- }
-}
diff --git a/tests/acceptance/features/bootstrap/PublicShareContext.php b/tests/acceptance/features/bootstrap/PublicShareContext.php
deleted file mode 100644
index ce25afa792b..00000000000
--- a/tests/acceptance/features/bootstrap/PublicShareContext.php
+++ /dev/null
@@ -1,253 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class PublicShareContext implements Context, ActorAwareInterface {
- use ActorAware;
- use FileListAncestorSetter;
-
- /**
- * @return Locator
- */
- public static function passwordField() {
- return Locator::forThe()->field("password")->
- describedAs("Password field in Authenticate page");
- }
-
- /**
- * @return Locator
- */
- public static function authenticateButton() {
- return Locator::forThe()->id("password-submit")->
- describedAs("Authenticate button in Authenticate page");
- }
-
- /**
- * @return Locator
- */
- public static function wrongPasswordMessage() {
- return Locator::forThe()->css(".warning .wrongPasswordMsg")->
- describedAs("Wrong password message in Authenticate page");
- }
-
- /**
- * @return Locator
- */
- public static function shareMenuButton() {
- return Locator::forThe()->id("header-actions-toggle")->
- describedAs("Share menu button in Shared file page");
- }
-
- /**
- * @return Locator
- */
- public static function shareMenu() {
- return Locator::forThe()->id("header-actions-menu")->
- describedAs("Share menu in Shared file page");
- }
-
- /**
- * @return Locator
- */
- public static function downloadItemInShareMenu() {
- return Locator::forThe()->id("download")->
- descendantOf(self::shareMenu())->
- describedAs("Download item in Share menu in Shared file page");
- }
-
- /**
- * @return Locator
- */
- public static function directLinkItemInShareMenu() {
- return Locator::forThe()->id("directLink-container")->
- descendantOf(self::shareMenu())->
- describedAs("Direct link item in Share menu in Shared file page");
- }
-
- /**
- * @return Locator
- */
- public static function saveItemInShareMenu() {
- return Locator::forThe()->id("save-external-share")->
- descendantOf(self::shareMenu())->
- describedAs("Save item in Share menu in Shared file page");
- }
-
- /**
- * @return Locator
- */
- public static function textPreview() {
- return Locator::forThe()->css(".text-preview")->
- describedAs("Text preview in Shared file page");
- }
-
- /**
- * @return Locator
- */
- public static function downloadButton() {
- return Locator::forThe()->id("downloadFile")->
- describedAs("Download button in Shared file page");
- }
-
- /**
- * @When I visit the shared link I wrote down
- */
- public function iVisitTheSharedLinkIWroteDown() {
- $this->actor->getSession()->visit($this->actor->getSharedNotebook()["shared link"]);
- }
-
- /**
- * @When I visit the direct download shared link I wrote down
- */
- public function iVisitTheDirectDownloadSharedLinkIWroteDown() {
- $this->actor->getSession()->visit($this->actor->getSharedNotebook()["shared link"] . "/download");
- }
-
- /**
- * @When I authenticate with password :password
- */
- public function iAuthenticateWithPassword($password) {
- $this->actor->find(self::passwordField(), 10)->setValue($password);
- $this->actor->find(self::authenticateButton())->click();
- }
-
- /**
- * @When I open the Share menu
- */
- public function iOpenTheShareMenu() {
- $this->actor->find(self::shareMenuButton(), 10)->click();
- }
-
- /**
- * @Then I see that the current page is the Authenticate page for the shared link I wrote down
- */
- public function iSeeThatTheCurrentPageIsTheAuthenticatePageForTheSharedLinkIWroteDown() {
- Assert::assertEquals(
- $this->actor->getSharedNotebook()["shared link"] . "/authenticate/showShare",
- $this->actor->getSession()->getCurrentUrl());
- }
-
- /**
- * @Then I see that the current page is the Authenticate page for the direct download shared link I wrote down
- */
- public function iSeeThatTheCurrentPageIsTheAuthenticatePageForTheDirectDownloadSharedLinkIWroteDown() {
- Assert::assertEquals(
- $this->actor->getSharedNotebook()["shared link"] . "/authenticate/downloadShare",
- $this->actor->getSession()->getCurrentUrl());
- }
-
- /**
- * @Then I see that the current page is the shared link I wrote down
- */
- public function iSeeThatTheCurrentPageIsTheSharedLinkIWroteDown() {
- Assert::assertEquals(
- $this->actor->getSharedNotebook()["shared link"],
- $this->actor->getSession()->getCurrentUrl());
-
- $this->setFileListAncestorForActor(null, $this->actor);
- }
-
- /**
- * @Then I see that the current page is the direct download shared link I wrote down
- */
- public function iSeeThatTheCurrentPageIsTheDirectDownloadSharedLinkIWroteDown() {
- Assert::assertEquals(
- $this->actor->getSharedNotebook()["shared link"] . "/download",
- $this->actor->getSession()->getCurrentUrl());
- }
-
- /**
- * @Then I see that a wrong password for the shared file message is shown
- */
- public function iSeeThatAWrongPasswordForTheSharedFileMessageIsShown() {
- Assert::assertTrue(
- $this->actor->find(self::wrongPasswordMessage(), 10)->isVisible());
- }
-
- /**
- * @Then I see that the Share menu is shown
- */
- public function iSeeThatTheShareMenuIsShown() {
- // Unlike other menus, the Share menu is always present in the DOM, so
- // the element could be found when it was no made visible yet due to the
- // command not having been processed by the browser.
- if (!WaitFor::elementToBeEventuallyShown(
- $this->actor, self::shareMenu(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The Share menu is not visible yet after $timeout seconds");
- }
-
- // The acceptance tests are run in a window wider than the mobile breakpoint, so the
- // download item should not be shown in the menu (although it will be in
- // the DOM).
- Assert::assertFalse(
- $this->actor->find(self::downloadItemInShareMenu())->isVisible(),
- "Download item in share menu is visible");
- Assert::assertTrue(
- $this->actor->find(self::directLinkItemInShareMenu())->isVisible(),
- "Direct link item in share menu is not visible");
- Assert::assertTrue(
- $this->actor->find(self::saveItemInShareMenu())->isVisible(),
- "Save item in share menu is not visible");
- }
-
- /**
- * @Then I see that the Share menu button is not shown
- */
- public function iSeeThatTheShareMenuButtonIsNotShown() {
- try {
- Assert::assertFalse(
- $this->actor->find(self::shareMenuButton())->isVisible());
- } catch (NoSuchElementException $exception) {
- }
- }
-
- /**
- * @Then I see that the shared file preview shows the text :text
- */
- public function iSeeThatTheSharedFilePreviewShowsTheText($text) {
- Assert::assertStringContainsString($text, $this->actor->find(self::textPreview(), 10)->getText());
- }
-
- /**
- * @Then I see that the download button is shown
- */
- public function iSeeThatTheDownloadButtonIsShown() {
- if (!WaitFor::elementToBeEventuallyShown(
- $this->actor, self::downloadButton(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The download button is not visible yet after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the download button is not shown
- */
- public function iSeeThatTheDownloadButtonIsNotShown() {
- try {
- Assert::assertFalse(
- $this->actor->find(self::downloadButton())->isVisible());
- } catch (NoSuchElementException $exception) {
- }
- }
-}
diff --git a/tests/acceptance/features/bootstrap/SearchContext.php b/tests/acceptance/features/bootstrap/SearchContext.php
deleted file mode 100644
index f776c078c68..00000000000
--- a/tests/acceptance/features/bootstrap/SearchContext.php
+++ /dev/null
@@ -1,114 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class SearchContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function searchBoxInput() {
- return Locator::forThe()->css("#header .searchbox input")->
- describedAs("Search box input in the header");
- }
-
- /**
- * @return Locator
- */
- public static function searchResults() {
- return Locator::forThe()->css("#searchresults")->
- describedAs("Search results");
- }
-
- /**
- * @return Locator
- */
- public static function searchResult($number) {
- return Locator::forThe()->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' result ')][$number]")->
- descendantOf(self::searchResults())->
- describedAs("Search result $number");
- }
-
- /**
- * @return Locator
- */
- public static function searchResultName($number) {
- return Locator::forThe()->css(".name")->
- descendantOf(self::searchResult($number))->
- describedAs("Name for search result $number");
- }
-
- /**
- * @return Locator
- */
- public static function searchResultPath($number) {
- // Currently search results for comments misuse the ".path" class to
- // dim the user name, so "div.path" needs to be used to find the proper
- // path element.
- return Locator::forThe()->css("div.path")->
- descendantOf(self::searchResult($number))->
- describedAs("Path for search result $number");
- }
-
- /**
- * @return Locator
- */
- public static function searchResultLink($number) {
- return Locator::forThe()->css(".link")->
- descendantOf(self::searchResult($number))->
- describedAs("Link for search result $number");
- }
-
- /**
- * @When I search for :query
- */
- public function iSearchFor($query) {
- $this->actor->find(self::searchBoxInput(), 10)->setValue($query);
- }
-
- /**
- * @When I open the search result :number
- */
- public function iOpenTheSearchResult($number) {
- $this->actor->find(self::searchResultLink($number), 10)->click();
- }
-
- /**
- * @Then I see that the search result :number is :name
- */
- public function iSeeThatTheSearchResultIs($number, $name) {
- Assert::assertEquals(
- $name, $this->actor->find(self::searchResultName($number), 10)->getText());
- }
-
- /**
- * @Then I see that the search result :number was found in :path
- */
- public function iSeeThatTheSearchResultWasFoundIn($number, $path) {
- Assert::assertEquals(
- $path, $this->actor->find(self::searchResultPath($number), 10)->getText());
- }
-}
diff --git a/tests/acceptance/features/bootstrap/SettingsContext.php b/tests/acceptance/features/bootstrap/SettingsContext.php
deleted file mode 100644
index ae1a559a360..00000000000
--- a/tests/acceptance/features/bootstrap/SettingsContext.php
+++ /dev/null
@@ -1,283 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class SettingsContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function acceptSharesByDefaultCheckbox() {
- // forThe()->checkbox("Accept user...") can not be used here; that would
- // return the checkbox itself, but the element that the user interacts
- // with is the label.
- return Locator::forThe()->xpath("//label[normalize-space() = 'Accept user and group shares by default']")->
- describedAs("Accept shares by default checkbox in Sharing section in Personal Sharing Settings");
- }
-
- /**
- * @return Locator
- */
- public static function acceptSharesByDefaultCheckboxInput() {
- return Locator::forThe()->checkbox("Accept user and group shares by default")->
- describedAs("Accept shares by default checkbox input in Sharing section in Personal Sharing Settings");
- }
-
- /**
- * @return Locator
- */
- public static function allowResharingCheckbox() {
- // forThe()->checkbox("Allow resharing") can not be used here; that
- // would return the checkbox itself, but the element that the user
- // interacts with is the label.
- return Locator::forThe()->xpath("//label[normalize-space() = 'Allow resharing']")->
- describedAs("Allow resharing checkbox in Sharing section in Administration Sharing Settings");
- }
-
- /**
- * @return Locator
- */
- public static function allowResharingCheckboxInput() {
- return Locator::forThe()->checkbox("Allow resharing")->
- describedAs("Allow resharing checkbox input in Sharing section in Administration Sharing Settings");
- }
-
- /**
- * @return Locator
- */
- public static function restrictUsernameAutocompletionToGroupsCheckbox() {
- // forThe()->checkbox("Restrict username...") can not be used here; that
- // would return the checkbox itself, but the element that the user
- // interacts with is the label.
- return Locator::forThe()->xpath("//label[normalize-space() = 'Allow username autocompletion to users within the same groups']")->
- describedAs("Allow username autocompletion to users within the same groups checkbox in Sharing section in Administration Sharing Settings");
- }
-
- /**
- * @return Locator
- */
- public static function restrictUsernameAutocompletionToGroupsCheckboxInput() {
- return Locator::forThe()->checkbox("Allow username autocompletion to users within the same groups")->
- describedAs("Allow username autocompletion to users within the same groups checkbox input in Sharing section in Administration Sharing Settings");
- }
-
- /**
- * @return Locator
- */
- public static function systemTagsSelectTagButton() {
- return Locator::forThe()->id("s2id_systemtag")->
- describedAs("Select tag button in system tags section in Administration Settings");
- }
-
- /**
- * @return Locator
- */
- public static function systemTagsItemInDropdownForTag($tag) {
- return Locator::forThe()->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' select2-result-label ')]//span[normalize-space() = '$tag']/ancestor::li")->
- descendantOf(self::select2Dropdown())->
- describedAs("Item in dropdown for tag $tag in system tags section in Administration Settings");
- }
-
- /**
- * @return Locator
- */
- private static function select2Dropdown() {
- return Locator::forThe()->css("#select2-drop")->
- describedAs("Select2 dropdown in Settings");
- }
-
- /**
- * @return Locator
- */
- private static function select2DropdownMask() {
- return Locator::forThe()->css("#select2-drop-mask")->
- describedAs("Select2 dropdown mask in Settings");
- }
-
- /**
- * @return Locator
- */
- public static function systemTagsTagNameInput() {
- return Locator::forThe()->id("systemtag_name")->
- describedAs("Tag name input in system tags section in Administration Settings");
- }
-
- /**
- * @return Locator
- */
- public static function systemTagsCreateOrUpdateButton() {
- return Locator::forThe()->id("systemtag_submit")->
- describedAs("Create/Update button in system tags section in Administration Settings");
- }
-
- /**
- * @return Locator
- */
- public static function systemTagsResetButton() {
- return Locator::forThe()->id("systemtag_reset")->
- describedAs("Reset button in system tags section in Administration Settings");
- }
-
- /**
- * @When I disable accepting the shares by default
- */
- public function iDisableAcceptingTheSharesByDefault() {
- $this->iSeeThatSharesAreAcceptedByDefault();
-
- $this->actor->find(self::acceptSharesByDefaultCheckbox(), 2)->click();
- }
-
- /**
- * @When I disable resharing
- */
- public function iDisableResharing() {
- $this->iSeeThatResharingIsEnabled();
-
- $this->actor->find(self::allowResharingCheckbox(), 2)->click();
- }
-
- /**
- * @When I enable restricting username autocompletion to groups
- */
- public function iEnableRestrictingUsernameAutocompletionToGroups() {
- $this->iSeeThatUsernameAutocompletionIsNotRestrictedToGroups();
-
- $this->actor->find(self::restrictUsernameAutocompletionToGroupsCheckbox(), 2)->click();
- }
-
- /**
- * @When I create the tag :tag in the settings
- */
- public function iCreateTheTagInTheSettings($tag) {
- $this->actor->find(self::systemTagsResetButton(), 10)->click();
- $this->actor->find(self::systemTagsTagNameInput())->setValue($tag);
- $this->actor->find(self::systemTagsCreateOrUpdateButton())->click();
- }
-
- /**
- * @Then I see that shares are accepted by default
- */
- public function iSeeThatSharesAreAcceptedByDefault() {
- Assert::assertTrue(
- $this->actor->find(self::acceptSharesByDefaultCheckboxInput(), 10)->isChecked());
- }
-
- /**
- * @Then I see that resharing is enabled
- */
- public function iSeeThatResharingIsEnabled() {
- Assert::assertTrue(
- $this->actor->find(self::allowResharingCheckboxInput(), 10)->isChecked());
- }
-
- /**
- * @Then I see that resharing is disabled
- */
- public function iSeeThatResharingIsDisabled() {
- Assert::assertFalse(
- $this->actor->find(self::allowResharingCheckboxInput(), 10)->isChecked());
- }
-
- /**
- * @Then I see that username autocompletion is restricted to groups
- */
- public function iSeeThatUsernameAutocompletionIsRestrictedToGroups() {
- Assert::assertTrue(
- $this->actor->find(self::restrictUsernameAutocompletionToGroupsCheckboxInput(), 10)->isChecked());
- }
-
- /**
- * @Then I see that username autocompletion is not restricted to groups
- */
- public function iSeeThatUsernameAutocompletionIsNotRestrictedToGroups() {
- Assert::assertFalse(
- $this->actor->find(self::restrictUsernameAutocompletionToGroupsCheckboxInput(), 10)->isChecked());
- }
-
- /**
- * @Then I see that shares are not accepted by default
- */
- public function iSeeThatSharesAreNotAcceptedByDefault() {
- Assert::assertFalse(
- $this->actor->find(self::acceptSharesByDefaultCheckboxInput(), 10)->isChecked());
- }
-
- /**
- * @Then I see that the button to select tags is shown
- */
- public function iSeeThatTheButtonToSelectTagsIsShown() {
- Assert::assertTrue($this->actor->find(self::systemTagsSelectTagButton(), 10)->isVisible());
- }
-
- /**
- * @Then I see that the dropdown for tags in the settings eventually contains the tag :tag
- */
- public function iSeeThatTheDropdownForTagsInTheSettingsEventuallyContainsTheTag($tag) {
- // When the dropdown is opened it is not automatically updated if new
- // tags are added to the server, and when a tag is created, no explicit
- // feedback is provided to the user about the completion of that
- // operation (that is, when the tag is added to the server). Therefore,
- // to verify that creating a tag does in fact add it to the server it is
- // necessary to repeatedly open the dropdown until the tag is shown in
- // the dropdown (or the limit of tries is reached).
-
- Assert::assertTrue($this->actor->find(self::systemTagsSelectTagButton(), 10)->isVisible());
-
- $actor = $this->actor;
-
- $tagFoundInDropdownCallback = function () use ($actor, $tag) {
- // Open the dropdown to look for the tag.
- $actor->find(self::systemTagsSelectTagButton())->click();
-
- // When the dropdown is opened it is initially empty, and its
- // contents are updated once received from the server. Therefore, a
- // timeout must be used when looking for the tags.
- try {
- $tagFound = $this->actor->find(self::systemTagsItemInDropdownForTag($tag), 10)->isVisible();
- } catch (NoSuchElementException $exception) {
- $tagFound = false;
- }
-
- // Close again the dropdown after looking for the tag. When a
- // dropdown is opened Select2 creates a special element that masks
- // every other element but the dropdown to get all mouse clicks;
- // this is used by Select2 to close the dropdown when the user
- // clicks outside it.
- $actor->find(self::select2DropdownMask())->click();
-
- return $tagFound;
- };
-
- $numberOfTries = 5;
- for ($i = 0; $i < $numberOfTries; $i++) {
- if ($tagFoundInDropdownCallback()) {
- return;
- }
- }
-
- Assert::fail("The dropdown in system tags section in Administration Settings does not contain the tag $tag after $numberOfTries tries");
- }
-}
diff --git a/tests/acceptance/features/bootstrap/SettingsMenuContext.php b/tests/acceptance/features/bootstrap/SettingsMenuContext.php
deleted file mode 100644
index dfd090f921a..00000000000
--- a/tests/acceptance/features/bootstrap/SettingsMenuContext.php
+++ /dev/null
@@ -1,228 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv) (skjnldsv@protonmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class SettingsMenuContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function settingsSectionInHeader() {
- return Locator::forThe()->xpath("//*[@id = 'header']//*[@id = 'user-menu']")->
- describedAs("Settings menu section in the header");
- }
-
- /**
- * @return Locator
- */
- public static function settingsMenuButton() {
- return Locator::forThe()->css(".header-menu__trigger")->
- descendantOf(self::settingsSectionInHeader())->
- describedAs("Settings menu button");
- }
-
- /**
- * @return Locator
- */
- public static function settingsMenu() {
- return Locator::forThe()->css(".user-menu__nav")->
- descendantOf(self::settingsSectionInHeader())->
- describedAs("Settings menu");
- }
-
- /**
- * @return Locator
- */
- public static function usersMenuItem() {
- return self::menuItemFor("Users");
- }
-
- /**
- * @return Locator
- */
- public static function usersAppsItem() {
- return self::menuItemFor("Apps");
- }
-
- /**
- * @return Locator
- */
- public static function logOutMenuItem() {
- return self::menuItemFor("Log out");
- }
-
- /**
- * @return Locator
- */
- private static function menuItemFor($itemText) {
- return Locator::forThe()->xpath("//a[normalize-space() = '$itemText']")->
- descendantOf(self::settingsMenu())->
- describedAs($itemText . " item in Settings menu");
- }
-
- /**
- * @param string $itemText
- * @return Locator
- */
- private static function settingsPanelFor($itemText) {
- return Locator::forThe()->xpath("//div[@id = 'app-navigation' or contains(@class, 'app-navigation')]//ul//li[@class = 'app-navigation-caption' and normalize-space() = '$itemText']")->
- describedAs($itemText . " item in Settings panel");
- }
-
- /**
- * @param string $itemText
- * @return Locator
- */
- private static function settingsPanelEntryFor($itemText) {
- return Locator::forThe()->xpath("//div[@id = 'app-navigation' or contains(@class, 'app-navigation')]//ul//li[normalize-space() = '$itemText']")->
- describedAs($itemText . " entry in Settings panel");
- }
-
- /**
- * @return array
- */
- public function menuItems() {
- return $this->actor->find(self::settingsMenu(), 10)
- ->getWrappedElement()->findAll('xpath', '//a');
- }
-
- /**
- * @When I open the Settings menu
- */
- public function iOpenTheSettingsMenu() {
- $this->actor->find(self::settingsMenuButton(), 10)->click();
- }
-
- /**
- * @When I open the User settings
- */
- public function iOpenTheUserSettings() {
- $this->iOpenTheSettingsMenu();
-
- $this->actor->find(self::usersMenuItem(), 2)->click();
- }
-
- /**
- * @When I open the Apps management
- */
- public function iOpenTheAppsManagement() {
- $this->iOpenTheSettingsMenu();
-
- $this->actor->find(self::usersAppsItem(), 2)->click();
- }
-
- /**
- * @When I visit the settings page
- */
- public function iVisitTheSettingsPage() {
- $this->iOpenTheSettingsMenu();
- $this->actor->find(self::menuItemFor('Settings'), 2)->click();
- }
-
- /**
- * @When I visit the admin settings page
- */
- public function iVisitTheAdminSettingsPage() {
- $this->iOpenTheSettingsMenu();
- $this->actor->find(self::menuItemFor('Administration settings'), 2)->click();
- }
-
- /**
- * @When I log out
- */
- public function iLogOut() {
- $this->iOpenTheSettingsMenu();
-
- $this->actor->find(self::logOutMenuItem(), 2)->click();
- }
-
- /**
- * @Then I see that the Settings menu is shown
- */
- public function iSeeThatTheSettingsMenuIsShown() {
- Assert::assertTrue(
- $this->actor->find(self::settingsMenu(), 10)->isVisible());
- }
-
- /**
- * @Then I see that the Settings menu has only :items items
- */
- public function iSeeThatTheSettingsMenuHasOnlyXItems($items) {
- Assert::assertCount(intval($items), self::menuItems());
- }
-
- /**
- * @Then I see that the :itemText item in the Settings menu is shown
- */
- public function iSeeThatTheItemInTheSettingsMenuIsShown($itemText) {
- Assert::assertTrue(
- $this->actor->find(self::menuItemFor($itemText), 10)->isVisible());
- }
-
- /**
- * @Then I see that the :itemText item in the Settings menu is not shown
- */
- public function iSeeThatTheItemInTheSettingsMenuIsNotShown($itemText) {
- $this->iSeeThatTheSettingsMenuIsShown();
-
- try {
- Assert::assertFalse(
- $this->actor->find(self::menuItemFor($itemText))->isVisible());
- } catch (NoSuchElementException $exception) {
- }
- }
-
- /**
- * @Then I see that the :itemText settings panel is shown
- */
- public function iSeeThatTheItemSettingsPanelIsShown($itemText) {
- Assert::assertTrue(
- $this->actor->find(self::settingsPanelFor($itemText), 10)->isVisible()
- );
- }
-
- /**
- * @Then I see that the :itemText entry in the settings panel is shown
- */
- public function iSeeThatTheItemEntryInTheSettingsPanelIsShown($itemText) {
- Assert::assertTrue(
- $this->actor->find(self::settingsPanelEntryFor($itemText), 10)->isVisible()
- );
- }
-
- /**
- * @Then I see that the :itemText settings panel is not shown
- */
- public function iSeeThatTheItemSettingsPanelIsNotShown($itemText) {
- try {
- Assert::assertFalse(
- $this->actor->find(self::settingsPanelFor($itemText), 10)->isVisible()
- );
- } catch (NoSuchElementException $exception) {
- }
- }
-}
diff --git a/tests/acceptance/features/bootstrap/ThemingAppContext.php b/tests/acceptance/features/bootstrap/ThemingAppContext.php
deleted file mode 100644
index e680a3ca55c..00000000000
--- a/tests/acceptance/features/bootstrap/ThemingAppContext.php
+++ /dev/null
@@ -1,186 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class ThemingAppContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function inputFieldFor($parameterName) {
- return Locator::forThe()->css("input")->
- descendantOf(self::parameterDivFor($parameterName))->
- describedAs("Input field for $parameterName parameter in Theming app");
- }
-
- /**
- * @return Locator
- */
- public static function resetButtonFor($parameterName) {
- return Locator::forThe()->css(".theme-undo")->
- descendantOf(self::parameterDivFor($parameterName))->
- describedAs("Reset button for $parameterName parameter in Theming app");
- }
-
- /**
- * @return Locator
- */
- private static function parameterDivFor($parameterName) {
- return Locator::forThe()->xpath("//*[@id='theming']//label//*[normalize-space() = '$parameterName']/ancestor::div[1]")->
- describedAs("Div for $parameterName parameter in Theming app");
- }
-
- /**
- * @return Locator
- */
- public static function statusMessage() {
- return Locator::forThe()->id("theming_settings_msg")->
- describedAs("Status message in Theming app");
- }
-
- /**
- * @When I set the :parameterName parameter in the Theming app to :parameterValue
- */
- public function iSetTheParameterInTheThemingAppTo($parameterName, $parameterValue) {
- $this->actor->find(self::inputFieldFor($parameterName), 10)->setValue($parameterValue);
- }
-
- /**
- * @When I reset the :parameterName parameter in the Theming app to its default value
- */
- public function iSetTheParameterInTheThemingAppToItsDefaultValue($parameterName) {
- // The reset button is not shown when the cursor is outside the input
- // field, so ensure that the cursor is on the input field by clicking on
- // it.
- $this->actor->find(self::inputFieldFor($parameterName), 10)->click();
-
- $this->actor->find(self::resetButtonFor($parameterName), 10)->click();
- }
-
- /**
- * @Then I see that the color selector in the Theming app has loaded
- */
- public function iSeeThatTheColorSelectorInTheThemingAppHasLoaded() {
- // Checking if the color selector has loaded by getting the background color
- // of the input element. If the value present in the element matches the
- // background of the input element, it means the color element has been
- // initialized.
-
- Assert::assertTrue($this->actor->find(self::inputFieldFor("Color"), 10)->isVisible());
-
- $actor = $this->actor;
-
- $colorSelectorLoadedCallback = function () use ($actor) {
- $colorSelectorValue = $this->getRGBArray($actor->getSession()->evaluateScript("return $('#admin-theming-color').text().trim();"));
- $inputBgColorRgb = $this->getRGBArray($actor->getSession()->evaluateScript("return $('#admin-theming-color').css('background-color');"));
-
- $matches = [];
- preg_match_all('/\d+/', $inputBgColorRgb, $matches);
- $inputBgColorHex = sprintf("#%02x%02x%02x", $matches[0][0], $matches[0][1], $matches[0][2]);
-
- if ($colorSelectorValue == $inputBgColorHex) {
- return true;
- }
-
- return false;
- };
-
- if (!Utils::waitFor($colorSelectorLoadedCallback, $timeout = 10 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) {
- Assert::fail("The color selector in Theming app has not been loaded after $timeout seconds");
- }
- }
-
- private function getRGBArray($color) {
- if (preg_match("/rgb\(\s*(\d+),\s*(\d+),\s*(\d+)\)/", $color, $matches)) {
- // Already an RGB (R, G, B) color
- // Convert from "rgb(R, G, B)" string to RGB array
- $tmpColor = array_splice($matches, 1);
- } elseif ($color[0] === '#') {
- $color = substr($color, 1);
- // HEX Color, convert to RGB array.
- $tmpColor = sscanf($color, "%02X%02X%02X");
- } else {
- Assert::fail("The acceptance test does not know how to handle the color string : '$color'. "
- . "Please provide # before HEX colors in your features.");
- }
- return $tmpColor;
- }
-
- /**
- * @Then I see that the primary color is eventually :color
- */
- public function iSeeThatThePrimaryColorIsEventually($color) {
- $primaryColorMatchesCallback = function () use ($color) {
- $primaryColor = $this->actor->getSession()->evaluateScript("return getComputedStyle(document.documentElement).getPropertyValue('--color-primary').trim();");
- $primaryColor = $this->getRGBArray($primaryColor);
- $color = $this->getRGBArray($color);
-
- return $primaryColor == $color;
- };
-
- if (!Utils::waitFor($primaryColorMatchesCallback, $timeout = 10 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) {
- Assert::fail("The primary color is not $color yet after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the non-plain background color variable is eventually :color
- */
- public function iSeeThatTheNonPlainBackgroundColorVariableIsEventually($color) {
- $colorVariableMatchesCallback = function () use ($color) {
- $colorVariable = $this->actor->getSession()->evaluateScript("return getComputedStyle(document.documentElement).getPropertyValue('--color-primary-default').trim();");
- $colorVariable = $this->getRGBArray($colorVariable);
- $color = $this->getRGBArray($color);
-
- return $colorVariable == $color;
- };
-
- if (!Utils::waitFor($colorVariableMatchesCallback, $timeout = 10 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) {
- Assert::fail("The non-plain background color variable is not $color yet after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the parameters in the Theming app are eventually saved
- */
- public function iSeeThatTheParametersInTheThemingAppAreEventuallySaved() {
- Assert::assertTrue($this->actor->find(self::statusMessage(), 10)->isVisible());
-
- $actor = $this->actor;
-
- $savedStatusMessageShownCallback = function () use ($actor) {
- if ($actor->find(self::statusMessage())->getText() !== "Saved") {
- return false;
- }
-
- return true;
- };
-
- if (!Utils::waitFor($savedStatusMessageShownCallback, $timeout = 10 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) {
- Assert::fail("The 'Saved' status messages in Theming app has not been shown after $timeout seconds");
- }
- }
-}
diff --git a/tests/acceptance/features/bootstrap/ToastContext.php b/tests/acceptance/features/bootstrap/ToastContext.php
deleted file mode 100644
index 7ca3df2f47e..00000000000
--- a/tests/acceptance/features/bootstrap/ToastContext.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-
-class ToastContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function toastMessage($message) {
- return Locator::forThe()->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' toastify ') and normalize-space(text()) = '$message']")->
- descendantOf(self::toastContainer())->
- describedAs("$message toast");
- }
-
- /**
- * @return Locator
- */
- private static function toastContainer() {
- return Locator::forThe()->xpath("//*[@id=\"content\" or contains(@class, 'content')]")->
- describedAs("Toast container");
- }
-
- /**
- * @Then I see that the :message toast is shown
- */
- public function iSeeThatTheToastIsShown($message) {
- Assert::assertTrue($this->actor->find(
- self::toastMessage($message), 10)->isVisible());
- }
-}
diff --git a/tests/acceptance/features/bootstrap/UsersSettingsContext.php b/tests/acceptance/features/bootstrap/UsersSettingsContext.php
deleted file mode 100644
index 3ed74788e7e..00000000000
--- a/tests/acceptance/features/bootstrap/UsersSettingsContext.php
+++ /dev/null
@@ -1,379 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- * @copyright Copyright (c) 2018, John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
- * @copyright Copyright (c) 2019, Greta Doci <gretadoci@gmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use PHPUnit\Framework\Assert;
-use WebDriver\Key;
-
-class UsersSettingsContext implements Context, ActorAwareInterface {
- use ActorAware;
-
- /**
- * @return Locator
- */
- public static function newUserForm() {
- return Locator::forThe()->css('[data-test="form"]')->
- describedAs("New user form in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function userNameFieldForNewUser() {
- return Locator::forThe()->css('[data-test="username"]')->
- describedAs("User name field for new user in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function displayNameFieldForNewUser() {
- return Locator::forThe()->css('[data-test="displayName"]')->
- describedAs("Display name field for new user in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function passwordFieldForNewUser() {
- return Locator::forThe()->css('[data-test="password"]')->
- describedAs("Password field for new user in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function newUserButton() {
- return Locator::forThe()->id("new-user-button")->
- describedAs("New user button in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function createNewUserButton() {
- return Locator::forThe()->css('[data-test="submit"]')->
- describedAs("Create user button in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function rowForUser($user) {
- return Locator::forThe()->xpath("//tbody[contains(@class, 'user-list__body')]/tr[td[@data-test='$user']]")->
- describedAs("Row for user $user in Users Settings");
- }
-
- /**
- * Warning: you need to watch out for the proper classes order
- *
- * @return Locator
- */
- public static function classCellForUser($class, $user) {
- return Locator::forThe()->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' $class ')]")->
- descendantOf(self::rowForUser($user))->
- describedAs("$class cell for user $user in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function inputForUserInCell($cell, $user) {
- return Locator::forThe()->css("input")->
- descendantOf(self::classCellForUser($cell, $user))->
- describedAs("$cell input for user $user in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function displayNameCellForUser($user) {
- return self::inputForUserInCell("displayName", $user);
- }
-
- /**
- * @return Locator
- */
- public static function optionInInputForUser($cell, $user) {
- return Locator::forThe()->css(".vs__dropdown-option--highlight")->
- describedAs("Selected $cell option in $cell input for user $user in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function actionsMenuOf($user) {
- return Locator::forThe()->css(".userActions .action-item:not(.action-item--single)")->
- descendantOf(self::rowForUser($user))->
- describedAs("Actions menu for user $user in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function theAction($action, $user) {
- return Locator::forThe()->xpath("//button[@aria-label = normalize-space('$action')]")->
- describedAs("$action action for the user $user row in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function theColumn($column) {
- return Locator::forThe()->xpath("//div[@class='user-list-grid']//div[normalize-space() = '$column']")->
- describedAs("The $column column in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function selectedSelectOption($cell, $user) {
- return Locator::forThe()->css(".vs__selected .name-parts")->
- descendantOf(self::classCellForUser($cell, $user))->
- describedAs("The selected option of the $cell select for the user $user in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function editModeToggle($user) {
- return Locator::forThe()->css(".userActions .action-items button:first-of-type")->
- descendantOf(self::rowForUser($user))->
- describedAs("The edit toggle button for the user $user in Users Settings");
- }
-
- /**
- * @return Locator
- */
- public static function editModeOn($user) {
- return Locator::forThe()->css("div.user-list-grid div.row.row--editable[data-id=$user]")->
- describedAs("I see the edit mode is on for the user $user in Users Settings");
- }
-
- /**
- * @When I click the New user button
- */
- public function iClickTheNewUserButton() {
- $this->actor->find(self::newUserButton(), 10)->click();
- }
-
- /**
- * @When I click the :action action in the :user actions menu
- */
- public function iClickTheAction($action, $user) {
- $this->actor->find(self::theAction($action, $user), 10)->click();
- }
-
- /**
- * @When I open the actions menu for the user :user
- */
- public function iOpenTheActionsMenuOf($user) {
- $this->actor->find(self::actionsMenuOf($user), 10)->click();
- }
-
- /**
- * @When I set the user name for the new user to :user
- */
- public function iSetTheUserNameForTheNewUserTo($user) {
- $this->actor->find(self::userNameFieldForNewUser(), 10)->setValue($user);
- }
-
- /**
- * @When I set the display name for the new user to :displayName
- */
- public function iSetTheDisplayNameForTheNewUserTo($displayName) {
- $this->actor->find(self::displayNameFieldForNewUser(), 10)->setValue($displayName);
- }
-
- /**
- * @When I set the password for the new user to :password
- */
- public function iSetThePasswordForTheNewUserTo($password) {
- $this->actor->find(self::passwordFieldForNewUser(), 10)->setValue($password);
- }
-
- /**
- * @When I create the new user
- */
- public function iCreateTheNewUser() {
- $this->actor->find(self::createNewUserButton(), 10)->click();
- }
-
- /**
- * @When I toggle the edit mode for the user :user
- */
- public function iToggleTheEditModeForUser($user) {
- $this->actor->find(self::editModeToggle($user), 10)->click();
- }
-
- /**
- * @When I create user :user with password :password
- */
- public function iCreateUserWithPassword($user, $password) {
- $this->actor->find(self::userNameFieldForNewUser(), 10)->setValue($user);
- $this->actor->find(self::passwordFieldForNewUser())->setValue($password);
- $this->actor->find(self::createNewUserButton())->click();
- }
-
- /**
- * @When I set the :field for :user to :value
- */
- public function iSetTheFieldForUserTo($field, $user, $value) {
- $this->actor->find(self::inputForUserInCell($field, $user), 2)->setValue($value . Key::ENTER);
- }
-
- /**
- * Assigning/withdrawing is the same action (it toggles).
- *
- * @When I assign the user :user to the group :group
- * @When I withdraw the user :user from the group :group
- */
- public function iAssignTheUserToTheGroup($user, $group) {
- $this->actor->find(self::inputForUserInCell('groups', $user))->setValue($group);
- $this->actor->find(self::optionInInputForUser('groups', $user))->click();
- }
-
- /**
- * @When I set the user :user quota to :quota
- */
- public function iSetTheUserQuotaTo($user, $quota) {
- $this->actor->find(self::inputForUserInCell('quota', $user))->setValue($quota);
- $this->actor->find(self::optionInInputForUser('quota', $user))->click();
- }
-
- /**
- * @Then I see that the list of users contains the user :user
- */
- public function iSeeThatTheListOfUsersContainsTheUser($user) {
- if (!WaitFor::elementToBeEventuallyShown(
- $this->actor,
- self::rowForUser($user),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The user $user in the list of users is not shown yet after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the list of users does not contains the user :user
- */
- public function iSeeThatTheListOfUsersDoesNotContainsTheUser($user) {
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::rowForUser($user),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The user $user in the list of users is still shown after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the new user form is shown
- */
- public function iSeeThatTheNewUserFormIsShown() {
- if (!WaitFor::elementToBeEventuallyShown(
- $this->actor,
- self::newUserForm(),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The new user form is not shown yet after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the :action action in the :user actions menu is shown
- */
- public function iSeeTheAction($action, $user) {
- Assert::assertTrue(
- $this->actor->find(self::theAction($action, $user), 10)->isVisible());
- }
-
- /**
- * @Then I see that the :column column is shown
- */
- public function iSeeThatTheColumnIsShown($column) {
- Assert::assertTrue(
- $this->actor->find(self::theColumn($column), 10)->isVisible());
- }
-
- /**
- * @Then I see that the :field of :user is :value
- */
- public function iSeeThatTheFieldOfUserIs($field, $user, $value) {
- Assert::assertEquals(
- $this->actor->find(self::inputForUserInCell($field, $user), 10)->getValue(), $value);
- }
-
- /**
- * @Then I see that the display name for the user :user is :displayName
- */
- public function iSeeThatTheDisplayNameForTheUserIs($user, $displayName) {
- Assert::assertEquals(
- $displayName, $this->actor->find(self::displayNameCellForUser($user), 10)->getValue());
- }
-
- /**
- * @Then I see that the :cell cell for user :user is done loading
- */
- public function iSeeThatTheCellForUserIsDoneLoading($cell, $user) {
- // It could happen that the cell for the user was done loading and thus
- // the loading icon hidden again even before finding the loading icon
- // started. Therefore, if the loading icon could not be found it is just
- // assumed that it was already hidden again. Nevertheless, this check
- // should be done anyway to ensure that the following scenario steps are
- // not executed before the cell for the user was done loading.
- try {
- $this->actor->find(self::classCellForUser($cell . ' icon-loading-small', $user), 1);
- } catch (NoSuchElementException $exception) {
- echo "The loading icon for user $user was not found after " . (1 * $this->actor->getFindTimeoutMultiplier()) . " seconds, assumming that it was shown and hidden again before the check started and continuing";
-
- return;
- }
-
- if (!WaitFor::elementToBeEventuallyNotShown(
- $this->actor,
- self::classCellForUser($cell . ' icon-loading-small', $user),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The loading icon for user $user is still shown after $timeout seconds");
- }
- }
-
- /**
- * @Then I see that the user quota of :user is :quota
- */
- public function iSeeThatTheuserQuotaIs($user, $quota) {
- Assert::assertEquals(
- $this->actor->find(self::selectedSelectOption('quota', $user), 2)->getText(), $quota);
- }
-
- /**
- * @Then I see that the edit mode is on for user :user
- */
- public function iSeeThatTheEditModeIsOn($user) {
- if (!WaitFor::elementToBeEventuallyShown(
- $this->actor,
- self::editModeOn($user),
- $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
- Assert::fail("The edit mode for user $user in the list of users is not on yet after $timeout seconds");
- }
- }
-}
diff --git a/tests/acceptance/features/bootstrap/WaitFor.php b/tests/acceptance/features/bootstrap/WaitFor.php
deleted file mode 100644
index 37a268360aa..00000000000
--- a/tests/acceptance/features/bootstrap/WaitFor.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * Helper class with common "wait for" functions.
- */
-class WaitFor {
- /**
- * Waits for the element to be visible.
- *
- * @param Actor $actor the Actor used to find the element.
- * @param Locator $elementLocator the locator for the element.
- * @param float $timeout the number of seconds (decimals allowed) to wait at
- * most for the element to be visible.
- * @param float $timeoutStep the number of seconds (decimals allowed) to
- * wait before checking the visibility again.
- * @return boolean true if the element is visible before (or exactly when)
- * the timeout expires, false otherwise.
- */
- public static function elementToBeEventuallyShown(Actor $actor, Locator $elementLocator, $timeout = 10, $timeoutStep = 1) {
- $elementShownCallback = function () use ($actor, $elementLocator) {
- try {
- return $actor->find($elementLocator)->isVisible();
- } catch (NoSuchElementException $exception) {
- return false;
- }
- };
-
- return Utils::waitFor($elementShownCallback, $timeout, $timeoutStep);
- }
-
- /**
- * Waits for the element to be hidden (either not visible or not found in
- * the DOM).
- *
- * @param Actor $actor the Actor used to find the element.
- * @param Locator $elementLocator the locator for the element.
- * @param float $timeout the number of seconds (decimals allowed) to wait at
- * most for the element to be hidden.
- * @param float $timeoutStep the number of seconds (decimals allowed) to
- * wait before checking the visibility again.
- * @return boolean true if the element is hidden before (or exactly when)
- * the timeout expires, false otherwise.
- */
- public static function elementToBeEventuallyNotShown(Actor $actor, Locator $elementLocator, $timeout = 10, $timeoutStep = 1) {
- $elementNotShownCallback = function () use ($actor, $elementLocator) {
- try {
- return !$actor->find($elementLocator)->isVisible();
- } catch (NoSuchElementException $exception) {
- return true;
- }
- };
-
- return Utils::waitFor($elementNotShownCallback, $timeout, $timeoutStep);
- }
-}
diff --git a/tests/acceptance/features/core/Actor.php b/tests/acceptance/features/core/Actor.php
deleted file mode 100644
index abe9a390920..00000000000
--- a/tests/acceptance/features/core/Actor.php
+++ /dev/null
@@ -1,214 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * An actor in a test scenario.
- *
- * Every Actor object is intended to be used only in a single test scenario.
- * An Actor can control its web browser thanks to the Mink Session received when
- * it was created, so in each scenario each Actor must have its own Mink
- * Session; the same Mink Session can be used by different Actors in different
- * scenarios, but never by different Actors in the same scenario.
- *
- * The test servers used in an scenario can change between different test runs,
- * so an Actor stores the base URL for the current test server being used; in
- * most cases the tests are specified using relative paths that can be converted
- * to the appropriate absolute URL using locatePath() in the step
- * implementation.
- *
- * An Actor can find elements in its Mink Session using its find() method; it is
- * a wrapper over the find() method provided by Mink that extends it with
- * several features: the element can be looked for based on a Locator object, an
- * exception is thrown if the element is not found, and, optionally, it is
- * possible to try again to find the element several times before giving up.
- *
- * The returned object is also a wrapper over the element itself that
- * automatically handles common causes of failed commands, like clicking on a
- * hidden element; in this case, the wrapper would wait for the element to be
- * visible up to the timeout set to find the element.
- *
- * The amount of time to wait before giving up is specified in each call to
- * find(). However, a general multiplier to be applied to every timeout can be
- * set using setFindTimeoutMultiplier(); this makes possible to retry longer
- * before giving up without modifying the tests themselves. Note that the
- * multiplier affects the timeout, but not the timeout step; the rate at which
- * find() will try again to find the element does not change.
- *
- * All actors share a notebook in which data can be annotated. This makes
- * possible to share data between different test steps, no matter which Actor
- * performs them.
- */
-class Actor {
- /**
- * @var string
- */
- private $name;
-
- /**
- * @var \Behat\Mink\Session
- */
- private $session;
-
- /**
- * @var string
- */
- private $baseUrl;
-
- /**
- * @var float
- */
- private $findTimeoutMultiplier;
-
- /**
- * @var array
- */
- private $sharedNotebook;
-
- /**
- * Creates a new Actor.
- *
- * @param string $name the name of the actor.
- * @param \Behat\Mink\Session $session the Mink Session used to control its
- * web browser.
- * @param string $baseUrl the base URL used when solving relative URLs.
- * @param array $sharedNotebook the notebook shared between all actors.
- */
- public function __construct($name, \Behat\Mink\Session $session, $baseUrl, &$sharedNotebook) {
- $this->name = $name;
- $this->session = $session;
- $this->baseUrl = $baseUrl;
- $this->sharedNotebook = &$sharedNotebook;
- $this->findTimeoutMultiplier = 1;
- }
-
- /**
- * Returns the name of this Actor.
- *
- * @return string the name of this Actor.
- */
- public function getName() {
- return $this->name;
- }
-
- /**
- * Sets the base URL.
- *
- * @param string $baseUrl the base URL used when solving relative URLs.
- */
- public function setBaseUrl($baseUrl) {
- $this->baseUrl = $baseUrl;
- }
-
- /**
- * Returns the multiplier for find timeouts.
- *
- * @return float the multiplier to apply to find timeouts.
- */
- public function getFindTimeoutMultiplier() {
- return $this->findTimeoutMultiplier;
- }
-
- /**
- * Sets the multiplier for find timeouts.
- *
- * @param float $findTimeoutMultiplier the multiplier to apply to find
- * timeouts.
- */
- public function setFindTimeoutMultiplier($findTimeoutMultiplier) {
- $this->findTimeoutMultiplier = $findTimeoutMultiplier;
- }
-
- /**
- * Returns the Mink Session used to control its web browser.
- *
- * @return \Behat\Mink\Session the Mink Session used to control its web
- * browser.
- */
- public function getSession() {
- return $this->session;
- }
-
- /**
- * Returns the full path for the given relative path based on the base URL.
- *
- * @param string relativePath the relative path.
- * @return string the full path.
- */
- public function locatePath($relativePath) {
- return $this->baseUrl . $relativePath;
- }
-
- /**
- * Finds an element in the Mink Session of this Actor.
- *
- * The given element locator is relative to its ancestor (either another
- * locator or an actual element); if it has no ancestor then the base
- * document element is used.
- *
- * Sometimes an element may not be found simply because it has not appeared
- * yet; for those cases this method supports trying again to find the
- * element several times before giving up. The timeout parameter controls
- * how much time to wait, at most, to find the element; the timeoutStep
- * parameter controls how much time to wait before trying again to find the
- * element. If ancestor locators need to be found the timeout is applied
- * individually to each one, that is, if the timeout is 10 seconds the
- * method will wait up to 10 seconds to find the ancestor of the ancestor
- * and, then, up to 10 seconds to find the ancestor and, then, up to 10
- * seconds to find the element. By default the timeout is 0, so the element
- * and its ancestor will be looked for just once; the default time to wait
- * before retrying is half a second. If the timeout is not 0 it will be
- * affected by the multiplier set using setFindTimeoutMultiplier(), if any.
- *
- * When found, the element is returned wrapped in an ElementWrapper; the
- * ElementWrapper handles common causes of failures when executing commands
- * in an element, like clicking on a hidden element.
- *
- * In any case, if the element, or its ancestors, can not be found a
- * NoSuchElementException is thrown.
- *
- * @param Locator $elementLocator the locator for the element.
- * @param float $timeout the number of seconds (decimals allowed) to wait at
- * most for the element to appear.
- * @param float $timeoutStep the number of seconds (decimals allowed) to
- * wait before trying to find the element again.
- * @return ElementWrapper an ElementWrapper object for the element.
- * @throws NoSuchElementException if the element, or its ancestor, can not
- * be found.
- */
- public function find(Locator $elementLocator, $timeout = 0, $timeoutStep = 0.5) {
- $timeout = $timeout * $this->findTimeoutMultiplier;
-
- $elementFinder = new ElementFinder($this->session, $elementLocator, $timeout, $timeoutStep);
-
- return new ElementWrapper($elementFinder);
- }
-
- /**
- * Returns the shared notebook of the Actors.
- *
- * @return array the shared notebook of the Actors.
- */
- public function &getSharedNotebook() {
- return $this->sharedNotebook;
- }
-}
diff --git a/tests/acceptance/features/core/ActorAware.php b/tests/acceptance/features/core/ActorAware.php
deleted file mode 100644
index c734d7e1906..00000000000
--- a/tests/acceptance/features/core/ActorAware.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-trait ActorAware {
- /**
- * @var Actor
- */
- protected $actor;
-
- /**
- * @param Actor $actor
- */
- public function setCurrentActor(Actor $actor) {
- $this->actor = $actor;
- }
-}
diff --git a/tests/acceptance/features/core/ActorAwareInterface.php b/tests/acceptance/features/core/ActorAwareInterface.php
deleted file mode 100644
index 7b855aed4d3..00000000000
--- a/tests/acceptance/features/core/ActorAwareInterface.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-interface ActorAwareInterface {
- /**
- * @param Actor $actor
- */
- public function setCurrentActor(Actor $actor);
-}
diff --git a/tests/acceptance/features/core/ActorContext.php b/tests/acceptance/features/core/ActorContext.php
deleted file mode 100644
index 7f152a1f3eb..00000000000
--- a/tests/acceptance/features/core/ActorContext.php
+++ /dev/null
@@ -1,194 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Hook\Scope\BeforeStepScope;
-use Behat\MinkExtension\Context\RawMinkContext;
-
-/**
- * Behat context to set the actor used in sibling contexts.
- *
- * This helper context provides a step definition ("I act as XXX") to change the
- * current actor of the scenario, which makes possible to use different browser
- * sessions in the same scenario.
- *
- * Sibling contexts that want to have access to the current actor of the
- * scenario must implement the ActorAwareInterface; this can be done just by
- * using the ActorAware trait.
- *
- * Besides updating the current actor in sibling contexts the ActorContext also
- * propagates its inherited "base_url" Mink parameter to the Actors as needed.
- *
- * By default no multiplier for the find timeout is set in the Actors. However,
- * it can be customized using the "actorTimeoutMultiplier" parameter of the
- * ActorContext in "behat.yml". This parameter also affects the overall timeout
- * to start a session for an Actor before giving up.
- *
- * Every actor used in the scenarios must have a corresponding Mink session
- * declared in "behat.yml" with the same name as the actor. All used sessions
- * are stopped after each scenario is run.
- */
-class ActorContext extends RawMinkContext {
- /**
- * @var array
- */
- private $actors;
-
- /**
- * @var array
- */
- private $sharedNotebook;
-
- /**
- * @var Actor
- */
- private $currentActor;
-
- /**
- * @var float
- */
- private $actorTimeoutMultiplier;
-
- /**
- * Creates a new ActorContext.
- *
- * @param float $actorTimeoutMultiplier the timeout multiplier for Actor
- * related timeouts.
- */
- public function __construct($actorTimeoutMultiplier = 1) {
- $this->actorTimeoutMultiplier = $actorTimeoutMultiplier;
- }
-
- /**
- * Sets a Mink parameter.
- *
- * When the "base_url" parameter is set its value is propagated to all the
- * Actors.
- *
- * @param string $name the name of the parameter.
- * @param string $value the value of the parameter.
- */
- public function setMinkParameter($name, $value) {
- parent::setMinkParameter($name, $value);
-
- if ($name === "base_url") {
- foreach ($this->actors as $actor) {
- $actor->setBaseUrl($value);
- }
- }
- }
-
- /**
- * Returns the session with the given name.
- *
- * If the session is not started it is started before returning it; if the
- * session fails to start (typically due to a timeout connecting with the
- * web browser) it will be tried again up to $actorTimeoutMultiplier times
- * in total (rounded up to the next integer) before giving up.
- *
- * @param string|null $sname the name of the session to get, or null for the
- * default session.
- * @return \Behat\Mink\Session the session.
- */
- public function getSession($name = null) {
- for ($i = 0; $i < ($this->actorTimeoutMultiplier - 1); $i++) {
- try {
- return parent::getSession($name);
- } catch (\Behat\Mink\Exception\DriverException $exception) {
- echo "Exception when getting " . ($name == null? "default session": "session '$name'") . ": " . $exception->getMessage() . "\n";
- echo "Trying again\n";
- }
- }
-
- return parent::getSession($name);
- }
-
- /**
- * @BeforeScenario
- *
- * Initializes the Actors for the new Scenario with the default Actor.
- *
- * Other Actors are added (and their Mink Sessions started) only when they
- * are used in an "I act as XXX" step.
- */
- public function initializeActors() {
- $this->actors = [];
- $this->sharedNotebook = [];
-
- $this->getSession()->start();
-
- $this->getSession()->maximizeWindow();
-
- $this->actors["default"] = new Actor("default", $this->getSession(), $this->getMinkParameter("base_url"), $this->sharedNotebook);
- $this->actors["default"]->setFindTimeoutMultiplier($this->actorTimeoutMultiplier);
-
- $this->currentActor = $this->actors["default"];
- }
-
- /**
- * @BeforeStep
- */
- public function setCurrentActorInSiblingActorAwareContexts(BeforeStepScope $scope) {
- $environment = $scope->getEnvironment();
-
- foreach ($environment->getContexts() as $context) {
- if ($context instanceof ActorAwareInterface) {
- $context->setCurrentActor($this->currentActor);
- }
- }
- }
-
- /**
- * @Given I act as :actorName
- */
- public function iActAs($actorName) {
- if (!array_key_exists($actorName, $this->actors)) {
- $this->getSession($actorName)->start();
-
- $this->getSession($actorName)->maximizeWindow();
-
- $this->actors[$actorName] = new Actor($actorName, $this->getSession($actorName), $this->getMinkParameter("base_url"), $this->sharedNotebook);
- $this->actors[$actorName]->setFindTimeoutMultiplier($this->actorTimeoutMultiplier);
- }
-
- $this->currentActor = $this->actors[$actorName];
-
- // Ensure that the browser window of the actor is the one in the
- // foreground; this works around a bug in the Firefox driver of Selenium
- // and/or maybe in Firefox itself when interacting with a window in the
- // background, but also reflects better how the user would interact with
- // the browser in real life.
- $session = $this->actors[$actorName]->getSession();
- $session->switchToWindow($session->getWindowName());
- }
-
- /**
- * @AfterScenario
- *
- * Stops all the Mink Sessions used in the last Scenario.
- */
- public function cleanUpSessions() {
- foreach ($this->actors as $actor) {
- $actor->getSession()->stop();
- }
- }
-}
diff --git a/tests/acceptance/features/core/ElementFinder.php b/tests/acceptance/features/core/ElementFinder.php
deleted file mode 100644
index 714b100bfa2..00000000000
--- a/tests/acceptance/features/core/ElementFinder.php
+++ /dev/null
@@ -1,203 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * Command object to find Mink elements.
- *
- * The element locator is relative to its ancestor (either another locator or an
- * actual element); if it has no ancestor then the base document element is
- * used.
- *
- * Sometimes an element may not be found simply because it has not appeared yet;
- * for those cases ElementFinder supports trying again to find the element
- * several times before giving up. The timeout parameter controls how much time
- * to wait, at most, to find the element; the timeoutStep parameter controls how
- * much time to wait before trying again to find the element. If ancestor
- * locators need to be found the timeout is applied individually to each one,
- * that is, if the timeout is 10 seconds the method will wait up to 10 seconds
- * to find the ancestor of the ancestor and, then, up to 10 seconds to find the
- * ancestor and, then, up to 10 seconds to find the element. By default the
- * timeout is 0, so the element and its ancestor will be looked for just once;
- * the default time to wait before retrying is half a second.
- *
- * In any case, if the element, or its ancestors, can not be found a
- * NoSuchElementException is thrown.
- */
-class ElementFinder {
- /**
- * Finds an element in the given Mink Session.
- *
- * @see ElementFinder
- */
- private static function findInternal(\Behat\Mink\Session $session, Locator $elementLocator, $timeout, $timeoutStep) {
- $element = null;
- $selector = $elementLocator->getSelector();
- $locator = $elementLocator->getLocator();
- $ancestorElement = self::findAncestorElement($session, $elementLocator, $timeout, $timeoutStep);
-
- $findCallback = function () use (&$element, $selector, $locator, $ancestorElement) {
- $element = $ancestorElement->find($selector, $locator);
-
- return $element !== null;
- };
- if (!Utils::waitFor($findCallback, $timeout, $timeoutStep)) {
- $message = $elementLocator->getDescription() . " could not be found";
- if ($timeout > 0) {
- $message = $message . " after $timeout seconds";
- }
- throw new NoSuchElementException($message);
- }
-
- return $element;
- }
-
- /**
- * Returns the ancestor element from which the given locator will be looked
- * for.
- *
- * If the ancestor of the given locator is another locator the element for
- * the ancestor locator is found and returned. If the ancestor of the given
- * locator is already an element that element is the one returned. If the
- * given locator has no ancestor then the base document element is returned.
- *
- * The timeout is used only when finding the element for the ancestor
- * locator; if the timeout expires a NoSuchElementException is thrown.
- *
- * @param \Behat\Mink\Session $session the Mink Session to get the ancestor
- * element from.
- * @param Locator $elementLocator the locator for the element to get its
- * ancestor.
- * @param float $timeout the number of seconds (decimals allowed) to wait at
- * most for the ancestor element to appear.
- * @param float $timeoutStep the number of seconds (decimals allowed) to
- * wait before trying to find the ancestor element again.
- * @return \Behat\Mink\Element\Element the ancestor element found.
- * @throws NoSuchElementException if the ancestor element can not be found.
- */
- private static function findAncestorElement(\Behat\Mink\Session $session, Locator $elementLocator, $timeout, $timeoutStep) {
- $ancestorElement = $elementLocator->getAncestor();
- if ($ancestorElement instanceof Locator) {
- try {
- $ancestorElement = self::findInternal($session, $ancestorElement, $timeout, $timeoutStep);
- } catch (NoSuchElementException $exception) {
- // Little hack to show the stack of ancestor elements that could
- // not be found, as Behat only shows the message of the last
- // exception in the chain.
- $message = $exception->getMessage() . "\n" .
- $elementLocator->getDescription() . " could not be found";
- if ($timeout > 0) {
- $message = $message . " after $timeout seconds";
- }
- throw new NoSuchElementException($message, $exception);
- }
- }
-
- if ($ancestorElement === null) {
- $ancestorElement = $session->getPage();
- }
-
- return $ancestorElement;
- }
-
- /**
- * @var \Behat\Mink\Session
- */
- private $session;
-
- /**
- * @param Locator
- */
- private $elementLocator;
-
- /**
- * @var float
- */
- private $timeout;
-
- /**
- * @var float
- */
- private $timeoutStep;
-
- /**
- * Creates a new ElementFinder.
- *
- * @param \Behat\Mink\Session $session the Mink Session to get the element
- * from.
- * @param Locator $elementLocator the locator for the element.
- * @param float $timeout the number of seconds (decimals allowed) to wait at
- * most for the element to appear.
- * @param float $timeoutStep the number of seconds (decimals allowed) to
- * wait before trying to find the element again.
- */
- public function __construct(\Behat\Mink\Session $session, Locator $elementLocator, $timeout, $timeoutStep) {
- $this->session = $session;
- $this->elementLocator = $elementLocator;
- $this->timeout = $timeout;
- $this->timeoutStep = $timeoutStep;
- }
-
- /**
- * Returns the description of the element to find.
- *
- * @return string the description of the element to find.
- */
- public function getDescription() {
- return $this->elementLocator->getDescription();
- }
-
- /**
- * Returns the timeout.
- *
- * @return float the number of seconds (decimals allowed) to wait at most
- * for the element to appear.
- */
- public function getTimeout() {
- return $this->timeout;
- }
-
- /**
- * Returns the timeout step.
- *
- * @return float the number of seconds (decimals allowed) to wait before
- * trying to find the element again.
- */
- public function getTimeoutStep() {
- return $this->timeoutStep;
- }
-
- /**
- * Finds an element using the parameters set in the constructor of this
- * ElementFinder.
- *
- * If the element, or its ancestors, can not be found a
- * NoSuchElementException is thrown.
- *
- * @return \Behat\Mink\Element\Element the element found.
- * @throws NoSuchElementException if the element, or its ancestor, can not
- * be found.
- */
- public function find() {
- return self::findInternal($this->session, $this->elementLocator, $this->timeout, $this->timeoutStep);
- }
-}
diff --git a/tests/acceptance/features/core/ElementWrapper.php b/tests/acceptance/features/core/ElementWrapper.php
deleted file mode 100644
index 6ac9a6b8e8f..00000000000
--- a/tests/acceptance/features/core/ElementWrapper.php
+++ /dev/null
@@ -1,358 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * Wrapper to automatically handle failed commands on Mink elements.
- *
- * Commands executed on Mink elements may fail for several reasons. The
- * ElementWrapper frees the caller of the commands from handling the most common
- * reasons of failure.
- *
- * StaleElementReference exceptions are thrown when the command is executed on
- * an element that is no longer attached to the DOM. This can happen even in
- * a chained call like "$actor->find($locator)->click()"; in the milliseconds
- * between finding the element and clicking it the element could have been
- * removed from the page (for example, if a previous interaction with the page
- * started an asynchronous update of the DOM). Every command executed through
- * the ElementWrapper is guarded against StaleElementReference exceptions; if
- * the element is stale it is found again using the same parameters to find it
- * in the first place.
- *
- * NoSuchElement exceptions are sometimes thrown instead of
- * StaleElementReference exceptions. This can happen when the Selenium2 driver
- * for Mink performs an action on an element through the WebDriver session
- * instead of directly through the WebDriver element. In that case, if the
- * element with the given ID does not exist, a NoSuchElement exception would be
- * thrown instead of a StaleElementReference exception, so those cases are
- * handled like StaleElementReference exceptions.
- *
- * ElementNotVisible exceptions are thrown when the command requires the element
- * to be visible but the element is not. Finding an element only guarantees that
- * (at that time) the element is attached to the DOM, but it does not provide
- * any guarantee regarding its visibility. Due to that, a call like
- * "$actor->find($locator)->click()" can fail if the element was hidden and
- * meant to be made visible by a previous interaction with the page, but that
- * interaction triggered an asynchronous update that was not finished when the
- * click command is executed. All commands executed through the ElementWrapper
- * that require the element to be visible are guarded against ElementNotVisible
- * exceptions; if the element is not visible it is waited for it to be visible
- * up to the timeout set to find it.
- *
- * MoveTargetOutOfBounds exceptions are sometimes thrown instead of
- * ElementNotVisible exceptions. This can happen when the Selenium2 driver for
- * Mink moves the cursor on an element using the "moveto" method of the
- * WebDriver session, for example, before clicking on an element. In that case,
- * if the element is not visible, "moveto" would throw a MoveTargetOutOfBounds
- * exception instead of an ElementNotVisible exception, so those cases are
- * handled like ElementNotVisible exceptions.
- *
- * ElementNotInteractable exceptions are thrown in Selenium 3 when the command
- * needs to interact with an element but that is not possible. This could be a
- * transitive situation (for example, due to an animation), so the command is
- * executed again after a small timeout.
- *
- * Despite the automatic handling it is possible for the commands to throw those
- * exceptions when they are executed again; this class does not handle cases
- * like an element becoming stale several times in a row (uncommon) or an
- * element not becoming visible before the timeout expires (which would mean
- * that the timeout is too short or that the test has to, indeed, fail). In a
- * similar way, MoveTargetOutOfBounds exceptions would be thrown again if
- * originally they were thrown because the element was visible but "out of
- * reach". ElementNotInteractable exceptions would be thrown again if it is not
- * possible to interact yet with the element after the wait (which could mean
- * that the test has to, indeed, fail, although it could mean too that the
- * automatic handling needs to be improved).
- *
- * If needed, automatically handling failed commands can be disabled calling
- * "doNotHandleFailedCommands()"; as it returns the ElementWrapper it can be
- * chained with the command to execute (but note that automatically handling
- * failed commands will still be disabled if further commands are executed on
- * the ElementWrapper).
- */
-class ElementWrapper {
- /**
- * @var ElementFinder
- */
- private $elementFinder;
-
- /**
- * @var \Behat\Mink\Element\Element
- */
- private $element;
-
- /**
- * @param boolean
- */
- private $handleFailedCommands;
-
- /**
- * Creates a new ElementWrapper.
- *
- * The wrapped element is found in the constructor itself using the
- * ElementFinder.
- *
- * @param ElementFinder $elementFinder the command object to find the
- * wrapped element.
- * @throws NoSuchElementException if the element, or its ancestor, can not
- * be found.
- */
- public function __construct(ElementFinder $elementFinder) {
- $this->elementFinder = $elementFinder;
- $this->element = $elementFinder->find();
- $this->handleFailedCommands = true;
- }
-
- /**
- * Returns the raw Mink element.
- *
- * @return \Behat\Mink\Element\Element the wrapped element.
- */
- public function getWrappedElement() {
- return $this->element;
- }
-
- /**
- * Prevents the automatic handling of failed commands.
- *
- * @return ElementWrapper this ElementWrapper.
- */
- public function doNotHandleFailedCommands() {
- $this->handleFailedCommands = false;
-
- return $this;
- }
-
- /**
- * Returns whether the wrapped element is visible or not.
- *
- * @return bool true if the wrapped element is visible, false otherwise.
- */
- public function isVisible() {
- $commandCallback = function () {
- return $this->element->isVisible();
- };
- return $this->executeCommand($commandCallback, "visibility could not be got");
- }
-
- /**
- * Returns whether the wrapped element is checked or not.
- *
- * @return bool true if the wrapped element is checked, false otherwise.
- */
- public function isChecked() {
- $commandCallback = function () {
- return $this->element->isChecked();
- };
- return $this->executeCommand($commandCallback, "check state could not be got");
- }
-
- /**
- * Returns the text of the wrapped element.
- *
- * If the wrapped element is not visible the returned text is an empty
- * string.
- *
- * @return string the text of the wrapped element, or an empty string if it
- * is not visible.
- */
- public function getText() {
- $commandCallback = function () {
- return $this->element->getText();
- };
- return $this->executeCommand($commandCallback, "text could not be got");
- }
-
- /**
- * Returns the value of the wrapped element.
- *
- * The value can be got even if the wrapped element is not visible.
- *
- * @return string the value of the wrapped element.
- */
- public function getValue() {
- $commandCallback = function () {
- return $this->element->getValue();
- };
- return $this->executeCommand($commandCallback, "value could not be got");
- }
-
- /**
- * Sets the given value on the wrapped element.
- *
- * If automatically waits for the wrapped element to be visible (up to the
- * timeout set when finding it).
- *
- * @param string $value the value to set.
- */
- public function setValue($value) {
- $commandCallback = function () use ($value) {
- $this->element->setValue($value);
- };
- $this->executeCommandOnVisibleElement($commandCallback, "value could not be set");
- }
-
- /**
- * Clicks on the wrapped element.
- *
- * If automatically waits for the wrapped element to be visible (up to the
- * timeout set when finding it).
- */
- public function click() {
- $commandCallback = function () {
- $this->element->click();
- };
- $this->executeCommandOnVisibleElement($commandCallback, "could not be clicked");
- }
-
- /**
- * Check the wrapped element.
- *
- * If automatically waits for the wrapped element to be visible (up to the
- * timeout set when finding it).
- */
- public function check() {
- $commandCallback = function () {
- $this->element->check();
- };
- $this->executeCommand($commandCallback, "could not be checked");
- }
-
- /**
- * uncheck the wrapped element.
- *
- * If automatically waits for the wrapped element to be visible (up to the
- * timeout set when finding it).
- */
- public function uncheck() {
- $commandCallback = function () {
- $this->element->uncheck();
- };
- $this->executeCommand($commandCallback, "could not be unchecked");
- }
-
- /**
- * Executes the given command.
- *
- * If a StaleElementReference or a NoSuchElement exception is thrown the
- * wrapped element is found again and, then, the command is executed again.
- *
- * @param \Closure $commandCallback the command to execute.
- * @param string $errorMessage an error message that describes the failed
- * command (appended to the description of the element).
- */
- private function executeCommand(\Closure $commandCallback, $errorMessage) {
- if (!$this->handleFailedCommands) {
- return $commandCallback();
- }
-
- try {
- return $commandCallback();
- } catch (\WebDriver\Exception\StaleElementReference $exception) {
- $this->printFailedCommandMessage($exception, $errorMessage);
- } catch (\WebDriver\Exception\NoSuchElement $exception) {
- $this->printFailedCommandMessage($exception, $errorMessage);
- }
-
- $this->element = $this->elementFinder->find();
-
- return $commandCallback();
- }
-
- /**
- * Executes the given command on a visible element.
- *
- * If a StaleElementReference or a NoSuchElement exception is thrown the
- * wrapped element is found again and, then, the command is executed again.
- * If an ElementNotVisible or a MoveTargetOutOfBounds exception is thrown it
- * is waited for the wrapped element to be visible and, then, the command is
- * executed again.
- * If an ElementNotInteractable exception is thrown it is also waited for
- * the wrapped element to be visible. It is very likely that the element was
- * visible already, but it is not possible to easily check if the element
- * can be interacted with, retrying will be only useful if it was a
- * transitive situation that resolves itself with a wait (for example, due
- * to an animation) and waiting for the element to be visible will always
- * start with a wait.
- *
- * @param \Closure $commandCallback the command to execute.
- * @param string $errorMessage an error message that describes the failed
- * command (appended to the description of the element).
- */
- private function executeCommandOnVisibleElement(\Closure $commandCallback, $errorMessage) {
- if (!$this->handleFailedCommands) {
- return $commandCallback();
- }
-
- try {
- return $this->executeCommand($commandCallback, $errorMessage);
- } catch (\WebDriver\Exception\ElementNotVisible $exception) {
- $this->printFailedCommandMessage($exception, $errorMessage);
- } catch (\WebDriver\Exception\MoveTargetOutOfBounds $exception) {
- $this->printFailedCommandMessage($exception, $errorMessage);
- } catch (\Exception $exception) {
- // The "ElementNotInteractable" exception is not available yet in
- // the current "instaclick/php-webdriver" version, so it is thrown
- // as a generic exception with a specific message.
- if (stripos($exception->getMessage(), "element not interactable") === false) {
- throw $exception;
- }
- $this->printFailedCommandMessage($exception, $errorMessage);
- }
-
- $this->waitForElementToBeVisible();
-
- return $commandCallback();
- }
-
- /**
- * Prints information about the failed command.
- *
- * @param \Exception exception the exception thrown by the command.
- * @param string $errorMessage an error message that describes the failed
- * command (appended to the description of the locator of the element).
- */
- private function printFailedCommandMessage(\Exception $exception, $errorMessage) {
- echo $this->elementFinder->getDescription() . " " . $errorMessage . "\n";
- echo "Exception message: " . $exception->getMessage() . "\n";
- echo "Trying again\n";
- }
-
- /**
- * Waits for the wrapped element to be visible.
- *
- * This method waits up to the timeout used when finding the wrapped
- * element; therefore, it may return when the element is still not visible.
- *
- * @return boolean true if the element is visible after the wait, false
- * otherwise.
- */
- private function waitForElementToBeVisible() {
- $isVisibleCallback = function () {
- return $this->isVisible();
- };
- $timeout = $this->elementFinder->getTimeout();
- $timeoutStep = $this->elementFinder->getTimeoutStep();
-
- return Utils::waitFor($isVisibleCallback, $timeout, $timeoutStep);
- }
-}
diff --git a/tests/acceptance/features/core/Locator.php b/tests/acceptance/features/core/Locator.php
deleted file mode 100644
index 1b933399e6b..00000000000
--- a/tests/acceptance/features/core/Locator.php
+++ /dev/null
@@ -1,313 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * Data object for the information needed to locate an element in a web page
- * using Mink.
- *
- * Locators can be created directly using the constructor, or through a more
- * fluent interface with Locator::forThe().
- */
-class Locator {
- /**
- * @var string
- */
- private $description;
-
- /**
- * @var string
- */
- private $selector;
-
- /**
- * @var string|array
- */
- private $locator;
-
- /**
- * @var null|Locator|\Behat\Mink\Element\ElementInterface
- */
- private $ancestor;
-
- /**
- * Starting point for the fluent interface to create Locators.
- *
- * @return LocatorBuilder
- */
- public static function forThe() {
- return new LocatorBuilder();
- }
-
- /**
- * @param string $description
- * @param string $selector
- * @param string|array $locator
- * @param null|Locator|\Behat\Mink\Element\ElementInterface $ancestor
- */
- public function __construct($description, $selector, $locator, $ancestor = null) {
- $this->description = $description;
- $this->selector = $selector;
- $this->locator = $locator;
- $this->ancestor = $ancestor;
- }
-
- /**
- * @return string
- */
- public function getDescription() {
- return $this->description;
- }
-
- /**
- * @return string
- */
- public function getSelector() {
- return $this->selector;
- }
-
- /**
- * @return string|array
- */
- public function getLocator() {
- return $this->locator;
- }
-
- /**
- * @return null|Locator|\Behat\Mink\Element\ElementInterface
- */
- public function getAncestor() {
- return $this->ancestor;
- }
-}
-
-class LocatorBuilder {
- /**
- * @param string $selector
- * @param string|array $locator
- * @return LocatorBuilderSecondStep
- */
- public function customSelector($selector, $locator) {
- return new LocatorBuilderSecondStep($selector, $locator);
- }
-
- /**
- * @param string $cssExpression
- * @return LocatorBuilderSecondStep
- */
- public function css($cssExpression) {
- return $this->customSelector("css", $cssExpression);
- }
-
- /**
- * @param string $xpathExpression
- * @return LocatorBuilderSecondStep
- */
- public function xpath($xpathExpression) {
- return $this->customSelector("xpath", $xpathExpression);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function id($value) {
- return $this->customSelector("named_exact", ["id", $value]);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function idOrName($value) {
- return $this->customSelector("named_exact", ["id_or_name", $value]);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function link($value) {
- return $this->customSelector("named_exact", ["link", $value]);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function button($value) {
- return $this->customSelector("named_exact", ["button", $value]);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function linkOrButton($value) {
- return $this->customSelector("named_exact", ["link_or_button", $value]);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function field($value) {
- return $this->customSelector("named_exact", ["field", $value]);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function selectField($value) {
- return $this->customSelector("named_exact", ["select", $value]);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function checkbox($value) {
- return $this->customSelector("named_exact", ["checkbox", $value]);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function radioButton($value) {
- return $this->customSelector("named_exact", ["radio", $value]);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function fileInput($value) {
- return $this->customSelector("named_exact", ["file", $value]);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function optionGroup($value) {
- return $this->customSelector("named_exact", ["optgroup", $value]);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function option($value) {
- return $this->customSelector("named_exact", ["option", $value]);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function fieldSet($value) {
- return $this->customSelector("named_exact", ["fieldset", $value]);
- }
-
- /**
- * @param string $value
- * @return LocatorBuilderSecondStep
- */
- public function table($value) {
- return $this->customSelector("named_exact", ["table", $value]);
- }
-}
-
-class LocatorBuilderSecondStep {
- /**
- * @var string
- */
- private $selector;
-
- /**
- * @var string|array
- */
- private $locator;
-
- /**
- * @param string $selector
- * @param string|array $locator
- */
- public function __construct($selector, $locator) {
- $this->selector = $selector;
- $this->locator = $locator;
- }
-
- /**
- * @param Locator|\Behat\Mink\Element\ElementInterface $ancestor
- * @return LocatorBuilderThirdStep
- */
- public function descendantOf($ancestor) {
- return new LocatorBuilderThirdStep($this->selector, $this->locator, $ancestor);
- }
-
- /**
- * @param string $description
- * @return Locator
- */
- public function describedAs($description) {
- return new Locator($description, $this->selector, $this->locator);
- }
-}
-
-class LocatorBuilderThirdStep {
- /**
- * @var string
- */
- private $selector;
-
- /**
- * @var string|array
- */
- private $locator;
-
- /**
- * @var Locator|\Behat\Mink\Element\ElementInterface
- */
- private $ancestor;
-
- /**
- * @param string $selector
- * @param string|array $locator
- * @param Locator|\Behat\Mink\Element\ElementInterface $ancestor
- */
- public function __construct($selector, $locator, $ancestor) {
- $this->selector = $selector;
- $this->locator = $locator;
- $this->ancestor = $ancestor;
- }
-
- /**
- * @param string $description
- * @return Locator
- */
- public function describedAs($description) {
- return new Locator($description, $this->selector, $this->locator, $this->ancestor);
- }
-}
diff --git a/tests/acceptance/features/core/NextcloudTestServerContext.php b/tests/acceptance/features/core/NextcloudTestServerContext.php
deleted file mode 100644
index d0dc0c32181..00000000000
--- a/tests/acceptance/features/core/NextcloudTestServerContext.php
+++ /dev/null
@@ -1,126 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-use Behat\Behat\Context\Context;
-use Behat\Behat\Hook\Scope\BeforeScenarioScope;
-
-/**
- * Behat context to run each scenario against a clean Nextcloud server.
- *
- * Before each scenario is run, this context sets up a fresh Nextcloud server
- * with predefined data and configuration. Thanks to this every scenario is
- * independent from the others and they all know the initial state of the
- * server.
- *
- * This context is expected to be used along with RawMinkContext contexts (or
- * subclasses). As the server address can be different for each scenario, this
- * context automatically sets the "base_url" parameter of all its sibling
- * RawMinkContexts; just add NextcloudTestServerContext to the context list of a
- * suite in "behat.yml".
- *
- * The Nextcloud server is provided by an instance of NextcloudTestServerHelper;
- * its class must be specified when this context is created. By default,
- * "NextcloudTestServerLocalBuiltInHelper" is used, although that can be
- * customized using the "nextcloudTestServerHelper" parameter in "behat.yml". In
- * the same way, the parameters to be passed to the helper when it is created
- * can be customized using the "nextcloudTestServerHelperParameters" parameter,
- * which is an array (without keys) with the value of the parameters in the same
- * order as in the constructor of the helper class (by default, [ ]).
- *
- * Example of custom parameters in "behat.yml":
- * default:
- * suites:
- * default:
- * contexts:
- * - NextcloudTestServerContext:
- * nextcloudTestServerHelper: NextcloudTestServerCustomHelper
- * nextcloudTestServerHelperParameters:
- * - first-parameter-value
- * - second-parameter-value
- */
-class NextcloudTestServerContext implements Context {
- /**
- * @var NextcloudTestServerHelper
- */
- private $nextcloudTestServerHelper;
-
- /**
- * Creates a new NextcloudTestServerContext.
- *
- * @param string $nextcloudTestServerHelper the name of the
- * NextcloudTestServerHelper implementing class to use.
- * @param array $nextcloudTestServerHelperParameters the parameters for the
- * constructor of the $nextcloudTestServerHelper class.
- */
- public function __construct($nextcloudTestServerHelper = "NextcloudTestServerLocalBuiltInHelper",
- $nextcloudTestServerHelperParameters = [ ]) {
- $nextcloudTestServerHelperClass = new ReflectionClass($nextcloudTestServerHelper);
-
- if ($nextcloudTestServerHelperParameters === null) {
- $nextcloudTestServerHelperParameters = [];
- }
-
- $this->nextcloudTestServerHelper = $nextcloudTestServerHelperClass->newInstanceArgs($nextcloudTestServerHelperParameters);
- }
-
- /**
- * @BeforeScenario
- *
- * Sets up the Nextcloud test server before each scenario.
- *
- * Once the Nextcloud test server is set up, the "base_url" parameter of the
- * sibling RawMinkContexts is set to the base URL of the Nextcloud test
- * server.
- *
- * @param \Behat\Behat\Hook\Scope\BeforeScenarioScope $scope the
- * BeforeScenario hook scope.
- * @throws \Exception if the Nextcloud test server can not be set up or its
- * base URL got.
- */
- public function setUpNextcloudTestServer(BeforeScenarioScope $scope) {
- $this->nextcloudTestServerHelper->setUp();
-
- $this->setBaseUrlInSiblingRawMinkContexts($scope, $this->nextcloudTestServerHelper->getBaseUrl());
- }
-
- /**
- * @AfterScenario
- *
- * Cleans up the Nextcloud test server after each scenario.
- *
- * @throws \Exception if the Nextcloud test server can not be cleaned up.
- */
- public function cleanUpNextcloudTestServer() {
- $this->nextcloudTestServerHelper->cleanUp();
- }
-
- private function setBaseUrlInSiblingRawMinkContexts(BeforeScenarioScope $scope, $baseUrl) {
- $environment = $scope->getEnvironment();
-
- foreach ($environment->getContexts() as $context) {
- if ($context instanceof Behat\MinkExtension\Context\RawMinkContext) {
- $context->setMinkParameter("base_url", $baseUrl);
- }
- }
- }
-}
diff --git a/tests/acceptance/features/core/NextcloudTestServerHelper.php b/tests/acceptance/features/core/NextcloudTestServerHelper.php
deleted file mode 100644
index 69b8ce70505..00000000000
--- a/tests/acceptance/features/core/NextcloudTestServerHelper.php
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * Interface for classes that manage a Nextcloud server during acceptance tests.
- *
- * A NextcloudTestServerHelper takes care of setting up a Nextcloud server to be
- * used in acceptance tests through its "setUp" method. It does not matter
- * wheter the server is a fresh new server just started or an already running
- * server; in any case, the state of the server must comply with the initial
- * state expected by the tests (like having performed the Nextcloud installation
- * or having an admin user with certain password).
- *
- * As the IP address and thus its the base URL of the server is not known
- * beforehand, the NextcloudTestServerHelper must provide it through its
- * "getBaseUrl" method. Note that this must be the base URL from the point of
- * view of the Selenium server, which may be a different value than the base URL
- * from the point of view of the acceptance tests themselves.
- *
- * Once the Nextcloud test server is no longer needed the "cleanUp" method will
- * be called; depending on how the Nextcloud test server was set up it may not
- * need to do anything.
- *
- * All the methods throw an exception if they fail to execute; as, due to the
- * current use of this interface, it is just a warning for the test runner and
- * nothing to be explicitly catched a plain base Exception is used.
- */
-interface NextcloudTestServerHelper {
- /**
- * Sets up the Nextcloud test server.
- *
- * @throws \Exception if the Nextcloud test server can not be set up.
- */
- public function setUp();
-
- /**
- * Cleans up the Nextcloud test server.
- *
- * @throws \Exception if the Nextcloud test server can not be cleaned up.
- */
- public function cleanUp();
-
- /**
- * Returns the base URL of the Nextcloud test server (from the point of view
- * of the Selenium server).
- *
- * @return string the base URL of the Nextcloud test server.
- * @throws \Exception if the base URL can not be determined.
- */
- public function getBaseUrl();
-}
diff --git a/tests/acceptance/features/core/NextcloudTestServerLocalApacheHelper.php b/tests/acceptance/features/core/NextcloudTestServerLocalApacheHelper.php
deleted file mode 100644
index 367e950931d..00000000000
--- a/tests/acceptance/features/core/NextcloudTestServerLocalApacheHelper.php
+++ /dev/null
@@ -1,128 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * Helper to manage a Nextcloud test server started directly by the acceptance
- * tests themselves using the Apache web server.
- *
- * The Nextcloud test server is executed using the Apache web server; the
- * default Apache directory is expected to have been set to the root directory
- * of the Nextcloud server (for example, by linking "var/www/html" to it); in
- * any case, note that the acceptance tests must be run from the acceptance
- * tests directory. The "setUp" method resets the Nextcloud server to its
- * initial state and starts it, while the "cleanUp" method stops it. To be able
- * to reset the Nextcloud server to its initial state a Git repository must be
- * provided in the root directory of the Nextcloud server; the last commit in
- * that Git repository must provide the initial state for the Nextcloud server
- * expected by the acceptance tests. When the Nextcloud server is reset the
- * owner of "apps", "config" and "data" must be set to the user that Apache
- * server is run as; it is assumed that Apache is run as "www-data".
- *
- * The Nextcloud server is available at "$nextcloudServerDomain", which can be
- * optionally specified when the NextcloudTestServerLocalApacheHelper is
- * created; if no value is given "127.0.0.1" is used by default. In any case,
- * the value of "$nextcloudServerDomain" must be seen as a trusted domain by the
- * Nextcloud server (which would be the case for "127.0.0.1" if it was installed
- * by running "occ maintenance:install"). The base URL to access the Nextcloud
- * server can be got from "getBaseUrl".
- */
-class NextcloudTestServerLocalApacheHelper implements NextcloudTestServerHelper {
- /**
- * @var string
- */
- private $nextcloudServerDomain;
-
- /**
- * Creates a new NextcloudTestServerLocalApacheHelper.
- */
- public function __construct($nextcloudServerDomain = "127.0.0.1") {
- $this->nextcloudServerDomain = $nextcloudServerDomain;
- }
-
- /**
- * Sets up the Nextcloud test server.
- *
- * It resets the Nextcloud test server restoring its last saved Git state
- * and then waits for the Nextcloud test server to start again; if the
- * server can not be reset or if it does not start again after some time an
- * exception is thrown (as it is just a warning for the test runner and
- * nothing to be explicitly catched a plain base Exception is used).
- *
- * @throws \Exception if the Nextcloud test server can not be reset or
- * started again.
- */
- public function setUp(): void {
- // Ensure that previous Apache server is not running (as cleanUp may not
- // have been called).
- $this->stopApacheServer();
-
- $this->execOrException("cd ../../ && git reset --hard HEAD");
- $this->execOrException("cd ../../ && git clean -d --force");
- $this->execOrException("cd ../../ && chown -R www-data:www-data apps config data");
-
- $this->execOrException("service apache2 start");
-
- $timeout = 60;
- if (!Utils::waitForServer($this->getBaseUrl(), $timeout)) {
- throw new Exception("Nextcloud test server could not be started");
- }
- }
-
- /**
- * Cleans up the Nextcloud test server.
- *
- * It stops the running Nextcloud test server, if any.
- */
- public function cleanUp() {
- $this->stopApacheServer();
- }
-
- /**
- * Returns the base URL of the Nextcloud test server.
- *
- * @return string the base URL of the Nextcloud test server.
- */
- public function getBaseUrl() {
- return "http://" . $this->nextcloudServerDomain . "/index.php";
- }
-
- /**
- * Executes the given command, throwing an Exception if it fails.
- *
- * @param string $command the command to execute.
- * @throws \Exception if the command fails to execute.
- */
- private function execOrException($command) {
- exec($command . " 2>&1", $output, $returnValue);
- if ($returnValue != 0) {
- throw new Exception("'$command' could not be executed: " . implode("\n", $output));
- }
- }
-
- /**
- * Stops the Apache server started in setUp, if any.
- */
- private function stopApacheServer() {
- $this->execOrException("service apache2 stop");
- }
-}
diff --git a/tests/acceptance/features/core/NextcloudTestServerLocalBuiltInHelper.php b/tests/acceptance/features/core/NextcloudTestServerLocalBuiltInHelper.php
deleted file mode 100644
index a1ab1f8720a..00000000000
--- a/tests/acceptance/features/core/NextcloudTestServerLocalBuiltInHelper.php
+++ /dev/null
@@ -1,142 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * Helper to manage a Nextcloud test server started directly by the acceptance
- * tests themselves using the PHP built-in web server.
- *
- * The Nextcloud test server is executed using the PHP built-in web server
- * directly from the grandparent directory of the acceptance tests directory
- * (that is, the root directory of the Nextcloud server); note that the
- * acceptance tests must be run from the acceptance tests directory. The "setUp"
- * method resets the Nextcloud server to its initial state and starts it, while
- * the "cleanUp" method stops it. To be able to reset the Nextcloud server to
- * its initial state a Git repository must be provided in the root directory of
- * the Nextcloud server; the last commit in that Git repository must provide the
- * initial state for the Nextcloud server expected by the acceptance tests.
- *
- * The Nextcloud server is available at "$nextcloudServerDomain", which can be
- * optionally specified when the NextcloudTestServerLocalBuiltInHelper is
- * created; if no value is given "127.0.0.1" is used by default. In any case,
- * the value of "$nextcloudServerDomain" must be seen as a trusted domain by the
- * Nextcloud server (which would be the case for "127.0.0.1" if it was installed
- * by running "occ maintenance:install"). The base URL to access the Nextcloud
- * server can be got from "getBaseUrl".
- */
-class NextcloudTestServerLocalBuiltInHelper implements NextcloudTestServerHelper {
- /**
- * @var string
- */
- private $nextcloudServerDomain;
-
- /**
- * @var string
- */
- private $phpServerPid;
-
- /**
- * Creates a new NextcloudTestServerLocalBuiltInHelper.
- */
- public function __construct($nextcloudServerDomain = "127.0.0.1") {
- $this->nextcloudServerDomain = $nextcloudServerDomain;
-
- $this->phpServerPid = "";
- }
-
- /**
- * Sets up the Nextcloud test server.
- *
- * It resets the Nextcloud test server restoring its last saved Git state
- * and then waits for the Nextcloud test server to start again; if the
- * server can not be reset or if it does not start again after some time an
- * exception is thrown (as it is just a warning for the test runner and
- * nothing to be explicitly catched a plain base Exception is used).
- *
- * @throws \Exception if the Nextcloud test server can not be reset or
- * started again.
- */
- public function setUp(): void {
- // Ensure that previous PHP server is not running (as cleanUp may not
- // have been called).
- $this->killPhpServer();
-
- $this->execOrException("cd ../../ && git reset --hard HEAD");
- $this->execOrException("cd ../../ && git clean -d --force");
-
- // execOrException is not used because the server is started in the
- // background, so the command will always succeed even if the server
- // itself fails.
- $this->phpServerPid = exec("php -S " . $this->nextcloudServerDomain . ":80 -t ../../ >/dev/null 2>&1 & echo $!");
-
- $timeout = 60;
- if (!Utils::waitForServer($this->getBaseUrl(), $timeout)) {
- throw new Exception("Nextcloud test server could not be started");
- }
- }
-
- /**
- * Cleans up the Nextcloud test server.
- *
- * It kills the running Nextcloud test server, if any.
- */
- public function cleanUp() {
- $this->killPhpServer();
- }
-
- /**
- * Returns the base URL of the Nextcloud test server.
- *
- * @return string the base URL of the Nextcloud test server.
- */
- public function getBaseUrl() {
- return "http://" . $this->nextcloudServerDomain . "/index.php";
- }
-
- /**
- * Executes the given command, throwing an Exception if it fails.
- *
- * @param string $command the command to execute.
- * @throws \Exception if the command fails to execute.
- */
- private function execOrException($command) {
- exec($command . " 2>&1", $output, $returnValue);
- if ($returnValue != 0) {
- throw new Exception("'$command' could not be executed: " . implode("\n", $output));
- }
- }
-
- /**
- * Kills the PHP built-in web server started in setUp, if any.
- */
- private function killPhpServer() {
- if ($this->phpServerPid == "") {
- return;
- }
-
- // execOrException is not used because the PID may no longer exist when
- // trying to kill it.
- exec("kill " . $this->phpServerPid);
-
- $this->phpServerPid = "";
- }
-}
diff --git a/tests/acceptance/features/core/NoSuchElementException.php b/tests/acceptance/features/core/NoSuchElementException.php
deleted file mode 100644
index 35583c7e63f..00000000000
--- a/tests/acceptance/features/core/NoSuchElementException.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * Exception to signal that the element looked for could not be found.
- */
-class NoSuchElementException extends \Exception {
- /**
- * @param string $message
- * @param null|\Exception $previous
- */
- public function __construct($message, \Exception $previous = null) {
- parent::__construct($message, 0, $previous);
- }
-}
diff --git a/tests/acceptance/features/core/Utils.php b/tests/acceptance/features/core/Utils.php
deleted file mode 100644
index eb7c65e993a..00000000000
--- a/tests/acceptance/features/core/Utils.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-
-/**
- *
- * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-class Utils {
- /**
- * Waits at most $timeout seconds for the given condition to be true,
- * checking it again every $timeoutStep seconds.
- *
- * Note that the timeout is no longer taken into account when a condition is
- * met; that is, true will be returned if the condition is met before the
- * timeout expires, but also if it is met exactly when the timeout expires.
- * For example, even if the timeout is set to 0, the condition will be
- * checked at least once, and true will be returned in that case if the
- * condition was met.
- *
- * @param \Closure $conditionCallback the condition to wait for, as a
- * function that returns a boolean.
- * @param float $timeout the number of seconds (decimals allowed) to wait at
- * most for the condition to be true.
- * @param float $timeoutStep the number of seconds (decimals allowed) to
- * wait before checking the condition again.
- * @return boolean true if the condition is met before (or exactly when) the
- * timeout expires, false otherwise.
- */
- public static function waitFor($conditionCallback, $timeout, $timeoutStep) {
- $elapsedTime = 0;
- $conditionMet = false;
-
- while (!($conditionMet = $conditionCallback()) && $elapsedTime < $timeout) {
- usleep($timeoutStep * 1000000);
-
- $elapsedTime += $timeoutStep;
- }
-
- return $conditionMet;
- }
-
- /**
- * Waits at most $timeout seconds for the server at the given URL to be up,
- * checking it again every $timeoutStep seconds.
- *
- * Note that it does not verify whether the URL returns a valid HTTP status
- * or not; it simply checks that the server at the given URL is accessible.
- *
- * @param string $url the URL for the server to check.
- * @param float $timeout the number of seconds (decimals allowed) to wait at
- * most for the server.
- * @param float $timeoutStep the number of seconds (decimals allowed) to
- * wait before checking the server again; by default, 0.5 seconds.
- * @return boolean true if the server was found, false otherwise.
- */
- public static function waitForServer($url, $timeout, $timeoutStep = 0.5) {
- $isServerUpCallback = function () use ($url) {
- $curlHandle = curl_init($url);
-
- // Returning the transfer as the result of curl_exec prevents the
- // transfer from being written to the output.
- curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
-
- $transfer = curl_exec($curlHandle);
-
- curl_close($curlHandle);
-
- return $transfer !== false;
- };
- return self::waitFor($isServerUpCallback, $timeout, $timeoutStep);
- }
-}
diff --git a/tests/acceptance/features/header.feature b/tests/acceptance/features/header.feature
deleted file mode 100644
index 1d120e66b34..00000000000
--- a/tests/acceptance/features/header.feature
+++ /dev/null
@@ -1,86 +0,0 @@
-@apache
-Feature: header
-
- Scenario: admin users can see admin-level items in the Settings menu
- Given I am logged in as the admin
- When I open the Settings menu
- Then I see that the Settings menu is shown
- And I see that the Settings menu has only 9 items
- And I see that the "Set status" item in the Settings menu is shown
- And I see that the "Appearance and accessibility" item in the Settings menu is shown
- And I see that the "Personal settings" item in the Settings menu is shown
- And I see that the "Administration settings" item in the Settings menu is shown
- And I see that the "Apps" item in the Settings menu is shown
- And I see that the "Users" item in the Settings menu is shown
- And I see that the "Help" item in the Settings menu is shown
- And I see that the "Log out" item in the Settings menu is shown
-
- Scenario: normal users can see basic items in the Settings menu
- Given I am logged in
- When I open the Settings menu
- Then I see that the Settings menu is shown
- And I see that the Settings menu has only 6 items
- And I see that the "Set status" item in the Settings menu is shown
- And I see that the "Appearance and accessibility" item in the Settings menu is shown
- And I see that the "Settings" item in the Settings menu is shown
- And I see that the "Help" item in the Settings menu is shown
- And I see that the "Log out" item in the Settings menu is shown
-
- Scenario: other users are seen in the contacts menu
- Given I am logged in as the admin
- When I open the Contacts menu
- Then I see that the Contacts menu is shown
- And I see that the contact "user0" in the Contacts menu is shown
- And I see that the contact "admin" in the Contacts menu is not shown
-
-# Scenario: users from other groups are not seen in the contacts menu when autocompletion is restricted within the same group
-# Given I am logged in as the admin
-# And I visit the admin settings page
-# And I open the "Sharing" section of the "Administration" group
-# And I enable restricting username autocompletion to groups
-# And I see that username autocompletion is restricted to groups
-# When I open the Contacts menu
-# Then I see that the Contacts menu is shown
-# And I see that the contact "user0" in the Contacts menu is not shown
-# And I see that the contact "admin" in the Contacts menu is not shown
-
- Scenario: just added users are seen in the contacts menu
- Given I am logged in as the admin
- And I open the User settings
- And I click the New user button
- And I see that the new user form is shown
- And I create user user2 with password 123456acb
- # And I see that the list of users contains the user user2
- When I open the Contacts menu
- Then I see that the Contacts menu is shown
- And I see that the contact "user0" in the Contacts menu is shown
- And I see that the contact "user1" in the Contacts menu is shown
- And I see that the contact "user2" in the Contacts menu is shown
- And I see that the contact "admin" in the Contacts menu is not shown
-
- Scenario: search for other users in the contacts menu
- Given I am logged in as the admin
- And I open the Contacts menu
- And I see that the Contacts menu is shown
- And I see that the contact "user0" in the Contacts menu is shown
- And I see that the contact "user1" in the Contacts menu is shown
- And I see that the Contacts menu search input is shown
- When I search for the user "user0"
- # First check that "user1" is no longer shown to ensure that the search was
- # made; checking that "user0" is shown or that "admin" is not shown does not
- # guarantee that (as they were already being shown and not being shown,
- # respectively, before the search started).
- Then I see that the contact "user1" in the Contacts menu is eventually not shown
- And I see that the contact "user0" in the Contacts menu is shown
- And I see that the contact "admin" in the Contacts menu is not shown
-
- Scenario: search for unknown users in the contacts menu
- Given I am logged in as the admin
- And I open the Contacts menu
- And I see that the Contacts menu is shown
- And I see that the contact "user0" in the Contacts menu is shown
- And I see that the Contacts menu search input is shown
- When I search for the user "unknownuser"
- Then I see that the no results message in the Contacts menu is shown
- And I see that the contact "user0" in the Contacts menu is not shown
- And I see that the contact "admin" in the Contacts menu is not shown
diff --git a/tests/acceptance/features/login.feature b/tests/acceptance/features/login.feature
deleted file mode 100644
index 1022ec26aec..00000000000
--- a/tests/acceptance/features/login.feature
+++ /dev/null
@@ -1,55 +0,0 @@
-@apache
-Feature: login
-
- Scenario: log in with valid user and password
- Given I visit the Home page
- When I log in with user user0 and password 123456acb
- Then I see that the current page is the Files app
-
- Scenario: try to log in with valid user and invalid password
- Given I visit the Home page
- When I log in with user user0 and password 654321
- Then I see that the current page is the Login page
- And I see that a wrong password message is shown
-
-# Scenario: log in with valid user and invalid password once fixed by admin
-# Given I act as John
-# And I can not log in with user user0 and password 654231
-# When I act as Jane
-# And I am logged in as the admin
-# And I open the User settings
-# And I set the password for user0 to 654321
-# And I act as John
-# And I log in with user user0 and password 654321
-# Then I see that the current page is the Files app
-
- Scenario: try to log in with invalid user
- Given I visit the Home page
- When I log in with user unknownUser and password 123456acb
- Then I see that the current page is the Login page
- And I see that a wrong password message is shown
-
- Scenario: try to log in as disabled user
- Given I visit the Home page
- When I log in with user disabledUser and password 123456acb
- Then I see that the current page is the Login page
- And I see that the disabled user message is shown
-
- Scenario: log in with invalid user once fixed by admin
- Given I act as John
- And I can not log in with user unknownUser and password 123456acb
- When I act as Jane
- And I am logged in as the admin
- And I open the User settings
- And I click the New user button
- And I see that the new user form is shown
- And I create user unknownUser with password 123456acb
- # And I see that the list of users contains the user unknownUser
- And I act as John
- And I log in with user unknownUser and password 123456acb
- Then I see that the current page is the Files app
-
- Scenario: log out
- Given I am logged in
- When I log out
- Then I see that the current page is the Login page
diff --git a/tests/acceptance/features/users.feature b/tests/acceptance/features/users.feature
deleted file mode 100644
index 0f32819c027..00000000000
--- a/tests/acceptance/features/users.feature
+++ /dev/null
@@ -1,77 +0,0 @@
-@apache
-Feature: users
-
- Scenario: assign user to a group
- Given I act as Jane
- And I am logged in as the admin
- And I open the User settings
- # And I see that the list of users contains the user user0
- # When I toggle the edit mode for the user user0
- # Then I see that the edit mode is on for user user0
- # disabled because we need the TAB patch:
- # https://github.com/minkphp/MinkSelenium2Driver/pull/244
- # When I assign the user user0 to the group admin
- # Then I see that the section Admins is shown
- # And I see that the section Admins has a count of 2
-
- Scenario: create and delete a group
- Given I act as Jane
- And I am logged in as the admin
- And I open the User settings
- # And I see that the list of users contains the user user0
- # disabled because we need the TAB patch:
- # https://github.com/minkphp/MinkSelenium2Driver/pull/244
- # And I assign the user user0 to the group Group1
- # And I see that the section Group1 is shown
- # And I click the "icon-delete" button on the Group1 section
- # And I see that the confirmation dialog is shown
- # When I click the "Yes" button of the confirmation dialog
- # Then I see that the section Group1 is not shown
-
- Scenario: delete an empty group
- Given I act as Jane
- And I am logged in as the admin
- And I open the User settings
- # disabled because we need the TAB patch:
- # https://github.com/minkphp/MinkSelenium2Driver/pull/244
- # And I assign the user user0 to the group Group1
- # And I see that the section Group1 is shown
- # And I withdraw the user user0 from the group Group1
- # And I see that the section Group1 does not have a count
- # And I click the "icon-delete" button on the Group1 section
- # And I see that the confirmation dialog is shown
- # When I click the "Yes" button of the confirmation dialog
- # Then I see that the section Group1 is not shown
-
-# Scenario: change email
-# Given I act as Jane
-# And I am logged in as the admin
-# And I open the User settings
-# And I see that the list of users contains the user user0
-# And I see that the mailAddress of user0 is ""
-# When I set the mailAddress for user0 to "test@nextcloud.com"
-# And I see that the mailAddress cell for user user0 is done loading
-# Then I see that the mailAddress of user0 is "test@nextcloud.com"
-
- Scenario: change user quota
- Given I act as Jane
- And I am logged in as the admin
- And I open the User settings
- # And I see that the list of users contains the user user0
- # When I toggle the edit mode for the user user0
- # Then I see that the edit mode is on for user user0
- # And I see that the user quota of user0 is Unlimited
- # disabled because we need the TAB patch:
- # https://github.com/minkphp/MinkSelenium2Driver/pull/244
- # When I set the user user0 quota to 1GB
- # And I see that the quota cell for user user0 is done loading
- # Then I see that the user quota of user0 is "1 GB"
- # When I set the user user0 quota to Unlimited
- # And I see that the quota cell for user user0 is done loading
- # Then I see that the user quota of user0 is Unlimited
- # When I set the user user0 quota to 0
- # And I see that the quota cell for user user0 is done loading
- # Then I see that the user quota of user0 is "0 B"
- # When I set the user user0 quota to Default
- # And I see that the quota cell for user user0 is done loading
- # Then I see that the user quota of user0 is "Default quota"
diff --git a/tests/acceptance/installAndConfigureServer.sh b/tests/acceptance/installAndConfigureServer.sh
deleted file mode 100755
index 7f24446cef4..00000000000
--- a/tests/acceptance/installAndConfigureServer.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/bash
-
-# @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
-#
-# @license GNU AGPL version 3 or any later version
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# Helper script to install and configure the Nextcloud server as expected by the
-# acceptance tests.
-#
-# This script is not meant to be called manually; it is called when needed by
-# the acceptance tests launchers.
-
-set -o errexit
-
-NEXTCLOUD_SERVER_DOMAIN=""
-if [ "$1" = "--nextcloud-server-domain" ]; then
- NEXTCLOUD_SERVER_DOMAIN=$2
-
- shift 2
-fi
-
-php occ maintenance:install --admin-pass=admin
-
-OC_PASS=123456acb php occ user:add --password-from-env user0
-OC_PASS=123456acb php occ user:add --password-from-env user1
-OC_PASS=123456acb php occ user:add --password-from-env disabledUser
-php occ user:disable disabledUser
-
-# Redirect to files after login for acceptance tests
-php occ app:disable dashboard
-
-# Disable browser warning as selenium is old
-php occ config:system:set no_unsupported_browser_warning --value=true --type=boolean
-
-if [ "$NEXTCLOUD_SERVER_DOMAIN" != "" ]; then
- # Default first trusted domain is "localhost"; replace it with given domain.
- php occ config:system:set trusted_domains 0 --value="$NEXTCLOUD_SERVER_DOMAIN"
-fi
diff --git a/tests/acceptance/run-local.sh b/tests/acceptance/run-local.sh
deleted file mode 100755
index 7e66ca71ec7..00000000000
--- a/tests/acceptance/run-local.sh
+++ /dev/null
@@ -1,229 +0,0 @@
-#!/usr/bin/env bash
-
-# @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
-#
-# @license GNU AGPL version 3 or any later version
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# Helper script to run the acceptance tests, which test a running Nextcloud
-# instance from the point of view of a real user, configured to start the
-# Nextcloud server themselves and from their grandparent directory.
-#
-# The acceptance tests are written in Behat so, besides running the tests, this
-# script installs Behat, its dependencies, and some related packages in the
-# "vendor" subdirectory of the acceptance tests. The acceptance tests expect
-# that the last commit in the Git repository provides the default state of the
-# Nextcloud server, so the script installs the Nextcloud server and saves a
-# snapshot of the whole grandparent directory (no .gitignore file is used) in
-# the Git repository. Finally, the acceptance tests also use the Selenium server
-# to control a web browser, so this script waits for the Selenium server
-# (which should have been started before executing this script) to be ready
-# before running the tests.
-#
-# By default the acceptance tests run are those for the Nextcloud server;
-# acceptance tests for apps can be run by providing the
-# "--acceptance-tests-dir XXX" option. When this option is used the Behat
-# configuration and the Nextcloud installation script used by the acceptance
-# tests for the Nextcloud server are ignored; they must be provided in the given
-# acceptance tests directory. Note, however, that the context classes for the
-# Nextcloud server and the core acceptance test framework classes are
-# automatically loaded; there is no need to explicitly set them in the Behat
-# configuration. Also, even when that option is used, the packages installed by
-# this script end in the "vendor" subdirectory of the acceptance tests for the
-# Nextcloud server, not in the one given in the option.
-
-# Exit immediately on errors.
-set -o errexit
-
-# Ensure working directory is script directory, as some actions (like installing
-# Behat through Composer or running Behat) expect that.
-cd "$(dirname $0)"
-
-# "--acceptance-tests-dir XXX" option can be provided to set the directory
-# (relative to the root directory of the Nextcloud server) used to look for the
-# Behat configuration and the Nextcloud installation script.
-# By default it is "tests/acceptance", that is, the acceptance tests for the
-# Nextcloud server itself.
-ACCEPTANCE_TESTS_DIR="tests/acceptance"
-if [ "$1" = "--acceptance-tests-dir" ]; then
- ACCEPTANCE_TESTS_DIR=$2
-
- shift 2
-fi
-
-ACCEPTANCE_TESTS_CONFIG_DIR="../../$ACCEPTANCE_TESTS_DIR/config"
-DEV_BRANCH="master"
-
-# "--timeout-multiplier N" option can be provided to set the timeout multiplier
-# to be used in ActorContext.
-TIMEOUT_MULTIPLIER=""
-if [ "$1" = "--timeout-multiplier" ]; then
- if [[ ! "$2" =~ ^[0-9]+$ ]]; then
- echo "--timeout-multiplier must be followed by a positive integer"
-
- exit 1
- fi
-
- TIMEOUT_MULTIPLIER=$2
-
- shift 2
-fi
-
-# "--nextcloud-server-domain XXX" option can be provided to set the domain used
-# by the Selenium server to access the Nextcloud server.
-DEFAULT_NEXTCLOUD_SERVER_DOMAIN="127.0.0.1"
-NEXTCLOUD_SERVER_DOMAIN="$DEFAULT_NEXTCLOUD_SERVER_DOMAIN"
-if [ "$1" = "--nextcloud-server-domain" ]; then
- NEXTCLOUD_SERVER_DOMAIN=$2
-
- shift 2
-fi
-
-# "--selenium-server XXX" option can be provided to set the domain and port used
-# by the acceptance tests to access the Selenium server.
-DEFAULT_SELENIUM_SERVER="127.0.0.1:4444"
-SELENIUM_SERVER="$DEFAULT_SELENIUM_SERVER"
-if [ "$1" = "--selenium-server" ]; then
- SELENIUM_SERVER=$2
-
- shift 2
-fi
-
-# Safety parameter to prevent executing this script by mistake and messing with
-# the Git repository.
-if [ "$1" != "allow-git-repository-modifications" ]; then
- echo "To run the acceptance tests use \"run.sh\" instead"
-
- exit 1
-fi
-
-SCENARIO_TO_RUN=$2
-if [ "$ACCEPTANCE_TESTS_DIR" != "tests/acceptance" ]; then
- if [ "$SCENARIO_TO_RUN" == "" ]; then
- echo "When an acceptance tests directory is given the scenario to run" \
- "should be provided too (paths are relative to the acceptance" \
- "tests directory; use the features directory to run all tests)"
- echo "No scenario was given, so \"features/\" was automatically used"
-
- SCENARIO_TO_RUN="features/"
- fi
-
- SCENARIO_TO_RUN=../../$ACCEPTANCE_TESTS_DIR/$SCENARIO_TO_RUN
-fi
-
-if [ "$TIMEOUT_MULTIPLIER" != "" ]; then
- # Although Behat documentation states that using the BEHAT_PARAMS
- # environment variable "You can set any value for any option that is
- # available in a behat.yml file" this is currently not true for the
- # constructor parameters of contexts (see
- # https://github.com/Behat/Behat/issues/983). Thus, the default "behat.yml"
- # configuration file has to be adjusted to provide the appropriate
- # parameters for ActorContext.
- ORIGINAL="\
- - ActorContext"
- REPLACEMENT="\
- - ActorContext:\n\
- actorTimeoutMultiplier: $TIMEOUT_MULTIPLIER"
- sed --in-place "s/$ORIGINAL/$REPLACEMENT/" $ACCEPTANCE_TESTS_CONFIG_DIR/behat.yml
-fi
-
-if [ "$NEXTCLOUD_SERVER_DOMAIN" != "$DEFAULT_NEXTCLOUD_SERVER_DOMAIN" ]; then
- # Although Behat documentation states that using the BEHAT_PARAMS
- # environment variable "You can set any value for any option that is
- # available in a behat.yml file" this is currently not true for the
- # constructor parameters of contexts (see
- # https://github.com/Behat/Behat/issues/983). Thus, the default "behat.yml"
- # configuration file has to be adjusted to provide the appropriate
- # parameters for NextcloudTestServerContext.
- #
- # Note that the substitution below is only valid if no parameters for
- # the helper are set in behat.yml, although it is valid if a specific
- # helper is.
- ORIGINAL="\
- - NextcloudTestServerContext:\?"
- REPLACEMENT="\
- - NextcloudTestServerContext:\n\
- nextcloudTestServerHelperParameters:\n\
- - $NEXTCLOUD_SERVER_DOMAIN"
- sed --in-place "s/$ORIGINAL/$REPLACEMENT/" $ACCEPTANCE_TESTS_CONFIG_DIR/behat.yml
-fi
-
-# Due to a bug in the Mink Extension for Behat it is not possible to use the
-# "paths.base" variable in the path to the custom Firefox profile. Thus, the
-# default "behat.yml" configuration file has to be adjusted to replace the
-# variable by its value before the configuration file is parsed by Behat.
-ORIGINAL="profile: %paths.base%"
-REPLACEMENT="profile: $ACCEPTANCE_TESTS_CONFIG_DIR"
-# As the substitution does not involve regular expressions or multilines it can
-# be done just with Bash. Moreover, this does not require escaping the regular
-# expression characters that may appear in the path, like "/".
-FILE_CONTENTS=$(<$ACCEPTANCE_TESTS_CONFIG_DIR/behat.yml)
-echo "${FILE_CONTENTS//$ORIGINAL/$REPLACEMENT}" > $ACCEPTANCE_TESTS_CONFIG_DIR/behat.yml
-
-# Set the Selenium server to be used by Mink. Although Mink sessions can be
-# extended through BEHAT_PARAMS this would require adding here too each new
-# session added to "behat.yml", including those added in the acceptance
-# tests of apps. Instead, the default "behat.yml" configuration file is
-# adjusted to replace the simulated "selenium.server" variable by its value
-# before the configuration file is parsed by Behat.
-ORIGINAL="wd_host: %selenium.server%"
-REPLACEMENT="wd_host: http://$SELENIUM_SERVER/wd/hub"
-# As the substitution does not involve regular expressions or multilines it
-# can be done just with Bash. Moreover, this does not require escaping the
-# regular expression characters that may appear in the URL, like "/".
-FILE_CONTENTS=$(<$ACCEPTANCE_TESTS_CONFIG_DIR/behat.yml)
-echo "${FILE_CONTENTS//$ORIGINAL/$REPLACEMENT}" > $ACCEPTANCE_TESTS_CONFIG_DIR/behat.yml
-
-composer install
-
-cd ../../
-
-# Link the default Apache directory to the root directory of the Nextcloud
-# server to make possible to run the Nextcloud server on Apache if needed.
-ln --symbolic $(pwd) /var/www/html
-
-# Add Notifications app to the "apps" directory (unless it is already there).
-if [ ! -e "apps/notifications" ]; then
- (cd apps && git clone --depth 1 --branch ${DEV_BRANCH} https://github.com/nextcloud/notifications)
-fi
-
-INSTALL_AND_CONFIGURE_SERVER_PARAMETERS=""
-if [ "$NEXTCLOUD_SERVER_DOMAIN" != "$DEFAULT_NEXTCLOUD_SERVER_DOMAIN" ]; then
- INSTALL_AND_CONFIGURE_SERVER_PARAMETERS+="--nextcloud-server-domain $NEXTCLOUD_SERVER_DOMAIN"
-fi
-
-echo "Installing and configuring Nextcloud server"
-# The server is installed and configured using the www-data user as it is the
-# user that Apache sub-processes will be run as; the PHP built-in web server is
-# run as the root user, and in that case the permissions of apps, config and
-# data dirs makes no difference, so this is valid for both cases.
-mkdir data
-chown -R www-data:www-data apps config data
-NEXTCLOUD_DIR=`pwd`
-su --shell /bin/bash --login www-data --command "cd $NEXTCLOUD_DIR && $ACCEPTANCE_TESTS_DIR/installAndConfigureServer.sh $INSTALL_AND_CONFIGURE_SERVER_PARAMETERS"
-
-echo "Saving the default state so acceptance tests can reset to it"
-find . -name ".gitignore" -exec rm --force {} \;
-# Create dummy files in empty directories to force Git to save the directories.
-find . -not -path "*.git*" -type d -empty -exec touch {}/.keep \;
-git add --all && echo 'Default state' | git -c user.name='John Doe' -c user.email='john@doe.org' commit --quiet --file=-
-
-cd tests/acceptance
-
-# Ensure that the Selenium server is ready before running the tests.
-echo "Waiting for Selenium"
-timeout 60s bash -c "while ! curl $SELENIUM_SERVER >/dev/null 2>&1; do sleep 1; done"
-
-vendor/bin/behat --colors --config=$ACCEPTANCE_TESTS_CONFIG_DIR/behat.yml $SCENARIO_TO_RUN
diff --git a/tests/acceptance/run.sh b/tests/acceptance/run.sh
deleted file mode 100755
index 8800f65a931..00000000000
--- a/tests/acceptance/run.sh
+++ /dev/null
@@ -1,254 +0,0 @@
-#!/usr/bin/env bash
-
-# @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
-#
-# @license GNU AGPL version 3 or any later version
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# Helper script to run the acceptance tests, which test a running Nextcloud
-# instance from the point of view of a real user.
-#
-# The acceptance tests are run in its own Docker container; the grandparent
-# directory of the acceptance tests directory (that is, the root directory of
-# the Nextcloud server) is copied to the container and the acceptance tests are
-# run inside it. Once the tests end the container is stopped. The acceptance
-# tests also use the Selenium server to control a web browser, so the Selenium
-# server is also launched before the tests start in its own Docker container (it
-# will be stopped automatically too once the tests end).
-#
-# To perform its job, the script requires the "docker" command to be available.
-#
-# The Docker Command Line Interface (the "docker" command) requires special
-# permissions to talk to the Docker daemon, and those permissions are typically
-# available only to the root user. Please see the Docker documentation to find
-# out how to give access to a regular user to the Docker daemon:
-# https://docs.docker.com/engine/installation/linux/linux-postinstall/
-#
-# Note, however, that being able to communicate with the Docker daemon is the
-# same as being able to get root privileges for the system. Therefore, you must
-# give access to the Docker daemon (and thus run this script as) ONLY to trusted
-# and secure users:
-# https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
-#
-# Finally, take into account that this script will automatically remove the
-# Docker containers named "selenium-nextcloud-local-test-acceptance" and
-# "nextcloud-local-test-acceptance", even if the script did not create them
-# (probably you will not have containers nor images with those names, but just
-# in case).
-
-# Sets the variables that abstract the differences in command names and options
-# between operating systems.
-#
-# Switches between timeout on GNU/Linux and gtimeout on macOS (same for mktemp
-# and gmktemp).
-function setOperatingSystemAbstractionVariables() {
- case "$OSTYPE" in
- darwin*)
- if [ "$(which gtimeout)" == "" ]; then
- echo "Please install coreutils (brew install coreutils)"
- exit 1
- fi
-
- MKTEMP=gmktemp
- TIMEOUT=gtimeout
- DOCKER_OPTIONS="-e no_proxy=localhost "
- ;;
- linux*)
- MKTEMP=mktemp
- TIMEOUT=timeout
- DOCKER_OPTIONS=" "
- ;;
- *)
- echo "Operating system ($OSTYPE) not supported"
- exit 1
- ;;
- esac
-}
-
-# Launches the Selenium server in a Docker container.
-#
-# The acceptance tests use Firefox by default but, unfortunately, Firefox >= 48
-# does not provide yet the same level of support as earlier versions for certain
-# features related to automated testing. Therefore, the Docker image used is not
-# the latest one, but an older version known to work.
-#
-# The acceptance tests expect the Selenium server to be accessible at
-# "127.0.0.1:4444"; as the Selenium server container and the container in which
-# the acceptance tests are run share the same network nothing else needs to be
-# done for the acceptance tests to access the Selenium server and for the
-# Selenium server to access the Nextcloud server. However, in order to ensure
-# from this script that the Selenium server was started the 4444 port of its
-# container is mapped to the 4444 port of the host.
-#
-# Besides the Selenium server, the Docker image also provides a VNC server, so
-# the 5900 port of the container is also mapped to the 5900 port of the host.
-#
-# The Docker container started here will be automatically stopped when the
-# script exits (see cleanUp). If the Selenium server can not be started then the
-# script will be exited immediately with an error state; the most common cause
-# for the Selenium server to fail to start is that another server is already
-# using the mapped ports in the host.
-#
-# As the web browser is run inside the Docker container it is not visible by
-# default. However, it can be viewed using VNC (for example,
-# "vncviewer 127.0.0.1:5900"); when asked for the password use "secret".
-function prepareSelenium() {
- SELENIUM_CONTAINER=selenium-nextcloud-local-test-acceptance
-
- echo "Starting Selenium server"
- docker run --detach --name=$SELENIUM_CONTAINER --publish 4444:4444 --publish 5900:5900 $DOCKER_OPTIONS selenium/standalone-chrome-debug:3.141.59
-
- echo "Waiting for Selenium server to be ready"
- if ! $TIMEOUT 10s bash -c "while ! curl 127.0.0.1:4444 >/dev/null 2>&1; do sleep 1; done"; then
- echo "Could not start Selenium server; running" \
- "\"docker run --rm --publish 4444:4444 --publish 5900:5900 $DOCKER_OPTIONS selenium/standalone-chrome-debug:3.141.59\"" \
- "could give you a hint of the problem"
-
- exit 1
- fi
-}
-
-# Creates a Docker container to run both the acceptance tests and the Nextcloud
-# server used by them.
-#
-# This function starts a Docker container with a copy the Nextcloud code from
-# the grandparent directory, although ignoring any configuration or data that it
-# may provide (for example, if that directory was used directly to deploy a
-# Nextcloud instance in a web server). As the Nextcloud code is copied to the
-# container instead of referenced the original code can be modified while the
-# acceptance tests are running without interfering in them.
-function prepareDocker() {
- NEXTCLOUD_LOCAL_CONTAINER=nextcloud-local-test-acceptance
-
- echo "Starting the Nextcloud container"
- # As the Nextcloud server container uses the network of the Selenium server
- # container the Nextcloud server can be accessed at "127.0.0.1" from the
- # Selenium server.
- # The container exits immediately if no command is given, so a Bash session
- # is created to prevent that.
- docker run \
- --detach \
- --name=$NEXTCLOUD_LOCAL_CONTAINER \
- --network=container:$SELENIUM_CONTAINER \
- --volume composer_cache:/root/.composer \
- --interactive \
- --tty ghcr.io/nextcloud/continuous-integration-acceptance-php8.0:latest bash
-
- # Use the $TMPDIR or, if not set, fall back to /tmp.
- NEXTCLOUD_LOCAL_TAR="$($MKTEMP --tmpdir="${TMPDIR:-/tmp}" --suffix=.tar nextcloud-local-XXXXXXXXXX)"
-
- # Setting the user and group of files in the tar would be superfluous, as
- # "docker cp" does not take them into account (the extracted files are set
- # to root).
- echo "Copying local Git working directory of Nextcloud to the container"
- tar --create --file="$NEXTCLOUD_LOCAL_TAR" \
- --exclude=".git" \
- --exclude="./build" \
- --exclude="./config/config.php" \
- --exclude="./data" \
- --exclude="./data-autotest" \
- --exclude="./tests" \
- --exclude="./apps-extra" \
- --exclude="./apps-writable" \
- --exclude="node_modules" \
- --directory=../../ \
- .
- tar --append --file="$NEXTCLOUD_LOCAL_TAR" --directory=../../ tests/acceptance/
-
- docker exec $NEXTCLOUD_LOCAL_CONTAINER mkdir /nextcloud
- docker cp - $NEXTCLOUD_LOCAL_CONTAINER:/nextcloud/ < "$NEXTCLOUD_LOCAL_TAR"
-
- # run-local.sh expects a Git repository to be available in the root of the
- # Nextcloud server, but it was excluded when the Git working directory was
- # copied to the container to avoid copying the large and unneeded history of
- # the repository.
- docker exec $NEXTCLOUD_LOCAL_CONTAINER bash -c "cd nextcloud && git init"
-}
-
-# Removes/stops temporal elements created/started by this script.
-function cleanUp() {
- # Disable (yes, "+" disables) exiting immediately on errors to ensure that
- # all the cleanup commands are executed (well, no errors should occur during
- # the cleanup anyway, but just in case).
- set +o errexit
-
- echo "Cleaning up"
-
- if [ -f "$NEXTCLOUD_LOCAL_TAR" ]; then
- echo "Removing $NEXTCLOUD_LOCAL_TAR"
- rm $NEXTCLOUD_LOCAL_TAR
- fi
-
- # The name filter must be specified as "^/XXX$" to get an exact match; using
- # just "XXX" would match every name that contained "XXX".
- if [ -n "$(docker ps --all --quiet --filter name="^/$NEXTCLOUD_LOCAL_CONTAINER$")" ]; then
- echo "Removing Docker container $NEXTCLOUD_LOCAL_CONTAINER"
- docker rm --volumes --force $NEXTCLOUD_LOCAL_CONTAINER
- fi
-
- if [ -n "$(docker ps --all --quiet --filter name="^/$SELENIUM_CONTAINER$")" ]; then
- echo "Removing Docker container $SELENIUM_CONTAINER"
- docker rm --volumes --force $SELENIUM_CONTAINER
- fi
-}
-
-# Exit immediately on errors.
-set -o errexit
-
-# Execute cleanUp when the script exits, either normally or due to an error.
-trap cleanUp EXIT
-
-# Ensure working directory is script directory, as some actions (like copying
-# the Git working directory to the container) expect that.
-cd "$(dirname $0)"
-
-# "--acceptance-tests-dir XXX" option can be provided to set the directory
-# (relative to the root directory of the Nextcloud server) used to look for the
-# Behat configuration and the Nextcloud installation script.
-# By default it is "tests/acceptance", that is, the acceptance tests for the
-# Nextcloud server itself.
-ACCEPTANCE_TESTS_DIR_OPTION=""
-if [ "$1" = "--acceptance-tests-dir" ]; then
- ACCEPTANCE_TESTS_DIR_OPTION="--acceptance-tests-dir $2"
-
- shift 2
-fi
-
-# "--timeout-multiplier N" option can be provided before the specific scenario
-# to run, if any, to set the timeout multiplier to be used in the acceptance
-# tests.
-TIMEOUT_MULTIPLIER_OPTION=""
-if [ "$1" = "--timeout-multiplier" ]; then
- if [[ ! "$2" =~ ^[0-9]+$ ]]; then
- echo "--timeout-multiplier must be followed by a positive integer"
-
- exit 1
- fi
-
- TIMEOUT_MULTIPLIER_OPTION="--timeout-multiplier $2"
-
- shift 2
-fi
-
-# If no parameter is provided to this script all the acceptance tests are run.
-SCENARIO_TO_RUN=$1
-
-setOperatingSystemAbstractionVariables
-
-prepareSelenium
-prepareDocker
-
-echo "Running tests"
-docker exec $NEXTCLOUD_LOCAL_CONTAINER bash -c "cd nextcloud && tests/acceptance/run-local.sh $ACCEPTANCE_TESTS_DIR_OPTION $TIMEOUT_MULTIPLIER_OPTION allow-git-repository-modifications $SCENARIO_TO_RUN"
diff --git a/tests/apps.php b/tests/apps.php
index 27bd428d949..5388e28ee43 100644
--- a/tests/apps.php
+++ b/tests/apps.php
@@ -1,33 +1,38 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-function loadDirectory($path) {
+function loadDirectory($path): void {
if (strpos($path, 'integration')) {
return;
}
+
if (strpos($path, 'Integration')) {
return;
}
- if ($dh = opendir($path)) {
- while ($name = readdir($dh)) {
- if ($name[0] !== '.') {
- $file = $path . '/' . $name;
- if (is_dir($file)) {
- loadDirectory($file);
- } elseif (substr($name, -4, 4) === '.php') {
- require_once $file;
- }
- }
+
+ if (! $dh = opendir($path)) {
+ return;
+ }
+
+ while ($name = readdir($dh)) {
+ if ($name[0] === '.') {
+ continue;
+ }
+
+ $file = $path . '/' . $name;
+ if (is_dir($file)) {
+ loadDirectory($file);
+ } elseif (str_ends_with($name, '.php')) {
+ require_once $file;
}
}
}
-function getSubclasses($parentClassName) {
+function getSubclasses($parentClassName): array {
$classes = [];
foreach (get_declared_classes() as $className) {
if (is_subclass_of($className, $parentClassName)) {
diff --git a/tests/apps/testapp_dependency_missing/appinfo/info.xml b/tests/apps/testapp_dependency_missing/appinfo/info.xml
index b0ca188aefc..f58846ce5e0 100644
--- a/tests/apps/testapp_dependency_missing/appinfo/info.xml
+++ b/tests/apps/testapp_dependency_missing/appinfo/info.xml
@@ -1,4 +1,8 @@
<?xml version="1.0"?>
+<!--
+ - SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<id>testapp_infoxml</id>
diff --git a/tests/apps/testapp_infoxml/appinfo/info.xml b/tests/apps/testapp_infoxml/appinfo/info.xml
index b7575687fe5..e7375aa2a62 100644
--- a/tests/apps/testapp_infoxml/appinfo/info.xml
+++ b/tests/apps/testapp_infoxml/appinfo/info.xml
@@ -1,4 +1,8 @@
<?xml version="1.0"?>
+<!--
+ - SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<id>testapp_infoxml</id>
diff --git a/tests/apps/testapp_name_missing/appinfo/info.xml b/tests/apps/testapp_name_missing/appinfo/info.xml
index 872c8752c75..c40b8ab4919 100644
--- a/tests/apps/testapp_name_missing/appinfo/info.xml
+++ b/tests/apps/testapp_name_missing/appinfo/info.xml
@@ -1,4 +1,8 @@
<?xml version="1.0"?>
+<!--
+ - SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<id>testapp_name_missing</id>
diff --git a/tests/apps/testapp_version/appinfo/info.xml b/tests/apps/testapp_version/appinfo/info.xml
index 3a48fccd45f..ba37b2038c7 100644
--- a/tests/apps/testapp_version/appinfo/info.xml
+++ b/tests/apps/testapp_version/appinfo/info.xml
@@ -1,4 +1,8 @@
<?xml version="1.0"?>
+<!--
+ - SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<id>testapp_version</id>
diff --git a/tests/blueprints/basic.toml b/tests/blueprints/basic.toml
index 28902fd5708..fa25b688aad 100644
--- a/tests/blueprints/basic.toml
+++ b/tests/blueprints/basic.toml
@@ -1,3 +1,5 @@
+# SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: AGPL-3.0-or-later
[[user]]
id = "test"
groups = ["test_group"]
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 7e5e4c7c547..3fdc6b51fba 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -1,5 +1,9 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
define('PHPUNIT_RUN', 1);
$configDir = getenv('CONFIG_DIR');
@@ -17,4 +21,8 @@ require_once __DIR__ . '/../lib/base.php';
OC_Hook::clear();
-set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/share/php');
+set_include_path(
+ get_include_path() . PATH_SEPARATOR
+ . '/usr/share/php' . PATH_SEPARATOR
+ . __DIR__ . '/..'
+);
diff --git a/tests/data/app/description-multi-lang.xml b/tests/data/app/description-multi-lang.xml
index e7eee3bcb8b..be1dd616a99 100644
--- a/tests/data/app/description-multi-lang.xml
+++ b/tests/data/app/description-multi-lang.xml
@@ -1,4 +1,8 @@
<?xml version="1.0"?>
+<!--
+ - SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
<info>
<id>files_encryption</id>
<name>Server-side Encryption</name>
diff --git a/tests/data/app/description-single-lang.xml b/tests/data/app/description-single-lang.xml
index 5fb1ba07e8e..36fb2aacbe2 100644
--- a/tests/data/app/description-single-lang.xml
+++ b/tests/data/app/description-single-lang.xml
@@ -1,4 +1,8 @@
<?xml version="1.0"?>
+<!--
+ - SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
<info>
<id>files_encryption</id>
<name>Server-side Encryption</name>
diff --git a/tests/data/app/expected-info.json.license b/tests/data/app/expected-info.json.license
new file mode 100644
index 00000000000..328cbf7b249
--- /dev/null
+++ b/tests/data/app/expected-info.json.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+SPDX-License-Identifier: AGPL-3.0-only
diff --git a/tests/data/app/invalid-info.xml b/tests/data/app/invalid-info.xml
index 0ddb13b89c0..1c39ae2d625 100644
--- a/tests/data/app/invalid-info.xml
+++ b/tests/data/app/invalid-info.xml
@@ -1,4 +1,9 @@
<?xml version="1.0"?>
+<!--
+ - SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-FileCopyrightText: 2014 ownCloud, Inc.
+ - SPDX-License-Identifier: AGPL-3.0-only
+-->
<info
<id>files_encryption</id>
<name>Server-side Encryption</name>
diff --git a/tests/data/app/navigation-one-item.json.license b/tests/data/app/navigation-one-item.json.license
new file mode 100644
index 00000000000..cbd71b0f672
--- /dev/null
+++ b/tests/data/app/navigation-one-item.json.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/tests/data/app/navigation-one-item.xml b/tests/data/app/navigation-one-item.xml
index a03e5c8ffbf..cb0bd5f2929 100644
--- a/tests/data/app/navigation-one-item.xml
+++ b/tests/data/app/navigation-one-item.xml
@@ -1,4 +1,8 @@
<?xml version="1.0"?>
+<!--
+ - SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<id>activity</id>
diff --git a/tests/data/app/navigation-two-items.json.license b/tests/data/app/navigation-two-items.json.license
new file mode 100644
index 00000000000..cbd71b0f672
--- /dev/null
+++ b/tests/data/app/navigation-two-items.json.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/tests/data/app/navigation-two-items.xml b/tests/data/app/navigation-two-items.xml
index fba60a2871d..153e12e6511 100644
--- a/tests/data/app/navigation-two-items.xml
+++ b/tests/data/app/navigation-two-items.xml
@@ -1,4 +1,8 @@
<?xml version="1.0"?>
+<!--
+ - SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
<id>activity</id>
diff --git a/tests/data/app/valid-info.xml b/tests/data/app/valid-info.xml
index 4788d046c13..9044c00f353 100644
--- a/tests/data/app/valid-info.xml
+++ b/tests/data/app/valid-info.xml
@@ -1,4 +1,9 @@
<?xml version="1.0"?>
+<!--
+ - SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-FileCopyrightText: 2014 ownCloud, Inc.
+ - SPDX-License-Identifier: AGPL-3.0-only
+-->
<info>
<id>files_encryption</id>
<name>Server-side Encryption</name>
diff --git a/tests/data/integritycheck/SomeApp.crt.license b/tests/data/integritycheck/SomeApp.crt.license
new file mode 100644
index 00000000000..2598a98f44c
--- /dev/null
+++ b/tests/data/integritycheck/SomeApp.crt.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+SPDX-License-Identifier: AGPL-3.0-only
diff --git a/tests/data/integritycheck/SomeApp.key.license b/tests/data/integritycheck/SomeApp.key.license
new file mode 100644
index 00000000000..2598a98f44c
--- /dev/null
+++ b/tests/data/integritycheck/SomeApp.key.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+SPDX-License-Identifier: AGPL-3.0-only
diff --git a/tests/data/integritycheck/core.crt.license b/tests/data/integritycheck/core.crt.license
new file mode 100644
index 00000000000..328cbf7b249
--- /dev/null
+++ b/tests/data/integritycheck/core.crt.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+SPDX-License-Identifier: AGPL-3.0-only
diff --git a/tests/data/integritycheck/core.key.license b/tests/data/integritycheck/core.key.license
new file mode 100644
index 00000000000..2598a98f44c
--- /dev/null
+++ b/tests/data/integritycheck/core.key.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+SPDX-License-Identifier: AGPL-3.0-only
diff --git a/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js b/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js
index a8e98e786f5..8221d01a682 100644
--- a/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js
+++ b/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js
@@ -106,6 +106,7 @@ OC.MimeTypeList={
"text/x-java-source": "text/code",
"text/x-ldif": "text/code",
"text/x-python": "text/code",
+ "text/x-rst": "text",
"text/x-shellscript": "text/code",
"web": "text/code",
"application/internet-shortcut": "link",
@@ -115,6 +116,7 @@ OC.MimeTypeList={
"image/targa": "image/tga",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform": "x-office/form",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf": "x-office/form-template",
+ "image/x-emf": "image/emf",
"my-custom/mimetype": "custom"
},
files: [
diff --git a/tests/data/integritycheck/mimetypeListModified/core/signature.json b/tests/data/integritycheck/mimetypeListModified/core/signature.json
index 43f489f6d3f..0f6ca137cdc 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": "2a6ab9af5353d464c0dd3bd651cfc13ba35009463949bc45bd8f7073828fa34fbdac7a81ba2b188e7e0c97fc63c2167825b069f61341e507ca33213b1e6e4593"
+ "core\/js\/mimetypelist.js": "c5cc5239ea67d5f09ef49b72929205be7684c7fc7c829637cb57963bfa5a3e9ec96aec97f2935cbe7c14e96c3294f3caa25829277e691e6b494dff4be50bdb21"
},
- "signature": "A5JmjvGiWC9iDaDL0\/wzIBx1ovV6xW5pL134ZtzcFh6dCRoYVZFZvInb98zz4Js3Y4R+uAv4XYKFgclG9BXjoa+q7SmN4qV95o870OsX3MEAaPRHEJv7V6P19hinwC0\/c6XUtMUlTn2IqdoacmELV3v+vmXiU0bYpNfqkYDjt1mCfl3EWB+uMCn+W849k1hoRc\/nI3JuDzl3VtP4G6zzJ3NexsXJOHOb6\/GyGVnkOltN3Ep5wBqXtr28LLLWWYbgxUEQ5ZNBd98PCpRm3r\/3eGreREccUzh+Kfo1XK+Rbnf8U6z3DXOwZK4cP\/CJBAhtlUDyw+TY58jcOSLxF2I61jqYoa8En2ukcQdXUvyTcsN+RzAKo+yhAPw0CJvDzb9zuS7gJUpev6nZnJKQ6dNQApQQILtwgz9dDlVKToxgyyhV1giTqEEZDvH1t2MSjz8fbGlm1YY60YJSs2SA\/cAff+sQVmoGCpRtdHriCDAET+5gTuz0wEXnvn6Jvxqxta9IZ0fisKCjfRH5FFdjfBM8Cgk6HOhSAfHoSH+ZFUGy8+NICZXe7CGr40iIjFLSIS0RgclQZSjYK8bfjA43XFpXeJNGjIvxHTr4tzm8gJ3YbVqCyN45HBcxS3q7yJCie3brqCZvXfXyhoGY6WhPAkBLQ+8nNP\/qeWlV8DMX+ZUYxso=",
+ "signature": "RCyHmaoLXr0NfqTWDM8xUhe2LsRwF2QMIGyDT9f4dShnyCO5VCApYbu6IzgiBVOAPBTSq\/Wv4NaivDbcNTVJKavTvOzJiWJvPy84Z8Xb3hceTL\/WuelFryPCZq11wy6Zrxt+\/FgAD+tHHao0BmMKa5iVFSl5i1cSUrA2W4CXxPybo2Ajbp4bOHSt6BIhzpsHtzuxxSfRGex19\/CqFGR5S8pXGAJ4gw5huJN2zkyLTEdRjuUW8RWNNZDt+XmVNp8\/ZzIePxoigo5u2tPxlwU0i4+5TejMGjxD07EhfrUWFJhgCheCdYv72cCsfKAuclpCFyB+Z9g6\/RhrUArvpXz2qD+foeL+6mhSyjTpyixmBvwrsL3VgYt+gg1T+wJukwnB2GD9xRjxGBL0j6Hgqs4saAgY9b+E\/wA89NtJ8+OP+wanCNqPJQG21UoeJRFFIbX\/K+YI39keNXM28kjFNgNBWlNbXqi8S6mRYX+PZBA6CVaXqfG\/NZzFLtRTbhoO3tOXqzgAx31XseZaPwlvl+gSCVaPdHkbCih9uV5gow05zdrQ2S7jGECBTRm4sMInP0lLZLVLED16W2gDbSk0Qey8dGBwwn\/WOnPS3LZrCzvstKkyBCVWVjaDhZ47WzxFRCXwJAmSoY1dFEGRG+B91hF413cw+SqqebfqNx99dFjpo0k=",
"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/data/integritycheck/root.crt.license b/tests/data/integritycheck/root.crt.license
new file mode 100644
index 00000000000..2598a98f44c
--- /dev/null
+++ b/tests/data/integritycheck/root.crt.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+SPDX-License-Identifier: AGPL-3.0-only
diff --git a/tests/data/integritycheck/root.key.license b/tests/data/integritycheck/root.key.license
new file mode 100644
index 00000000000..2598a98f44c
--- /dev/null
+++ b/tests/data/integritycheck/root.key.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+SPDX-License-Identifier: AGPL-3.0-only
diff --git a/tests/data/scss/styles-error.scss b/tests/data/scss/styles-error.scss
index bd6c6d4ffb5..4f3c8330a6b 100644
--- a/tests/data/scss/styles-error.scss
+++ b/tests/data/scss/styles-error.scss
@@ -1 +1,5 @@
+/**
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
body { error }
diff --git a/tests/data/scss/styles-success.scss b/tests/data/scss/styles-success.scss
index bf4efa71a6a..343ddf43ef2 100644
--- a/tests/data/scss/styles-success.scss
+++ b/tests/data/scss/styles-success.scss
@@ -1 +1,5 @@
-body { background-color: $color-primary; } \ No newline at end of file
+/**
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+body { background-color: $color-primary; }
diff --git a/tests/data/svg/files-app-red.svg b/tests/data/svg/files-app-red.svg
index 81d7fca1472..1a8ad23cf74 100644
--- a/tests/data/svg/files-app-red.svg
+++ b/tests/data/svg/files-app-red.svg
@@ -1 +1,5 @@
+<!--
+ - SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
<svg xmlns="http://www.w3.org/2000/svg" height="32" viewBox="0 0 32 32" width="32" version="1.1"><path fill="#f00" d="m3 4c-0.5 0-1 0.5-1 1v22c0 0.52 0.48 1 1 1h26c0.52 0 1-0.482 1-1v-18c0-0.5-0.5-1-1-1h-13l-4-4z"/></svg>
diff --git a/tests/data/svg/mixed-red.svg b/tests/data/svg/mixed-red.svg
index 5e3727abd46..37e786a23b5 100644
--- a/tests/data/svg/mixed-red.svg
+++ b/tests/data/svg/mixed-red.svg
@@ -1 +1,5 @@
+<!--
+ - SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
<svg width="50mm" height="50mm" version="1.1" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0,-247)"><rect x="3.3609" y="250.93" width="16.253" height="15.497" fill="#f00"/><ellipse cx="37.089" cy="257.97" rx="8.5517" ry="7.9375" fill="#f00"/><circle cx="12.19" cy="281.31" r="10" fill="#f00"/><rect x="29.293" y="272.81" width="16.253" height="15.497" fill="#f00"/></g></svg>
diff --git a/tests/data/svg/mixed-source.svg b/tests/data/svg/mixed-source.svg
index e4a94136c52..94449355a28 100644
--- a/tests/data/svg/mixed-source.svg
+++ b/tests/data/svg/mixed-source.svg
@@ -1 +1,5 @@
+<!--
+ - SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
<svg width="50mm" height="50mm" version="1.1" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0,-247)"><rect x="3.3609" y="250.93" width="16.253" height="15.497"/><ellipse cx="37.089" cy="257.97" rx="8.5517" ry="7.9375" fill="#123456"/><circle cx="12.19" cy="281.31" r="10"/><rect x="29.293" y="272.81" width="16.253" height="15.497" fill="#6474a5"/></g></svg>
diff --git a/tests/data/svg/rect-black.svg b/tests/data/svg/rect-black.svg
index 85ab8442c35..accedfff892 100644
--- a/tests/data/svg/rect-black.svg
+++ b/tests/data/svg/rect-black.svg
@@ -1 +1,5 @@
+<!--
+ - SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
<svg width="50mm" height="50mm" version="1.1" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0,-247)"><rect x="10" y="257" width="30" height="30"/></g></svg>
diff --git a/tests/data/svg/rect-red.svg b/tests/data/svg/rect-red.svg
index 8f0fae7f617..dbe93f8a423 100644
--- a/tests/data/svg/rect-red.svg
+++ b/tests/data/svg/rect-red.svg
@@ -1 +1,5 @@
+<!--
+ - SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
<svg width="50mm" height="50mm" version="1.1" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0,-247)"><rect x="10" y="257" width="30" height="30" fill="#f00"/></g></svg>
diff --git a/tests/data/svg/settings-admin-red.svg b/tests/data/svg/settings-admin-red.svg
index 54d7d3a9b15..26a24cfde8a 100644
--- a/tests/data/svg/settings-admin-red.svg
+++ b/tests/data/svg/settings-admin-red.svg
@@ -1 +1,5 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 16 16" height="16" width="16" version="1.1"><path color="#000" d="m1 1v4h4v-4h-4zm5 1v2h8v-2h-8zm-5 4v4h4v-4h-4zm5 1v2h8v-2h-8zm-5 4v4h4v-4h-4zm1 1h2v2h-2v-2zm4 0v2h8v-2h-8z" fill="#f00"/></svg>
+<!--
+ - SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-License-Identifier: AGPL-3.0-or-later
+-->
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="16" width="16" version="1.1"><path color="#000" d="m1 1v4h4v-4h-4zm5 1v2h8v-2h-8zm-5 4v4h4v-4h-4zm5 1v2h8v-2h-8zm-5 4v4h4v-4h-4zm1 1h2v2h-2v-2zm4 0v2h8v-2h-8z" fill="#f00"/></svg>
diff --git a/tests/data/testimage.webp b/tests/data/testimage.webp
index 4d882d047ba..d54cbfe8d27 100644
--- a/tests/data/testimage.webp
+++ b/tests/data/testimage.webp
Binary files differ
diff --git a/tests/docker/mysqlmb4.config.php b/tests/docker/mysqlmb4.config.php
index 3511e3c3723..0db5d5e54de 100644
--- a/tests/docker/mysqlmb4.config.php
+++ b/tests/docker/mysqlmb4.config.php
@@ -1,7 +1,11 @@
<?php
declare(strict_types=1);
-
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
$CONFIG = [
'mysql.utf8mb4' => true,
];
diff --git a/tests/drone-run-integration-tests.sh b/tests/drone-run-integration-tests.sh
index a341f363b86..78ff6d462bc 100755
--- a/tests/drone-run-integration-tests.sh
+++ b/tests/drone-run-integration-tests.sh
@@ -1,5 +1,8 @@
#!/bin/bash
+# SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
echo "========================="
echo "= List of changed files ="
echo "========================="
diff --git a/tests/drone-run-php-tests.sh b/tests/drone-run-php-tests.sh
index aad781a1c7b..c0b02ab2851 100755
--- a/tests/drone-run-php-tests.sh
+++ b/tests/drone-run-php-tests.sh
@@ -1,5 +1,8 @@
#!/bin/bash
+# SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
echo "========================="
echo "= List of changed files ="
echo "========================="
diff --git a/tests/drone-wait-objectstore.sh b/tests/drone-wait-objectstore.sh
index 7817d946682..64c806b9b3e 100755
--- a/tests/drone-wait-objectstore.sh
+++ b/tests/drone-wait-objectstore.sh
@@ -1,5 +1,8 @@
#!/bin/bash
+# SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
function get_swift_token() {
KEYSTONE_OUT=$(curl -s 'http://dockswift:5000/v2.0/tokens' -H 'Content-Type: application/json' -d '{"auth":{"passwordCredentials":{"username":"swift","password":"swift"},"tenantName":"service"}}')
if (echo "$KEYSTONE_OUT" | grep -q 'object-store')
diff --git a/tests/enable_all.php b/tests/enable_all.php
index c494f3e0d55..b95f00f767e 100644
--- a/tests/enable_all.php
+++ b/tests/enable_all.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Thomas Müller <thomas.mueller@tmit.eu>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2012-2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
require_once __DIR__.'/../lib/base.php';
diff --git a/tests/karma.config.js b/tests/karma.config.js
index 064ac196b3e..2847b046b25 100644
--- a/tests/karma.config.js
+++ b/tests/karma.config.js
@@ -1,22 +1,7 @@
/**
- * ownCloud
- *
- * @author Vincent Petry
- * @copyright 2014 Vincent Petry <pvince81@owncloud.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2014-2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
/**
@@ -50,13 +35,6 @@ module.exports = function(config) {
'files',
'files_versions',
{
- name: 'comments',
- srcFiles: [
- 'dist/comments-comments.js'
- ],
- testFiles: ['apps/comments/tests/js/**/*.js']
- },
- {
name: 'files_sharing',
srcFiles: [
// only test these files, others are not ready and mess
@@ -72,7 +50,6 @@ module.exports = function(config) {
],
testFiles: ['apps/files_sharing/tests/js/*.js']
},
- 'systemtags',
'files_trashbin',
];
}
diff --git a/tests/lib/APITest.php b/tests/lib/APITest.php
index 5e29629c92e..f7ac3aed4b7 100644
--- a/tests/lib/APITest.php
+++ b/tests/lib/APITest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Tom Needham <tom@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/Accounts/AccountManagerTest.php b/tests/lib/Accounts/AccountManagerTest.php
index d12dfbfacea..da31c77abc6 100644
--- a/tests/lib/Accounts/AccountManagerTest.php
+++ b/tests/lib/Accounts/AccountManagerTest.php
@@ -1,31 +1,16 @@
<?php
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Björn Schießle <schiessle@owncloud.com>
- * @author Thomas Citharel <nextcloud@tcit.fr>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Accounts;
use OC\Accounts\Account;
use OC\Accounts\AccountManager;
+use OC\PhoneNumberUtil;
use OCA\Settings\BackgroundJobs\VerifyUserData;
use OCP\Accounts\IAccountManager;
use OCP\Accounts\UserUpdatedEvent;
@@ -34,6 +19,7 @@ use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IDBConnection;
+use OCP\IPhoneNumberUtil;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\L10N\IFactory;
@@ -75,6 +61,8 @@ class AccountManagerTest extends TestCase {
/** @var IJobList|MockObject */
private $jobList;
+ /** @var IPhoneNumberUtil */
+ private $phoneNumberUtil;
/** accounts table name */
private string $table = 'accounts';
@@ -97,6 +85,7 @@ class AccountManagerTest extends TestCase {
$this->l10nFactory = $this->createMock(IFactory::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->crypto = $this->createMock(ICrypto::class);
+ $this->phoneNumberUtil = new PhoneNumberUtil();
$this->accountManager = new AccountManager(
$this->connection,
@@ -109,7 +98,8 @@ class AccountManagerTest extends TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->crypto
+ $this->crypto,
+ $this->phoneNumberUtil,
);
}
@@ -119,7 +109,7 @@ class AccountManagerTest extends TestCase {
$query->delete($this->table)->executeStatement();
}
- protected function makeUser(string $uid, string $name, string $email = null): IUser {
+ protected function makeUser(string $uid, string $name, ?string $email = null): IUser {
$user = $this->createMock(IUser::class);
$user->expects($this->any())
->method('getUid')
@@ -473,7 +463,8 @@ class AccountManagerTest extends TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->crypto
+ $this->crypto,
+ $this->phoneNumberUtil,
])
->onlyMethods($mockedMethods)
->getMock();
@@ -626,6 +617,12 @@ class AccountManagerTest extends TestCase {
],
[
+ 'name' => IAccountManager::PROPERTY_BIRTHDATE,
+ 'value' => '',
+ 'scope' => IAccountManager::SCOPE_LOCAL,
+ ],
+
+ [
'name' => IAccountManager::PROPERTY_PROFILE_ENABLED,
'value' => '1',
],
diff --git a/tests/lib/Accounts/AccountPropertyCollectionTest.php b/tests/lib/Accounts/AccountPropertyCollectionTest.php
index d8a6bafd24b..83a39dca94f 100644
--- a/tests/lib/Accounts/AccountPropertyCollectionTest.php
+++ b/tests/lib/Accounts/AccountPropertyCollectionTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2021 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\Accounts;
diff --git a/tests/lib/Accounts/AccountPropertyTest.php b/tests/lib/Accounts/AccountPropertyTest.php
index 55f83513349..f8aefccdbaa 100644
--- a/tests/lib/Accounts/AccountPropertyTest.php
+++ b/tests/lib/Accounts/AccountPropertyTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Accounts;
diff --git a/tests/lib/Accounts/AccountTest.php b/tests/lib/Accounts/AccountTest.php
index a86b1d0255b..d9242b073af 100644
--- a/tests/lib/Accounts/AccountTest.php
+++ b/tests/lib/Accounts/AccountTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Accounts;
diff --git a/tests/lib/Accounts/HooksTest.php b/tests/lib/Accounts/HooksTest.php
index 0907f31d842..df9420140d3 100644
--- a/tests/lib/Accounts/HooksTest.php
+++ b/tests/lib/Accounts/HooksTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Bjoern Schiessle <bjoern@schiessle.org>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Accounts;
diff --git a/tests/lib/Activity/ManagerTest.php b/tests/lib/Activity/ManagerTest.php
index 9a39f21f4e5..223021fa66a 100644
--- a/tests/lib/Activity/ManagerTest.php
+++ b/tests/lib/Activity/ManagerTest.php
@@ -1,28 +1,14 @@
<?php
/**
- * @copyright Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com>
- * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Activity;
+use OCP\Activity\Exceptions\IncompleteActivityException;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
@@ -167,7 +153,7 @@ class ManagerTest extends TestCase {
public function testPublishExceptionNoApp() {
- $this->expectException(\BadMethodCallException::class);
+ $this->expectException(IncompleteActivityException::class);
$event = $this->activityManager->generateEvent();
$this->activityManager->publish($event);
@@ -175,7 +161,7 @@ class ManagerTest extends TestCase {
public function testPublishExceptionNoType() {
- $this->expectException(\BadMethodCallException::class);
+ $this->expectException(IncompleteActivityException::class);
$event = $this->activityManager->generateEvent();
$event->setApp('test');
@@ -184,7 +170,7 @@ class ManagerTest extends TestCase {
public function testPublishExceptionNoAffectedUser() {
- $this->expectException(\BadMethodCallException::class);
+ $this->expectException(IncompleteActivityException::class);
$event = $this->activityManager->generateEvent();
$event->setApp('test')
@@ -194,7 +180,7 @@ class ManagerTest extends TestCase {
public function testPublishExceptionNoSubject() {
- $this->expectException(\BadMethodCallException::class);
+ $this->expectException(IncompleteActivityException::class);
$event = $this->activityManager->generateEvent();
$event->setApp('test')
diff --git a/tests/lib/AllConfigTest.php b/tests/lib/AllConfigTest.php
index fca4e8d8308..c703c47c94e 100644
--- a/tests/lib/AllConfigTest.php
+++ b/tests/lib/AllConfigTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Morris Jobke <hey@morrisjobke.de>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
@@ -277,6 +276,31 @@ class AllConfigTest extends \Test\TestCase {
$this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences`');
}
+ public function testGetUserKeysAllInts() {
+ $config = $this->getConfig();
+
+ // preparation - add something to the database
+ $data = [
+ ['userFetch', 'appFetch1', '123', 'value'],
+ ['userFetch', 'appFetch1', '456', 'value'],
+ ];
+ foreach ($data as $entry) {
+ $this->connection->executeUpdate(
+ 'INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, ' .
+ '`configkey`, `configvalue`) VALUES (?, ?, ?, ?)',
+ $entry
+ );
+ }
+
+ $value = $config->getUserKeys('userFetch', 'appFetch1');
+ $this->assertEquals(['123', '456'], $value);
+ $this->assertIsString($value[0]);
+ $this->assertIsString($value[1]);
+
+ // cleanup
+ $this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences`');
+ }
+
public function testGetUserValueDefault() {
$config = $this->getConfig();
diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php
index 3bf2195499f..c38cadf8e38 100644
--- a/tests/lib/App/AppManagerTest.php
+++ b/tests/lib/App/AppManagerTest.php
@@ -3,10 +3,9 @@
declare(strict_types=1);
/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\App;
@@ -23,6 +22,7 @@ use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
+use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;
use PHPUnit\Framework\MockObject\MockObject;
@@ -98,6 +98,8 @@ class AppManagerTest extends TestCase {
/** @var LoggerInterface|MockObject */
protected $logger;
+ protected IURLGenerator&MockObject $urlGenerator;
+
/** @var IAppManager */
protected $manager;
@@ -112,21 +114,121 @@ class AppManagerTest extends TestCase {
$this->cache = $this->createMock(ICache::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->logger = $this->createMock(LoggerInterface::class);
+ $this->urlGenerator = $this->createMock(IURLGenerator::class);
+
+ $this->overwriteService(AppConfig::class, $this->appConfig);
+ $this->overwriteService(IURLGenerator::class, $this->urlGenerator);
+
$this->cacheFactory->expects($this->any())
->method('createDistributed')
->with('settings')
->willReturn($this->cache);
+
+ $this->config
+ ->method('getSystemValueBool')
+ ->with('installed', false)
+ ->willReturn(true);
+
$this->manager = new AppManager(
$this->userSession,
$this->config,
- $this->appConfig,
$this->groupManager,
$this->cacheFactory,
$this->eventDispatcher,
- $this->logger
+ $this->logger,
);
}
+ /**
+ * @dataProvider dataGetAppIcon
+ */
+ public function testGetAppIcon($callback, ?bool $dark, string|null $expected) {
+ $this->urlGenerator->expects($this->atLeastOnce())
+ ->method('imagePath')
+ ->willReturnCallback($callback);
+
+ if ($dark !== null) {
+ $this->assertEquals($expected, $this->manager->getAppIcon('test', $dark));
+ } else {
+ $this->assertEquals($expected, $this->manager->getAppIcon('test'));
+ }
+ }
+
+ public function dataGetAppIcon(): array {
+ $nothing = function ($appId) {
+ $this->assertEquals('test', $appId);
+ throw new \RuntimeException();
+ };
+
+ $createCallback = function ($workingIcons) {
+ return function ($appId, $icon) use ($workingIcons) {
+ $this->assertEquals('test', $appId);
+ if (in_array($icon, $workingIcons)) {
+ return '/path/' . $icon;
+ }
+ throw new \RuntimeException();
+ };
+ };
+
+ return [
+ 'does not find anything' => [
+ $nothing,
+ false,
+ null,
+ ],
+ 'nothing if request dark but only bright available' => [
+ $createCallback(['app.svg']),
+ true,
+ null,
+ ],
+ 'nothing if request bright but only dark available' => [
+ $createCallback(['app-dark.svg']),
+ false,
+ null,
+ ],
+ 'bright and only app.svg' => [
+ $createCallback(['app.svg']),
+ false,
+ '/path/app.svg',
+ ],
+ 'dark and only app-dark.svg' => [
+ $createCallback(['app-dark.svg']),
+ true,
+ '/path/app-dark.svg',
+ ],
+ 'dark only appname -dark.svg' => [
+ $createCallback(['test-dark.svg']),
+ true,
+ '/path/test-dark.svg',
+ ],
+ 'bright and only appname.svg' => [
+ $createCallback(['test.svg']),
+ false,
+ '/path/test.svg',
+ ],
+ 'priotize custom over default' => [
+ $createCallback(['app.svg', 'test.svg']),
+ false,
+ '/path/test.svg',
+ ],
+ 'defaults to bright' => [
+ $createCallback(['test-dark.svg', 'test.svg']),
+ null,
+ '/path/test.svg',
+ ],
+ 'no dark icon on default' => [
+ $createCallback(['test-dark.svg', 'test.svg', 'app-dark.svg', 'app.svg']),
+ false,
+ '/path/test.svg',
+ ],
+ 'no bright icon on dark' => [
+ $createCallback(['test-dark.svg', 'test.svg', 'app-dark.svg', 'app.svg']),
+ true,
+ '/path/test-dark.svg',
+ ],
+ ];
+ }
+
public function testEnableApp() {
// making sure "files_trashbin" is disabled
if ($this->manager->isEnabledForUser('files_trashbin')) {
@@ -170,9 +272,14 @@ class AppManagerTest extends TestCase {
/** @var AppManager|MockObject $manager */
$manager = $this->getMockBuilder(AppManager::class)
->setConstructorArgs([
- $this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger
+ $this->userSession,
+ $this->config,
+ $this->groupManager,
+ $this->cacheFactory,
+ $this->eventDispatcher,
+ $this->logger,
])
- ->setMethods([
+ ->onlyMethods([
'getAppPath',
])
->getMock();
@@ -218,9 +325,14 @@ class AppManagerTest extends TestCase {
/** @var AppManager|MockObject $manager */
$manager = $this->getMockBuilder(AppManager::class)
->setConstructorArgs([
- $this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger
+ $this->userSession,
+ $this->config,
+ $this->groupManager,
+ $this->cacheFactory,
+ $this->eventDispatcher,
+ $this->logger,
])
- ->setMethods([
+ ->onlyMethods([
'getAppPath',
'getAppInfo',
])
@@ -274,9 +386,14 @@ class AppManagerTest extends TestCase {
/** @var AppManager|MockObject $manager */
$manager = $this->getMockBuilder(AppManager::class)
->setConstructorArgs([
- $this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger
+ $this->userSession,
+ $this->config,
+ $this->groupManager,
+ $this->cacheFactory,
+ $this->eventDispatcher,
+ $this->logger,
])
- ->setMethods([
+ ->onlyMethods([
'getAppPath',
'getAppInfo',
])
@@ -470,8 +587,15 @@ class AppManagerTest extends TestCase {
public function testGetAppsNeedingUpgrade() {
/** @var AppManager|MockObject $manager */
$manager = $this->getMockBuilder(AppManager::class)
- ->setConstructorArgs([$this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger])
- ->setMethods(['getAppInfo'])
+ ->setConstructorArgs([
+ $this->userSession,
+ $this->config,
+ $this->groupManager,
+ $this->cacheFactory,
+ $this->eventDispatcher,
+ $this->logger,
+ ])
+ ->onlyMethods(['getAppInfo'])
->getMock();
$appInfos = [
@@ -521,8 +645,15 @@ class AppManagerTest extends TestCase {
public function testGetIncompatibleApps() {
/** @var AppManager|MockObject $manager */
$manager = $this->getMockBuilder(AppManager::class)
- ->setConstructorArgs([$this->userSession, $this->config, $this->appConfig, $this->groupManager, $this->cacheFactory, $this->eventDispatcher, $this->logger])
- ->setMethods(['getAppInfo'])
+ ->setConstructorArgs([
+ $this->userSession,
+ $this->config,
+ $this->groupManager,
+ $this->cacheFactory,
+ $this->eventDispatcher,
+ $this->logger,
+ ])
+ ->onlyMethods(['getAppInfo'])
->getMock();
$appInfos = [
@@ -607,21 +738,124 @@ class AppManagerTest extends TestCase {
// none specified, default to files
[
'',
+ '',
+ '{}',
+ true,
'files',
],
+ // none specified, without fallback
+ [
+ '',
+ '',
+ '{}',
+ false,
+ '',
+ ],
// unexisting or inaccessible app specified, default to files
[
'unexist',
+ '',
+ '{}',
+ true,
'files',
],
+ // unexisting or inaccessible app specified, without fallbacks
+ [
+ 'unexist',
+ '',
+ '{}',
+ false,
+ '',
+ ],
// non-standard app
[
'settings',
+ '',
+ '{}',
+ true,
+ 'settings',
+ ],
+ // non-standard app, without fallback
+ [
+ 'settings',
+ '',
+ '{}',
+ false,
'settings',
],
// non-standard app with fallback
[
'unexist,settings',
+ '',
+ '{}',
+ true,
+ 'settings',
+ ],
+ // system default app and user apporder
+ [
+ // system default is settings
+ 'unexist,settings',
+ '',
+ // apporder says default app is files (order is lower)
+ '{"files_id":{"app":"files","order":1},"settings_id":{"app":"settings","order":2}}',
+ true,
+ // system default should override apporder
+ 'settings'
+ ],
+ // user-customized defaultapp
+ [
+ '',
+ 'files',
+ '',
+ true,
+ 'files',
+ ],
+ // user-customized defaultapp with systemwide
+ [
+ 'unexist,settings',
+ 'files',
+ '',
+ true,
+ 'files',
+ ],
+ // user-customized defaultapp with system wide and apporder
+ [
+ 'unexist,settings',
+ 'files',
+ '{"settings_id":{"app":"settings","order":1},"files_id":{"app":"files","order":2}}',
+ true,
+ 'files',
+ ],
+ // user-customized apporder fallback
+ [
+ '',
+ '',
+ '{"settings_id":{"app":"settings","order":1},"files":{"app":"files","order":2}}',
+ true,
+ 'settings',
+ ],
+ // user-customized apporder fallback with missing app key (entries added by closures does not always have an app key set (Nextcloud 27 spreed app for example))
+ [
+ '',
+ '',
+ '{"spreed":{"order":1},"files":{"app":"files","order":2}}',
+ true,
+ 'files',
+ ],
+ // user-customized apporder, but called without fallback
+ [
+ '',
+ '',
+ '{"settings":{"app":"settings","order":1},"files":{"app":"files","order":2}}',
+ false,
+ '',
+ ],
+ // user-customized apporder with an app that has multiple routes
+ [
+ '',
+ '',
+ '{"settings_id":{"app":"settings","order":1},"settings_id_2":{"app":"settings","order":3},"id_files":{"app":"files","order":2}}',
+ true,
'settings',
],
];
@@ -630,7 +864,7 @@ class AppManagerTest extends TestCase {
/**
* @dataProvider provideDefaultApps
*/
- public function testGetDefaultAppForUser($defaultApps, $expectedApp) {
+ public function testGetDefaultAppForUser($defaultApps, $userDefaultApps, $userApporder, $withFallbacks, $expectedApp) {
$user = $this->newUser('user1');
$this->userSession->expects($this->once())
@@ -642,11 +876,13 @@ class AppManagerTest extends TestCase {
->with('defaultapp', $this->anything())
->willReturn($defaultApps);
- $this->config->expects($this->once())
+ $this->config->expects($this->atLeastOnce())
->method('getUserValue')
- ->with('user1', 'core', 'defaultapp')
- ->willReturn('');
+ ->willReturnMap([
+ ['user1', 'core', 'defaultapp', '', $userDefaultApps],
+ ['user1', 'core', 'apporder', '[]', $userApporder],
+ ]);
- $this->assertEquals($expectedApp, $this->manager->getDefaultAppForUser());
+ $this->assertEquals($expectedApp, $this->manager->getDefaultAppForUser(null, $withFallbacks));
}
}
diff --git a/tests/lib/App/AppStore/Bundles/BundleBase.php b/tests/lib/App/AppStore/Bundles/BundleBase.php
index a886cf9aec1..4c31c49cdb1 100644
--- a/tests/lib/App/AppStore/Bundles/BundleBase.php
+++ b/tests/lib/App/AppStore/Bundles/BundleBase.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\App\AppStore\Bundles;
diff --git a/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php b/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php
index c1fe5ef328a..484b81b5197 100644
--- a/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php
+++ b/tests/lib/App/AppStore/Bundles/BundleFetcherTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\App\AppStore\Bundles;
@@ -26,6 +11,7 @@ use OC\App\AppStore\Bundles\EducationBundle;
use OC\App\AppStore\Bundles\EnterpriseBundle;
use OC\App\AppStore\Bundles\GroupwareBundle;
use OC\App\AppStore\Bundles\HubBundle;
+use OC\App\AppStore\Bundles\PublicSectorBundle;
use OC\App\AppStore\Bundles\SocialSharingBundle;
use OCP\IL10N;
use Test\TestCase;
@@ -53,6 +39,7 @@ class BundleFetcherTest extends TestCase {
new GroupwareBundle($this->l10n),
new SocialSharingBundle($this->l10n),
new EducationBundle($this->l10n),
+ new PublicSectorBundle($this->l10n),
];
$this->assertEquals($expected, $this->bundleFetcher->getBundles());
}
diff --git a/tests/lib/App/AppStore/Bundles/EducationBundleTest.php b/tests/lib/App/AppStore/Bundles/EducationBundleTest.php
index db96b3e46aa..a4508e6156b 100644
--- a/tests/lib/App/AppStore/Bundles/EducationBundleTest.php
+++ b/tests/lib/App/AppStore/Bundles/EducationBundleTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\App\AppStore\Bundles;
diff --git a/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php b/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php
index d24e8846f56..464d48102b2 100644
--- a/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php
+++ b/tests/lib/App/AppStore/Bundles/EnterpriseBundleTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\App\AppStore\Bundles;
diff --git a/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php b/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php
index 88391a6382f..5ba9ee4c4e1 100644
--- a/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php
+++ b/tests/lib/App/AppStore/Bundles/GroupwareBundleTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\App\AppStore\Bundles;
diff --git a/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php b/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php
index 17b2974b7c7..a2681cb0238 100644
--- a/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php
+++ b/tests/lib/App/AppStore/Bundles/SocialSharingBundleTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\App\AppStore\Bundles;
diff --git a/tests/lib/App/AppStore/Fetcher/AppDiscoverFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppDiscoverFetcherTest.php
new file mode 100644
index 00000000000..82f40043971
--- /dev/null
+++ b/tests/lib/App/AppStore/Fetcher/AppDiscoverFetcherTest.php
@@ -0,0 +1,116 @@
+<?php
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace Test\App\AppStore\Fetcher;
+
+use OC\App\AppStore\Fetcher\AppDiscoverFetcher;
+use OC\App\CompareVersion;
+use OCP\Files\NotFoundException;
+use OCP\Files\SimpleFS\ISimpleFile;
+use OCP\Files\SimpleFS\ISimpleFolder;
+use PHPUnit\Framework\MockObject\MockObject;
+
+class AppDiscoverFetcherTest extends FetcherBase {
+ protected CompareVersion|MockObject $compareVersion;
+
+ protected function setUp(): void {
+ parent::setUp();
+ $this->fileName = 'discover.json';
+ $this->endpoint = 'https://apps.nextcloud.com/api/v1/discover.json';
+
+ $this->compareVersion = $this->createMock(CompareVersion::class);
+
+ $this->fetcher = new AppDiscoverFetcher(
+ $this->appDataFactory,
+ $this->clientService,
+ $this->timeFactory,
+ $this->config,
+ $this->logger,
+ $this->registry,
+ $this->compareVersion,
+ );
+ }
+
+ public function testAppstoreDisabled() {
+ $this->config
+ ->method('getSystemValueBool')
+ ->willReturnCallback(function ($var, $default) {
+ if ($var === 'appstoreenabled') {
+ return false;
+ }
+ return $default;
+ });
+ $this->appData
+ ->expects($this->never())
+ ->method('getFolder');
+
+ $this->assertEquals([], $this->fetcher->get());
+ }
+
+ public function testNoInternet() {
+ $this->config
+ ->method('getSystemValueBool')
+ ->willReturnCallback(function ($var, $default) {
+ if ($var === 'has_internet_connection') {
+ return false;
+ }
+ return $default;
+ });
+ $this->config
+ ->method('getSystemValueString')
+ ->willReturnCallback(function ($var, $default) {
+ return $default;
+ });
+ $this->appData
+ ->expects($this->never())
+ ->method('getFolder');
+
+ $this->assertEquals([], $this->fetcher->get());
+ }
+
+ /**
+ * @dataProvider dataGetETag
+ */
+ public function testGetEtag(string|null $expected, bool $throws, string $content = '') {
+ $folder = $this->createMock(ISimpleFolder::class);
+ if (!$throws) {
+ $file = $this->createMock(ISimpleFile::class);
+ $file->expects($this->once())
+ ->method('getContent')
+ ->willReturn($content);
+ $folder->expects($this->once())
+ ->method('getFile')
+ ->with('discover.json')
+ ->willReturn($file);
+ } else {
+ $folder->expects($this->once())
+ ->method('getFile')
+ ->with('discover.json')
+ ->willThrowException(new NotFoundException(''));
+ }
+
+ $this->appData->expects($this->once())
+ ->method('getFolder')
+ ->with('/')
+ ->willReturn($folder);
+
+ $etag = $this->fetcher->getETag();
+ $this->assertEquals($expected, $etag);
+ if ($expected !== null) {
+ $this->assertTrue(gettype($etag) === 'string');
+ }
+ }
+
+ public function dataGetETag(): array {
+ return [
+ 'file not found' => [null, true],
+ 'empty file' => [null, false, ''],
+ 'missing etag' => [null, false, '{ "foo": "bar" }'],
+ 'valid etag' => ['test', false, '{ "ETag": "test" }'],
+ 'numeric etag' => ['132', false, '{ "ETag": 132 }'],
+ ];
+ }
+}
diff --git a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
index 39b0a699092..9a04c11a1f3 100644
--- a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
+++ b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\App\AppStore\Fetcher;
@@ -2098,6 +2083,95 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg==
->willReturnCallback(function ($key, $default) {
if ($key === 'version') {
return '11.0.0.2';
+ } else {
+ return $default;
+ }
+ });
+ $this->config->method('getSystemValue')
+ ->willReturnCallback(function ($key, $default) {
+ if ($key === 'appsallowlist') {
+ return ['contacts'];
+ }
+ return $default;
+ });
+ $this->config->method('getAppValue')
+ ->willReturnCallback(function ($app, $key, $default) {
+ if ($app === 'support' && $key === 'subscription_key') {
+ return 'subscription-key';
+ }
+ return $default;
+ });
+ $this->config
+ ->method('getSystemValueBool')
+ ->willReturnArgument(1);
+
+ $file = $this->createMock(ISimpleFile::class);
+ $folder = $this->createMock(ISimpleFolder::class);
+ $folder
+ ->expects($this->once())
+ ->method('getFile')
+ ->with('apps.json')
+ ->willThrowException(new NotFoundException());
+ $folder
+ ->expects($this->once())
+ ->method('newFile')
+ ->with('apps.json')
+ ->willReturn($file);
+ $this->appData
+ ->expects($this->once())
+ ->method('getFolder')
+ ->with('/')
+ ->willReturn($folder);
+ $client = $this->createMock(IClient::class);
+ $this->clientService
+ ->expects($this->once())
+ ->method('newClient')
+ ->willReturn($client);
+ $response = $this->createMock(IResponse::class);
+ $client
+ ->expects($this->once())
+ ->method('get')
+ ->with('https://apps.nextcloud.com/api/v1/apps.json', [
+ 'timeout' => 60,
+ 'headers' => [
+ 'X-NC-Subscription-Key' => 'subscription-key',
+ ],
+ ])
+ ->willReturn($response);
+ $response
+ ->expects($this->once())
+ ->method('getBody')
+ ->willReturn(self::$responseJson);
+ $response->method('getHeader')
+ ->with($this->equalTo('ETag'))
+ ->willReturn('"myETag"');
+ $this->timeFactory
+ ->expects($this->once())
+ ->method('getTime')
+ ->willReturn(1234);
+
+ $this->registry
+ ->expects($this->exactly(2))
+ ->method('delegateHasValidSubscription')
+ ->willReturn(true);
+
+ $file
+ ->expects($this->once())
+ ->method('putContent');
+ $file
+ ->method('getContent')
+ ->willReturn(json_encode(self::$expectedResponse));
+
+ $apps = array_values($this->fetcher->get());
+ $this->assertEquals(count($apps), 1);
+ $this->assertEquals($apps[0]['id'], 'contacts');
+ }
+
+ public function testGetAppsAllowlistCustomAppstore(): void {
+ $this->config->method('getSystemValueString')
+ ->willReturnCallback(function ($key, $default) {
+ if ($key === 'version') {
+ return '11.0.0.2';
} elseif ($key === 'appstoreurl' && $default === 'https://apps.nextcloud.com/api/v1') {
return 'https://custom.appsstore.endpoint/api/v1';
} else {
@@ -2142,7 +2216,9 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg==
$client
->expects($this->once())
->method('get')
- ->with('https://custom.appsstore.endpoint/api/v1/apps.json')
+ ->with('https://custom.appsstore.endpoint/api/v1/apps.json', [
+ 'timeout' => 60,
+ ])
->willReturn($response);
$response
->expects($this->once())
@@ -2157,7 +2233,7 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg==
->willReturn(1234);
$this->registry
- ->expects($this->exactly(2))
+ ->expects($this->exactly(1))
->method('delegateHasValidSubscription')
->willReturn(true);
diff --git a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php
index 874a58fc6ba..b7dbf6eccd8 100644
--- a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php
+++ b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\App\AppStore\Fetcher;
@@ -64,6 +49,11 @@ class CategoryFetcherTest extends FetcherBase {
}
return $default;
});
+ $this->config
+ ->method('getSystemValueString')
+ ->willReturnCallback(function ($var, $default) {
+ return $default;
+ });
$this->appData
->expects($this->never())
->method('getFolder');
diff --git a/tests/lib/App/AppStore/Fetcher/FetcherBase.php b/tests/lib/App/AppStore/Fetcher/FetcherBase.php
index dbc3f2a687c..f2bc981d4a6 100644
--- a/tests/lib/App/AppStore/Fetcher/FetcherBase.php
+++ b/tests/lib/App/AppStore/Fetcher/FetcherBase.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\App\AppStore\Fetcher;
@@ -76,10 +61,13 @@ abstract class FetcherBase extends TestCase {
public function testGetWithAlreadyExistingFileAndUpToDateTimestampAndVersion() {
$this->config
- ->expects($this->exactly(1))
->method('getSystemValueString')
- ->with($this->equalTo('version'), $this->anything())
- ->willReturn('11.0.0.2');
+ ->willReturnCallback(function ($var, $default) {
+ if ($var === 'version') {
+ return '11.0.0.2';
+ }
+ return $default;
+ });
$this->config->method('getSystemValueBool')
->willReturnArgument(1);
diff --git a/tests/lib/App/AppStore/Version/VersionParserTest.php b/tests/lib/App/AppStore/Version/VersionParserTest.php
index edb48dc4130..c461bf7c6cf 100644
--- a/tests/lib/App/AppStore/Version/VersionParserTest.php
+++ b/tests/lib/App/AppStore/Version/VersionParserTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\App\AppStore\Version;
@@ -77,7 +62,7 @@ class VersionParserTest extends TestCase {
* @param Version $expected
*/
public function testGetVersion($input,
- Version $expected) {
+ Version $expected) {
$this->assertEquals($expected, $this->versionParser->getVersion($input));
}
diff --git a/tests/lib/App/AppStore/Version/VersionTest.php b/tests/lib/App/AppStore/Version/VersionTest.php
index 969c96a57a8..68da79fdc8d 100644
--- a/tests/lib/App/AppStore/Version/VersionTest.php
+++ b/tests/lib/App/AppStore/Version/VersionTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\App\AppStore\Version;
diff --git a/tests/lib/App/CompareVersionTest.php b/tests/lib/App/CompareVersionTest.php
index 0988304f8fc..b9af3a96b22 100644
--- a/tests/lib/App/CompareVersionTest.php
+++ b/tests/lib/App/CompareVersionTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\App;
diff --git a/tests/lib/App/DependencyAnalyzerTest.php b/tests/lib/App/DependencyAnalyzerTest.php
index f2ae412c2f6..1b9c977e737 100644
--- a/tests/lib/App/DependencyAnalyzerTest.php
+++ b/tests/lib/App/DependencyAnalyzerTest.php
@@ -1,13 +1,9 @@
<?php
/**
- * @author Thomas Müller
- * @author Lukas Reschke
- * @copyright 2014 Thomas Müller deepdiver@owncloud.com
- * @copyright 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2014-2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace Test\App;
use OC\App\DependencyAnalyzer;
diff --git a/tests/lib/App/InfoParserTest.php b/tests/lib/App/InfoParserTest.php
index bc561611501..9affe3ff9ae 100644
--- a/tests/lib/App/InfoParserTest.php
+++ b/tests/lib/App/InfoParserTest.php
@@ -1,17 +1,15 @@
<?php
/**
- * @author Thomas Müller
- * @copyright 2014 Thomas Müller deepdiver@owncloud.com
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2014-2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-
namespace Test\App;
use OC;
use OC\App\InfoParser;
-use Test\TestCase;
use OCP\Cache\CappedMemoryCache;
+use Test\TestCase;
class InfoParserTest extends TestCase {
/** @var OCP\Cache\CappedMemoryCache */
diff --git a/tests/lib/App/PlatformRepositoryTest.php b/tests/lib/App/PlatformRepositoryTest.php
index 51884b26e71..e1eb7b16b40 100644
--- a/tests/lib/App/PlatformRepositoryTest.php
+++ b/tests/lib/App/PlatformRepositoryTest.php
@@ -1,12 +1,9 @@
<?php
-
/**
- * @author Thomas Müller
- * @copyright 2014 Thomas Müller deepdiver@owncloud.com
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2020-2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2014-2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-
namespace Test\App;
use OC;
diff --git a/tests/lib/AppConfigTest.php b/tests/lib/AppConfigTest.php
index d4ae66cb2f1..f82f3b45b32 100644
--- a/tests/lib/AppConfigTest.php
+++ b/tests/lib/AppConfigTest.php
@@ -1,17 +1,20 @@
<?php
+
+declare(strict_types=1);
/**
- * Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it>
- * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace Test;
+use InvalidArgumentException;
use OC\AppConfig;
-use OC\DB\Connection;
-use OCP\IConfig;
+use OCP\Exceptions\AppConfigTypeConflictException;
+use OCP\Exceptions\AppConfigUnknownKeyException;
+use OCP\IAppConfig;
+use OCP\IDBConnection;
+use OCP\Security\ICrypto;
+use Psr\Log\LoggerInterface;
/**
* Class AppConfigTest
@@ -21,348 +24,1440 @@ use OCP\IConfig;
* @package Test
*/
class AppConfigTest extends TestCase {
- /** @var \OCP\IAppConfig */
- protected $appConfig;
-
- /** @var Connection */
- protected $connection;
+ protected IAppConfig $appConfig;
+ protected IDBConnection $connection;
+ private LoggerInterface $logger;
+ private ICrypto $crypto;
+ private array $originalConfig;
- protected $originalConfig;
+ /**
+ * @var array<string, array<array<string, string, int, bool, bool>>>
+ * [appId => [configKey, configValue, valueType, lazy, sensitive]]
+ */
+ private array $baseStruct =
+ [
+ 'testapp' => [
+ 'enabled' => ['enabled', 'true'],
+ 'installed_version' => ['installed_version', '1.2.3'],
+ 'depends_on' => ['depends_on', 'someapp'],
+ 'deletethis' => ['deletethis', 'deletethis'],
+ 'key' => ['key', 'value']
+ ],
+ 'someapp' => [
+ 'key' => ['key', 'value'],
+ 'otherkey' => ['otherkey', 'othervalue']
+ ],
+ '123456' => [
+ 'enabled' => ['enabled', 'true'],
+ 'key' => ['key', 'value']
+ ],
+ 'anotherapp' => [
+ 'enabled' => ['enabled', 'false'],
+ 'key' => ['key', 'value']
+ ],
+ 'non-sensitive-app' => [
+ 'lazy-key' => ['lazy-key', 'value', IAppConfig::VALUE_STRING, true, false],
+ 'non-lazy-key' => ['non-lazy-key', 'value', IAppConfig::VALUE_STRING, false, false],
+ ],
+ 'sensitive-app' => [
+ 'lazy-key' => ['lazy-key', 'value', IAppConfig::VALUE_STRING, true, true],
+ 'non-lazy-key' => ['non-lazy-key', 'value', IAppConfig::VALUE_STRING, false, true],
+ ],
+ 'only-lazy' => [
+ 'lazy-key' => ['lazy-key', 'value', IAppConfig::VALUE_STRING, true]
+ ],
+ 'typed' => [
+ 'mixed' => ['mixed', 'mix', IAppConfig::VALUE_MIXED],
+ 'string' => ['string', 'value', IAppConfig::VALUE_STRING],
+ 'int' => ['int', '42', IAppConfig::VALUE_INT],
+ 'float' => ['float', '3.14', IAppConfig::VALUE_FLOAT],
+ 'bool' => ['bool', '1', IAppConfig::VALUE_BOOL],
+ 'array' => ['array', '{"test": 1}', IAppConfig::VALUE_ARRAY],
+ ],
+ 'prefix-app' => [
+ 'key1' => ['key1', 'value'],
+ 'prefix1' => ['prefix1', 'value'],
+ 'prefix-2' => ['prefix-2', 'value'],
+ 'key-2' => ['key-2', 'value'],
+ ]
+ ];
protected function setUp(): void {
parent::setUp();
- $this->connection = \OC::$server->get(Connection::class);
+ $this->connection = \OCP\Server::get(IDBConnection::class);
+ $this->logger = \OCP\Server::get(LoggerInterface::class);
+ $this->crypto = \OCP\Server::get(ICrypto::class);
+
+ // storing current config and emptying the data table
$sql = $this->connection->getQueryBuilder();
$sql->select('*')
->from('appconfig');
- $result = $sql->execute();
+ $result = $sql->executeQuery();
$this->originalConfig = $result->fetchAll();
$result->closeCursor();
$sql = $this->connection->getQueryBuilder();
$sql->delete('appconfig');
- $sql->execute();
-
- $this->overwriteService(AppConfig::class, new \OC\AppConfig($this->connection));
+ $sql->executeStatement();
$sql = $this->connection->getQueryBuilder();
$sql->insert('appconfig')
- ->values([
- 'appid' => $sql->createParameter('appid'),
- 'configkey' => $sql->createParameter('configkey'),
- 'configvalue' => $sql->createParameter('configvalue'),
- ]);
-
- $sql->setParameters([
- 'appid' => 'testapp',
- 'configkey' => 'enabled',
- 'configvalue' => 'true',
- ])->execute();
- $sql->setParameters([
- 'appid' => 'testapp',
- 'configkey' => 'installed_version',
- 'configvalue' => '1.2.3',
- ])->execute();
- $sql->setParameters([
- 'appid' => 'testapp',
- 'configkey' => 'depends_on',
- 'configvalue' => 'someapp',
- ])->execute();
- $sql->setParameters([
- 'appid' => 'testapp',
- 'configkey' => 'deletethis',
- 'configvalue' => 'deletethis',
- ])->execute();
- $sql->setParameters([
- 'appid' => 'testapp',
- 'configkey' => 'key',
- 'configvalue' => 'value',
- ])->execute();
-
- $sql->setParameters([
- 'appid' => 'someapp',
- 'configkey' => 'key',
- 'configvalue' => 'value',
- ])->execute();
- $sql->setParameters([
- 'appid' => 'someapp',
- 'configkey' => 'otherkey',
- 'configvalue' => 'othervalue',
- ])->execute();
-
- $sql->setParameters([
- 'appid' => '123456',
- 'configkey' => 'key',
- 'configvalue' => 'value',
- ])->execute();
- $sql->setParameters([
- 'appid' => '123456',
- 'configkey' => 'enabled',
- 'configvalue' => 'false',
- ])->execute();
-
- $sql->setParameters([
- 'appid' => 'anotherapp',
- 'configkey' => 'key',
- 'configvalue' => 'value',
- ])->execute();
- $sql->setParameters([
- 'appid' => 'anotherapp',
- 'configkey' => 'enabled',
- 'configvalue' => 'false',
- ])->execute();
+ ->values(
+ [
+ 'appid' => $sql->createParameter('appid'),
+ 'configkey' => $sql->createParameter('configkey'),
+ 'configvalue' => $sql->createParameter('configvalue'),
+ 'type' => $sql->createParameter('type'),
+ 'lazy' => $sql->createParameter('lazy')
+ ]
+ );
+
+ foreach ($this->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;
+ }
+
+ $sql->setParameters(
+ [
+ 'appid' => $appId,
+ 'configkey' => $row[0],
+ 'configvalue' => $value,
+ 'type' => $type,
+ 'lazy' => (($row[3] ?? false) === true) ? 1 : 0
+ ]
+ )->executeStatement();
+ }
+ }
}
protected function tearDown(): void {
$sql = $this->connection->getQueryBuilder();
$sql->delete('appconfig');
- $sql->execute();
+ $sql->executeStatement();
$sql = $this->connection->getQueryBuilder();
$sql->insert('appconfig')
- ->values([
- 'appid' => $sql->createParameter('appid'),
- 'configkey' => $sql->createParameter('configkey'),
- 'configvalue' => $sql->createParameter('configvalue'),
- ]);
-
- foreach ($this->originalConfig as $configs) {
+ ->values(
+ [
+ 'appid' => $sql->createParameter('appid'),
+ 'configkey' => $sql->createParameter('configkey'),
+ 'configvalue' => $sql->createParameter('configvalue'),
+ 'lazy' => $sql->createParameter('lazy'),
+ 'type' => $sql->createParameter('type'),
+ ]
+ );
+
+ foreach ($this->originalConfig as $key => $configs) {
$sql->setParameter('appid', $configs['appid'])
->setParameter('configkey', $configs['configkey'])
- ->setParameter('configvalue', $configs['configvalue']);
- $sql->execute();
+ ->setParameter('configvalue', $configs['configvalue'])
+ ->setParameter('lazy', ($configs['lazy'] === '1') ? '1' : '0')
+ ->setParameter('type', $configs['type']);
+ $sql->executeStatement();
}
- $this->restoreService(AppConfig::class);
+ // $this->restoreService(AppConfig::class);
parent::tearDown();
}
- public function testGetApps() {
- $config = new \OC\AppConfig(\OC::$server->get(Connection::class));
+ /**
+ * @param bool $preLoading TRUE will preload the 'fast' cache, which is the normal behavior of usual
+ * IAppConfig
+ *
+ * @return IAppConfig
+ */
+ private function generateAppConfig(bool $preLoading = true): IAppConfig {
+ /** @var AppConfig $config */
+ $config = new \OC\AppConfig(
+ $this->connection,
+ $this->logger,
+ $this->crypto,
+ );
+ $msg = ' generateAppConfig() failed to confirm cache status';
+
+ // confirm cache status
+ $status = $config->statusCache();
+ $this->assertSame(false, $status['fastLoaded'], $msg);
+ $this->assertSame(false, $status['lazyLoaded'], $msg);
+ $this->assertSame([], $status['fastCache'], $msg);
+ $this->assertSame([], $status['lazyCache'], $msg);
+ if ($preLoading) {
+ // simple way to initiate the load of non-lazy config values in cache
+ $config->getValueString('core', 'preload', '');
+
+ // confirm cache status
+ $status = $config->statusCache();
+ $this->assertSame(true, $status['fastLoaded'], $msg);
+ $this->assertSame(false, $status['lazyLoaded'], $msg);
+
+ $apps = array_values(array_diff(array_keys($this->baseStruct), ['only-lazy']));
+ $this->assertEqualsCanonicalizing($apps, array_keys($status['fastCache']), $msg);
+ $this->assertSame([], array_keys($status['lazyCache']), $msg);
+ }
- $this->assertEqualsCanonicalizing([
- 'anotherapp',
- 'someapp',
- 'testapp',
- 123456,
- ], $config->getApps());
+ return $config;
}
- public function testGetKeys() {
- $config = new \OC\AppConfig(\OC::$server->get(Connection::class));
+ public function testGetApps(): void {
+ $config = $this->generateAppConfig(false);
- $keys = $config->getKeys('testapp');
- $this->assertEqualsCanonicalizing([
- 'deletethis',
- 'depends_on',
- 'enabled',
- 'installed_version',
- 'key',
- ], $keys);
+ $this->assertEqualsCanonicalizing(array_keys($this->baseStruct), $config->getApps());
}
- public function testGetValue() {
- $config = new \OC\AppConfig(\OC::$server->get(Connection::class));
+ /**
+ * returns list of app and their keys
+ *
+ * @return array<string, string[]> ['appId' => ['key1', 'key2', ]]
+ * @see testGetKeys
+ */
+ public function providerGetAppKeys(): array {
+ $appKeys = [];
+ foreach ($this->baseStruct as $appId => $appData) {
+ $keys = [];
+ foreach ($appData as $row) {
+ $keys[] = $row[0];
+ }
+ $appKeys[] = [(string)$appId, $keys];
+ }
- $value = $config->getValue('testapp', 'installed_version');
- $this->assertConfigKey('testapp', 'installed_version', $value);
+ return $appKeys;
+ }
- $value = $config->getValue('testapp', 'nonexistant');
- $this->assertNull($value);
+ /**
+ * returns list of config keys
+ *
+ * @return array<string, string, string, int, bool, bool> [appId, key, value, type, lazy, sensitive]
+ * @see testIsSensitive
+ * @see testIsLazy
+ * @see testGetKeys
+ */
+ public function providerGetKeys(): array {
+ $appKeys = [];
+ foreach ($this->baseStruct as $appId => $appData) {
+ foreach ($appData as $row) {
+ $appKeys[] = [
+ (string)$appId, $row[0], $row[1], $row[2] ?? IAppConfig::VALUE_MIXED, $row[3] ?? false,
+ $row[4] ?? false
+ ];
+ }
+ }
- $value = $config->getValue('testapp', 'nonexistant', 'default');
- $this->assertEquals('default', $value);
+ return $appKeys;
}
- public function testHasKey() {
- $config = new \OC\AppConfig(\OC::$server->get(Connection::class));
+ /**
+ * @dataProvider providerGetAppKeys
+ *
+ * @param string $appId
+ * @param array $expectedKeys
+ */
+ public function testGetKeys(string $appId, array $expectedKeys): void {
+ $config = $this->generateAppConfig();
+ $this->assertEqualsCanonicalizing($expectedKeys, $config->getKeys($appId));
+ }
- $this->assertTrue($config->hasKey('testapp', 'installed_version'));
- $this->assertFalse($config->hasKey('testapp', 'nonexistant'));
- $this->assertFalse($config->hasKey('nonexistant', 'nonexistant'));
+ public function testGetKeysOnUnknownAppShouldReturnsEmptyArray(): void {
+ $config = $this->generateAppConfig();
+ $this->assertEqualsCanonicalizing([], $config->getKeys('unknown-app'));
}
- public function testSetValueUpdate() {
- $config = new \OC\AppConfig(\OC::$server->get(Connection::class));
+ /**
+ * @dataProvider providerGetKeys
+ *
+ * @param string $appId
+ * @param string $configKey
+ * @param string $value
+ * @param bool $lazy
+ */
+ public function testHasKey(string $appId, string $configKey, string $value, int $type, bool $lazy): void {
+ $config = $this->generateAppConfig();
+ $this->assertEquals(true, $config->hasKey($appId, $configKey, $lazy));
+ }
- $this->assertEquals('1.2.3', $config->getValue('testapp', 'installed_version'));
- $this->assertConfigKey('testapp', 'installed_version', '1.2.3');
+ public function testHasKeyOnNonExistentKeyReturnsFalse(): void {
+ $config = $this->generateAppConfig();
+ $this->assertEquals(false, $config->hasKey(array_keys($this->baseStruct)[0], 'inexistant-key'));
+ }
- $wasModified = $config->setValue('testapp', 'installed_version', '1.2.3');
- if (!(\OC::$server->get(Connection::class) instanceof \OC\DB\OracleConnection)) {
- $this->assertFalse($wasModified);
- }
+ public function testHasKeyOnUnknownAppReturnsFalse(): void {
+ $config = $this->generateAppConfig();
+ $this->assertEquals(false, $config->hasKey('inexistant-app', 'inexistant-key'));
+ }
- $this->assertEquals('1.2.3', $config->getValue('testapp', 'installed_version'));
- $this->assertConfigKey('testapp', 'installed_version', '1.2.3');
+ public function testHasKeyOnMistypedAsLazyReturnsFalse(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(false, $config->hasKey('non-sensitive-app', 'non-lazy-key', true));
+ }
- $this->assertTrue($config->setValue('testapp', 'installed_version', '1.33.7'));
+ public function testHasKeyOnMistypeAsNonLazyReturnsFalse(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(false, $config->hasKey('non-sensitive-app', 'lazy-key', false));
+ }
+ public function testHasKeyOnMistypeAsNonLazyReturnsTrueWithLazyArgumentIsNull(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(true, $config->hasKey('non-sensitive-app', 'lazy-key', null));
+ }
- $this->assertEquals('1.33.7', $config->getValue('testapp', 'installed_version'));
- $this->assertConfigKey('testapp', 'installed_version', '1.33.7');
+ /**
+ * @dataProvider providerGetKeys
+ */
+ public function testIsSensitive(
+ string $appId, string $configKey, string $configValue, int $type, bool $lazy, bool $sensitive
+ ): void {
+ $config = $this->generateAppConfig();
+ $this->assertEquals($sensitive, $config->isSensitive($appId, $configKey, $lazy));
+ }
- $config->setValue('someapp', 'somekey', 'somevalue');
- $this->assertConfigKey('someapp', 'somekey', 'somevalue');
+ public function testIsSensitiveOnNonExistentKeyThrowsException(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(AppConfigUnknownKeyException::class);
+ $config->isSensitive(array_keys($this->baseStruct)[0], 'inexistant-key');
}
- public function testSetValueInsert() {
- $config = new \OC\AppConfig(\OC::$server->get(Connection::class));
+ public function testIsSensitiveOnUnknownAppThrowsException(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(AppConfigUnknownKeyException::class);
+ $config->isSensitive('unknown-app', 'inexistant-key');
+ }
- $this->assertFalse($config->hasKey('someapp', 'somekey'));
- $this->assertNull($config->getValue('someapp', 'somekey'));
+ public function testIsSensitiveOnSensitiveMistypedAsLazy(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(true, $config->isSensitive('sensitive-app', 'non-lazy-key', true));
+ }
- $this->assertTrue($config->setValue('someapp', 'somekey', 'somevalue'));
+ public function testIsSensitiveOnNonSensitiveMistypedAsLazy(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(false, $config->isSensitive('non-sensitive-app', 'non-lazy-key', true));
+ }
- $this->assertTrue($config->hasKey('someapp', 'somekey'));
- $this->assertEquals('somevalue', $config->getValue('someapp', 'somekey'));
- $this->assertConfigKey('someapp', 'somekey', 'somevalue');
+ public function testIsSensitiveOnSensitiveMistypedAsNonLazyThrowsException(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(AppConfigUnknownKeyException::class);
+ $config->isSensitive('sensitive-app', 'lazy-key', false);
+ }
- $wasInserted = $config->setValue('someapp', 'somekey', 'somevalue');
- if (!(\OC::$server->get(Connection::class) instanceof \OC\DB\OracleConnection)) {
- $this->assertFalse($wasInserted);
- }
+ public function testIsSensitiveOnNonSensitiveMistypedAsNonLazyThrowsException(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(AppConfigUnknownKeyException::class);
+ $config->isSensitive('non-sensitive-app', 'lazy-key', false);
}
- public function testDeleteKey() {
- $config = new \OC\AppConfig(\OC::$server->get(Connection::class));
+ /**
+ * @dataProvider providerGetKeys
+ */
+ public function testIsLazy(string $appId, string $configKey, string $configValue, int $type, bool $lazy
+ ): void {
+ $config = $this->generateAppConfig();
+ $this->assertEquals($lazy, $config->isLazy($appId, $configKey));
+ }
- $this->assertTrue($config->hasKey('testapp', 'deletethis'));
+ public function testIsLazyOnNonExistentKeyThrowsException(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(AppConfigUnknownKeyException::class);
+ $config->isLazy(array_keys($this->baseStruct)[0], 'inexistant-key');
+ }
- $config->deleteKey('testapp', 'deletethis');
+ public function testIsLazyOnUnknownAppThrowsException(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(AppConfigUnknownKeyException::class);
+ $config->isLazy('unknown-app', 'inexistant-key');
+ }
- $this->assertFalse($config->hasKey('testapp', 'deletethis'));
+ public function testGetAllValues(): void {
+ $config = $this->generateAppConfig();
+ $this->assertEquals(
+ [
+ 'array' => ['test' => 1],
+ 'bool' => true,
+ 'float' => 3.14,
+ 'int' => 42,
+ 'mixed' => 'mix',
+ 'string' => 'value',
+ ],
+ $config->getAllValues('typed')
+ );
+ }
- $sql = \OC::$server->getDatabaseConnection()->getQueryBuilder();
- $sql->select('configvalue')
- ->from('appconfig')
- ->where($sql->expr()->eq('appid', $sql->createParameter('appid')))
- ->andWhere($sql->expr()->eq('configkey', $sql->createParameter('configkey')))
- ->setParameter('appid', 'testapp')
- ->setParameter('configkey', 'deletethis');
- $query = $sql->execute();
- $result = $query->fetch();
- $query->closeCursor();
- $this->assertFalse($result);
+ public function testGetAllValuesWithEmptyApp(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(InvalidArgumentException::class);
+ $config->getAllValues('');
}
- public function testDeleteApp() {
- $config = new \OC\AppConfig(\OC::$server->get(Connection::class));
+ /**
+ * @dataProvider providerGetAppKeys
+ *
+ * @param string $appId
+ * @param array $keys
+ */
+ public function testGetAllValuesWithEmptyKey(string $appId, array $keys): void {
+ $config = $this->generateAppConfig();
+ $this->assertEqualsCanonicalizing($keys, array_keys($config->getAllValues($appId, '')));
+ }
- $this->assertTrue($config->hasKey('someapp', 'otherkey'));
+ public function testGetAllValuesWithPrefix(): void {
+ $config = $this->generateAppConfig();
+ $this->assertEqualsCanonicalizing(['prefix1', 'prefix-2'], array_keys($config->getAllValues('prefix-app', 'prefix')));
+ }
- $config->deleteApp('someapp');
+ public function testSearchValues(): void {
+ $config = $this->generateAppConfig();
+ $this->assertEqualsCanonicalizing(['testapp' => 'true', '123456' => 'true', 'anotherapp' => 'false'], $config->searchValues('enabled'));
+ }
- $this->assertFalse($config->hasKey('someapp', 'otherkey'));
+ public function testGetValueString(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame('value', $config->getValueString('typed', 'string', ''));
+ }
- $sql = \OC::$server->getDatabaseConnection()->getQueryBuilder();
- $sql->select('configvalue')
- ->from('appconfig')
- ->where($sql->expr()->eq('appid', $sql->createParameter('appid')))
- ->setParameter('appid', 'someapp');
- $query = $sql->execute();
- $result = $query->fetch();
- $query->closeCursor();
- $this->assertFalse($result);
+ public function testGetValueStringOnUnknownAppReturnsDefault(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame('default-1', $config->getValueString('typed-1', 'string', 'default-1'));
}
- public function testGetValuesNotAllowed() {
- $config = new \OC\AppConfig(\OC::$server->get(Connection::class));
+ public function testGetValueStringOnNonExistentKeyReturnsDefault(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame('default-2', $config->getValueString('typed', 'string-2', 'default-2'));
+ }
- $this->assertFalse($config->getValues('testapp', 'enabled'));
+ public function testGetValueStringOnWrongType(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(AppConfigTypeConflictException::class);
+ $config->getValueString('typed', 'int');
+ }
- $this->assertFalse($config->getValues(false, false));
+ public function testGetNonLazyValueStringAsLazy(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame('value', $config->getValueString('non-sensitive-app', 'non-lazy-key', 'default', lazy: true));
}
- public function testGetValues() {
- $config = new \OC\AppConfig(\OC::$server->get(Connection::class));
+ public function testGetValueInt() {
+ $config = $this->generateAppConfig();
+ $this->assertSame(42, $config->getValueInt('typed', 'int', 0));
+ }
- $sql = \OC::$server->getDatabaseConnection()->getQueryBuilder();
- $sql->select(['configkey', 'configvalue'])
- ->from('appconfig')
- ->where($sql->expr()->eq('appid', $sql->createParameter('appid')))
- ->setParameter('appid', 'testapp');
- $query = $sql->execute();
- $expected = [];
- while ($row = $query->fetch()) {
- $expected[$row['configkey']] = $row['configvalue'];
- }
- $query->closeCursor();
+ public function testGetValueIntOnUnknownAppReturnsDefault(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(1, $config->getValueInt('typed-1', 'int', 1));
+ }
- $values = $config->getValues('testapp', false);
- $this->assertEquals($expected, $values);
+ public function testGetValueIntOnNonExistentKeyReturnsDefault() {
+ $config = $this->generateAppConfig();
+ $this->assertSame(2, $config->getValueInt('typed', 'int-2', 2));
+ }
- $sql = \OC::$server->getDatabaseConnection()->getQueryBuilder();
- $sql->select(['appid', 'configvalue'])
- ->from('appconfig')
- ->where($sql->expr()->eq('configkey', $sql->createParameter('configkey')))
- ->setParameter('configkey', 'enabled');
- $query = $sql->execute();
- $expected = [];
- while ($row = $query->fetch()) {
- $expected[$row['appid']] = $row['configvalue'];
- }
- $query->closeCursor();
+ public function testGetValueIntOnWrongType(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(AppConfigTypeConflictException::class);
+ $config->getValueInt('typed', 'float');
+ }
+
+ public function testGetValueFloat() {
+ $config = $this->generateAppConfig();
+ $this->assertSame(3.14, $config->getValueFloat('typed', 'float', 0));
+ }
+
+ public function testGetValueFloatOnNonUnknownAppReturnsDefault(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(1.11, $config->getValueFloat('typed-1', 'float', 1.11));
+ }
+
+ public function testGetValueFloatOnNonExistentKeyReturnsDefault() {
+ $config = $this->generateAppConfig();
+ $this->assertSame(2.22, $config->getValueFloat('typed', 'float-2', 2.22));
+ }
+
+ public function testGetValueFloatOnWrongType(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(AppConfigTypeConflictException::class);
+ $config->getValueFloat('typed', 'bool');
+ }
+
+ public function testGetValueBool(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(true, $config->getValueBool('typed', 'bool'));
+ }
+
+ public function testGetValueBoolOnUnknownAppReturnsDefault(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(false, $config->getValueBool('typed-1', 'bool', false));
+ }
+
+ public function testGetValueBoolOnNonExistentKeyReturnsDefault(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(false, $config->getValueBool('typed', 'bool-2'));
+ }
- $values = $config->getValues(false, 'enabled');
- $this->assertEquals($expected, $values);
+ public function testGetValueBoolOnWrongType(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(AppConfigTypeConflictException::class);
+ $config->getValueBool('typed', 'array');
}
- public function testGetFilteredValues() {
- /** @var \OC\AppConfig|\PHPUnit\Framework\MockObject\MockObject $config */
- $config = $this->getMockBuilder(\OC\AppConfig::class)
- ->setConstructorArgs([\OC::$server->get(Connection::class)])
- ->setMethods(['getValues'])
- ->getMock();
+ public function testGetValueArray(): void {
+ $config = $this->generateAppConfig();
+ $this->assertEqualsCanonicalizing(['test' => 1], $config->getValueArray('typed', 'array', []));
+ }
- $config->expects($this->once())
- ->method('getValues')
- ->with('user_ldap', false)
- ->willReturn([
- 'ldap_agent_password' => 'secret',
- 's42ldap_agent_password' => 'secret',
- 'ldap_dn' => 'dn',
- ]);
+ public function testGetValueArrayOnUnknownAppReturnsDefault(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame([1], $config->getValueArray('typed-1', 'array', [1]));
+ }
- $values = $config->getFilteredValues('user_ldap');
- $this->assertEquals([
- 'ldap_agent_password' => IConfig::SENSITIVE_VALUE,
- 's42ldap_agent_password' => IConfig::SENSITIVE_VALUE,
- 'ldap_dn' => 'dn',
- ], $values);
+ public function testGetValueArrayOnNonExistentKeyReturnsDefault(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame([1, 2], $config->getValueArray('typed', 'array-2', [1, 2]));
}
- public function testSettingConfigParallel() {
- $appConfig1 = new \OC\AppConfig(\OC::$server->get(Connection::class));
- $appConfig2 = new \OC\AppConfig(\OC::$server->get(Connection::class));
- $appConfig1->getValue('testapp', 'foo', 'v1');
- $appConfig2->getValue('testapp', 'foo', 'v1');
+ public function testGetValueArrayOnWrongType(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(AppConfigTypeConflictException::class);
+ $config->getValueArray('typed', 'string');
+ }
- $appConfig1->setValue('testapp', 'foo', 'v1');
- $this->assertConfigKey('testapp', 'foo', 'v1');
- $appConfig2->setValue('testapp', 'foo', 'v2');
- $this->assertConfigKey('testapp', 'foo', 'v2');
+ /**
+ * @return array
+ * @see testGetValueType
+ *
+ * @see testGetValueMixed
+ */
+ public function providerGetValueMixed(): array {
+ return [
+ // key, value, type
+ ['mixed', 'mix', IAppConfig::VALUE_MIXED],
+ ['string', 'value', IAppConfig::VALUE_STRING],
+ ['int', '42', IAppConfig::VALUE_INT],
+ ['float', '3.14', IAppConfig::VALUE_FLOAT],
+ ['bool', '1', IAppConfig::VALUE_BOOL],
+ ['array', '{"test": 1}', IAppConfig::VALUE_ARRAY],
+ ];
}
/**
- * @param string $app
+ * @dataProvider providerGetValueMixed
+ *
* @param string $key
- * @param string $expected
+ * @param string $value
*/
- protected function assertConfigKey($app, $key, $expected) {
- $sql = \OC::$server->getDatabaseConnection()->getQueryBuilder();
+ public function testGetValueMixed(string $key, string $value): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame($value, $config->getValueMixed('typed', $key));
+ }
+
+ /**
+ * @dataProvider providerGetValueMixed
+ *
+ * @param string $key
+ * @param string $value
+ * @param int $type
+ */
+ public function testGetValueType(string $key, string $value, int $type): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame($type, $config->getValueType('typed', $key));
+ }
+
+ public function testGetValueTypeOnUnknownApp(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(AppConfigUnknownKeyException::class);
+ $config->getValueType('typed-1', 'string');
+ }
+
+ public function testGetValueTypeOnNonExistentKey(): void {
+ $config = $this->generateAppConfig();
+ $this->expectException(AppConfigUnknownKeyException::class);
+ $config->getValueType('typed', 'string-2');
+ }
+
+ public function testSetValueString(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1');
+ $this->assertSame('value-1', $config->getValueString('feed', 'string', ''));
+ }
+
+ public function testSetValueStringCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1');
+ $status = $config->statusCache();
+ $this->assertSame('value-1', $status['fastCache']['feed']['string']);
+ }
+
+ public function testSetValueStringDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1');
+ $config->clearCache();
+ $this->assertSame('value-1', $config->getValueString('feed', 'string', ''));
+ }
+
+ public function testSetValueStringIsUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1');
+ $this->assertSame(true, $config->setValueString('feed', 'string', 'value-2'));
+ }
+
+ public function testSetValueStringIsNotUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1');
+ $this->assertSame(false, $config->setValueString('feed', 'string', 'value-1'));
+ }
+
+ public function testSetValueStringIsUpdatedCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1');
+ $config->setValueString('feed', 'string', 'value-2');
+ $status = $config->statusCache();
+ $this->assertSame('value-2', $status['fastCache']['feed']['string']);
+ }
+
+ public function testSetValueStringIsUpdatedDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1');
+ $config->setValueString('feed', 'string', 'value-2');
+ $config->clearCache();
+ $this->assertSame('value-2', $config->getValueString('feed', 'string', ''));
+ }
+
+ public function testSetValueInt(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42);
+ $this->assertSame(42, $config->getValueInt('feed', 'int', 0));
+ }
+
+ public function testSetValueIntCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42);
+ $status = $config->statusCache();
+ $this->assertSame('42', $status['fastCache']['feed']['int']);
+ }
+
+ public function testSetValueIntDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42);
+ $config->clearCache();
+ $this->assertSame(42, $config->getValueInt('feed', 'int', 0));
+ }
+
+ public function testSetValueIntIsUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42);
+ $this->assertSame(true, $config->setValueInt('feed', 'int', 17));
+ }
+
+ public function testSetValueIntIsNotUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42);
+ $this->assertSame(false, $config->setValueInt('feed', 'int', 42));
+ }
+
+ public function testSetValueIntIsUpdatedCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42);
+ $config->setValueInt('feed', 'int', 17);
+ $status = $config->statusCache();
+ $this->assertSame('17', $status['fastCache']['feed']['int']);
+ }
+
+ public function testSetValueIntIsUpdatedDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42);
+ $config->setValueInt('feed', 'int', 17);
+ $config->clearCache();
+ $this->assertSame(17, $config->getValueInt('feed', 'int', 0));
+ }
+
+ public function testSetValueFloat(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14);
+ $this->assertSame(3.14, $config->getValueFloat('feed', 'float', 0));
+ }
+
+ public function testSetValueFloatCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14);
+ $status = $config->statusCache();
+ $this->assertSame('3.14', $status['fastCache']['feed']['float']);
+ }
+
+ public function testSetValueFloatDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14);
+ $config->clearCache();
+ $this->assertSame(3.14, $config->getValueFloat('feed', 'float', 0));
+ }
+
+ public function testSetValueFloatIsUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14);
+ $this->assertSame(true, $config->setValueFloat('feed', 'float', 1.23));
+ }
+
+ public function testSetValueFloatIsNotUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14);
+ $this->assertSame(false, $config->setValueFloat('feed', 'float', 3.14));
+ }
+
+ public function testSetValueFloatIsUpdatedCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14);
+ $config->setValueFloat('feed', 'float', 1.23);
+ $status = $config->statusCache();
+ $this->assertSame('1.23', $status['fastCache']['feed']['float']);
+ }
+
+ public function testSetValueFloatIsUpdatedDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14);
+ $config->setValueFloat('feed', 'float', 1.23);
+ $config->clearCache();
+ $this->assertSame(1.23, $config->getValueFloat('feed', 'float', 0));
+ }
+
+ public function testSetValueBool(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueBool('feed', 'bool', true);
+ $this->assertSame(true, $config->getValueBool('feed', 'bool', false));
+ }
+
+ public function testSetValueBoolCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueBool('feed', 'bool', true);
+ $status = $config->statusCache();
+ $this->assertSame('1', $status['fastCache']['feed']['bool']);
+ }
+
+ public function testSetValueBoolDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueBool('feed', 'bool', true);
+ $config->clearCache();
+ $this->assertSame(true, $config->getValueBool('feed', 'bool', false));
+ }
+
+ public function testSetValueBoolIsUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueBool('feed', 'bool', true);
+ $this->assertSame(true, $config->setValueBool('feed', 'bool', false));
+ }
+
+ public function testSetValueBoolIsNotUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueBool('feed', 'bool', true);
+ $this->assertSame(false, $config->setValueBool('feed', 'bool', true));
+ }
+
+ public function testSetValueBoolIsUpdatedCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueBool('feed', 'bool', true);
+ $config->setValueBool('feed', 'bool', false);
+ $status = $config->statusCache();
+ $this->assertSame('0', $status['fastCache']['feed']['bool']);
+ }
+
+ public function testSetValueBoolIsUpdatedDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueBool('feed', 'bool', true);
+ $config->setValueBool('feed', 'bool', false);
+ $config->clearCache();
+ $this->assertSame(false, $config->getValueBool('feed', 'bool', true));
+ }
+
+
+ public function testSetValueArray(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1]);
+ $this->assertSame(['test' => 1], $config->getValueArray('feed', 'array', []));
+ }
+
+ public function testSetValueArrayCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1]);
+ $status = $config->statusCache();
+ $this->assertSame('{"test":1}', $status['fastCache']['feed']['array']);
+ }
+
+ public function testSetValueArrayDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1]);
+ $config->clearCache();
+ $this->assertSame(['test' => 1], $config->getValueArray('feed', 'array', []));
+ }
+
+ public function testSetValueArrayIsUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1]);
+ $this->assertSame(true, $config->setValueArray('feed', 'array', ['test' => 2]));
+ }
+
+ public function testSetValueArrayIsNotUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1]);
+ $this->assertSame(false, $config->setValueArray('feed', 'array', ['test' => 1]));
+ }
+
+ public function testSetValueArrayIsUpdatedCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1]);
+ $config->setValueArray('feed', 'array', ['test' => 2]);
+ $status = $config->statusCache();
+ $this->assertSame('{"test":2}', $status['fastCache']['feed']['array']);
+ }
+
+ public function testSetValueArrayIsUpdatedDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1]);
+ $config->setValueArray('feed', 'array', ['test' => 2]);
+ $config->clearCache();
+ $this->assertSame(['test' => 2], $config->getValueArray('feed', 'array', []));
+ }
+
+ public function testSetLazyValueString(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1', true);
+ $this->assertSame('value-1', $config->getValueString('feed', 'string', '', true));
+ }
+
+ public function testSetLazyValueStringCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1', true);
+ $status = $config->statusCache();
+ $this->assertSame('value-1', $status['lazyCache']['feed']['string']);
+ }
+
+ public function testSetLazyValueStringDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1', true);
+ $config->clearCache();
+ $this->assertSame('value-1', $config->getValueString('feed', 'string', '', true));
+ }
+
+ public function testSetLazyValueStringAsNonLazy(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1', true);
+ $config->setValueString('feed', 'string', 'value-1', false);
+ $this->assertSame('value-1', $config->getValueString('feed', 'string', ''));
+ }
+
+ public function testSetNonLazyValueStringAsLazy(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1', false);
+ $config->setValueString('feed', 'string', 'value-1', true);
+ $this->assertSame('value-1', $config->getValueString('feed', 'string', '', true));
+ }
+
+ public function testSetSensitiveValueString(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1', sensitive: true);
+ $this->assertSame('value-1', $config->getValueString('feed', 'string', ''));
+ }
+
+ public function testSetSensitiveValueStringCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1', sensitive: true);
+ $status = $config->statusCache();
+ $this->assertStringStartsWith(self::invokePrivate(AppConfig::class, 'ENCRYPTION_PREFIX'), $status['fastCache']['feed']['string']);
+ }
+
+ public function testSetSensitiveValueStringDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1', sensitive: true);
+ $config->clearCache();
+ $this->assertSame('value-1', $config->getValueString('feed', 'string', ''));
+ }
+
+ public function testSetNonSensitiveValueStringAsSensitive(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1', sensitive: false);
+ $config->setValueString('feed', 'string', 'value-1', sensitive: true);
+ $this->assertSame(true, $config->isSensitive('feed', 'string'));
+
+ $this->assertConfigValueNotEquals('feed', 'string', 'value-1');
+ $this->assertConfigValueNotEquals('feed', 'string', 'value-2');
+ }
+
+ public function testSetSensitiveValueStringAsNonSensitiveStaysSensitive(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1', sensitive: true);
+ $config->setValueString('feed', 'string', 'value-2', sensitive: false);
+ $this->assertSame(true, $config->isSensitive('feed', 'string'));
+
+ $this->assertConfigValueNotEquals('feed', 'string', 'value-1');
+ $this->assertConfigValueNotEquals('feed', 'string', 'value-2');
+ }
+
+ public function testSetSensitiveValueStringAsNonSensitiveAreStillUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', 'value-1', sensitive: true);
+ $config->setValueString('feed', 'string', 'value-2', sensitive: false);
+ $this->assertSame('value-2', $config->getValueString('feed', 'string', ''));
+
+ $this->assertConfigValueNotEquals('feed', 'string', 'value-1');
+ $this->assertConfigValueNotEquals('feed', 'string', 'value-2');
+ }
+
+ public function testSetLazyValueInt(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42, true);
+ $this->assertSame(42, $config->getValueInt('feed', 'int', 0, true));
+ }
+
+ public function testSetLazyValueIntCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42, true);
+ $status = $config->statusCache();
+ $this->assertSame('42', $status['lazyCache']['feed']['int']);
+ }
+
+ public function testSetLazyValueIntDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42, true);
+ $config->clearCache();
+ $this->assertSame(42, $config->getValueInt('feed', 'int', 0, true));
+ }
+
+ public function testSetLazyValueIntAsNonLazy(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42, true);
+ $config->setValueInt('feed', 'int', 42, false);
+ $this->assertSame(42, $config->getValueInt('feed', 'int', 0));
+ }
+
+ public function testSetNonLazyValueIntAsLazy(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42, false);
+ $config->setValueInt('feed', 'int', 42, true);
+ $this->assertSame(42, $config->getValueInt('feed', 'int', 0, true));
+ }
+
+ public function testSetSensitiveValueInt(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42, sensitive: true);
+ $this->assertSame(42, $config->getValueInt('feed', 'int', 0));
+ }
+
+ public function testSetSensitiveValueIntCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42, sensitive: true);
+ $status = $config->statusCache();
+ $this->assertStringStartsWith(self::invokePrivate(AppConfig::class, 'ENCRYPTION_PREFIX'), $status['fastCache']['feed']['int']);
+ }
+
+ public function testSetSensitiveValueIntDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42, sensitive: true);
+ $config->clearCache();
+ $this->assertSame(42, $config->getValueInt('feed', 'int', 0));
+ }
+
+ public function testSetNonSensitiveValueIntAsSensitive(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42);
+ $config->setValueInt('feed', 'int', 42, sensitive: true);
+ $this->assertSame(true, $config->isSensitive('feed', 'int'));
+ }
+
+ public function testSetSensitiveValueIntAsNonSensitiveStaysSensitive(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42, sensitive: true);
+ $config->setValueInt('feed', 'int', 17);
+ $this->assertSame(true, $config->isSensitive('feed', 'int'));
+ }
+
+ public function testSetSensitiveValueIntAsNonSensitiveAreStillUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueInt('feed', 'int', 42, sensitive: true);
+ $config->setValueInt('feed', 'int', 17);
+ $this->assertSame(17, $config->getValueInt('feed', 'int', 0));
+ }
+
+ public function testSetLazyValueFloat(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14, true);
+ $this->assertSame(3.14, $config->getValueFloat('feed', 'float', 0, true));
+ }
+
+ public function testSetLazyValueFloatCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14, true);
+ $status = $config->statusCache();
+ $this->assertSame('3.14', $status['lazyCache']['feed']['float']);
+ }
+
+ public function testSetLazyValueFloatDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14, true);
+ $config->clearCache();
+ $this->assertSame(3.14, $config->getValueFloat('feed', 'float', 0, true));
+ }
+
+ public function testSetLazyValueFloatAsNonLazy(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14, true);
+ $config->setValueFloat('feed', 'float', 3.14, false);
+ $this->assertSame(3.14, $config->getValueFloat('feed', 'float', 0));
+ }
+
+ public function testSetNonLazyValueFloatAsLazy(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14, false);
+ $config->setValueFloat('feed', 'float', 3.14, true);
+ $this->assertSame(3.14, $config->getValueFloat('feed', 'float', 0, true));
+ }
+
+ public function testSetSensitiveValueFloat(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14, sensitive: true);
+ $this->assertSame(3.14, $config->getValueFloat('feed', 'float', 0));
+ }
+
+ public function testSetSensitiveValueFloatCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14, sensitive: true);
+ $status = $config->statusCache();
+ $this->assertStringStartsWith(self::invokePrivate(AppConfig::class, 'ENCRYPTION_PREFIX'), $status['fastCache']['feed']['float']);
+ }
+
+ public function testSetSensitiveValueFloatDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14, sensitive: true);
+ $config->clearCache();
+ $this->assertSame(3.14, $config->getValueFloat('feed', 'float', 0));
+ }
+
+ public function testSetNonSensitiveValueFloatAsSensitive(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14);
+ $config->setValueFloat('feed', 'float', 3.14, sensitive: true);
+ $this->assertSame(true, $config->isSensitive('feed', 'float'));
+ }
+
+ public function testSetSensitiveValueFloatAsNonSensitiveStaysSensitive(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14, sensitive: true);
+ $config->setValueFloat('feed', 'float', 1.23);
+ $this->assertSame(true, $config->isSensitive('feed', 'float'));
+ }
+
+ public function testSetSensitiveValueFloatAsNonSensitiveAreStillUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueFloat('feed', 'float', 3.14, sensitive: true);
+ $config->setValueFloat('feed', 'float', 1.23);
+ $this->assertSame(1.23, $config->getValueFloat('feed', 'float', 0));
+ }
+
+ public function testSetLazyValueBool(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueBool('feed', 'bool', true, true);
+ $this->assertSame(true, $config->getValueBool('feed', 'bool', false, true));
+ }
+
+ public function testSetLazyValueBoolCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueBool('feed', 'bool', true, true);
+ $status = $config->statusCache();
+ $this->assertSame('1', $status['lazyCache']['feed']['bool']);
+ }
+
+ public function testSetLazyValueBoolDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueBool('feed', 'bool', true, true);
+ $config->clearCache();
+ $this->assertSame(true, $config->getValueBool('feed', 'bool', false, true));
+ }
+
+ public function testSetLazyValueBoolAsNonLazy(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueBool('feed', 'bool', true, true);
+ $config->setValueBool('feed', 'bool', true, false);
+ $this->assertSame(true, $config->getValueBool('feed', 'bool', false));
+ }
+
+ public function testSetNonLazyValueBoolAsLazy(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueBool('feed', 'bool', true, false);
+ $config->setValueBool('feed', 'bool', true, true);
+ $this->assertSame(true, $config->getValueBool('feed', 'bool', false, true));
+ }
+
+ public function testSetLazyValueArray(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1], true);
+ $this->assertSame(['test' => 1], $config->getValueArray('feed', 'array', [], true));
+ }
+
+ public function testSetLazyValueArrayCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1], true);
+ $status = $config->statusCache();
+ $this->assertSame('{"test":1}', $status['lazyCache']['feed']['array']);
+ }
+
+ public function testSetLazyValueArrayDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1], true);
+ $config->clearCache();
+ $this->assertSame(['test' => 1], $config->getValueArray('feed', 'array', [], true));
+ }
+
+ public function testSetLazyValueArrayAsNonLazy(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1], true);
+ $config->setValueArray('feed', 'array', ['test' => 1], false);
+ $this->assertSame(['test' => 1], $config->getValueArray('feed', 'array', []));
+ }
+
+ public function testSetNonLazyValueArrayAsLazy(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1], false);
+ $config->setValueArray('feed', 'array', ['test' => 1], true);
+ $this->assertSame(['test' => 1], $config->getValueArray('feed', 'array', [], true));
+ }
+
+
+ public function testSetSensitiveValueArray(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1], sensitive: true);
+ $this->assertEqualsCanonicalizing(['test' => 1], $config->getValueArray('feed', 'array', []));
+ }
+
+ public function testSetSensitiveValueArrayCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1], sensitive: true);
+ $status = $config->statusCache();
+ $this->assertStringStartsWith(self::invokePrivate(AppConfig::class, 'ENCRYPTION_PREFIX'), $status['fastCache']['feed']['array']);
+ }
+
+ public function testSetSensitiveValueArrayDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1], sensitive: true);
+ $config->clearCache();
+ $this->assertEqualsCanonicalizing(['test' => 1], $config->getValueArray('feed', 'array', []));
+ }
+
+ public function testSetNonSensitiveValueArrayAsSensitive(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1]);
+ $config->setValueArray('feed', 'array', ['test' => 1], sensitive: true);
+ $this->assertSame(true, $config->isSensitive('feed', 'array'));
+ }
+
+ public function testSetSensitiveValueArrayAsNonSensitiveStaysSensitive(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1], sensitive: true);
+ $config->setValueArray('feed', 'array', ['test' => 2]);
+ $this->assertSame(true, $config->isSensitive('feed', 'array'));
+ }
+
+ public function testSetSensitiveValueArrayAsNonSensitiveAreStillUpdated(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueArray('feed', 'array', ['test' => 1], sensitive: true);
+ $config->setValueArray('feed', 'array', ['test' => 2]);
+ $this->assertEqualsCanonicalizing(['test' => 2], $config->getValueArray('feed', 'array', []));
+ }
+
+ public function testUpdateNotSensitiveToSensitive(): void {
+ $config = $this->generateAppConfig();
+ $config->updateSensitive('non-sensitive-app', 'lazy-key', true);
+ $this->assertSame(true, $config->isSensitive('non-sensitive-app', 'lazy-key', true));
+ }
+
+ public function testUpdateSensitiveToNotSensitive(): void {
+ $config = $this->generateAppConfig();
+ $config->updateSensitive('sensitive-app', 'lazy-key', false);
+ $this->assertSame(false, $config->isSensitive('sensitive-app', 'lazy-key', true));
+ }
+
+ public function testUpdateSensitiveToSensitiveReturnsFalse(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(false, $config->updateSensitive('sensitive-app', 'lazy-key', true));
+ }
+
+ public function testUpdateNotSensitiveToNotSensitiveReturnsFalse(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(false, $config->updateSensitive('non-sensitive-app', 'lazy-key', false));
+ }
+
+ public function testUpdateSensitiveOnUnknownKeyReturnsFalse(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(false, $config->updateSensitive('non-sensitive-app', 'unknown-key', true));
+ }
+
+ public function testUpdateNotLazyToLazy(): void {
+ $config = $this->generateAppConfig();
+ $config->updateLazy('non-sensitive-app', 'non-lazy-key', true);
+ $this->assertSame(true, $config->isLazy('non-sensitive-app', 'non-lazy-key'));
+ }
+
+ public function testUpdateLazyToNotLazy(): void {
+ $config = $this->generateAppConfig();
+ $config->updateLazy('non-sensitive-app', 'lazy-key', false);
+ $this->assertSame(false, $config->isLazy('non-sensitive-app', 'lazy-key'));
+ }
+
+ public function testUpdateLazyToLazyReturnsFalse(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(false, $config->updateLazy('non-sensitive-app', 'lazy-key', true));
+ }
+
+ public function testUpdateNotLazyToNotLazyReturnsFalse(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(false, $config->updateLazy('non-sensitive-app', 'non-lazy-key', false));
+ }
+
+ public function testUpdateLazyOnUnknownKeyReturnsFalse(): void {
+ $config = $this->generateAppConfig();
+ $this->assertSame(false, $config->updateLazy('non-sensitive-app', 'unknown-key', true));
+ }
+
+ public function testGetDetails(): void {
+ $config = $this->generateAppConfig();
+ $this->assertEquals(
+ [
+ 'app' => 'non-sensitive-app',
+ 'key' => 'lazy-key',
+ 'value' => 'value',
+ 'type' => 4,
+ 'lazy' => true,
+ 'typeString' => 'string',
+ 'sensitive' => false,
+ ],
+ $config->getDetails('non-sensitive-app', 'lazy-key')
+ );
+ }
+
+ public function testGetDetailsSensitive(): void {
+ $config = $this->generateAppConfig();
+ $this->assertEquals(
+ [
+ 'app' => 'sensitive-app',
+ 'key' => 'lazy-key',
+ 'value' => 'value',
+ 'type' => 4,
+ 'lazy' => true,
+ 'typeString' => 'string',
+ 'sensitive' => true,
+ ],
+ $config->getDetails('sensitive-app', 'lazy-key')
+ );
+ }
+
+ public function testGetDetailsInt(): void {
+ $config = $this->generateAppConfig();
+ $this->assertEquals(
+ [
+ 'app' => 'typed',
+ 'key' => 'int',
+ 'value' => '42',
+ 'type' => 8,
+ 'lazy' => false,
+ 'typeString' => 'integer',
+ 'sensitive' => false
+ ],
+ $config->getDetails('typed', 'int')
+ );
+ }
+
+ public function testGetDetailsFloat(): void {
+ $config = $this->generateAppConfig();
+ $this->assertEquals(
+ [
+ 'app' => 'typed',
+ 'key' => 'float',
+ 'value' => '3.14',
+ 'type' => 16,
+ 'lazy' => false,
+ 'typeString' => 'float',
+ 'sensitive' => false
+ ],
+ $config->getDetails('typed', 'float')
+ );
+ }
+
+ public function testGetDetailsBool(): void {
+ $config = $this->generateAppConfig();
+ $this->assertEquals(
+ [
+ 'app' => 'typed',
+ 'key' => 'bool',
+ 'value' => '1',
+ 'type' => 32,
+ 'lazy' => false,
+ 'typeString' => 'boolean',
+ 'sensitive' => false
+ ],
+ $config->getDetails('typed', 'bool')
+ );
+ }
+
+ public function testGetDetailsArray(): void {
+ $config = $this->generateAppConfig();
+ $this->assertEquals(
+ [
+ 'app' => 'typed',
+ 'key' => 'array',
+ 'value' => '{"test": 1}',
+ 'type' => 64,
+ 'lazy' => false,
+ 'typeString' => 'array',
+ 'sensitive' => false
+ ],
+ $config->getDetails('typed', 'array')
+ );
+ }
+
+ public function testDeleteKey(): void {
+ $config = $this->generateAppConfig();
+ $config->deleteKey('anotherapp', 'key');
+ $this->assertSame('default', $config->getValueString('anotherapp', 'key', 'default'));
+ }
+
+ public function testDeleteKeyCache(): void {
+ $config = $this->generateAppConfig();
+ $config->deleteKey('anotherapp', 'key');
+ $status = $config->statusCache();
+ $this->assertEqualsCanonicalizing(['enabled' => 'false'], $status['fastCache']['anotherapp']);
+ }
+
+ public function testDeleteKeyDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->deleteKey('anotherapp', 'key');
+ $config->clearCache();
+ $this->assertSame('default', $config->getValueString('anotherapp', 'key', 'default'));
+ }
+
+ public function testDeleteApp(): void {
+ $config = $this->generateAppConfig();
+ $config->deleteApp('anotherapp');
+ $this->assertSame('default', $config->getValueString('anotherapp', 'key', 'default'));
+ $this->assertSame('default', $config->getValueString('anotherapp', 'enabled', 'default'));
+ }
+
+ public function testDeleteAppCache(): void {
+ $config = $this->generateAppConfig();
+ $status = $config->statusCache();
+ $this->assertSame(true, isset($status['fastCache']['anotherapp']));
+ $config->deleteApp('anotherapp');
+ $status = $config->statusCache();
+ $this->assertSame(false, isset($status['fastCache']['anotherapp']));
+ }
+
+ public function testDeleteAppDatabase(): void {
+ $config = $this->generateAppConfig();
+ $config->deleteApp('anotherapp');
+ $config->clearCache();
+ $this->assertSame('default', $config->getValueString('anotherapp', 'key', 'default'));
+ $this->assertSame('default', $config->getValueString('anotherapp', 'enabled', 'default'));
+ }
+
+ public function testClearCache(): void {
+ $config = $this->generateAppConfig();
+ $config->setValueString('feed', 'string', '123454');
+ $config->clearCache();
+ $status = $config->statusCache();
+ $this->assertSame([], $status['fastCache']);
+ }
+
+ public function testSensitiveValuesAreEncrypted(): void {
+ $key = self::getUniqueID('secret');
+
+ $appConfig = $this->generateAppConfig();
+ $secret = md5((string) time());
+ $appConfig->setValueString('testapp', $key, $secret, sensitive: true);
+
+ $this->assertConfigValueNotEquals('testapp', $key, $secret);
+
+ // Can get in same run
+ $actualSecret = $appConfig->getValueString('testapp', $key);
+ $this->assertEquals($secret, $actualSecret);
+
+ // Can get freshly decrypted from DB
+ $newAppConfig = $this->generateAppConfig();
+ $actualSecret = $newAppConfig->getValueString('testapp', $key);
+ $this->assertEquals($secret, $actualSecret);
+ }
+
+ public function testMigratingNonSensitiveValueToSensitiveWithSetValue(): void {
+ $key = self::getUniqueID('secret');
+ $appConfig = $this->generateAppConfig();
+ $secret = sha1((string) time());
+
+ // Unencrypted
+ $appConfig->setValueString('testapp', $key, $secret);
+ $this->assertConfigKey('testapp', $key, $secret);
+
+ // Can get freshly decrypted from DB
+ $newAppConfig = $this->generateAppConfig();
+ $actualSecret = $newAppConfig->getValueString('testapp', $key);
+ $this->assertEquals($secret, $actualSecret);
+
+ // Encrypting on change
+ $appConfig->setValueString('testapp', $key, $secret, sensitive: true);
+ $this->assertConfigValueNotEquals('testapp', $key, $secret);
+
+ // Can get in same run
+ $actualSecret = $appConfig->getValueString('testapp', $key);
+ $this->assertEquals($secret, $actualSecret);
+
+ // Can get freshly decrypted from DB
+ $newAppConfig = $this->generateAppConfig();
+ $actualSecret = $newAppConfig->getValueString('testapp', $key);
+ $this->assertEquals($secret, $actualSecret);
+ }
+
+ public function testUpdateSensitiveValueToNonSensitiveWithUpdateSensitive(): void {
+ $key = self::getUniqueID('secret');
+ $appConfig = $this->generateAppConfig();
+ $secret = sha1((string) time());
+
+ // Encrypted
+ $appConfig->setValueString('testapp', $key, $secret, sensitive: true);
+ $this->assertConfigValueNotEquals('testapp', $key, $secret);
+
+ // Migrate to non-sensitive / non-encrypted
+ $appConfig->updateSensitive('testapp', $key, false);
+ $this->assertConfigKey('testapp', $key, $secret);
+ }
+
+ public function testUpdateNonSensitiveValueToSensitiveWithUpdateSensitive(): void {
+ $key = self::getUniqueID('secret');
+ $appConfig = $this->generateAppConfig();
+ $secret = sha1((string) time());
+
+ // Unencrypted
+ $appConfig->setValueString('testapp', $key, $secret);
+ $this->assertConfigKey('testapp', $key, $secret);
+
+ // Migrate to sensitive / encrypted
+ $appConfig->updateSensitive('testapp', $key, true);
+ $this->assertConfigValueNotEquals('testapp', $key, $secret);
+ }
+
+ protected function loadConfigValueFromDatabase(string $app, string $key): string|false {
+ $sql = $this->connection->getQueryBuilder();
$sql->select('configvalue')
->from('appconfig')
->where($sql->expr()->eq('appid', $sql->createParameter('appid')))
->andWhere($sql->expr()->eq('configkey', $sql->createParameter('configkey')))
->setParameter('appid', $app)
->setParameter('configkey', $key);
- $query = $sql->execute();
- $actual = $query->fetch();
+ $query = $sql->executeQuery();
+ $actual = $query->fetchOne();
$query->closeCursor();
- $this->assertEquals($expected, $actual['configvalue']);
+ return $actual;
+ }
+
+ protected function assertConfigKey(string $app, string $key, string|false $expected): void {
+ $this->assertEquals($expected, $this->loadConfigValueFromDatabase($app, $key));
+ }
+
+ protected function assertConfigValueNotEquals(string $app, string $key, string|false $expected): void {
+ $this->assertNotEquals($expected, $this->loadConfigValueFromDatabase($app, $key));
}
}
diff --git a/tests/lib/AppFramework/AppTest.php b/tests/lib/AppFramework/AppTest.php
index 3dc62246e97..48f95564a22 100644
--- a/tests/lib/AppFramework/AppTest.php
+++ b/tests/lib/AppFramework/AppTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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;
diff --git a/tests/lib/AppFramework/Bootstrap/BootContextTest.php b/tests/lib/AppFramework/Bootstrap/BootContextTest.php
index 86f653604a9..3a97ff2bbfc 100644
--- a/tests/lib/AppFramework/Bootstrap/BootContextTest.php
+++ b/tests/lib/AppFramework/Bootstrap/BootContextTest.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\AppFramework\Bootstrap;
diff --git a/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php b/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php
index a706abecc4f..ce07a628773 100644
--- a/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php
+++ b/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\AppFramework\Bootstrap;
@@ -83,7 +67,8 @@ class CoordinatorTest extends TestCase {
$this->dashboardManager,
$this->eventDispatcher,
$this->eventLogger,
- $this->logger
+ $this->appManager,
+ $this->logger,
);
}
diff --git a/tests/lib/AppFramework/Bootstrap/FunctionInjectorTest.php b/tests/lib/AppFramework/Bootstrap/FunctionInjectorTest.php
index 909a98f97c8..c32331e8ba1 100644
--- a/tests/lib/AppFramework/Bootstrap/FunctionInjectorTest.php
+++ b/tests/lib/AppFramework/Bootstrap/FunctionInjectorTest.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\AppFramework\Bootstrap;
diff --git a/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php b/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php
index 55f30a895f5..1e0b13b5755 100644
--- a/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php
+++ b/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\AppFramework\Bootstrap;
diff --git a/tests/lib/AppFramework/Controller/ApiControllerTest.php b/tests/lib/AppFramework/Controller/ApiControllerTest.php
index 975b92c5b96..6dea9938225 100644
--- a/tests/lib/AppFramework/Controller/ApiControllerTest.php
+++ b/tests/lib/AppFramework/Controller/ApiControllerTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Controller;
diff --git a/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php b/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php
index e996f287c16..bec1b7a2a63 100644
--- a/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php
+++ b/tests/lib/AppFramework/Controller/AuthPublicShareControllerTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2018, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Controller;
diff --git a/tests/lib/AppFramework/Controller/ControllerTest.php b/tests/lib/AppFramework/Controller/ControllerTest.php
index cb6fc777dee..044b554d014 100644
--- a/tests/lib/AppFramework/Controller/ControllerTest.php
+++ b/tests/lib/AppFramework/Controller/ControllerTest.php
@@ -1,28 +1,14 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Controller;
+use OC\AppFramework\DependencyInjection\DIContainer;
use OC\AppFramework\Http\Request;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
@@ -30,7 +16,6 @@ use OCP\AppFramework\Http\JSONResponse;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IRequestId;
-use OC\AppFramework\DependencyInjection\DIContainer;
class ChildController extends Controller {
public function __construct($appName, $request) {
diff --git a/tests/lib/AppFramework/Controller/OCSControllerTest.php b/tests/lib/AppFramework/Controller/OCSControllerTest.php
index ce110f435ef..ea86c01a364 100644
--- a/tests/lib/AppFramework/Controller/OCSControllerTest.php
+++ b/tests/lib/AppFramework/Controller/OCSControllerTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2015 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Controller;
diff --git a/tests/lib/AppFramework/Controller/PublicShareControllerTest.php b/tests/lib/AppFramework/Controller/PublicShareControllerTest.php
index 9c03ba4cb6e..be28843b03f 100644
--- a/tests/lib/AppFramework/Controller/PublicShareControllerTest.php
+++ b/tests/lib/AppFramework/Controller/PublicShareControllerTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2018, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Controller;
diff --git a/tests/lib/AppFramework/Db/EntityTest.php b/tests/lib/AppFramework/Db/EntityTest.php
index d76a8ccfe06..a521b480f8f 100644
--- a/tests/lib/AppFramework/Db/EntityTest.php
+++ b/tests/lib/AppFramework/Db/EntityTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt dev@bernhard-posselt.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Db;
diff --git a/tests/lib/AppFramework/Db/QBMapperTest.php b/tests/lib/AppFramework/Db/QBMapperTest.php
index 82830dcc05a..f984d977df5 100644
--- a/tests/lib/AppFramework/Db/QBMapperTest.php
+++ b/tests/lib/AppFramework/Db/QBMapperTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2019, Marius David Wieschollek <git.public@mdns.eu>
- *
- * @author Marius David Wieschollek <git.public@mdns.eu>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Db;
diff --git a/tests/lib/AppFramework/Db/TransactionalTest.php b/tests/lib/AppFramework/Db/TransactionalTest.php
index fc2d4121382..a60c4386fea 100644
--- a/tests/lib/AppFramework/Db/TransactionalTest.php
+++ b/tests/lib/AppFramework/Db/TransactionalTest.php
@@ -1,25 +1,9 @@
<?php
declare(strict_types=1);
-/*
- * @copyright 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\AppFramework\Db;
diff --git a/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php b/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php
index 04422643121..94264f0de02 100644
--- a/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php
+++ b/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php
@@ -1,26 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @author Morris Jobke
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright 2013 Morris Jobke <morris.jobke@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\DependencyInjection;
diff --git a/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php b/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php
index 369a30ba7a3..ad126ad99e2 100644
--- a/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php
+++ b/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2017, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\DependencyInjection;
diff --git a/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php b/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php
index 8e6ac32b416..ba3aacd5424 100644
--- a/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php
+++ b/tests/lib/AppFramework/Http/ContentSecurityPolicyTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Lukas Reschke lukas@owncloud.com
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * 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\Http;
@@ -468,6 +467,15 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'nonce-".base64_encode($nonce) . "';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
$this->contentSecurityPolicy->useJsNonce($nonce);
+ $this->contentSecurityPolicy->useStrictDynamicOnScripts(false);
+ $this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
+ }
+
+ public function testGetPolicyNonceDefault() {
+ $nonce = 'my-nonce';
+ $expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'nonce-".base64_encode($nonce) . "';script-src-elem 'strict-dynamic' 'nonce-".base64_encode($nonce) . "';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
+
+ $this->contentSecurityPolicy->useJsNonce($nonce);
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
@@ -477,6 +485,31 @@ class ContentSecurityPolicyTest extends \Test\TestCase {
$this->contentSecurityPolicy->useJsNonce($nonce);
$this->contentSecurityPolicy->useStrictDynamic(true);
+ $this->contentSecurityPolicy->useStrictDynamicOnScripts(false);
+ $this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
+ }
+
+ public function testGetPolicyNonceStrictDynamicDefault() {
+ $nonce = 'my-nonce';
+ $expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'strict-dynamic' 'nonce-".base64_encode($nonce) . "';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
+
+ $this->contentSecurityPolicy->useJsNonce($nonce);
+ $this->contentSecurityPolicy->useStrictDynamic(true);
+ $this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
+ }
+
+ public function testGetPolicyStrictDynamicOnScriptsOff() {
+ $expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
+
+ $this->contentSecurityPolicy->useStrictDynamicOnScripts(false);
+ $this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
+ }
+
+ public function testGetPolicyStrictDynamicAndStrictDynamicOnScripts() {
+ $expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self';style-src 'self' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self' data:;connect-src 'self';media-src 'self';frame-ancestors 'self';form-action 'self'";
+
+ $this->contentSecurityPolicy->useStrictDynamic(true);
+ $this->contentSecurityPolicy->useStrictDynamicOnScripts(true);
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
}
diff --git a/tests/lib/AppFramework/Http/DataResponseTest.php b/tests/lib/AppFramework/Http/DataResponseTest.php
index ccde23b48bb..39f7e76ea0c 100644
--- a/tests/lib/AppFramework/Http/DataResponseTest.php
+++ b/tests/lib/AppFramework/Http/DataResponseTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2014 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Http;
diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php
index 7f81701a8b3..cb32302d4be 100644
--- a/tests/lib/AppFramework/Http/DispatcherTest.php
+++ b/tests/lib/AppFramework/Http/DispatcherTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Http;
@@ -31,14 +16,15 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\JSONResponse;
+use OCP\AppFramework\Http\ParameterOutOfRangeException;
use OCP\AppFramework\Http\Response;
use OCP\Diagnostics\IEventLogger;
use OCP\IConfig;
use OCP\IRequest;
+use OCP\IRequestId;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
-use OCP\IRequestId;
class TestController extends Controller {
/**
@@ -522,4 +508,51 @@ class DispatcherTest extends \Test\TestCase {
$this->assertEquals('{"text":[3,true,4,1]}', $response[3]);
}
+
+
+ public function rangeDataProvider(): array {
+ return [
+ [PHP_INT_MIN, PHP_INT_MAX, 42, false],
+ [0, 12, -5, true],
+ [-12, 0, 5, true],
+ [7, 14, 5, true],
+ [7, 14, 10, false],
+ [-14, -7, -10, false],
+ ];
+ }
+
+ /**
+ * @dataProvider rangeDataProvider
+ */
+ public function testEnsureParameterValueSatisfiesRange(int $min, int $max, int $input, bool $throw): void {
+ $this->reflector = $this->createMock(ControllerMethodReflector::class);
+ $this->reflector->expects($this->any())
+ ->method('getRange')
+ ->willReturn([
+ 'min' => $min,
+ 'max' => $max,
+ ]);
+
+ $this->dispatcher = new Dispatcher(
+ $this->http,
+ $this->middlewareDispatcher,
+ $this->reflector,
+ $this->request,
+ $this->config,
+ \OC::$server->getDatabaseConnection(),
+ $this->logger,
+ $this->eventLogger,
+ $this->container,
+ );
+
+ if ($throw) {
+ $this->expectException(ParameterOutOfRangeException::class);
+ }
+
+ $this->invokePrivate($this->dispatcher, 'ensureParameterValueSatisfiesRange', ['myArgument', $input]);
+ if (!$throw) {
+ // do not mark this test risky
+ $this->assertTrue(true);
+ }
+ }
}
diff --git a/tests/lib/AppFramework/Http/DownloadResponseTest.php b/tests/lib/AppFramework/Http/DownloadResponseTest.php
index 89de248cea0..425e5ecde1f 100644
--- a/tests/lib/AppFramework/Http/DownloadResponseTest.php
+++ b/tests/lib/AppFramework/Http/DownloadResponseTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Http;
diff --git a/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php b/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php
index 328e464f981..7d64b37b3c0 100644
--- a/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php
+++ b/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Lukas Reschke lukas@owncloud.com
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * 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\Http;
@@ -425,6 +424,42 @@ class EmptyContentSecurityPolicyTest extends \Test\TestCase {
$this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
}
+ public function testGetPolicyWithJsNonceAndStrictDynamic() {
+ $expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'strict-dynamic' 'nonce-TXlKc05vbmNl' www.nextcloud.com;frame-ancestors 'none'";
+
+ $this->contentSecurityPolicy->addAllowedScriptDomain('www.nextcloud.com');
+ $this->contentSecurityPolicy->useStrictDynamic(true);
+ $this->contentSecurityPolicy->useJsNonce('MyJsNonce');
+ $this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
+ }
+
+ public function testGetPolicyWithJsNonceAndStrictDynamicAndStrictDynamicOnScripts() {
+ $expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'strict-dynamic' 'nonce-TXlKc05vbmNl' www.nextcloud.com;frame-ancestors 'none'";
+
+ $this->contentSecurityPolicy->addAllowedScriptDomain('www.nextcloud.com');
+ $this->contentSecurityPolicy->useStrictDynamic(true);
+ $this->contentSecurityPolicy->useStrictDynamicOnScripts(true);
+ $this->contentSecurityPolicy->useJsNonce('MyJsNonce');
+ // Should be same as `testGetPolicyWithJsNonceAndStrictDynamic` because of fallback
+ $this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
+ }
+
+ public function testGetPolicyWithJsNonceAndStrictDynamicOnScripts() {
+ $expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'nonce-TXlKc05vbmNl' www.nextcloud.com;script-src-elem 'strict-dynamic' 'nonce-TXlKc05vbmNl' www.nextcloud.com;frame-ancestors 'none'";
+
+ $this->contentSecurityPolicy->addAllowedScriptDomain('www.nextcloud.com');
+ $this->contentSecurityPolicy->useStrictDynamicOnScripts(true);
+ $this->contentSecurityPolicy->useJsNonce('MyJsNonce');
+ $this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
+ }
+
+ public function testGetPolicyWithStrictDynamicOnScripts() {
+ $expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none'";
+
+ $this->contentSecurityPolicy->useStrictDynamicOnScripts(true);
+ $this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy());
+ }
+
public function testGetPolicyWithJsNonceAndSelfScriptDomain() {
$expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'nonce-TXlKc05vbmNl';frame-ancestors 'none'";
diff --git a/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php b/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php
index 6ced435286c..ca65fcd978c 100644
--- a/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php
+++ b/tests/lib/AppFramework/Http/EmptyFeaturePolicyTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Http;
diff --git a/tests/lib/AppFramework/Http/FeaturePolicyTest.php b/tests/lib/AppFramework/Http/FeaturePolicyTest.php
index 60ddca7481b..ce6a87406e8 100644
--- a/tests/lib/AppFramework/Http/FeaturePolicyTest.php
+++ b/tests/lib/AppFramework/Http/FeaturePolicyTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Http;
diff --git a/tests/lib/AppFramework/Http/FileDisplayResponseTest.php b/tests/lib/AppFramework/Http/FileDisplayResponseTest.php
index 0a244a85754..a75c6fdd591 100644
--- a/tests/lib/AppFramework/Http/FileDisplayResponseTest.php
+++ b/tests/lib/AppFramework/Http/FileDisplayResponseTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Http;
diff --git a/tests/lib/AppFramework/Http/HttpTest.php b/tests/lib/AppFramework/Http/HttpTest.php
index d3d23425f7c..46d2bb9d17a 100644
--- a/tests/lib/AppFramework/Http/HttpTest.php
+++ b/tests/lib/AppFramework/Http/HttpTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Http;
diff --git a/tests/lib/AppFramework/Http/JSONResponseTest.php b/tests/lib/AppFramework/Http/JSONResponseTest.php
index 82f00457907..bacc5999348 100644
--- a/tests/lib/AppFramework/Http/JSONResponseTest.php
+++ b/tests/lib/AppFramework/Http/JSONResponseTest.php
@@ -1,26 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @author Morris Jobke
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright 2013 Morris Jobke <morris.jobke@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Http;
diff --git a/tests/lib/AppFramework/Http/OutputTest.php b/tests/lib/AppFramework/Http/OutputTest.php
index 5fe35d24bde..cad49ae77ba 100644
--- a/tests/lib/AppFramework/Http/OutputTest.php
+++ b/tests/lib/AppFramework/Http/OutputTest.php
@@ -1,9 +1,7 @@
<?php
/**
- * Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Http;
diff --git a/tests/lib/AppFramework/Http/PublicTemplateResponseTest.php b/tests/lib/AppFramework/Http/PublicTemplateResponseTest.php
index cbf8f8303c3..fbed0746751 100644
--- a/tests/lib/AppFramework/Http/PublicTemplateResponseTest.php
+++ b/tests/lib/AppFramework/Http/PublicTemplateResponseTest.php
@@ -1,25 +1,8 @@
<?php
/**
- * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Http;
diff --git a/tests/lib/AppFramework/Http/RedirectResponseTest.php b/tests/lib/AppFramework/Http/RedirectResponseTest.php
index c49c4a7c1f7..dd0142b77a7 100644
--- a/tests/lib/AppFramework/Http/RedirectResponseTest.php
+++ b/tests/lib/AppFramework/Http/RedirectResponseTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Http;
diff --git a/tests/lib/AppFramework/Http/RequestIdTest.php b/tests/lib/AppFramework/Http/RequestIdTest.php
index 9f9afed4b7f..b3cfe2a8f4a 100644
--- a/tests/lib/AppFramework/Http/RequestIdTest.php
+++ b/tests/lib/AppFramework/Http/RequestIdTest.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2022 Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Http;
diff --git a/tests/lib/AppFramework/Http/RequestStream.php b/tests/lib/AppFramework/Http/RequestStream.php
index 1a99685e340..99f664b48ac 100644
--- a/tests/lib/AppFramework/Http/RequestStream.php
+++ b/tests/lib/AppFramework/Http/RequestStream.php
@@ -1,5 +1,8 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
namespace Test\AppFramework\Http;
/**
diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php
index 0ce2e283bb5..f0e1f459028 100644
--- a/tests/lib/AppFramework/Http/RequestTest.php
+++ b/tests/lib/AppFramework/Http/RequestTest.php
@@ -1,14 +1,9 @@
<?php
/**
- * @copyright 2013 Thomas Tanghus (thomas@tanghus.net)
- * @copyright 2016 Lukas Reschke lukas@owncloud.com
- * @copyright 2022 Stanimir Bozhilov (stanimir@audriga.com)
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * 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\Http;
use OC\AppFramework\Http\Request;
@@ -549,331 +544,188 @@ class RequestTest extends \Test\TestCase {
$this->assertEquals('3', $request->getParams()['id']);
}
- public function testGetRemoteAddressWithoutTrustedRemote() {
- $this->config
- ->expects($this->once())
- ->method('getSystemValue')
- ->with('trusted_proxies')
- ->willReturn([]);
-
- $request = new Request(
- [
- 'server' => [
+ public function dataGetRemoteAddress(): array {
+ return [
+ 'IPv4 without trusted remote' => [
+ [
'REMOTE_ADDR' => '10.0.0.2',
'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
- 'HTTP_X_FORWARDED_FOR' => '192.168.0.233'
+ 'HTTP_X_FORWARDED_FOR' => '192.168.0.233',
],
+ [],
+ [],
+ '10.0.0.2',
],
- $this->requestId,
- $this->config,
- $this->csrfTokenManager,
- $this->stream
- );
-
- $this->assertSame('10.0.0.2', $request->getRemoteAddress());
- }
-
- public function testGetRemoteAddressWithNoTrustedHeader() {
- $this->config
- ->expects($this->exactly(2))
- ->method('getSystemValue')
- ->withConsecutive(
- ['trusted_proxies'],
- ['forwarded_for_headers'],
- )->willReturnOnConsecutiveCalls(
- ['10.0.0.2'],
- []
- );
-
- $request = new Request(
- [
- 'server' => [
+ 'IPv4 without trusted headers' => [
+ [
'REMOTE_ADDR' => '10.0.0.2',
'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
- 'HTTP_X_FORWARDED_FOR' => '192.168.0.233'
+ 'HTTP_X_FORWARDED_FOR' => '192.168.0.233',
],
- ],
- $this->requestId,
- $this->config,
- $this->csrfTokenManager,
- $this->stream
- );
-
- $this->assertSame('10.0.0.2', $request->getRemoteAddress());
- }
-
- public function testGetRemoteAddressWithSingleTrustedRemote() {
- $this->config
- ->expects($this->exactly(2))
- ->method('getSystemValue')
- ->withConsecutive(
- ['trusted_proxies'],
- ['forwarded_for_headers'],
- )-> willReturnOnConsecutiveCalls(
['10.0.0.2'],
- ['HTTP_X_FORWARDED'],
- );
-
- $request = new Request(
- [
- 'server' => [
+ [],
+ '10.0.0.2',
+ ],
+ 'IPv4 with single trusted remote' => [
+ [
'REMOTE_ADDR' => '10.0.0.2',
'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
- 'HTTP_X_FORWARDED_FOR' => '192.168.0.233'
+ 'HTTP_X_FORWARDED_FOR' => '192.168.0.233',
],
- ],
- $this->requestId,
- $this->config,
- $this->csrfTokenManager,
- $this->stream
- );
-
- $this->assertSame('10.4.0.5', $request->getRemoteAddress());
- }
-
- public function testGetRemoteAddressIPv6WithSingleTrustedRemote() {
- $this->config
- ->expects($this->exactly(2))
- ->method('getSystemValue')
- ->withConsecutive(
- ['trusted_proxies'],
- ['forwarded_for_headers'],
- )-> willReturnOnConsecutiveCalls(
- ['2001:db8:85a3:8d3:1319:8a2e:370:7348'],
+ ['10.0.0.2'],
['HTTP_X_FORWARDED'],
- );
-
- $request = new Request(
- [
- 'server' => [
+ '10.4.0.4',
+ ],
+ 'IPv6 with single trusted remote' => [
+ [
'REMOTE_ADDR' => '2001:db8:85a3:8d3:1319:8a2e:370:7348',
'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
- 'HTTP_X_FORWARDED_FOR' => '192.168.0.233'
+ 'HTTP_X_FORWARDED_FOR' => '192.168.0.233',
],
+ ['2001:db8:85a3:8d3:1319:8a2e:370:7348'],
+ ['HTTP_X_FORWARDED'],
+ '10.4.0.4',
],
- $this->requestId,
- $this->config,
- $this->csrfTokenManager,
- $this->stream
- );
-
- $this->assertSame('10.4.0.5', $request->getRemoteAddress());
- }
-
- public function testGetRemoteAddressVerifyPriorityHeader() {
- $this->config
- ->expects($this->exactly(2))
- ->method('getSystemValue')
- ->withConsecutive(
- ['trusted_proxies'],
- ['forwarded_for_headers'],
- )-> willReturnOnConsecutiveCalls(
+ 'IPv4 with multiple trusted remotes' => [
+ [
+ 'REMOTE_ADDR' => '10.0.0.2',
+ 'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4, ::1',
+ 'HTTP_X_FORWARDED_FOR' => '192.168.0.233',
+ ],
+ ['10.0.0.2', '::1'],
+ ['HTTP_X_FORWARDED'],
+ '10.4.0.4',
+ ],
+ 'IPv4 order of forwarded-for headers' => [
+ [
+ 'REMOTE_ADDR' => '10.0.0.2',
+ 'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
+ 'HTTP_X_FORWARDED_FOR' => '192.168.0.233',
+ ],
['10.0.0.2'],
[
- 'HTTP_CLIENT_IP',
- 'HTTP_X_FORWARDED_FOR',
'HTTP_X_FORWARDED',
+ 'HTTP_X_FORWARDED_FOR',
+ 'HTTP_CLIENT_IP',
],
- );
-
- $request = new Request(
- [
- 'server' => [
+ '192.168.0.233',
+ ],
+ 'IPv4 order of forwarded-for headers (reversed)' => [
+ [
'REMOTE_ADDR' => '10.0.0.2',
'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
- 'HTTP_X_FORWARDED_FOR' => '192.168.0.233'
+ 'HTTP_X_FORWARDED_FOR' => '192.168.0.233',
],
- ],
- $this->requestId,
- $this->config,
- $this->csrfTokenManager,
- $this->stream
- );
-
- $this->assertSame('192.168.0.233', $request->getRemoteAddress());
- }
-
- public function testGetRemoteAddressIPv6VerifyPriorityHeader() {
- $this->config
- ->expects($this->exactly(2))
- ->method('getSystemValue')
- ->withConsecutive(
- ['trusted_proxies'],
- ['forwarded_for_headers'],
- )-> willReturnOnConsecutiveCalls(
- ['2001:db8:85a3:8d3:1319:8a2e:370:7348'],
+ ['10.0.0.2'],
[
'HTTP_CLIENT_IP',
'HTTP_X_FORWARDED_FOR',
- 'HTTP_X_FORWARDED'
+ 'HTTP_X_FORWARDED',
],
- );
-
- $request = new Request(
- [
- 'server' => [
+ '10.4.0.4',
+ ],
+ 'IPv6 order of forwarded-for headers' => [
+ [
'REMOTE_ADDR' => '2001:db8:85a3:8d3:1319:8a2e:370:7348',
'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
- 'HTTP_X_FORWARDED_FOR' => '192.168.0.233'
+ 'HTTP_X_FORWARDED_FOR' => '192.168.0.233',
],
- ],
- $this->requestId,
- $this->config,
- $this->csrfTokenManager,
- $this->stream
- );
-
- $this->assertSame('192.168.0.233', $request->getRemoteAddress());
- }
-
- public function testGetRemoteAddressWithMatchingCidrTrustedRemote() {
- $this->config
- ->expects($this->exactly(2))
- ->method('getSystemValue')
- ->withConsecutive(
- ['trusted_proxies'],
- ['forwarded_for_headers'],
- )-> willReturnOnConsecutiveCalls(
- ['192.168.2.0/24'],
- ['HTTP_X_FORWARDED_FOR'],
- );
-
- $request = new Request(
- [
- 'server' => [
- 'REMOTE_ADDR' => '192.168.2.99',
- 'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
- 'HTTP_X_FORWARDED_FOR' => '192.168.0.233'
+ ['2001:db8:85a3:8d3:1319:8a2e:370:7348'],
+ [
+ 'HTTP_X_FORWARDED',
+ 'HTTP_X_FORWARDED_FOR',
+ 'HTTP_CLIENT_IP',
],
+ '192.168.0.233',
],
- $this->requestId,
- $this->config,
- $this->csrfTokenManager,
- $this->stream
- );
-
- $this->assertSame('192.168.0.233', $request->getRemoteAddress());
- }
-
- public function testGetRemoteAddressWithNotMatchingCidrTrustedRemote() {
- $this->config
- ->expects($this->once())
- ->method('getSystemValue')
- ->with('trusted_proxies')
- ->willReturn(['192.168.2.0/24']);
-
- $request = new Request(
- [
- 'server' => [
+ 'IPv4 matching CIDR of trusted proxy' => [
+ [
'REMOTE_ADDR' => '192.168.3.99',
'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
- 'HTTP_X_FORWARDED_FOR' => '192.168.0.233'
+ 'HTTP_X_FORWARDED_FOR' => '192.168.0.233',
],
+ ['192.168.2.0/24'],
+ ['HTTP_X_FORWARDED_FOR'],
+ '192.168.3.99',
],
- $this->requestId,
- $this->config,
- $this->csrfTokenManager,
- $this->stream
- );
-
- $this->assertSame('192.168.3.99', $request->getRemoteAddress());
- }
-
- public function testGetRemoteIpv6AddressWithMatchingIpv6CidrTrustedRemote() {
- $this->config
- ->expects($this->exactly(2))
- ->method('getSystemValue')
- ->withConsecutive(
- ['trusted_proxies'],
- ['forwarded_for_headers']
- )->willReturnOnConsecutiveCalls(
- ['2001:db8:85a3:8d3:1319:8a20::/95'],
- ['HTTP_X_FORWARDED_FOR']
- );
-
- $request = new Request(
- [
- 'server' => [
+ 'IPv6 matching CIDR of trusted proxy' => [
+ [
'REMOTE_ADDR' => '2001:db8:85a3:8d3:1319:8a21:370:7348',
'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
- 'HTTP_X_FORWARDED_FOR' => '192.168.0.233'
+ 'HTTP_X_FORWARDED_FOR' => '192.168.0.233',
],
+ ['2001:db8:85a3:8d3:1319:8a20::/95'],
+ ['HTTP_X_FORWARDED_FOR'],
+ '192.168.0.233',
],
- $this->requestId,
- $this->config,
- $this->csrfTokenManager,
- $this->stream
- );
-
- $this->assertSame('192.168.0.233', $request->getRemoteAddress());
- }
-
- public function testGetRemoteAddressIpv6WithNotMatchingCidrTrustedRemote() {
- $this->config
- ->expects($this->once())
- ->method('getSystemValue')
- ->with('trusted_proxies')
- ->willReturn(['fd::/8']);
-
- $request = new Request(
- [
- 'server' => [
+ 'IPv6 not matching CIDR of trusted proxy' => [
+ [
'REMOTE_ADDR' => '2001:db8:85a3:8d3:1319:8a2e:370:7348',
'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
- 'HTTP_X_FORWARDED_FOR' => '192.168.0.233'
+ 'HTTP_X_FORWARDED_FOR' => '192.168.0.233',
],
+ ['fd::/8'],
+ [],
+ '2001:db8:85a3:8d3:1319:8a2e:370:7348',
],
- $this->requestId,
- $this->config,
- $this->csrfTokenManager,
- $this->stream
- );
-
- $this->assertSame('2001:db8:85a3:8d3:1319:8a2e:370:7348', $request->getRemoteAddress());
- }
-
- public function testGetRemoteAddressIpv6WithInvalidTrustedProxy() {
- $this->config
- ->expects($this->once())
- ->method('getSystemValue')
- ->with('trusted_proxies')
- ->willReturn(['fx::/8']);
-
- $request = new Request(
- [
- 'server' => [
+ 'IPv6 with invalid trusted proxy' => [
+ [
'REMOTE_ADDR' => '2001:db8:85a3:8d3:1319:8a2e:370:7348',
'HTTP_X_FORWARDED' => '10.4.0.5, 10.4.0.4',
- 'HTTP_X_FORWARDED_FOR' => '192.168.0.233'
+ 'HTTP_X_FORWARDED_FOR' => '192.168.0.233',
],
+ ['fx::/8'],
+ [],
+ '2001:db8:85a3:8d3:1319:8a2e:370:7348',
],
- $this->requestId,
- $this->config,
- $this->csrfTokenManager,
- $this->stream
- );
-
- $this->assertSame('2001:db8:85a3:8d3:1319:8a2e:370:7348', $request->getRemoteAddress());
+ 'IPv4 forwarded for IPv6' => [
+ [
+ 'REMOTE_ADDR' => '192.168.2.99',
+ 'HTTP_X_FORWARDED_FOR' => '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
+ ],
+ ['192.168.2.0/24'],
+ ['HTTP_X_FORWARDED_FOR'],
+ '2001:db8:85a3:8d3:1319:8a2e:370:7348',
+ ],
+ 'IPv4 with port' => [
+ [
+ 'REMOTE_ADDR' => '2001:db8:85a3:8d3:1319:8a2e:370:7348',
+ 'HTTP_X_FORWARDED_FOR' => '192.168.2.99:8080',
+ ],
+ ['2001:db8::/8'],
+ ['HTTP_X_FORWARDED_FOR'],
+ '192.168.2.99',
+ ],
+ 'IPv6 with port' => [
+ [
+ 'REMOTE_ADDR' => '192.168.2.99',
+ 'HTTP_X_FORWARDED_FOR' => '[2001:db8:85a3:8d3:1319:8a2e:370:7348]:8080',
+ ],
+ ['192.168.2.0/24'],
+ ['HTTP_X_FORWARDED_FOR'],
+ '2001:db8:85a3:8d3:1319:8a2e:370:7348',
+ ],
+ ];
}
- public function testGetRemoteAddressWithXForwardedForIPv6() {
+ /**
+ * @dataProvider dataGetRemoteAddress
+ */
+ public function testGetRemoteAddress(array $headers, array $trustedProxies, array $forwardedForHeaders, string $expected): void {
$this->config
- ->expects($this->exactly(2))
->method('getSystemValue')
->withConsecutive(
['trusted_proxies'],
['forwarded_for_headers'],
- )-> willReturnOnConsecutiveCalls(
- ['192.168.2.0/24'],
- ['HTTP_X_FORWARDED_FOR'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ $trustedProxies,
+ $forwardedForHeaders,
);
$request = new Request(
[
- 'server' => [
- 'REMOTE_ADDR' => '192.168.2.99',
- 'HTTP_X_FORWARDED_FOR' => '[2001:db8:85a3:8d3:1319:8a2e:370:7348]',
- ],
+ 'server' => $headers,
],
$this->requestId,
$this->config,
@@ -881,7 +733,7 @@ class RequestTest extends \Test\TestCase {
$this->stream
);
- $this->assertSame('2001:db8:85a3:8d3:1319:8a2e:370:7348', $request->getRemoteAddress());
+ $this->assertSame($expected, $request->getRemoteAddress());
}
/**
@@ -1796,14 +1648,14 @@ class RequestTest extends \Test\TestCase {
public function providesGetRequestUriWithOverwriteData() {
return [
['/scriptname.php/some/PathInfo', '/owncloud/', ''],
- ['/scriptname.php/some/PathInfo', '/owncloud/', '123'],
+ ['/scriptname.php/some/PathInfo', '/owncloud/', '123', '123.123.123.123'],
];
}
/**
* @dataProvider providesGetRequestUriWithOverwriteData
*/
- public function testGetRequestUriWithOverwrite($expectedUri, $overwriteWebRoot, $overwriteCondAddr) {
+ public function testGetRequestUriWithOverwrite($expectedUri, $overwriteWebRoot, $overwriteCondAddr, $remoteAddr = '') {
$this->config
->expects($this->exactly(2))
->method('getSystemValueString')
@@ -1812,13 +1664,14 @@ class RequestTest extends \Test\TestCase {
['overwritecondaddr', '', $overwriteCondAddr],
]);
- $request = $this->getMockBuilder('\OC\AppFramework\Http\Request')
+ $request = $this->getMockBuilder(Request::class)
->setMethods(['getScriptName'])
->setConstructorArgs([
[
'server' => [
'REQUEST_URI' => '/test.php/some/PathInfo',
'SCRIPT_NAME' => '/test.php',
+ 'REMOTE_ADDR' => $remoteAddr
]
],
$this->requestId,
diff --git a/tests/lib/AppFramework/Http/ResponseTest.php b/tests/lib/AppFramework/Http/ResponseTest.php
index c1c122e789e..d01d29e7071 100644
--- a/tests/lib/AppFramework/Http/ResponseTest.php
+++ b/tests/lib/AppFramework/Http/ResponseTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Http;
@@ -229,7 +214,6 @@ class ResponseTest extends \Test\TestCase {
$headers = $this->childResponse->getHeaders();
$this->assertEquals('no-cache, no-store, must-revalidate', $headers['Cache-Control']);
- $this->assertFalse(isset($headers['Pragma']));
$this->assertFalse(isset($headers['Expires']));
}
@@ -245,7 +229,6 @@ class ResponseTest extends \Test\TestCase {
$headers = $this->childResponse->getHeaders();
$this->assertEquals('private, max-age=33, must-revalidate', $headers['Cache-Control']);
- $this->assertEquals('private', $headers['Pragma']);
$this->assertEquals('Thu, 15 Jan 1970 06:56:40 +0000', $headers['Expires']);
}
diff --git a/tests/lib/AppFramework/Http/StreamResponseTest.php b/tests/lib/AppFramework/Http/StreamResponseTest.php
index 3c0105ad145..637fb025142 100644
--- a/tests/lib/AppFramework/Http/StreamResponseTest.php
+++ b/tests/lib/AppFramework/Http/StreamResponseTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2015 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Http;
diff --git a/tests/lib/AppFramework/Http/TemplateResponseTest.php b/tests/lib/AppFramework/Http/TemplateResponseTest.php
index 13eef5c7c22..df9824d3032 100644
--- a/tests/lib/AppFramework/Http/TemplateResponseTest.php
+++ b/tests/lib/AppFramework/Http/TemplateResponseTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Http;
diff --git a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
index d37c1c47609..890735008fc 100644
--- a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware;
diff --git a/tests/lib/AppFramework/Middleware/CompressionMiddlewareTest.php b/tests/lib/AppFramework/Middleware/CompressionMiddlewareTest.php
index 79e07ac6686..a0848b70796 100644
--- a/tests/lib/AppFramework/Middleware/CompressionMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/CompressionMiddlewareTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware;
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
index f408320971d..fd3ed861405 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Middleware;
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareTest.php b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
index f9e775269d4..0662f822103 100644
--- a/tests/lib/AppFramework/Middleware/MiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/MiddlewareTest.php
@@ -1,35 +1,20 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Middleware;
+use OC\AppFramework\DependencyInjection\DIContainer;
use OC\AppFramework\Http\Request;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Middleware;
use OCP\IConfig;
use OCP\IRequestId;
-use OC\AppFramework\DependencyInjection\DIContainer;
class ChildMiddleware extends Middleware {
};
diff --git a/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php b/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php
index 3b69a289e99..e41bb45e069 100644
--- a/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware;
diff --git a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
index 4839ff75b5e..28b2ba34fca 100644
--- a/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/OCSMiddlewareTest.php
@@ -1,23 +1,7 @@
<?php
/**
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware;
diff --git a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
index a025f39419a..03cd253044d 100644
--- a/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/PublicShare/PublicShareMiddlewareTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2018, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware\PublicShare;
diff --git a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php
index 0492d5f7fcf..a224ebae949 100644
--- a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php
@@ -1,23 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
- * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware\Security;
diff --git a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
index 80c2ed84451..ab06b020c9b 100644
--- a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
@@ -1,14 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright Bernhard Posselt 2014
+ * SPDX-FileCopyrightText: 2016-2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2014-2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-
namespace Test\AppFramework\Middleware\Security;
use OC\AppFramework\Http\Request;
diff --git a/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php
index 284634f7db2..63a3e7ff123 100644
--- a/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/CSPMiddlewareTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware\Security;
diff --git a/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php
index 154b43f69a5..1cdd99b1aae 100644
--- a/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/FeaturePolicyMiddlewareTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware\Security;
diff --git a/tests/lib/AppFramework/Middleware/Security/Mock/CORSMiddlewareController.php b/tests/lib/AppFramework/Middleware/Security/Mock/CORSMiddlewareController.php
index 44e6c7a588b..769cba87207 100644
--- a/tests/lib/AppFramework/Middleware/Security/Mock/CORSMiddlewareController.php
+++ b/tests/lib/AppFramework/Middleware/Security/Mock/CORSMiddlewareController.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware\Security\Mock;
diff --git a/tests/lib/AppFramework/Middleware/Security/Mock/NormalController.php b/tests/lib/AppFramework/Middleware/Security/Mock/NormalController.php
index e732b89e308..99f33be1cc9 100644
--- a/tests/lib/AppFramework/Middleware/Security/Mock/NormalController.php
+++ b/tests/lib/AppFramework/Middleware/Security/Mock/NormalController.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware\Security\Mock;
diff --git a/tests/lib/AppFramework/Middleware/Security/Mock/OCSController.php b/tests/lib/AppFramework/Middleware/Security/Mock/OCSController.php
index d053124fe19..93e793ecca9 100644
--- a/tests/lib/AppFramework/Middleware/Security/Mock/OCSController.php
+++ b/tests/lib/AppFramework/Middleware/Security/Mock/OCSController.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware\Security\Mock;
diff --git a/tests/lib/AppFramework/Middleware/Security/Mock/PasswordConfirmationMiddlewareController.php b/tests/lib/AppFramework/Middleware/Security/Mock/PasswordConfirmationMiddlewareController.php
index 5b83575f711..82d6cf8f251 100644
--- a/tests/lib/AppFramework/Middleware/Security/Mock/PasswordConfirmationMiddlewareController.php
+++ b/tests/lib/AppFramework/Middleware/Security/Mock/PasswordConfirmationMiddlewareController.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware\Security\Mock;
diff --git a/tests/lib/AppFramework/Middleware/Security/Mock/SecurityMiddlewareController.php b/tests/lib/AppFramework/Middleware/Security/Mock/SecurityMiddlewareController.php
index b0a59faba78..dae26b2fad5 100644
--- a/tests/lib/AppFramework/Middleware/Security/Mock/SecurityMiddlewareController.php
+++ b/tests/lib/AppFramework/Middleware/Security/Mock/SecurityMiddlewareController.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware\Security\Mock;
diff --git a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
index 3752259c61b..3613ca624a3 100644
--- a/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/PasswordConfirmationMiddlewareTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2018, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware\Security;
diff --git a/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php
index 47d479b18a1..fddca471215 100644
--- a/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/RateLimitingMiddlewareTest.php
@@ -3,26 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
- * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware\Security;
@@ -37,6 +19,7 @@ use OCP\AppFramework\Http\Attribute\UserRateLimit;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IRequest;
+use OCP\ISession;
use OCP\IUser;
use OCP\IUserSession;
use PHPUnit\Framework\MockObject\MockObject;
@@ -77,6 +60,7 @@ class RateLimitingMiddlewareTest extends TestCase {
private IUserSession|MockObject $userSession;
private ControllerMethodReflector $reflector;
private Limiter|MockObject $limiter;
+ private ISession|MockObject $session;
private RateLimitingMiddleware $rateLimitingMiddleware;
protected function setUp(): void {
@@ -86,12 +70,14 @@ class RateLimitingMiddlewareTest extends TestCase {
$this->userSession = $this->createMock(IUserSession::class);
$this->reflector = new ControllerMethodReflector();
$this->limiter = $this->createMock(Limiter::class);
+ $this->session = $this->createMock(ISession::class);
$this->rateLimitingMiddleware = new RateLimitingMiddleware(
$this->request,
$this->userSession,
$this->reflector,
- $this->limiter
+ $this->limiter,
+ $this->session
);
}
diff --git a/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php
index 787f5c92fd7..b4d7ee10f7c 100644
--- a/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/SameSiteCookieMiddlewareTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2017, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware\Security;
diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
index 7c59a8c1452..1d7753a3477 100644
--- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
@@ -1,23 +1,8 @@
<?php
/**
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\AppFramework\Middleware\Security;
diff --git a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
index 09838423e85..8ecc73791c9 100644
--- a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
@@ -1,17 +1,11 @@
<?php
declare(strict_types=1);
-
/**
- * ownCloud - App Framework
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Thomas Müller <deepdiver@owncloud.com>
- * @copyright Thomas Müller 2014
+ * SPDX-FileCopyrightText: 2016-2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-
namespace Test\AppFramework\Middleware;
use OC\AppFramework\Middleware\SessionMiddleware;
diff --git a/tests/lib/AppFramework/OCS/BaseResponseTest.php b/tests/lib/AppFramework/OCS/BaseResponseTest.php
index a1e0c620574..aaa107ef013 100644
--- a/tests/lib/AppFramework/OCS/BaseResponseTest.php
+++ b/tests/lib/AppFramework/OCS/BaseResponseTest.php
@@ -3,31 +3,25 @@
declare(strict_types=1);
/**
- * @copyright 2020 Daniel Kesselberg <mail@danielkesselberg.de>
- *
- * @author 2020 Daniel Kesselberg <mail@danielkesselberg.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\AppFramework\Middleware;
use OC\AppFramework\OCS\BaseResponse;
+class ArrayValue implements \JsonSerializable {
+ private $array;
+ public function __construct(array $array) {
+ $this->array = $array;
+ }
+
+ public function jsonSerialize(): mixed {
+ return $this->array;
+ }
+}
+
class BaseResponseTest extends \Test\TestCase {
public function testToXml(): void {
/** @var BaseResponse $response */
@@ -56,4 +50,32 @@ class BaseResponseTest extends \Test\TestCase {
$writer->outputMemory(true)
);
}
+
+ public function testToXmlJsonSerializable(): void {
+ /** @var BaseResponse $response */
+ $response = $this->createMock(BaseResponse::class);
+
+ $writer = new \XMLWriter();
+ $writer->openMemory();
+ $writer->setIndent(false);
+ $writer->startDocument();
+
+ $data = [
+ 'hello' => 'hello',
+ 'information' => new ArrayValue([
+ '@test' => 'some data',
+ 'someElement' => 'withAttribute',
+ ]),
+ 'value without key',
+ 'object' => new \stdClass(),
+ ];
+
+ $this->invokePrivate($response, 'toXml', [$data, $writer]);
+ $writer->endDocument();
+
+ $this->assertEquals(
+ "<?xml version=\"1.0\"?>\n<hello>hello</hello><information test=\"some data\"><someElement>withAttribute</someElement></information><element>value without key</element><object/>\n",
+ $writer->outputMemory(true)
+ );
+ }
}
diff --git a/tests/lib/AppFramework/Routing/RoutingTest.php b/tests/lib/AppFramework/Routing/RoutingTest.php
index d7fde02dbcb..00b586e6cc4 100644
--- a/tests/lib/AppFramework/Routing/RoutingTest.php
+++ b/tests/lib/AppFramework/Routing/RoutingTest.php
@@ -1,11 +1,16 @@
<?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;
@@ -142,7 +147,8 @@ class RoutingTest extends \Test\TestCase {
$this->createMock(IRequest::class),
$this->createMock(IConfig::class),
$this->createMock(IEventLogger::class),
- $this->createMock(ContainerInterface::class)
+ $this->createMock(ContainerInterface::class),
+ $this->createMock(IAppManager::class),
])
->getMock();
@@ -169,7 +175,8 @@ class RoutingTest extends \Test\TestCase {
$this->createMock(IRequest::class),
$this->createMock(IConfig::class),
$this->createMock(IEventLogger::class),
- $this->createMock(ContainerInterface::class)
+ $this->createMock(ContainerInterface::class),
+ $this->createMock(IAppManager::class),
])
->getMock();
@@ -235,7 +242,8 @@ class RoutingTest extends \Test\TestCase {
$this->createMock(IRequest::class),
$this->createMock(IConfig::class),
$this->createMock(IEventLogger::class),
- $this->createMock(ContainerInterface::class)
+ $this->createMock(ContainerInterface::class),
+ $this->createMock(IAppManager::class),
])
->getMock();
@@ -267,14 +275,14 @@ class RoutingTest extends \Test\TestCase {
* @param string $postfix
*/
private function assertSimpleOCSRoute($routes,
- $name,
- $verb,
- $url,
- $controllerName,
- $actionName,
- array $requirements = [],
- array $defaults = [],
- $postfix = '') {
+ $name,
+ $verb,
+ $url,
+ $controllerName,
+ $actionName,
+ array $requirements = [],
+ array $defaults = [],
+ $postfix = '') {
if ($postfix) {
$name .= $postfix;
}
@@ -291,7 +299,8 @@ class RoutingTest extends \Test\TestCase {
$this->createMock(IRequest::class),
$this->createMock(IConfig::class),
$this->createMock(IEventLogger::class),
- $this->createMock(ContainerInterface::class)
+ $this->createMock(ContainerInterface::class),
+ $this->createMock(IAppManager::class),
])
->getMock();
@@ -324,7 +333,8 @@ class RoutingTest extends \Test\TestCase {
$this->createMock(IRequest::class),
$this->createMock(IConfig::class),
$this->createMock(IEventLogger::class),
- $this->createMock(ContainerInterface::class)
+ $this->createMock(ContainerInterface::class),
+ $this->createMock(IAppManager::class),
])
->getMock();
@@ -377,7 +387,8 @@ class RoutingTest extends \Test\TestCase {
$this->createMock(IRequest::class),
$this->createMock(IConfig::class),
$this->createMock(IEventLogger::class),
- $this->createMock(ContainerInterface::class)
+ $this->createMock(ContainerInterface::class),
+ $this->createMock(IAppManager::class),
])
->getMock();
diff --git a/tests/lib/AppFramework/Services/AppConfigTest.php b/tests/lib/AppFramework/Services/AppConfigTest.php
new file mode 100644
index 00000000000..0ee4afe9bf6
--- /dev/null
+++ b/tests/lib/AppFramework/Services/AppConfigTest.php
@@ -0,0 +1,675 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+namespace Test\AppFramework\Services;
+
+use OC\AppConfig as AppConfigCore;
+use OC\AppFramework\Services\AppConfig;
+use OCP\Exceptions\AppConfigTypeConflictException;
+use OCP\Exceptions\AppConfigUnknownKeyException;
+use OCP\IAppConfig as IAppConfigCore;
+use OCP\IConfig;
+use PHPUnit\Framework\MockObject\MockObject;
+use Test\TestCase;
+
+class AppConfigTest extends TestCase {
+ private IConfig|MockObject $config;
+ private IAppConfigCore|MockObject $appConfigCore;
+ private AppConfig $appConfig;
+
+ private const TEST_APPID = 'appconfig-test';
+
+ protected function setUp(): void {
+ 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);
+ }
+
+ public function testGetAppKeys(): void {
+ $expected = ['key1', 'key2', 'key3', 'key4', 'key5', 'key6', 'key7', 'test8'];
+ $this->appConfigCore->expects($this->once())
+ ->method('getKeys')
+ ->with(self::TEST_APPID)
+ ->willReturn($expected);
+ $this->assertSame($expected, $this->appConfig->getAppKeys());
+ }
+
+
+ /**
+ * @return array
+ * @see testHasAppKey
+ */
+ public function providerHasAppKey(): array {
+ return [
+ // lazy, expected
+ [false, true],
+ [true, true],
+ [false, false],
+ [true, false],
+ ];
+ }
+
+ /**
+ * @dataProvider providerHasAppKey
+ *
+ * @param bool $lazy
+ * @param bool $expected
+ */
+ public function testHasAppKey(bool $lazy, bool $expected): void {
+ $key = 'key';
+ $this->appConfigCore->expects($this->once())
+ ->method('hasKey')
+ ->with(self::TEST_APPID, $key, $lazy)
+ ->willReturn($expected);
+ $this->assertSame($expected, $this->appConfig->hasAppKey($key, $lazy));
+ }
+
+
+ /**
+ * @return array
+ * @see testIsSensitive
+ */
+ public function providerIsSensitive(): array {
+ return [
+ // lazy, expected
+ [false, true],
+ [true, true],
+ [false, false],
+ [true, false],
+ ];
+ }
+
+ /**
+ * @dataProvider providerIsSensitive
+ *
+ * @param bool $lazy
+ * @param bool $expected
+ */
+ public function testIsSensitive(bool $lazy, bool $expected): void {
+ $key = 'key';
+ $this->appConfigCore->expects($this->once())
+ ->method('isSensitive')
+ ->with(self::TEST_APPID, $key, $lazy)
+ ->willReturn($expected);
+
+ $this->assertSame($expected, $this->appConfig->isSensitive($key, $lazy));
+ }
+
+ /**
+ * @dataProvider providerIsSensitive
+ *
+ * @param bool $lazy
+ * @param bool $expected
+ */
+ public function testIsSensitiveException(bool $lazy, bool $expected): void {
+ $key = 'unknown-key';
+ $this->appConfigCore->expects($this->once())
+ ->method('isSensitive')
+ ->with(self::TEST_APPID, $key, $lazy)
+ ->willThrowException(new AppConfigUnknownKeyException());
+
+ $this->expectException(AppConfigUnknownKeyException::class);
+ $this->appConfig->isSensitive($key, $lazy);
+ }
+
+ /**
+ * @return array
+ * @see testIsLazy
+ */
+ public function providerIsLazy(): array {
+ return [
+ // expected
+ [true],
+ [false],
+ ];
+ }
+
+ /**
+ * @dataProvider providerIsLazy
+ *
+ * @param bool $expected
+ */
+ public function testIsLazy(bool $expected): void {
+ $key = 'key';
+ $this->appConfigCore->expects($this->once())
+ ->method('isLazy')
+ ->with(self::TEST_APPID, $key)
+ ->willReturn($expected);
+
+ $this->assertSame($expected, $this->appConfig->isLazy($key));
+ }
+
+ public function testIsLazyException(): void {
+ $key = 'unknown-key';
+ $this->appConfigCore->expects($this->once())
+ ->method('isLazy')
+ ->with(self::TEST_APPID, $key)
+ ->willThrowException(new AppConfigUnknownKeyException());
+
+ $this->expectException(AppConfigUnknownKeyException::class);
+ $this->appConfig->isLazy($key);
+ }
+
+ /**
+ * @return array
+ * @see testGetAllAppValues
+ */
+ public function providerGetAllAppValues(): array {
+ return [
+ // key, filtered
+ ['', false],
+ ['', true],
+ ['key', false],
+ ['key', true],
+ ];
+ }
+
+ /**
+ * @dataProvider providerGetAllAppValues
+ *
+ * @param string $key
+ * @param bool $filtered
+ */
+ public function testGetAllAppValues(string $key, bool $filtered): void {
+ $expected = [
+ 'key1' => 'value1',
+ 'key2' => 3,
+ 'key3' => 3.14,
+ 'key4' => true
+ ];
+
+ $this->appConfigCore->expects($this->once())
+ ->method('getAllValues')
+ ->with(self::TEST_APPID, $key, $filtered)
+ ->willReturn($expected);
+
+ $this->assertSame($expected, $this->appConfig->getAllAppValues($key, $filtered));
+ }
+
+ public function testSetAppValue(): void {
+ $key = 'key';
+ $value = 'value';
+ $this->appConfigCore->expects($this->once())
+ ->method('setValueMixed')
+ ->with(self::TEST_APPID, $key, $value);
+
+ $this->appConfig->setAppValue($key, $value);
+ }
+
+ /**
+ * @return array
+ * @see testSetAppValueString
+ * @see testSetAppValueStringException
+ * @see testSetAppValueInt
+ * @see testSetAppValueIntException
+ * @see testSetAppValueFloat
+ * @see testSetAppValueFloatException
+ * @see testSetAppValueArray
+ * @see testSetAppValueArrayException
+ */
+ public function providerSetAppValue(): array {
+ return [
+ // lazy, sensitive, expected
+ [false, false, true],
+ [false, true, true],
+ [true, true, true],
+ [true, false, true],
+ [false, false, false],
+ [false, true, false],
+ [true, true, false],
+ [true, false, false],
+ ];
+ }
+
+ /**
+ * @dataProvider providerSetAppValue
+ *
+ * @param bool $lazy
+ * @param bool $sensitive
+ * @param bool $expected
+ */
+ public function testSetAppValueString(bool $lazy, bool $sensitive, bool $expected): void {
+ $key = 'key';
+ $value = 'valueString';
+ $this->appConfigCore->expects($this->once())
+ ->method('setValueString')
+ ->with(self::TEST_APPID, $key, $value, $lazy, $sensitive)
+ ->willReturn($expected);
+
+ $this->assertSame($expected, $this->appConfig->setAppValueString($key, $value, $lazy, $sensitive));
+ }
+
+ /**
+ * @dataProvider providerSetAppValue
+ *
+ * @param bool $lazy
+ * @param bool $sensitive
+ */
+ public function testSetAppValueStringException(bool $lazy, bool $sensitive): void {
+ $key = 'key';
+ $value = 'valueString';
+ $this->appConfigCore->expects($this->once())
+ ->method('setValueString')
+ ->with(self::TEST_APPID, $key, $value, $lazy, $sensitive)
+ ->willThrowException(new AppConfigTypeConflictException());
+
+ $this->expectException(AppConfigTypeConflictException::class);
+ $this->appConfig->setAppValueString($key, $value, $lazy, $sensitive);
+ }
+
+ /**
+ * @dataProvider providerSetAppValue
+ *
+ * @param bool $lazy
+ * @param bool $sensitive
+ * @param bool $expected
+ */
+ public function testSetAppValueInt(bool $lazy, bool $sensitive, bool $expected): void {
+ $key = 'key';
+ $value = 42;
+ $this->appConfigCore->expects($this->once())
+ ->method('setValueInt')
+ ->with(self::TEST_APPID, $key, $value, $lazy, $sensitive)
+ ->willReturn($expected);
+
+ $this->assertSame($expected, $this->appConfig->setAppValueInt($key, $value, $lazy, $sensitive));
+ }
+
+ /**
+ * @dataProvider providerSetAppValue
+ *
+ * @param bool $lazy
+ * @param bool $sensitive
+ */
+ public function testSetAppValueIntException(bool $lazy, bool $sensitive): void {
+ $key = 'key';
+ $value = 42;
+ $this->appConfigCore->expects($this->once())
+ ->method('setValueInt')
+ ->with(self::TEST_APPID, $key, $value, $lazy, $sensitive)
+ ->willThrowException(new AppConfigTypeConflictException());
+
+ $this->expectException(AppConfigTypeConflictException::class);
+ $this->appConfig->setAppValueInt($key, $value, $lazy, $sensitive);
+ }
+
+ /**
+ * @dataProvider providerSetAppValue
+ *
+ * @param bool $lazy
+ * @param bool $sensitive
+ * @param bool $expected
+ */
+ public function testSetAppValueFloat(bool $lazy, bool $sensitive, bool $expected): void {
+ $key = 'key';
+ $value = 3.14;
+ $this->appConfigCore->expects($this->once())
+ ->method('setValueFloat')
+ ->with(self::TEST_APPID, $key, $value, $lazy, $sensitive)
+ ->willReturn($expected);
+
+ $this->assertSame($expected, $this->appConfig->setAppValueFloat($key, $value, $lazy, $sensitive));
+ }
+
+ /**
+ * @dataProvider providerSetAppValue
+ *
+ * @param bool $lazy
+ * @param bool $sensitive
+ */
+ public function testSetAppValueFloatException(bool $lazy, bool $sensitive): void {
+ $key = 'key';
+ $value = 3.14;
+ $this->appConfigCore->expects($this->once())
+ ->method('setValueFloat')
+ ->with(self::TEST_APPID, $key, $value, $lazy, $sensitive)
+ ->willThrowException(new AppConfigTypeConflictException());
+
+ $this->expectException(AppConfigTypeConflictException::class);
+ $this->appConfig->setAppValueFloat($key, $value, $lazy, $sensitive);
+ }
+
+ /**
+ * @return array
+ * @see testSetAppValueBool
+ */
+ public function providerSetAppValueBool(): array {
+ return [
+ // lazy, expected
+ [false, true],
+ [false, false],
+ [true, true],
+ [true, false],
+ ];
+ }
+
+ /**
+ * @dataProvider providerSetAppValueBool
+ *
+ * @param bool $lazy
+ * @param bool $expected
+ */
+ public function testSetAppValueBool(bool $lazy, bool $expected): void {
+ $key = 'key';
+ $value = true;
+ $this->appConfigCore->expects($this->once())
+ ->method('setValueBool')
+ ->with(self::TEST_APPID, $key, $value, $lazy)
+ ->willReturn($expected);
+
+ $this->assertSame($expected, $this->appConfig->setAppValueBool($key, $value, $lazy));
+ }
+
+ /**
+ * @dataProvider providerSetAppValueBool
+ *
+ * @param bool $lazy
+ */
+ public function testSetAppValueBoolException(bool $lazy): void {
+ $key = 'key';
+ $value = true;
+ $this->appConfigCore->expects($this->once())
+ ->method('setValueBool')
+ ->with(self::TEST_APPID, $key, $value, $lazy)
+ ->willThrowException(new AppConfigTypeConflictException());
+
+ $this->expectException(AppConfigTypeConflictException::class);
+ $this->appConfig->setAppValueBool($key, $value, $lazy);
+ }
+
+ /**
+ * @dataProvider providerSetAppValue
+ *
+ * @param bool $lazy
+ * @param bool $sensitive
+ * @param bool $expected
+ */
+ public function testSetAppValueArray(bool $lazy, bool $sensitive, bool $expected): void {
+ $key = 'key';
+ $value = ['item' => true];
+ $this->appConfigCore->expects($this->once())
+ ->method('setValueArray')
+ ->with(self::TEST_APPID, $key, $value, $lazy, $sensitive)
+ ->willReturn($expected);
+
+ $this->assertSame($expected, $this->appConfig->setAppValueArray($key, $value, $lazy, $sensitive));
+ }
+
+ /**
+ * @dataProvider providerSetAppValue
+ *
+ * @param bool $lazy
+ * @param bool $sensitive
+ */
+ public function testSetAppValueArrayException(bool $lazy, bool $sensitive): void {
+ $key = 'key';
+ $value = ['item' => true];
+ $this->appConfigCore->expects($this->once())
+ ->method('setValueArray')
+ ->with(self::TEST_APPID, $key, $value, $lazy, $sensitive)
+ ->willThrowException(new AppConfigTypeConflictException());
+
+ $this->expectException(AppConfigTypeConflictException::class);
+ $this->appConfig->setAppValueArray($key, $value, $lazy, $sensitive);
+ }
+
+ public function testGetAppValue(): void {
+ $key = 'key';
+ $value = 'value';
+ $default = 'default';
+ $this->appConfigCore->expects($this->once())
+ ->method('getValueMixed')
+ ->with(self::TEST_APPID, $key, $default)
+ ->willReturn($value);
+
+ $this->assertSame($value, $this->appConfig->getAppValue($key, $default));
+ }
+
+ public function testGetAppValueDefault(): void {
+ $key = 'key';
+ $default = 'default';
+ $this->appConfigCore->expects($this->once())
+ ->method('getValueMixed')
+ ->with(self::TEST_APPID, $key, $default)
+ ->willReturn($default);
+
+ $this->assertSame($default, $this->appConfig->getAppValue($key, $default));
+ }
+
+ /**
+ * @return array
+ * @see testGetAppValueString
+ * @see testGetAppValueStringException
+ * @see testGetAppValueInt
+ * @see testGetAppValueIntException
+ * @see testGetAppValueFloat
+ * @see testGetAppValueFloatException
+ * @see testGetAppValueBool
+ * @see testGetAppValueBoolException
+ * @see testGetAppValueArray
+ * @see testGetAppValueArrayException
+ */
+ public function providerGetAppValue(): array {
+ return [
+ // lazy, exist
+ [false, false],
+ [false, true],
+ [true, true],
+ [true, false]
+ ];
+ }
+
+ /**
+ * @dataProvider providerGetAppValue
+ *
+ * @param bool $lazy
+ * @param bool $exist
+ */
+ public function testGetAppValueString(bool $lazy, bool $exist): void {
+ $key = 'key';
+ $value = 'valueString';
+ $default = 'default';
+
+ $expected = ($exist) ? $value : $default;
+ $this->appConfigCore->expects($this->once())
+ ->method('getValueString')
+ ->with(self::TEST_APPID, $key, $default, $lazy)
+ ->willReturn($expected);
+
+ $this->assertSame($expected, $this->appConfig->getAppValueString($key, $default, $lazy));
+ }
+
+ /**
+ * @dataProvider providerGetAppValue
+ *
+ * @param bool $lazy
+ */
+ public function testGetAppValueStringException(bool $lazy): void {
+ $key = 'key';
+ $default = 'default';
+
+ $this->appConfigCore->expects($this->once())
+ ->method('getValueString')
+ ->with(self::TEST_APPID, $key, $default, $lazy)
+ ->willThrowException(new AppConfigTypeConflictException());
+
+ $this->expectException(AppConfigTypeConflictException::class);
+ $this->appConfig->getAppValueString($key, $default, $lazy);
+ }
+
+ /**
+ * @dataProvider providerGetAppValue
+ *
+ * @param bool $lazy
+ * @param bool $exist
+ */
+ public function testGetAppValueInt(bool $lazy, bool $exist): void {
+ $key = 'key';
+ $value = 42;
+ $default = 17;
+
+ $expected = ($exist) ? $value : $default;
+ $this->appConfigCore->expects($this->once())
+ ->method('getValueInt')
+ ->with(self::TEST_APPID, $key, $default, $lazy)
+ ->willReturn($expected);
+
+ $this->assertSame($expected, $this->appConfig->getAppValueInt($key, $default, $lazy));
+ }
+
+ /**
+ * @dataProvider providerGetAppValue
+ *
+ * @param bool $lazy
+ */
+ public function testGetAppValueIntException(bool $lazy): void {
+ $key = 'key';
+ $default = 17;
+
+ $this->appConfigCore->expects($this->once())
+ ->method('getValueInt')
+ ->with(self::TEST_APPID, $key, $default, $lazy)
+ ->willThrowException(new AppConfigTypeConflictException());
+
+ $this->expectException(AppConfigTypeConflictException::class);
+ $this->appConfig->getAppValueInt($key, $default, $lazy);
+ }
+
+ /**
+ * @dataProvider providerGetAppValue
+ *
+ * @param bool $lazy
+ * @param bool $exist
+ */
+ public function testGetAppValueFloat(bool $lazy, bool $exist): void {
+ $key = 'key';
+ $value = 3.14;
+ $default = 17.04;
+
+ $expected = ($exist) ? $value : $default;
+ $this->appConfigCore->expects($this->once())
+ ->method('getValueFloat')
+ ->with(self::TEST_APPID, $key, $default, $lazy)
+ ->willReturn($expected);
+
+ $this->assertSame($expected, $this->appConfig->getAppValueFloat($key, $default, $lazy));
+ }
+
+ /**
+ * @dataProvider providerGetAppValue
+ *
+ * @param bool $lazy
+ */
+ public function testGetAppValueFloatException(bool $lazy): void {
+ $key = 'key';
+ $default = 17.04;
+
+ $this->appConfigCore->expects($this->once())
+ ->method('getValueFloat')
+ ->with(self::TEST_APPID, $key, $default, $lazy)
+ ->willThrowException(new AppConfigTypeConflictException());
+
+ $this->expectException(AppConfigTypeConflictException::class);
+ $this->appConfig->getAppValueFloat($key, $default, $lazy);
+ }
+
+ /**
+ * @dataProvider providerGetAppValue
+ *
+ * @param bool $lazy
+ * @param bool $exist
+ */
+ public function testGetAppValueBool(bool $lazy, bool $exist): void {
+ $key = 'key';
+ $value = true;
+ $default = false;
+
+ $expected = ($exist) ? $value : $default; // yes, it can be simplified
+ $this->appConfigCore->expects($this->once())
+ ->method('getValueBool')
+ ->with(self::TEST_APPID, $key, $default, $lazy)
+ ->willReturn($expected);
+
+ $this->assertSame($expected, $this->appConfig->getAppValueBool($key, $default, $lazy));
+ }
+
+ /**
+ * @dataProvider providerGetAppValue
+ *
+ * @param bool $lazy
+ */
+ public function testGetAppValueBoolException(bool $lazy): void {
+ $key = 'key';
+ $default = false;
+
+ $this->appConfigCore->expects($this->once())
+ ->method('getValueBool')
+ ->with(self::TEST_APPID, $key, $default, $lazy)
+ ->willThrowException(new AppConfigTypeConflictException());
+
+ $this->expectException(AppConfigTypeConflictException::class);
+ $this->appConfig->getAppValueBool($key, $default, $lazy);
+ }
+
+ /**
+ * @dataProvider providerGetAppValue
+ *
+ * @param bool $lazy
+ * @param bool $exist
+ */
+ public function testGetAppValueArray(bool $lazy, bool $exist): void {
+ $key = 'key';
+ $value = ['item' => true];
+ $default = [];
+
+ $expected = ($exist) ? $value : $default;
+ $this->appConfigCore->expects($this->once())
+ ->method('getValueArray')
+ ->with(self::TEST_APPID, $key, $default, $lazy)
+ ->willReturn($expected);
+
+ $this->assertSame($expected, $this->appConfig->getAppValueArray($key, $default, $lazy));
+ }
+
+ /**
+ * @dataProvider providerGetAppValue
+ *
+ * @param bool $lazy
+ */
+ public function testGetAppValueArrayException(bool $lazy): void {
+ $key = 'key';
+ $default = [];
+
+ $this->appConfigCore->expects($this->once())
+ ->method('getValueArray')
+ ->with(self::TEST_APPID, $key, $default, $lazy)
+ ->willThrowException(new AppConfigTypeConflictException());
+
+ $this->expectException(AppConfigTypeConflictException::class);
+ $this->appConfig->getAppValueArray($key, $default, $lazy);
+ }
+
+ public function testDeleteAppValue(): void {
+ $key = 'key';
+ $this->appConfigCore->expects($this->once())
+ ->method('deleteKey')
+ ->with(self::TEST_APPID, $key);
+
+ $this->appConfig->deleteAppValue($key);
+ }
+
+ public function testDeleteAppValues(): void {
+ $this->appConfigCore->expects($this->once())
+ ->method('deleteApp')
+ ->with(self::TEST_APPID);
+
+ $this->appConfig->deleteAppValues();
+ }
+}
diff --git a/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php b/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php
index 5452fb853b9..05ad6456904 100644
--- a/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php
+++ b/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Utility;
@@ -54,6 +39,14 @@ class MiddleController extends BaseController {
public function test3() {
}
+
+ /**
+ * @psalm-param int<-4, 42> $rangedOne
+ * @psalm-param int<min, max> $rangedTwo
+ * @return void
+ */
+ public function test4(int $rangedOne, int $rangedTwo) {
+ }
}
class EndController extends MiddleController {
@@ -234,4 +227,17 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
$this->assertFalse($reader->hasAnnotation('Annotation'));
}
+
+ public function testRangeDetection() {
+ $reader = new ControllerMethodReflector();
+ $reader->reflect('Test\AppFramework\Utility\EndController', 'test4');
+
+ $rangeInfo1 = $reader->getRange('rangedOne');
+ $this->assertSame(-4, $rangeInfo1['min']);
+ $this->assertSame(42, $rangeInfo1['max']);
+
+ $rangeInfo2 = $reader->getRange('rangedTwo');
+ $this->assertSame(PHP_INT_MIN, $rangeInfo2['min']);
+ $this->assertSame(PHP_INT_MAX, $rangeInfo2['max']);
+ }
}
diff --git a/tests/lib/AppFramework/Utility/SimpleContainerTest.php b/tests/lib/AppFramework/Utility/SimpleContainerTest.php
index 61b3299671b..d27d29db951 100644
--- a/tests/lib/AppFramework/Utility/SimpleContainerTest.php
+++ b/tests/lib/AppFramework/Utility/SimpleContainerTest.php
@@ -3,24 +3,9 @@
declare(strict_types=1);
/**
- * ownCloud - App Framework
- *
- * @author Bernhard Posselt
- * @copyright 2014 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * 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\Utility;
@@ -50,6 +35,17 @@ class ClassComplexConstructor {
}
}
+class ClassNullableUntypedConstructorArg {
+ public function __construct($class) {
+ }
+}
+class ClassNullableTypedConstructorArg {
+ public $class;
+ public function __construct(?\Some\Class $class) {
+ $this->class = $class;
+ }
+}
+
interface IInterfaceConstructor {
}
class ClassInterfaceConstructor {
@@ -243,4 +239,17 @@ class SimpleContainerTest extends \Test\TestCase {
$this->assertNotSame(
$this->container->query('test'), $this->container->query('test1'));
}
+
+ public function testQueryUntypedNullable(): void {
+ $this->expectException(\OCP\AppFramework\QueryException::class);
+
+ $this->container->query(ClassNullableUntypedConstructorArg::class);
+ }
+
+ public function testQueryTypedNullable(): void {
+ /** @var ClassNullableTypedConstructorArg $service */
+ $service = $this->container->query(ClassNullableTypedConstructorArg::class);
+
+ self::assertNull($service->class);
+ }
}
diff --git a/tests/lib/AppFramework/Utility/TimeFactoryTest.php b/tests/lib/AppFramework/Utility/TimeFactoryTest.php
index 5811a2cf86a..276b2d6da4f 100644
--- a/tests/lib/AppFramework/Utility/TimeFactoryTest.php
+++ b/tests/lib/AppFramework/Utility/TimeFactoryTest.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2022, Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\AppFramework\Utility;
@@ -46,4 +30,21 @@ class TimeFactoryTest extends \Test\TestCase {
$now = $withTimeZone->now();
self::assertSame('Europe/Berlin', $now->getTimezone()->getName());
}
+
+ public function testGetTimeZone(): void {
+ $expected = new \DateTimeZone('Europe/Berlin');
+ $actual = $this->timeFactory->getTimeZone('Europe/Berlin');
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testGetTimeZoneUTC(): void {
+ $expected = new \DateTimeZone('UTC');
+ $actual = $this->timeFactory->getTimeZone();
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testGetTimeZoneInvalid(): void {
+ $this->expectException(\Exception::class);
+ $this->timeFactory->getTimeZone('blubblub');
+ }
}
diff --git a/tests/lib/AppScriptSortTest.php b/tests/lib/AppScriptSortTest.php
index 2db3e2282d9..ae7b5c326ec 100644
--- a/tests/lib/AppScriptSortTest.php
+++ b/tests/lib/AppScriptSortTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Lukas Reschke <lukas@statuscode.ch>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php
index 12fbdb011d9..4fe88e09e6a 100644
--- a/tests/lib/AppTest.php
+++ b/tests/lib/AppTest.php
@@ -1,10 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
@@ -14,6 +12,8 @@ use OC\App\InfoParser;
use OC\AppConfig;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IAppConfig;
+use OCP\IURLGenerator;
+use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
/**
@@ -537,6 +537,7 @@ class AppTest extends \Test\TestCase {
private function setupAppConfigMock() {
+ /** @var AppConfig|MockObject */
$appConfig = $this->getMockBuilder(AppConfig::class)
->setMethods(['getValues'])
->setConstructorArgs([\OC::$server->getDatabaseConnection()])
@@ -557,11 +558,11 @@ class AppTest extends \Test\TestCase {
$this->overwriteService(AppManager::class, new AppManager(
\OC::$server->getUserSession(),
\OC::$server->getConfig(),
- $appConfig,
\OC::$server->getGroupManager(),
\OC::$server->getMemCacheFactory(),
\OC::$server->get(IEventDispatcher::class),
- \OC::$server->get(LoggerInterface::class)
+ \OC::$server->get(LoggerInterface::class),
+ \OC::$server->get(IURLGenerator::class),
));
}
diff --git a/tests/lib/Archive/TARTest.php b/tests/lib/Archive/TARTest.php
index 6b16f061623..36629a0273f 100644
--- a/tests/lib/Archive/TARTest.php
+++ b/tests/lib/Archive/TARTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Archive;
diff --git a/tests/lib/Archive/TestBase.php b/tests/lib/Archive/TestBase.php
index a816cd97710..6475b49e549 100644
--- a/tests/lib/Archive/TestBase.php
+++ b/tests/lib/Archive/TestBase.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Archive;
diff --git a/tests/lib/Archive/ZIPTest.php b/tests/lib/Archive/ZIPTest.php
index 14443471da1..62467ca230e 100644
--- a/tests/lib/Archive/ZIPTest.php
+++ b/tests/lib/Archive/ZIPTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Archive;
diff --git a/tests/lib/Authentication/Events/RemoteWipeFinishedTest.php b/tests/lib/Authentication/Events/RemoteWipeFinishedTest.php
index f28f0ef78bb..c8fd688d154 100644
--- a/tests/lib/Authentication/Events/RemoteWipeFinishedTest.php
+++ b/tests/lib/Authentication/Events/RemoteWipeFinishedTest.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\Events;
diff --git a/tests/lib/Authentication/Events/RemoteWipeStartedTest.php b/tests/lib/Authentication/Events/RemoteWipeStartedTest.php
index d6b0ef7019e..27bd10dea05 100644
--- a/tests/lib/Authentication/Events/RemoteWipeStartedTest.php
+++ b/tests/lib/Authentication/Events/RemoteWipeStartedTest.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\Events;
diff --git a/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php
index daf8d272c2f..d1cbaae22fb 100644
--- a/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php
+++ b/tests/lib/Authentication/Listeners/RemoteWipeActivityListenerTest.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\Events;
diff --git a/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php
index 7a715dd3f0c..27dd85d9961 100644
--- a/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php
+++ b/tests/lib/Authentication/Listeners/RemoteWipeEmailListenerTest.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\Authentication\Listeners;
diff --git a/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php b/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php
index e5a329a4a7f..d223f0d05a1 100644
--- a/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php
+++ b/tests/lib/Authentication/Listeners/RemoteWipeNotificationsListenerTest.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\Events;
diff --git a/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php b/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php
index 20b85a293d4..f91371a86b7 100644
--- a/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php
+++ b/tests/lib/Authentication/Listeners/UserDeletedTokenCleanupListenerTest.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\Listeners;
diff --git a/tests/lib/Authentication/Login/ALoginCommandTest.php b/tests/lib/Authentication/Login/ALoginCommandTest.php
index 7d56a76e10c..2ab59835bfe 100644
--- a/tests/lib/Authentication/Login/ALoginCommandTest.php
+++ b/tests/lib/Authentication/Login/ALoginCommandTest.php
@@ -1,23 +1,7 @@
<?php
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
diff --git a/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php b/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php
index 1d6250415a9..1a97f0e345b 100644
--- a/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php
+++ b/tests/lib/Authentication/Login/ClearLostPasswordTokensCommandTest.php
@@ -1,24 +1,8 @@
<?php
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
diff --git a/tests/lib/Authentication/Login/CompleteLoginCommandTest.php b/tests/lib/Authentication/Login/CompleteLoginCommandTest.php
index 3f7f9e4fe73..eeb39d5173d 100644
--- a/tests/lib/Authentication/Login/CompleteLoginCommandTest.php
+++ b/tests/lib/Authentication/Login/CompleteLoginCommandTest.php
@@ -1,24 +1,8 @@
<?php
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
diff --git a/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php b/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php
index eb48463402d..049b6b1c94b 100644
--- a/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php
+++ b/tests/lib/Authentication/Login/CreateSessionTokenCommandTest.php
@@ -1,24 +1,8 @@
<?php
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
diff --git a/tests/lib/Authentication/Login/EmailLoginCommandTest.php b/tests/lib/Authentication/Login/EmailLoginCommandTest.php
index 4544aedec11..236825e77bb 100644
--- a/tests/lib/Authentication/Login/EmailLoginCommandTest.php
+++ b/tests/lib/Authentication/Login/EmailLoginCommandTest.php
@@ -1,24 +1,8 @@
<?php
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
diff --git a/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php b/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php
index 890dd63892a..9f9a36faf9f 100644
--- a/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php
+++ b/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php
@@ -1,24 +1,8 @@
<?php
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
diff --git a/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php b/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php
index d3ebf205943..bb5d6235f86 100644
--- a/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php
+++ b/tests/lib/Authentication/Login/LoggedInCheckCommandTest.php
@@ -1,24 +1,8 @@
<?php
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
diff --git a/tests/lib/Authentication/Login/PreLoginHookCommandTest.php b/tests/lib/Authentication/Login/PreLoginHookCommandTest.php
index 2e83ef51ffa..824042e1dee 100644
--- a/tests/lib/Authentication/Login/PreLoginHookCommandTest.php
+++ b/tests/lib/Authentication/Login/PreLoginHookCommandTest.php
@@ -1,24 +1,8 @@
<?php
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
diff --git a/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php b/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php
index ae08b6205d5..068516b933b 100644
--- a/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php
+++ b/tests/lib/Authentication/Login/SetUserTimezoneCommandTest.php
@@ -1,24 +1,8 @@
<?php
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
diff --git a/tests/lib/Authentication/Login/TwoFactorCommandTest.php b/tests/lib/Authentication/Login/TwoFactorCommandTest.php
index 679bae07351..54f634618fd 100644
--- a/tests/lib/Authentication/Login/TwoFactorCommandTest.php
+++ b/tests/lib/Authentication/Login/TwoFactorCommandTest.php
@@ -1,24 +1,8 @@
<?php
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
diff --git a/tests/lib/Authentication/Login/UidLoginCommandTest.php b/tests/lib/Authentication/Login/UidLoginCommandTest.php
index 812215f266e..e56c4323fd4 100644
--- a/tests/lib/Authentication/Login/UidLoginCommandTest.php
+++ b/tests/lib/Authentication/Login/UidLoginCommandTest.php
@@ -1,24 +1,8 @@
<?php
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
diff --git a/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php b/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php
index 07b32daa065..d471b73659f 100644
--- a/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php
+++ b/tests/lib/Authentication/Login/UpdateLastPasswordConfirmCommandTest.php
@@ -1,24 +1,8 @@
<?php
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
diff --git a/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php b/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php
index fe30d3b4fea..a36fb5c70bd 100644
--- a/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php
+++ b/tests/lib/Authentication/Login/UserDisabledCheckCommandTest.php
@@ -1,24 +1,8 @@
<?php
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
diff --git a/tests/lib/Authentication/LoginCredentials/CredentialsTest.php b/tests/lib/Authentication/LoginCredentials/CredentialsTest.php
index f550325a6dc..ed3ea469653 100644
--- a/tests/lib/Authentication/LoginCredentials/CredentialsTest.php
+++ b/tests/lib/Authentication/LoginCredentials/CredentialsTest.php
@@ -1,25 +1,8 @@
<?php
/**
- * @copyright 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\LoginCredentials;
diff --git a/tests/lib/Authentication/LoginCredentials/StoreTest.php b/tests/lib/Authentication/LoginCredentials/StoreTest.php
index 80d64d5466f..06dd2527930 100644
--- a/tests/lib/Authentication/LoginCredentials/StoreTest.php
+++ b/tests/lib/Authentication/LoginCredentials/StoreTest.php
@@ -1,25 +1,8 @@
<?php
/**
- * @copyright 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2016 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\LoginCredentials;
diff --git a/tests/lib/Authentication/Token/ManagerTest.php b/tests/lib/Authentication/Token/ManagerTest.php
index 3dd889dcae2..98baffed14b 100644
--- a/tests/lib/Authentication/Token/ManagerTest.php
+++ b/tests/lib/Authentication/Token/ManagerTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\Token;
diff --git a/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php b/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php
index 68962b26931..4b87f7101b5 100644
--- a/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php
+++ b/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php
@@ -2,33 +2,16 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\Token;
use OC;
-use OC\Authentication\Token\IToken;
use OC\Authentication\Token\PublicKeyToken;
use OC\Authentication\Token\PublicKeyTokenMapper;
+use OCP\Authentication\Token\IToken;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\IUser;
@@ -249,7 +232,7 @@ class PublicKeyTokenMapperTest extends TestCase {
$this->assertCount(0, $this->mapper->getTokenByUser('user1000'));
}
- public function testDeleteById() {
+ public function testGetById() {
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
$user = $this->createMock(IUser::class);
$qb = $this->dbConnection->getQueryBuilder();
@@ -259,17 +242,8 @@ class PublicKeyTokenMapperTest extends TestCase {
$result = $qb->execute();
$id = $result->fetch()['id'];
- $this->mapper->deleteById('user1', (int)$id);
- $this->assertEquals(4, $this->getNumberOfTokens());
- }
-
- public function testDeleteByIdWrongUser() {
- /** @var IUser|\PHPUnit\Framework\MockObject\MockObject $user */
- $user = $this->createMock(IUser::class);
- $id = 33;
-
- $this->mapper->deleteById('user1000', $id);
- $this->assertEquals(5, $this->getNumberOfTokens());
+ $token = $this->mapper->getTokenById((int)$id);
+ $this->assertEquals('user1', $token->getUID());
}
public function testDeleteByName() {
diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
index b3f5241877e..3c81eade700 100644
--- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
+++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\Token;
@@ -29,12 +12,13 @@ namespace Test\Authentication\Token;
use OC\Authentication\Exceptions\ExpiredTokenException;
use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Exceptions\PasswordlessTokenException;
-use OC\Authentication\Token\IToken;
use OC\Authentication\Token\PublicKeyToken;
use OC\Authentication\Token\PublicKeyTokenMapper;
use OC\Authentication\Token\PublicKeyTokenProvider;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\Authentication\Token\IToken;
+use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Security\ICrypto;
@@ -60,6 +44,8 @@ class PublicKeyTokenProviderTest extends TestCase {
private $logger;
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
private $timeFactory;
+ /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
+ private $cacheFactory;
/** @var int */
private $time;
@@ -67,7 +53,7 @@ class PublicKeyTokenProviderTest extends TestCase {
parent::setUp();
$this->mapper = $this->createMock(PublicKeyTokenMapper::class);
- $this->hasher = \OC::$server->getHasher();
+ $this->hasher = \OC::$server->get(IHasher::class);
$this->crypto = \OC::$server->getCrypto();
$this->config = $this->createMock(IConfig::class);
$this->config->method('getSystemValueInt')
@@ -90,6 +76,7 @@ class PublicKeyTokenProviderTest extends TestCase {
$this->time = 1313131;
$this->timeFactory->method('getTime')
->willReturn($this->time);
+ $this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->tokenProvider = new PublicKeyTokenProvider(
$this->mapper,
@@ -99,6 +86,7 @@ class PublicKeyTokenProviderTest extends TestCase {
$this->logger,
$this->timeFactory,
$this->hasher,
+ $this->cacheFactory,
);
}
@@ -332,12 +320,12 @@ class PublicKeyTokenProviderTest extends TestCase {
$this->tokenProvider->invalidateToken('token7');
}
- public function testInvaildateTokenById() {
+ public function testInvalidateTokenById() {
$id = 123;
$this->mapper->expects($this->once())
- ->method('deleteById')
- ->with('uid', $id);
+ ->method('getTokenById')
+ ->with($id);
$this->tokenProvider->invalidateTokenById('uid', $id);
}
diff --git a/tests/lib/Authentication/Token/PublicKeyTokenTest.php b/tests/lib/Authentication/Token/PublicKeyTokenTest.php
index 35c2e0ece39..acbddebea35 100644
--- a/tests/lib/Authentication/Token/PublicKeyTokenTest.php
+++ b/tests/lib/Authentication/Token/PublicKeyTokenTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\Token;
diff --git a/tests/lib/Authentication/Token/RemoteWipeTest.php b/tests/lib/Authentication/Token/RemoteWipeTest.php
index 843dd4aec5c..1c4a0f73d84 100644
--- a/tests/lib/Authentication/Token/RemoteWipeTest.php
+++ b/tests/lib/Authentication/Token/RemoteWipeTest.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\Token;
diff --git a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
index 4f1b8d25b58..56acba46ef0 100644
--- a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\TwoFactorAuth\Db;
diff --git a/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php b/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php
index f8c4be09a6f..bf09b3d8ca3 100644
--- a/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php
@@ -1,23 +1,7 @@
<?php
/**
- * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
/**
diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
index 7647e3bda7d..a89b07f7716 100644
--- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
@@ -1,23 +1,9 @@
<?php
/**
- * @author Christoph Wurst <christoph@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Authentication\TwoFactorAuth;
@@ -39,8 +25,8 @@ use OCP\ISession;
use OCP\IUser;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
-use function reset;
use Test\TestCase;
+use function reset;
class ManagerTest extends TestCase {
/** @var IUser|MockObject */
@@ -629,13 +615,26 @@ class ManagerTest extends TestCase {
return false;
} elseif ($var === 'app_password') {
return false;
+ } elseif ($var === 'app_api') {
+ return false;
}
return true;
});
+ $this->session->method('get')
+ ->willReturnCallback(function ($var) {
+ if ($var === Manager::SESSION_UID_KEY) {
+ return 'user';
+ } elseif ($var === 'app_api') {
+ return true;
+ }
+ return null;
+ });
$this->session->expects($this->once())
->method('get')
- ->with(Manager::SESSION_UID_DONE)
- ->willReturn('user');
+ ->willReturnMap([
+ [Manager::SESSION_UID_DONE, 'user'],
+ ['app_api', true]
+ ]);
$this->assertFalse($this->manager->needsSecondFactor($user));
}
@@ -695,8 +694,10 @@ class ManagerTest extends TestCase {
public function testNeedsSecondFactorAppPassword() {
$user = $this->createMock(IUser::class);
$this->session->method('exists')
- ->with('app_password')
- ->willReturn(true);
+ ->willReturnMap([
+ ['app_password', true],
+ ['app_api', true]
+ ]);
$this->assertFalse($this->manager->needsSecondFactor($user));
}
diff --git a/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php b/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php
index 0119c977696..1d6127fa928 100644
--- a/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Authentication\TwoFactorAuth;
diff --git a/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php b/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php
index b71339dd0ed..bbbb8e8e55a 100644
--- a/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\Authentication\TwoFactorAuth;
diff --git a/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php
index 65447e1d8d6..0e8cf122080 100644
--- a/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\Authentication\TwoFactorAuth;
diff --git a/tests/lib/Authentication/TwoFactorAuth/ProviderSetTest.php b/tests/lib/Authentication/TwoFactorAuth/ProviderSetTest.php
index f6afbf245ee..b6b9640cd9b 100644
--- a/tests/lib/Authentication/TwoFactorAuth/ProviderSetTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/ProviderSetTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\TwoFactorAuth;
diff --git a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
index faddc0bc0c8..7485fe377ee 100644
--- a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Authentication\TwoFactorAuth;
diff --git a/tests/lib/AutoLoaderTest.php b/tests/lib/AutoLoaderTest.php
index 24eaa367435..22d66c6c4aa 100644
--- a/tests/lib/AutoLoaderTest.php
+++ b/tests/lib/AutoLoaderTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Thomas Müller <thomas.mueller@tmit.eu>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/Avatar/AvatarManagerTest.php b/tests/lib/Avatar/AvatarManagerTest.php
index 06ff4086f72..16754f7125c 100644
--- a/tests/lib/Avatar/AvatarManagerTest.php
+++ b/tests/lib/Avatar/AvatarManagerTest.php
@@ -1,25 +1,8 @@
<?php
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- * @author Lukas Reschke <lukas@statuscode.ch>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @copyright Copyright (c) 2016, Lukas Reschke <lukas@statuscode.ch>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Avatar;
@@ -29,6 +12,7 @@ use OC\Avatar\PlaceholderAvatar;
use OC\Avatar\UserAvatar;
use OC\KnownUser\KnownUserService;
use OC\User\Manager;
+use OC\User\User;
use OCP\Accounts\IAccount;
use OCP\Accounts\IAccountManager;
use OCP\Accounts\IAccountProperty;
@@ -37,7 +21,6 @@ use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IUser;
-use OC\User\User;
use OCP\IUserSession;
use Psr\Log\LoggerInterface;
@@ -108,6 +91,11 @@ class AvatarManagerTest extends \Test\TestCase {
->method('getUID')
->willReturn('valid-user');
+ $user
+ ->expects($this->any())
+ ->method('isEnabled')
+ ->willReturn(true);
+
// requesting user
$this->userSession->expects($this->once())
->method('getUser')
@@ -162,6 +150,11 @@ class AvatarManagerTest extends \Test\TestCase {
->method('getUID')
->willReturn('valid-user');
+ $user
+ ->expects($this->any())
+ ->method('isEnabled')
+ ->willReturn(true);
+
$this->userSession->expects($this->once())
->method('getUser')
->willReturn($user);
@@ -231,6 +224,12 @@ class AvatarManagerTest extends \Test\TestCase {
->expects($this->once())
->method('getUID')
->willReturn('valid-user');
+
+ $user
+ ->expects($this->any())
+ ->method('isEnabled')
+ ->willReturn(true);
+
$this->userManager
->expects($this->once())
->method('get')
diff --git a/tests/lib/Avatar/GuestAvatarTest.php b/tests/lib/Avatar/GuestAvatarTest.php
index 6cb70b82902..e71cabaa624 100644
--- a/tests/lib/Avatar/GuestAvatarTest.php
+++ b/tests/lib/Avatar/GuestAvatarTest.php
@@ -3,23 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018, Michael Weimann <mail@michael-weimann.eu>
- *
- * @author Michael Weimann <mail@michael-weimann.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Avatar;
diff --git a/tests/lib/Avatar/UserAvatarTest.php b/tests/lib/Avatar/UserAvatarTest.php
index a5cd08cc65d..2687972b8f6 100644
--- a/tests/lib/Avatar/UserAvatarTest.php
+++ b/tests/lib/Avatar/UserAvatarTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Avatar;
diff --git a/tests/lib/BackgroundJob/DummyJobList.php b/tests/lib/BackgroundJob/DummyJobList.php
index 8574f462ca7..fc80786d28b 100644
--- a/tests/lib/BackgroundJob/DummyJobList.php
+++ b/tests/lib/BackgroundJob/DummyJobList.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\BackgroundJob;
@@ -35,7 +34,7 @@ class DummyJobList extends \OC\BackgroundJob\JobList {
* @param IJob|class-string<IJob> $job
* @param mixed $argument
*/
- public function add($job, $argument = null): void {
+ public function add($job, $argument = null, ?int $firstCheck = null): void {
if (is_string($job)) {
/** @var IJob $job */
$job = \OCP\Server::get($job);
@@ -46,6 +45,10 @@ class DummyJobList extends \OC\BackgroundJob\JobList {
}
}
+ public function scheduleAfter(string $job, int $runAfter, $argument = null): void {
+ $this->add($job, $argument, $runAfter);
+ }
+
/**
* @param IJob|string $job
* @param mixed $argument
@@ -96,7 +99,7 @@ class DummyJobList extends \OC\BackgroundJob\JobList {
/**
* get the next job in the list
*/
- public function getNext(bool $onlyTimeSensitive = false): ?IJob {
+ public function getNext(bool $onlyTimeSensitive = false, ?array $jobClasses = null): ?IJob {
if (count($this->jobs) > 0) {
if ($this->last < (count($this->jobs) - 1)) {
$i = $this->last + 1;
@@ -112,7 +115,7 @@ class DummyJobList extends \OC\BackgroundJob\JobList {
/**
* set the job that was last ran
*
- * @param \OC\BackgroundJob\Job $job
+ * @param \OCP\BackgroundJob\Job $job
*/
public function setLastJob(IJob $job): void {
$i = array_search($job, $this->jobs);
diff --git a/tests/lib/BackgroundJob/JobListTest.php b/tests/lib/BackgroundJob/JobListTest.php
index 32ee1e79a5e..510d307eda8 100644
--- a/tests/lib/BackgroundJob/JobListTest.php
+++ b/tests/lib/BackgroundJob/JobListTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\BackgroundJob;
diff --git a/tests/lib/BackgroundJob/JobTest.php b/tests/lib/BackgroundJob/JobTest.php
index a4e0dcf4fd6..fa89a06c8f5 100644
--- a/tests/lib/BackgroundJob/JobTest.php
+++ b/tests/lib/BackgroundJob/JobTest.php
@@ -1,24 +1,27 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\BackgroundJob;
use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\ILogger;
+use Psr\Log\LoggerInterface;
class JobTest extends \Test\TestCase {
private $run = false;
private ITimeFactory $timeFactory;
+ private LoggerInterface $logger;
protected function setUp(): void {
parent::setUp();
$this->run = false;
- $this->timeFactory = \OC::$server->get(ITimeFactory::class);
+ $this->timeFactory = \OCP\Server::get(ITimeFactory::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
+
+ \OC::$server->registerService(LoggerInterface::class, fn ($c) => $this->logger);
}
public function testRemoveAfterException() {
@@ -29,14 +32,11 @@ class JobTest extends \Test\TestCase {
});
$jobList->add($job);
- $logger = $this->getMockBuilder(ILogger::class)
- ->disableOriginalConstructor()
- ->getMock();
- $logger->expects($this->once())
+ $this->logger->expects($this->once())
->method('error');
$this->assertCount(1, $jobList->getAll());
- $job->execute($jobList, $logger);
+ $job->start($jobList);
$this->assertTrue($this->run);
$this->assertCount(1, $jobList->getAll());
}
@@ -49,14 +49,11 @@ class JobTest extends \Test\TestCase {
});
$jobList->add($job);
- $logger = $this->getMockBuilder(ILogger::class)
- ->disableOriginalConstructor()
- ->getMock();
- $logger->expects($this->once())
+ $this->logger->expects($this->once())
->method('error');
$this->assertCount(1, $jobList->getAll());
- $job->execute($jobList, $logger);
+ $job->start($jobList);
$this->assertTrue($this->run);
$this->assertCount(1, $jobList->getAll());
}
diff --git a/tests/lib/BackgroundJob/QueuedJobTest.php b/tests/lib/BackgroundJob/QueuedJobTest.php
index 9378816ce61..ab4bacb201e 100644
--- a/tests/lib/BackgroundJob/QueuedJobTest.php
+++ b/tests/lib/BackgroundJob/QueuedJobTest.php
@@ -1,28 +1,17 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\BackgroundJob;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\BackgroundJob\QueuedJob;
-class TestQueuedJob extends \OC\BackgroundJob\QueuedJob {
- public $ran = false;
-
-
- public function run($argument) {
- $this->ran = true;
- }
-}
-
-
-class TestQueuedJobNew extends \OCP\BackgroundJob\QueuedJob {
- public $ran = false;
-
+class TestQueuedJobNew extends QueuedJob {
+ public bool $ran = false;
public function run($argument) {
$this->ran = true;
@@ -30,10 +19,7 @@ class TestQueuedJobNew extends \OCP\BackgroundJob\QueuedJob {
}
class QueuedJobTest extends \Test\TestCase {
- /**
- * @var DummyJobList $jobList
- */
- private $jobList;
+ private DummyJobList $jobList;
protected function setUp(): void {
parent::setUp();
@@ -41,22 +27,13 @@ class QueuedJobTest extends \Test\TestCase {
$this->jobList = new DummyJobList();
}
- public function testJobShouldBeRemoved() {
- $job = new TestQueuedJob();
- $this->jobList->add($job);
-
- $this->assertTrue($this->jobList->has($job, null));
- $job->execute($this->jobList);
- $this->assertTrue($job->ran);
- }
-
public function testJobShouldBeRemovedNew() {
- $job = new TestQueuedJobNew(\OC::$server->query(ITimeFactory::class));
+ $job = new TestQueuedJobNew(\OCP\Server::get(ITimeFactory::class));
$job->setId(42);
$this->jobList->add($job);
$this->assertTrue($this->jobList->has($job, null));
- $job->execute($this->jobList);
+ $job->start($this->jobList);
$this->assertTrue($job->ran);
}
}
diff --git a/tests/lib/BackgroundJob/TestJob.php b/tests/lib/BackgroundJob/TestJob.php
index cc7a4651c4b..ea0634e63d9 100644
--- a/tests/lib/BackgroundJob/TestJob.php
+++ b/tests/lib/BackgroundJob/TestJob.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\BackgroundJob;
@@ -22,8 +21,8 @@ class TestJob extends \OCP\BackgroundJob\Job {
* @param JobTest $testCase
* @param callable $callback
*/
- public function __construct(ITimeFactory $time = null, $testCase = null, $callback = null) {
- parent::__construct($time ?? \OC::$server->get(ITimeFactory::class));
+ public function __construct(?ITimeFactory $time = null, $testCase = null, $callback = null) {
+ parent::__construct($time ?? \OCP\Server::get(ITimeFactory::class));
$this->testCase = $testCase;
$this->callback = $callback;
}
diff --git a/tests/lib/BackgroundJob/TestParallelAwareJob.php b/tests/lib/BackgroundJob/TestParallelAwareJob.php
index 7fa0bda7bbf..f7a6cf5fa79 100644
--- a/tests/lib/BackgroundJob/TestParallelAwareJob.php
+++ b/tests/lib/BackgroundJob/TestParallelAwareJob.php
@@ -1,9 +1,7 @@
<?php
/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\BackgroundJob;
@@ -22,7 +20,7 @@ class TestParallelAwareJob extends \OCP\BackgroundJob\Job {
* @param JobTest $testCase
* @param callable $callback
*/
- public function __construct(ITimeFactory $time = null, $testCase = null, $callback = null) {
+ public function __construct(?ITimeFactory $time = null, $testCase = null, $callback = null) {
parent::__construct($time ?? \OC::$server->get(ITimeFactory::class));
$this->setAllowParallelRuns(false);
$this->testCase = $testCase;
diff --git a/tests/lib/BackgroundJob/TimedJobTest.php b/tests/lib/BackgroundJob/TimedJobTest.php
index 12f1c43adde..0ae245d1ff8 100644
--- a/tests/lib/BackgroundJob/TimedJobTest.php
+++ b/tests/lib/BackgroundJob/TimedJobTest.php
@@ -1,31 +1,17 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\BackgroundJob;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\BackgroundJob\TimedJob;
-class TestTimedJob extends \OC\BackgroundJob\TimedJob {
- /** @var bool */
- public $ran = false;
-
- public function __construct() {
- $this->setInterval(10);
- }
-
- public function run($argument) {
- $this->ran = true;
- }
-}
-
-class TestTimedJobNew extends \OCP\BackgroundJob\TimedJob {
- /** @var bool */
- public $ran = false;
+class TestTimedJobNew extends TimedJob {
+ public bool $ran = false;
public function __construct(ITimeFactory $timeFactory) {
parent::__construct($timeFactory);
@@ -38,57 +24,23 @@ class TestTimedJobNew extends \OCP\BackgroundJob\TimedJob {
}
class TimedJobTest extends \Test\TestCase {
- /** @var DummyJobList $jobList */
- private $jobList;
-
- /** @var ITimeFactory */
- private $time;
+ private DummyJobList $jobList;
+ private ITimeFactory $time;
protected function setUp(): void {
parent::setUp();
$this->jobList = new DummyJobList();
- $this->time = \OC::$server->query(ITimeFactory::class);
- }
-
- public function testShouldRunAfterInterval() {
- $job = new TestTimedJob();
- $this->jobList->add($job);
-
- $job->setLastRun(time() - 12);
- $job->execute($this->jobList);
- $this->assertTrue($job->ran);
+ $this->time = \OCP\Server::get(ITimeFactory::class);
}
- public function testShouldNotRunWithinInterval() {
- $job = new TestTimedJob();
- $this->jobList->add($job);
-
- $job->setLastRun(time() - 5);
- $job->execute($this->jobList);
- $this->assertFalse($job->ran);
- }
-
- public function testShouldNotTwice() {
- $job = new TestTimedJob();
- $this->jobList->add($job);
-
- $job->setLastRun(time() - 15);
- $job->execute($this->jobList);
- $this->assertTrue($job->ran);
- $job->ran = false;
- $job->execute($this->jobList);
- $this->assertFalse($job->ran);
- }
-
-
public function testShouldRunAfterIntervalNew() {
$job = new TestTimedJobNew($this->time);
$job->setId(42);
$this->jobList->add($job);
$job->setLastRun(time() - 12);
- $job->execute($this->jobList);
+ $job->start($this->jobList);
$this->assertTrue($job->ran);
}
@@ -98,7 +50,7 @@ class TimedJobTest extends \Test\TestCase {
$this->jobList->add($job);
$job->setLastRun(time() - 5);
- $job->execute($this->jobList);
+ $job->start($this->jobList);
$this->assertFalse($job->ran);
}
@@ -108,10 +60,10 @@ class TimedJobTest extends \Test\TestCase {
$this->jobList->add($job);
$job->setLastRun(time() - 15);
- $job->execute($this->jobList);
+ $job->start($this->jobList);
$this->assertTrue($job->ran);
$job->ran = false;
- $job->execute($this->jobList);
+ $job->start($this->jobList);
$this->assertFalse($job->ran);
}
}
diff --git a/tests/lib/Cache/CappedMemoryCacheTest.php b/tests/lib/Cache/CappedMemoryCacheTest.php
index b9d10b66100..6d1c7e6e372 100644
--- a/tests/lib/Cache/CappedMemoryCacheTest.php
+++ b/tests/lib/Cache/CappedMemoryCacheTest.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Robin Appelman
- * @copyright 2016 Robin Appelman icewind@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Cache;
diff --git a/tests/lib/Cache/FileCacheTest.php b/tests/lib/Cache/FileCacheTest.php
index 41675b7c461..ef738eaaacf 100644
--- a/tests/lib/Cache/FileCacheTest.php
+++ b/tests/lib/Cache/FileCacheTest.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Robin Appelman
- * @copyright 2012 Robin Appelman icewind@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Cache;
diff --git a/tests/lib/Cache/TestCache.php b/tests/lib/Cache/TestCache.php
index 1dd9761682d..1ed52ad5170 100644
--- a/tests/lib/Cache/TestCache.php
+++ b/tests/lib/Cache/TestCache.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Cache;
diff --git a/tests/lib/Calendar/ManagerTest.php b/tests/lib/Calendar/ManagerTest.php
index fcf6ab3a588..db98dfa1aed 100644
--- a/tests/lib/Calendar/ManagerTest.php
+++ b/tests/lib/Calendar/ManagerTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2017, Georg Ehrke <oc.list@georgehrke.com>
- *
- * @author Georg Ehrke <oc.list@georgehrke.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Calendar;
diff --git a/tests/lib/Calendar/Resource/ManagerTest.php b/tests/lib/Calendar/Resource/ManagerTest.php
index 854f83af845..d9d66699710 100644
--- a/tests/lib/Calendar/Resource/ManagerTest.php
+++ b/tests/lib/Calendar/Resource/ManagerTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018, Georg Ehrke <oc.list@georgehrke.com>
- *
- * @author Georg Ehrke <oc.list@georgehrke.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Calendar\Resource;
diff --git a/tests/lib/Calendar/Room/ManagerTest.php b/tests/lib/Calendar/Room/ManagerTest.php
index 9309a3fa0bb..587503da312 100644
--- a/tests/lib/Calendar/Room/ManagerTest.php
+++ b/tests/lib/Calendar/Room/ManagerTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2018, Georg Ehrke <oc.list@georgehrke.com>
- *
- * @author Georg Ehrke <oc.list@georgehrke.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Calendar\Room;
diff --git a/tests/lib/CapabilitiesManagerTest.php b/tests/lib/CapabilitiesManagerTest.php
index 690ee1496ac..14b83e3dda3 100644
--- a/tests/lib/CapabilitiesManagerTest.php
+++ b/tests/lib/CapabilitiesManagerTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test;
diff --git a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
index 1cbaa178445..fa491661f5f 100644
--- a/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/GroupPluginTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
diff --git a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
index 3eb28a861a5..5b15bca5c18 100644
--- a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
index 3cf76c562a1..9a31800ccbe 100644
--- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
@@ -38,8 +21,8 @@ use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
-use OCP\Share\IShare;
use OCP\Mail\IMailer;
+use OCP\Share\IShare;
use Test\TestCase;
class MailPluginTest extends TestCase {
diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
index 4fed1f179e7..39fdd3a2d22 100644
--- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
diff --git a/tests/lib/Collaboration/Collaborators/SearchResultTest.php b/tests/lib/Collaboration/Collaborators/SearchResultTest.php
index 98e454f2834..da879a7b7a4 100644
--- a/tests/lib/Collaboration/Collaborators/SearchResultTest.php
+++ b/tests/lib/Collaboration/Collaborators/SearchResultTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Joas Schilling
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
diff --git a/tests/lib/Collaboration/Collaborators/SearchTest.php b/tests/lib/Collaboration/Collaborators/SearchTest.php
index 1d55ee6dd22..91b01aac7ce 100644
--- a/tests/lib/Collaboration/Collaborators/SearchTest.php
+++ b/tests/lib/Collaboration/Collaborators/SearchTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
diff --git a/tests/lib/Collaboration/Collaborators/UserPluginTest.php b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
index 0d9d89c7f8b..eac7eb1124b 100644
--- a/tests/lib/Collaboration/Collaborators/UserPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/UserPluginTest.php
@@ -1,28 +1,14 @@
<?php
/**
- * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Collaborators;
+use OC\Collaboration\Collaborators\SearchResult;
+use OC\Collaboration\Collaborators\UserPlugin;
+use OC\KnownUser\KnownUserService;
use OCP\Collaboration\Collaborators\ISearchResult;
use OCP\IConfig;
use OCP\IGroup;
@@ -32,9 +18,6 @@ use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Share\IShare;
use OCP\UserStatus\IManager as IUserStatusManager;
-use OC\Collaboration\Collaborators\SearchResult;
-use OC\Collaboration\Collaborators\UserPlugin;
-use OC\KnownUser\KnownUserService;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
diff --git a/tests/lib/Collaboration/Resources/ManagerTest.php b/tests/lib/Collaboration/Resources/ManagerTest.php
index 80b1ac464a6..4ca88da8678 100644
--- a/tests/lib/Collaboration/Resources/ManagerTest.php
+++ b/tests/lib/Collaboration/Resources/ManagerTest.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019 Daniel Kesselberg <mail@danielkesselberg.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Resources;
diff --git a/tests/lib/Collaboration/Resources/ProviderManagerTest.php b/tests/lib/Collaboration/Resources/ProviderManagerTest.php
index 6c66422c9d3..01c201e0a4e 100644
--- a/tests/lib/Collaboration/Resources/ProviderManagerTest.php
+++ b/tests/lib/Collaboration/Resources/ProviderManagerTest.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019 Daniel Kesselberg <mail@danielkesselberg.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Collaboration\Resources;
diff --git a/tests/lib/Command/AsyncBusTest.php b/tests/lib/Command/AsyncBusTest.php
index bfe201ed369..7492a4912d7 100644
--- a/tests/lib/Command/AsyncBusTest.php
+++ b/tests/lib/Command/AsyncBusTest.php
@@ -1,10 +1,9 @@
<?php
/**
- * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Command;
diff --git a/tests/lib/Command/BackgroundJobsTest.php b/tests/lib/Command/BackgroundJobsTest.php
index 9d1741aff88..310f1057bb4 100644
--- a/tests/lib/Command/BackgroundJobsTest.php
+++ b/tests/lib/Command/BackgroundJobsTest.php
@@ -1,28 +1,9 @@
<?php
/**
- * The MIT License (MIT)
- *
- * Copyright (c) 2015 Christian Kampka <christian@kampka.net>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * SPDX-FileCopyrightText: 2016-2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2015 Christian Kampka <christian@kampka.net>
+ * SPDX-License-Identifier: MIT
*/
-
namespace Test\Command;
use OC\Core\Command\Background\Ajax;
diff --git a/tests/lib/Command/CronBusTest.php b/tests/lib/Command/CronBusTest.php
index 100de0a861c..96190f717c6 100644
--- a/tests/lib/Command/CronBusTest.php
+++ b/tests/lib/Command/CronBusTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Command;
@@ -44,14 +29,7 @@ class CronBusTest extends AsyncBusTest {
protected function runJobs() {
$jobs = $this->jobList->getAll();
foreach ($jobs as $job) {
- $job->execute($this->jobList);
+ $job->start($this->jobList);
}
}
-
- public function testClosureFromPreviousVersion() {
- $serializedClosure = 'C:32:"Opis\\Closure\\SerializableClosure":217:{a:5:{s:3:"use";a:0:{}s:8:"function";s:64:"function () {\\Test\\Command\\AsyncBusTest::$lastCommand = \'opis\';}";s:5:"scope";s:24:"Test\\Command\\CronBusTest";s:4:"this";N;s:4:"self";s:32:"0000000027dcfe2f00000000407fa805";}}';
- $this->jobList->add('OC\Command\ClosureJob', $serializedClosure);
- $this->runJobs();
- $this->assertEquals('opis', AsyncBusTest::$lastCommand);
- }
}
diff --git a/tests/lib/Command/Integrity/SignAppTest.php b/tests/lib/Command/Integrity/SignAppTest.php
index 66005ca06f5..41333863ad4 100644
--- a/tests/lib/Command/Integrity/SignAppTest.php
+++ b/tests/lib/Command/Integrity/SignAppTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Command\Integrity;
diff --git a/tests/lib/Command/Integrity/SignCoreTest.php b/tests/lib/Command/Integrity/SignCoreTest.php
index d67e2a9e2b4..51bec55b774 100644
--- a/tests/lib/Command/Integrity/SignCoreTest.php
+++ b/tests/lib/Command/Integrity/SignCoreTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Command\Integrity;
diff --git a/tests/lib/Comments/CommentTest.php b/tests/lib/Comments/CommentTest.php
index 328e6fd5447..feaa268a09e 100644
--- a/tests/lib/Comments/CommentTest.php
+++ b/tests/lib/Comments/CommentTest.php
@@ -1,5 +1,9 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
namespace Test\Comments;
use OC\Comments\Comment;
@@ -23,6 +27,8 @@ class CommentTest extends TestCase {
$creationDT = new \DateTime();
$latestChildDT = new \DateTime('yesterday');
$object = ['type' => 'files', 'id' => 'file64'];
+ $referenceId = sha1('referenceId');
+ $metaData = ['last_edit_actor_id' => 'admin'];
$comment
->setId($id)
@@ -34,7 +40,9 @@ class CommentTest extends TestCase {
->setActor($actor['type'], $actor['id'])
->setCreationDateTime($creationDT)
->setLatestChildDateTime($latestChildDT)
- ->setObject($object['type'], $object['id']);
+ ->setObject($object['type'], $object['id'])
+ ->setReferenceId($referenceId)
+ ->setMetaData($metaData);
$this->assertSame($id, $comment->getId());
$this->assertSame($parentId, $comment->getParentId());
@@ -48,6 +56,8 @@ class CommentTest extends TestCase {
$this->assertSame($latestChildDT, $comment->getLatestChildDateTime());
$this->assertSame($object['type'], $comment->getObjectType());
$this->assertSame($object['id'], $comment->getObjectId());
+ $this->assertSame($referenceId, $comment->getReferenceId());
+ $this->assertSame($metaData, $comment->getMetaData());
}
@@ -128,19 +138,24 @@ class CommentTest extends TestCase {
$comment->setMessage($msg);
}
- public function mentionsProvider() {
+ public function mentionsProvider(): array {
return [
[
- '@alice @bob look look, a cook!', ['alice', 'bob']
+ '@alice @bob look look, a cook!',
+ [['type' => 'user', 'id' => 'alice'], ['type' => 'user', 'id' => 'bob']],
],
[
- 'no mentions in this message', []
+ 'no mentions in this message',
+ []
],
[
- '@alice @bob look look, a duplication @alice test @bob!', ['alice', 'bob']
+ '@alice @bob look look, a duplication @alice test @bob!',
+ [['type' => 'user', 'id' => 'alice'], ['type' => 'user', 'id' => 'bob']],
],
[
- '@alice is the author, notify @bob, nevertheless mention her!', ['alice', 'bob'], 'alice'
+ '@alice is the author, notify @bob, nevertheless mention her!',
+ [['type' => 'user', 'id' => 'alice'], ['type' => 'user', 'id' => 'bob']],
+ /* author: */ 'alice'
],
[
'@foobar and @barfoo you should know, @foo@bar.com is valid' .
@@ -148,19 +163,38 @@ class CommentTest extends TestCase {
' cc @23452-4333-54353-2342 @yolo!' .
' however the most important thing to know is that www.croissant.com/@oil is not valid' .
' and won\'t match anything at all',
- ['bar@foo.org@foobar.io', '23452-4333-54353-2342', 'foo@bar.com', 'foobar', 'barfoo', 'yolo']
+ [
+ ['type' => 'user', 'id' => 'bar@foo.org@foobar.io'],
+ ['type' => 'user', 'id' => '23452-4333-54353-2342'],
+ ['type' => 'user', 'id' => 'foo@bar.com'],
+ ['type' => 'user', 'id' => 'foobar'],
+ ['type' => 'user', 'id' => 'barfoo'],
+ ['type' => 'user', 'id' => 'yolo'],
+ ],
+ ],
+ [
+ '@@chef is also a valid mention, no matter how strange it looks',
+ [['type' => 'user', 'id' => '@chef']],
],
[
- '@@chef is also a valid mention, no matter how strange it looks', ['@chef']
+ 'Also @"user with spaces" are now supported',
+ [['type' => 'user', 'id' => 'user with spaces']],
],
[
- 'Also @"user with spaces" are now supported', ['user with spaces']
+ 'Also @"guest/0123456789abcdef" are now supported',
+ [['type' => 'guest', 'id' => 'guest/0123456789abcdef']],
],
[
- 'Also @"guest/0123456789abcdef" are now supported', [], null, ['guest/0123456789abcdef']
+ 'Also @"group/My Group ID 321" are now supported',
+ [['type' => 'group', 'id' => 'My Group ID 321']],
],
[
- 'Also @"group/My Group ID 321" are now supported', [], null, [], ['My Group ID 321']
+ 'Welcome federation @"federated_group/My Group ID 321" @"federated_team/Former Cirle" @"federated_user/cloudId@http://example.tld:8080/nextcloud"! Now freshly supported',
+ [
+ ['type' => 'federated_user', 'id' => 'cloudId@http://example.tld:8080/nextcloud'],
+ ['type' => 'federated_group', 'id' => 'My Group ID 321'],
+ ['type' => 'federated_team', 'id' => 'Former Cirle'],
+ ],
],
];
}
@@ -169,31 +203,16 @@ class CommentTest extends TestCase {
* @dataProvider mentionsProvider
*
* @param string $message
- * @param array $expectedUids
- * @param string|null $author
- * @param array $expectedGuests
+ * @param array $expectedMentions
+ * @param ?string $author
*/
- public function testMentions(string $message, array $expectedUids, ?string $author = null, array $expectedGuests = [], array $expectedGroups = []): void {
+ public function testMentions(string $message, array $expectedMentions, ?string $author = null): void {
$comment = new Comment();
$comment->setMessage($message);
if (!is_null($author)) {
$comment->setActor('user', $author);
}
$mentions = $comment->getMentions();
- while ($mention = array_shift($mentions)) {
- if ($mention['type'] === 'user') {
- $id = array_shift($expectedUids);
- } elseif ($mention['type'] === 'guest') {
- $id = array_shift($expectedGuests);
- } elseif ($mention['type'] === 'group') {
- $id = array_shift($expectedGroups);
- } else {
- $this->fail('Unexpected mention type');
- continue;
- }
- $this->assertSame($id, $mention['id']);
- }
- $this->assertEmpty($mentions);
- $this->assertEmpty($expectedUids);
+ $this->assertSame($expectedMentions, $mentions);
}
}
diff --git a/tests/lib/Comments/FakeFactory.php b/tests/lib/Comments/FakeFactory.php
index 257e7dad93b..04604ab2b44 100644
--- a/tests/lib/Comments/FakeFactory.php
+++ b/tests/lib/Comments/FakeFactory.php
@@ -1,5 +1,9 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
namespace Test\Comments;
use OCP\IServerContainer;
diff --git a/tests/lib/Comments/FakeManager.php b/tests/lib/Comments/FakeManager.php
index b524f5a5000..b22264cb216 100644
--- a/tests/lib/Comments/FakeManager.php
+++ b/tests/lib/Comments/FakeManager.php
@@ -1,5 +1,9 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
namespace Test\Comments;
use OC\Comments\Comment;
@@ -22,7 +26,7 @@ class FakeManager implements ICommentsManager {
$objectId,
$limit = 0,
$offset = 0,
- \DateTime $notOlderThan = null
+ ?\DateTime $notOlderThan = null
) {
}
@@ -49,7 +53,7 @@ class FakeManager implements ICommentsManager {
return [];
}
- public function getNumberOfCommentsForObject($objectType, $objectId, \DateTime $notOlderThan = null, $verb = '') {
+ public function getNumberOfCommentsForObject($objectType, $objectId, ?\DateTime $notOlderThan = null, $verb = '') {
}
public function search(string $search, string $objectType, string $objectId, string $verb, int $offset, int $limit = 50): array {
diff --git a/tests/lib/Comments/ManagerTest.php b/tests/lib/Comments/ManagerTest.php
index 5fa1beee374..88ce2f1438f 100644
--- a/tests/lib/Comments/ManagerTest.php
+++ b/tests/lib/Comments/ManagerTest.php
@@ -1,5 +1,9 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
namespace Test\Comments;
use OC\Comments\Comment;
@@ -10,6 +14,8 @@ use OCP\Comments\IComment;
use OCP\Comments\ICommentsEventHandler;
use OCP\Comments\ICommentsManager;
use OCP\Comments\NotFoundException;
+use OCP\Files\Folder;
+use OCP\Files\IRootFolder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IInitialStateService;
@@ -26,11 +32,14 @@ use Test\TestCase;
class ManagerTest extends TestCase {
/** @var IDBConnection */
private $connection;
+ /** @var \PHPUnit\Framework\MockObject\MockObject|IRootFolder */
+ private $rootFolder;
protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
+ $this->rootFolder = $this->createMock(IRootFolder::class);
$sql = $this->connection->getDatabasePlatform()->getTruncateTableSQL('`*PREFIX*comments`');
$this->connection->prepare($sql)->execute();
@@ -65,6 +74,8 @@ class ManagerTest extends TestCase {
'object_type' => $qb->createNamedParameter('files'),
'object_id' => $qb->createNamedParameter($objectId),
'expire_date' => $qb->createNamedParameter($expireDate, 'datetime'),
+ 'reference_id' => $qb->createNamedParameter('referenceId'),
+ 'meta_data' => $qb->createNamedParameter(json_encode(['last_edit_actor_id' => 'admin'])),
])
->execute();
@@ -78,7 +89,8 @@ class ManagerTest extends TestCase {
$this->createMock(IConfig::class),
$this->createMock(ITimeFactory::class),
new EmojiHelper($this->connection),
- $this->createMock(IInitialStateService::class)
+ $this->createMock(IInitialStateService::class),
+ $this->rootFolder,
);
}
@@ -119,6 +131,8 @@ class ManagerTest extends TestCase {
'latest_child_timestamp' => $qb->createNamedParameter($latestChildDT, 'datetime'),
'object_type' => $qb->createNamedParameter('files'),
'object_id' => $qb->createNamedParameter('file64'),
+ 'reference_id' => $qb->createNamedParameter('referenceId'),
+ 'meta_data' => $qb->createNamedParameter(json_encode(['last_edit_actor_id' => 'admin'])),
])
->execute();
@@ -138,6 +152,8 @@ class ManagerTest extends TestCase {
$this->assertSame($comment->getObjectId(), 'file64');
$this->assertEquals($comment->getCreationDateTime()->getTimestamp(), $creationDT->getTimestamp());
$this->assertEquals($comment->getLatestChildDateTime(), $latestChildDT);
+ $this->assertEquals($comment->getReferenceId(), 'referenceId');
+ $this->assertEquals($comment->getMetaData(), ['last_edit_actor_id' => 'admin']);
}
@@ -323,23 +339,19 @@ class ManagerTest extends TestCase {
}
public function testGetNumberOfUnreadCommentsForFolder() {
- $query = $this->connection->getQueryBuilder();
- $query->insert('filecache')
- ->values([
- 'parent' => $query->createNamedParameter(1000),
- 'size' => $query->createNamedParameter(10),
- 'mtime' => $query->createNamedParameter(10),
- 'storage_mtime' => $query->createNamedParameter(10),
- 'path' => $query->createParameter('path'),
- 'path_hash' => $query->createParameter('path'),
- ]);
-
- $fileIds = [];
- for ($i = 0; $i < 4; $i++) {
- $query->setParameter('path', 'path_' . $i);
- $query->execute();
- $fileIds[] = $query->getLastInsertId();
- }
+ $folder = $this->createMock(Folder::class);
+ $fileIds = range(1111, 1114);
+ $children = array_map(function (int $id) {
+ $file = $this->createMock(Folder::class);
+ $file->method('getId')
+ ->willReturn($id);
+ return $file;
+ }, $fileIds);
+ $folder->method('getId')->willReturn(1000);
+ $folder->method('getDirectoryListing')->willReturn($children);
+ $this->rootFolder->method('getFirstNodeById')
+ ->with($folder->getId())
+ ->willReturn($folder);
// 2 comment for 1111 with 1 before read marker
// 2 comments for 1112 with no read marker
@@ -361,7 +373,7 @@ class ManagerTest extends TestCase {
$manager->setReadMark('files', (string) $fileIds[0], (new \DateTime())->modify('-1 days'), $user);
$manager->setReadMark('files', (string) $fileIds[2], (new \DateTime()), $user);
- $amount = $manager->getNumberOfUnreadCommentsForFolder(1000, $user);
+ $amount = $manager->getNumberOfUnreadCommentsForFolder($folder->getId(), $user);
$this->assertEquals([
$fileIds[0] => 1,
$fileIds[1] => 2,
@@ -660,7 +672,7 @@ class ManagerTest extends TestCase {
$user = \OC::$server->getUserManager()->createUser('xenia', '123456');
$this->assertTrue($user instanceof IUser);
- $manager = \OC::$server->getCommentsManager();
+ $manager = \OC::$server->get(ICommentsManager::class);
$comment = $manager->create('users', $user->getUID(), 'files', 'file64');
$comment
->setMessage('Most important comment I ever left on the Internet.')
@@ -744,7 +756,8 @@ class ManagerTest extends TestCase {
$this->createMock(IConfig::class),
Server::get(ITimeFactory::class),
new EmojiHelper($this->connection),
- $this->createMock(IInitialStateService::class)
+ $this->createMock(IInitialStateService::class),
+ $this->rootFolder,
);
// just to make sure they are really set, with correct actor data
@@ -789,7 +802,8 @@ class ManagerTest extends TestCase {
$this->createMock(IConfig::class),
Server::get(ITimeFactory::class),
new EmojiHelper($this->connection),
- $this->createMock(IInitialStateService::class)
+ $this->createMock(IInitialStateService::class),
+ $this->rootFolder,
);
$deleted = $manager->deleteCommentsExpiredAtObject('files');
diff --git a/tests/lib/ConfigTest.php b/tests/lib/ConfigTest.php
index 7c289472abd..e65cf7633e1 100644
--- a/tests/lib/ConfigTest.php
+++ b/tests/lib/ConfigTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php b/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php
index 7102ed80129..55129f7753f 100644
--- a/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php
@@ -1,25 +1,8 @@
<?php
/**
- * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Contacts\ContactsMenu;
diff --git a/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php b/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php
index 549bfd8670d..e9dcb2fba81 100644
--- a/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php
@@ -1,25 +1,8 @@
<?php
/**
- * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Contacts\ContactsMenu;
diff --git a/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php b/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php
index 497cf992e95..a5ac4543463 100644
--- a/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php
+++ b/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php
@@ -1,25 +1,8 @@
<?php
/**
- * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Contacts\ContactsMenu\Actions;
diff --git a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
index ccb888a6c3d..d66af2925f4 100644
--- a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
@@ -1,26 +1,10 @@
<?php
+
+declare(strict_types=1);
+
/**
- * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- * @copyright 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Contacts\ContactsMenu;
@@ -28,6 +12,8 @@ namespace Tests\Contacts\ContactsMenu;
use OC\Contacts\ContactsMenu\ContactsStore;
use OC\KnownUser\KnownUserService;
use OC\Profile\ProfileManager;
+use OCA\UserStatus\Db\UserStatus;
+use OCA\UserStatus\Service\StatusService;
use OCP\Contacts\IManager;
use OCP\IConfig;
use OCP\IGroupManager;
@@ -40,6 +26,7 @@ use Test\TestCase;
class ContactsStoreTest extends TestCase {
private ContactsStore $contactsStore;
+ private StatusService|MockObject $statusService;
/** @var IManager|MockObject */
private $contactsManager;
/** @var ProfileManager */
@@ -61,6 +48,7 @@ class ContactsStoreTest extends TestCase {
parent::setUp();
$this->contactsManager = $this->createMock(IManager::class);
+ $this->statusService = $this->createMock(StatusService::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->profileManager = $this->createMock(ProfileManager::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
@@ -70,13 +58,14 @@ class ContactsStoreTest extends TestCase {
$this->l10nFactory = $this->createMock(IL10NFactory::class);
$this->contactsStore = new ContactsStore(
$this->contactsManager,
+ $this->statusService,
$this->config,
$this->profileManager,
$this->userManager,
$this->urlGenerator,
$this->groupManager,
$this->knownUserService,
- $this->l10nFactory
+ $this->l10nFactory,
);
}
@@ -209,6 +198,7 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_exclude_groups', 'no', 'yes'],
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
['core', 'shareapi_exclude_groups_list', '', '["group1", "group5", "group6"]'],
+ ['core', 'shareapi_only_share_with_group_members_exclude_group_list', '', '[]'],
]);
/** @var IUser|MockObject $currentUser */
@@ -252,6 +242,7 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_restrict_user_enumeration_to_phone', 'no', 'no'],
['core', 'shareapi_exclude_groups', 'no', 'no'],
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
+ ['core', 'shareapi_only_share_with_group_members_exclude_group_list', '', '[]'],
]);
/** @var IUser|MockObject $currentUser */
@@ -326,6 +317,7 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_restrict_user_enumeration_to_phone', 'no', 'no'],
['core', 'shareapi_exclude_groups', 'no', 'no'],
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
+ ['core', 'shareapi_only_share_with_group_members_exclude_group_list', '', '[]'],
]);
/** @var IUser|MockObject $currentUser */
@@ -458,6 +450,7 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_restrict_user_enumeration_to_phone', 'no', 'yes'],
['core', 'shareapi_exclude_groups', 'no', 'no'],
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
+ ['core', 'shareapi_only_share_with_group_members_exclude_group_list', '', '[]'],
]);
/** @var IUser|MockObject $currentUser */
@@ -611,6 +604,7 @@ class ContactsStoreTest extends TestCase {
['core', 'shareapi_restrict_user_enumeration_to_phone', 'no', 'yes'],
['core', 'shareapi_exclude_groups', 'no', 'no'],
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
+ ['core', 'shareapi_only_share_with_group_members_exclude_group_list', '', '[]'],
]);
/** @var IUser|MockObject $currentUser */
@@ -964,4 +958,118 @@ class ContactsStoreTest extends TestCase {
$this->assertEquals(null, $entry);
}
+
+ public function testGetRecentStatusFirst(): void {
+ $user = $this->createMock(IUser::class);
+ $status1 = new UserStatus();
+ $status1->setUserId('user1');
+ $status2 = new UserStatus();
+ $status2->setUserId('user2');
+ $this->statusService->expects(self::once())
+ ->method('findAllRecentStatusChanges')
+ ->willReturn([
+ $status1,
+ $status2,
+ ]);
+ $user1 = $this->createMock(IUser::class);
+ $user1->method('getCloudId')->willReturn('user1@localcloud');
+ $user2 = $this->createMock(IUser::class);
+ $user2->method('getCloudId')->willReturn('user2@localcloud');
+ $this->userManager->expects(self::exactly(2))
+ ->method('get')
+ ->willReturnCallback(function ($uid) use ($user1, $user2) {
+ return match ($uid) {
+ 'user1' => $user1,
+ 'user2' => $user2,
+ };
+ });
+ $this->contactsManager
+ ->expects(self::exactly(3))
+ ->method('search')
+ ->willReturnCallback(function ($uid, $searchProps, $options) {
+ return match ([$uid, $options['limit'] ?? null]) {
+ ['user1@localcloud', 1] => [
+ [
+ 'UID' => 'user1',
+ 'URI' => 'user1.vcf',
+ ],
+ ],
+ ['user2@localcloud' => [], 1], // Simulate not found
+ ['', 4] => [
+ [
+ 'UID' => 'contact1',
+ 'URI' => 'contact1.vcf',
+ ],
+ [
+ 'UID' => 'contact2',
+ 'URI' => 'contact2.vcf',
+ ],
+ ],
+ default => [],
+ };
+ });
+
+ $contacts = $this->contactsStore->getContacts(
+ $user,
+ null,
+ 5,
+ );
+
+ self::assertCount(3, $contacts);
+ self::assertEquals('user1', $contacts[0]->getProperty('UID'));
+ self::assertEquals('contact1', $contacts[1]->getProperty('UID'));
+ self::assertEquals('contact2', $contacts[2]->getProperty('UID'));
+ }
+
+ public function testPaginateRecentStatus(): void {
+ $user = $this->createMock(IUser::class);
+ $status1 = new UserStatus();
+ $status1->setUserId('user1');
+ $status2 = new UserStatus();
+ $status2->setUserId('user2');
+ $status3 = new UserStatus();
+ $status3->setUserId('user3');
+ $this->statusService->expects(self::never())
+ ->method('findAllRecentStatusChanges');
+ $this->contactsManager
+ ->expects(self::exactly(2))
+ ->method('search')
+ ->willReturnCallback(function ($uid, $searchProps, $options) {
+ return match ([$uid, $options['limit'] ?? null, $options['offset'] ?? null]) {
+ ['', 2, 0] => [
+ [
+ 'UID' => 'contact1',
+ 'URI' => 'contact1.vcf',
+ ],
+ [
+ 'UID' => 'contact2',
+ 'URI' => 'contact2.vcf',
+ ],
+ ],
+ ['', 2, 3] => [
+ [
+ 'UID' => 'contact3',
+ 'URI' => 'contact3.vcf',
+ ],
+ ],
+ default => [],
+ };
+ });
+
+ $page1 = $this->contactsStore->getContacts(
+ $user,
+ null,
+ 2,
+ 0,
+ );
+ $page2 = $this->contactsStore->getContacts(
+ $user,
+ null,
+ 2,
+ 3,
+ );
+
+ self::assertCount(2, $page1);
+ self::assertCount(1, $page2);
+ }
}
diff --git a/tests/lib/Contacts/ContactsMenu/EntryTest.php b/tests/lib/Contacts/ContactsMenu/EntryTest.php
index 684edd9f25e..b06054ee77b 100644
--- a/tests/lib/Contacts/ContactsMenu/EntryTest.php
+++ b/tests/lib/Contacts/ContactsMenu/EntryTest.php
@@ -1,25 +1,8 @@
<?php
/**
- * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Contacts\ContactsMenu;
@@ -103,6 +86,12 @@ class EntryTest extends TestCase {
'emailAddresses' => ['user@example.com'],
'profileTitle' => null,
'profileUrl' => null,
+ 'status' => null,
+ 'statusMessage' => null,
+ 'statusMessageTimestamp' => null,
+ 'statusIcon' => null,
+ 'isUser' => false,
+ 'uid' => null,
];
$this->entry->setId(123);
diff --git a/tests/lib/Contacts/ContactsMenu/ManagerTest.php b/tests/lib/Contacts/ContactsMenu/ManagerTest.php
index eb776a6e39d..27ae9f5415c 100644
--- a/tests/lib/Contacts/ContactsMenu/ManagerTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ManagerTest.php
@@ -1,35 +1,18 @@
<?php
/**
- * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Contacts\ContactsMenu;
use OC\Contacts\ContactsMenu\ActionProviderStore;
use OC\Contacts\ContactsMenu\ContactsStore;
+use OC\Contacts\ContactsMenu\Entry;
use OC\Contacts\ContactsMenu\Manager;
use OCP\App\IAppManager;
use OCP\Constants;
-use OCP\Contacts\ContactsMenu\IEntry;
use OCP\Contacts\ContactsMenu\IProvider;
use OCP\IConfig;
use OCP\IUser;
@@ -65,7 +48,7 @@ class ManagerTest extends TestCase {
private function generateTestEntries(): array {
$entries = [];
foreach (range('Z', 'A') as $char) {
- $entry = $this->createMock(IEntry::class);
+ $entry = $this->createMock(Entry::class);
$entry->expects($this->any())
->method('getFullName')
->willReturn('Contact ' . $char);
diff --git a/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php b/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php
index e9eb41ad397..0c7c4922939 100644
--- a/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php
+++ b/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php
@@ -1,25 +1,8 @@
<?php
/**
- * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Contacts\ContactsMenu\Providers;
diff --git a/tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php b/tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php
index 5b4589de317..02bec43de6b 100644
--- a/tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php
+++ b/tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2023, Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\Contacts\ContactsMenu\Providers;
diff --git a/tests/lib/ContactsManagerTest.php b/tests/lib/ContactsManagerTest.php
index d15cd74bef8..91053cd0b52 100644
--- a/tests/lib/ContactsManagerTest.php
+++ b/tests/lib/ContactsManagerTest.php
@@ -1,5 +1,9 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
namespace Test;
use OCP\IAddressBook;
@@ -109,6 +113,9 @@ class ContactsManagerTest extends \Test\TestCase {
->method('delete')
->willReturn('returnMe');
+ $addressbook->expects($this->any())
+ ->method('getKey')
+ ->willReturn('addressbookKey');
$this->cm->registerAddressBook($addressbook);
$result = $this->cm->delete(1, $addressbook->getKey());
@@ -128,6 +135,10 @@ class ContactsManagerTest extends \Test\TestCase {
$addressbook->expects($this->never())
->method('delete');
+ $addressbook->expects($this->any())
+ ->method('getKey')
+ ->willReturn('addressbookKey');
+
$this->cm->registerAddressBook($addressbook);
$result = $this->cm->delete(1, $addressbook->getKey());
$this->assertEquals($result, null);
@@ -142,6 +153,10 @@ class ContactsManagerTest extends \Test\TestCase {
$addressbook->expects($this->never())
->method('delete');
+ $addressbook->expects($this->any())
+ ->method('getKey')
+ ->willReturn('addressbookKey');
+
$this->cm->registerAddressBook($addressbook);
$result = $this->cm->delete(1, 'noaddressbook');
$this->assertEquals($result, null);
@@ -161,6 +176,10 @@ class ContactsManagerTest extends \Test\TestCase {
->method('createOrUpdate')
->willReturn('returnMe');
+ $addressbook->expects($this->any())
+ ->method('getKey')
+ ->willReturn('addressbookKey');
+
$this->cm->registerAddressBook($addressbook);
$result = $this->cm->createOrUpdate([], $addressbook->getKey());
$this->assertEquals($result, 'returnMe');
@@ -179,6 +198,10 @@ class ContactsManagerTest extends \Test\TestCase {
$addressbook->expects($this->never())
->method('createOrUpdate');
+ $addressbook->expects($this->any())
+ ->method('getKey')
+ ->willReturn('addressbookKey');
+
$this->cm->registerAddressBook($addressbook);
$result = $this->cm->createOrUpdate([], $addressbook->getKey());
$this->assertEquals($result, null);
@@ -193,6 +216,10 @@ class ContactsManagerTest extends \Test\TestCase {
$addressbook->expects($this->never())
->method('createOrUpdate');
+ $addressbook->expects($this->any())
+ ->method('getKey')
+ ->willReturn('addressbookKey');
+
$this->cm->registerAddressBook($addressbook);
$result = $this->cm->createOrUpdate([], 'noaddressbook');
$this->assertEquals($result, null);
@@ -209,6 +236,10 @@ class ContactsManagerTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
+ $addressbook->expects($this->any())
+ ->method('getKey')
+ ->willReturn('addressbookKey');
+
$this->cm->registerAddressBook($addressbook);
$result = $this->cm->isEnabled();
$this->assertTrue($result);
diff --git a/tests/lib/DB/ConnectionFactoryTest.php b/tests/lib/DB/ConnectionFactoryTest.php
index de232bb1fdd..208f78f4512 100644
--- a/tests/lib/DB/ConnectionFactoryTest.php
+++ b/tests/lib/DB/ConnectionFactoryTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\DB;
diff --git a/tests/lib/DB/ConnectionTest.php b/tests/lib/DB/ConnectionTest.php
new file mode 100644
index 00000000000..3f06082ff0c
--- /dev/null
+++ b/tests/lib/DB/ConnectionTest.php
@@ -0,0 +1,101 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace Test\DB;
+
+use Doctrine\DBAL\Configuration;
+use Doctrine\DBAL\Driver;
+use Doctrine\DBAL\Driver\Connection as DriverConnection;
+use Doctrine\DBAL\Platforms\MySQLPlatform;
+use OC\DB\Adapter;
+use OC\DB\Connection;
+use Test\TestCase;
+
+/**
+ * @group DB
+ */
+class ConnectionTest extends TestCase {
+
+ public function testSingleNodeConnectsToPrimaryOnly(): void {
+ $connectionParams = [
+ 'user' => 'test',
+ 'password' => 'topsecret',
+ 'host' => 'test',
+ ];
+ $adapter = $this->createMock(Adapter::class);
+ $driver = $this->createMock(Driver::class);
+ $configuration = $this->createMock(Configuration::class);
+ $connection = $this->getMockBuilder(Connection::class)
+ ->onlyMethods(['connectTo'])
+ ->setConstructorArgs([
+ [
+ 'adapter' => $adapter,
+ 'platform' => new MySQLPlatform(),
+ 'tablePrefix' => 'nctest',
+ 'primary' => $connectionParams,
+ 'replica' => [
+ $connectionParams,
+ ],
+ ],
+ $driver,
+ $configuration,
+ ])
+ ->getMock();
+ $driverConnection = $this->createMock(DriverConnection::class);
+ $connection->expects(self::once())
+ ->method('connectTo')
+ ->with('primary')
+ ->willReturn($driverConnection);
+
+ $connection->ensureConnectedToReplica();
+ $connection->ensureConnectedToPrimary();
+ $connection->ensureConnectedToReplica();
+ }
+
+ public function testClusterConnectsToPrimaryAndReplica(): void {
+ $connectionParamsPrimary = [
+ 'user' => 'test',
+ 'password' => 'topsecret',
+ 'host' => 'testprimary',
+ ];
+ $connectionParamsReplica = [
+ 'user' => 'test',
+ 'password' => 'topsecret',
+ 'host' => 'testreplica',
+ ];
+ $adapter = $this->createMock(Adapter::class);
+ $driver = $this->createMock(Driver::class);
+ $configuration = $this->createMock(Configuration::class);
+ $connection = $this->getMockBuilder(Connection::class)
+ ->onlyMethods(['connectTo'])
+ ->setConstructorArgs([
+ [
+ 'adapter' => $adapter,
+ 'platform' => new MySQLPlatform(),
+ 'tablePrefix' => 'nctest',
+ 'primary' => $connectionParamsPrimary,
+ 'replica' => [
+ $connectionParamsReplica,
+ ],
+ ],
+ $driver,
+ $configuration,
+ ])
+ ->getMock();
+ $driverConnection = $this->createMock(DriverConnection::class);
+ $connection->expects(self::exactly(2))
+ ->method('connectTo')
+ ->willReturn($driverConnection);
+
+ $connection->ensureConnectedToReplica();
+ $connection->ensureConnectedToPrimary();
+ $connection->ensureConnectedToReplica();
+ }
+
+}
diff --git a/tests/lib/DB/Exception/DbalExceptionTest.php b/tests/lib/DB/Exception/DbalExceptionTest.php
index da57264aa76..470beff9080 100644
--- a/tests/lib/DB/Exception/DbalExceptionTest.php
+++ b/tests/lib/DB/Exception/DbalExceptionTest.php
@@ -1,24 +1,10 @@
<?php
declare(strict_types=1);
-
/**
- * @author Daniel Kesselberg <mail@danielkesselberg.de>
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace Test\DB\Exception;
use Doctrine\DBAL\ConnectionException;
@@ -31,6 +17,7 @@ use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Doctrine\DBAL\Exception\InvalidFieldNameException;
+use Doctrine\DBAL\Exception\LockWaitTimeoutException;
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
use Doctrine\DBAL\Exception\ServerException;
@@ -59,6 +46,7 @@ class DbalExceptionTest extends \Test\TestCase {
public function dataDriverException(): array {
return [
+ [LockWaitTimeoutException::class, DbalException::REASON_LOCK_WAIT_TIMEOUT],
[ForeignKeyConstraintViolationException::class, DbalException::REASON_FOREIGN_KEY_VIOLATION],
[NotNullConstraintViolationException::class, DbalException::REASON_NOT_NULL_CONSTRAINT_VIOLATION],
[UniqueConstraintViolationException::class, DbalException::REASON_UNIQUE_CONSTRAINT_VIOLATION],
diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php
index d982a47623b..6cd489258bf 100644
--- a/tests/lib/DB/MigrationsTest.php
+++ b/tests/lib/DB/MigrationsTest.php
@@ -1,10 +1,9 @@
<?php
/**
- * Copyright (c) 2016 Thomas Müller <thomas.mueller@tmit.eu>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\DB;
diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php
index 4d7d9cab19f..4714b569d81 100644
--- a/tests/lib/DB/MigratorTest.php
+++ b/tests/lib/DB/MigratorTest.php
@@ -1,26 +1,21 @@
<?php
/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\DB;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\ParameterType;
-use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
-use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaConfig;
use OC\DB\Migrator;
-use OC\DB\MySQLMigrator;
use OC\DB\OracleMigrator;
-use OC\DB\PostgreSqlMigrator;
use OC\DB\SQLiteMigrator;
use OCP\DB\Types;
use OCP\IConfig;
@@ -67,10 +62,6 @@ class MigratorTest extends \Test\TestCase {
return new SQLiteMigrator($this->connection, $this->config, $dispatcher);
} elseif ($platform instanceof OraclePlatform) {
return new OracleMigrator($this->connection, $this->config, $dispatcher);
- } elseif ($platform instanceof MySQLPlatform) {
- return new MySQLMigrator($this->connection, $this->config, $dispatcher);
- } elseif ($platform instanceof PostgreSQL94Platform) {
- return new PostgreSqlMigrator($this->connection, $this->config, $dispatcher);
}
return new Migrator($this->connection, $this->config, $dispatcher);
}
@@ -138,14 +129,6 @@ class MigratorTest extends \Test\TestCase {
return $config;
}
- private function isSQLite() {
- return $this->connection->getDatabasePlatform() instanceof SqlitePlatform;
- }
-
- private function isMySQL() {
- return $this->connection->getDatabasePlatform() instanceof MySQLPlatform;
- }
-
public function testUpgrade() {
[$startSchema, $endSchema] = $this->getDuplicateKeySchemas();
$migrator = $this->getMigrator();
diff --git a/tests/lib/DB/OCPostgreSqlPlatformTest.php b/tests/lib/DB/OCPostgreSqlPlatformTest.php
index 334a2ecc778..4f83e866a7c 100644
--- a/tests/lib/DB/OCPostgreSqlPlatformTest.php
+++ b/tests/lib/DB/OCPostgreSqlPlatformTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Victor Dubiniuk <dubiniuk@owncloud.com>
- *
- * @copyright Copyright (c) 2017, ownCloud GmbH
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2017 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\DB;
diff --git a/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php b/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php
index 35d8b4faa34..671bcfc209e 100644
--- a/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php
+++ b/tests/lib/DB/QueryBuilder/ExpressionBuilderDBTest.php
@@ -1,28 +1,17 @@
<?php
/**
- * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\DB\QueryBuilder;
+use Doctrine\DBAL\Schema\SchemaException;
+use Doctrine\DBAL\Types\Types;
use OC\DB\QueryBuilder\Literal;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\IConfig;
+use OCP\Server;
use Test\TestCase;
/**
@@ -31,11 +20,13 @@ use Test\TestCase;
class ExpressionBuilderDBTest extends TestCase {
/** @var \Doctrine\DBAL\Connection|\OCP\IDBConnection */
protected $connection;
+ protected $schemaSetup = false;
protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
+ $this->prepareTestingTable();
}
public function likeProvider() {
@@ -150,6 +141,59 @@ class ExpressionBuilderDBTest extends TestCase {
self::assertEquals('myvalue', $entries[0]['configvalue']);
}
+ public function testDateTimeEquals() {
+ $dateTime = new \DateTime('2023-01-01');
+ $insert = $this->connection->getQueryBuilder();
+ $insert->insert('testing')
+ ->values(['datetime' => $insert->createNamedParameter($dateTime, IQueryBuilder::PARAM_DATE)])
+ ->executeStatement();
+
+ $query = $this->connection->getQueryBuilder();
+ $result = $query->select('*')
+ ->from('testing')
+ ->where($query->expr()->eq('datetime', $query->createNamedParameter($dateTime, IQueryBuilder::PARAM_DATE)))
+ ->executeQuery();
+ $entries = $result->fetchAll();
+ $result->closeCursor();
+ self::assertCount(1, $entries);
+ }
+
+ public function testDateTimeLess() {
+ $dateTime = new \DateTime('2022-01-01');
+ $dateTimeCompare = new \DateTime('2022-01-02');
+ $insert = $this->connection->getQueryBuilder();
+ $insert->insert('testing')
+ ->values(['datetime' => $insert->createNamedParameter($dateTime, IQueryBuilder::PARAM_DATE)])
+ ->executeStatement();
+
+ $query = $this->connection->getQueryBuilder();
+ $result = $query->select('*')
+ ->from('testing')
+ ->where($query->expr()->lt('datetime', $query->createNamedParameter($dateTimeCompare, IQueryBuilder::PARAM_DATE)))
+ ->executeQuery();
+ $entries = $result->fetchAll();
+ $result->closeCursor();
+ self::assertCount(1, $entries);
+ }
+
+ public function testDateTimeGreater() {
+ $dateTime = new \DateTime('2023-01-02');
+ $dateTimeCompare = new \DateTime('2023-01-01');
+ $insert = $this->connection->getQueryBuilder();
+ $insert->insert('testing')
+ ->values(['datetime' => $insert->createNamedParameter($dateTime, IQueryBuilder::PARAM_DATE)])
+ ->executeStatement();
+
+ $query = $this->connection->getQueryBuilder();
+ $result = $query->select('*')
+ ->from('testing')
+ ->where($query->expr()->gt('datetime', $query->createNamedParameter($dateTimeCompare, IQueryBuilder::PARAM_DATE)))
+ ->executeQuery();
+ $entries = $result->fetchAll();
+ $result->closeCursor();
+ self::assertCount(1, $entries);
+ }
+
protected function createConfig($appId, $key, $value) {
$query = $this->connection->getQueryBuilder();
$query->insert('appconfig')
@@ -160,4 +204,31 @@ class ExpressionBuilderDBTest extends TestCase {
])
->execute();
}
+
+ protected function prepareTestingTable(): void {
+ if ($this->schemaSetup) {
+ $this->connection->getQueryBuilder()->delete('testing')->executeStatement();
+ }
+
+ $prefix = Server::get(IConfig::class)->getSystemValueString('dbtableprefix', 'oc_');
+ $schema = $this->connection->createSchema();
+ try {
+ $schema->getTable($prefix . 'testing');
+ $this->connection->getQueryBuilder()->delete('testing')->executeStatement();
+ } catch (SchemaException $e) {
+ $this->schemaSetup = true;
+ $table = $schema->createTable($prefix . 'testing');
+ $table->addColumn('id', Types::BIGINT, [
+ 'autoincrement' => true,
+ 'notnull' => true,
+ ]);
+
+ $table->addColumn('datetime', Types::DATETIME_MUTABLE, [
+ 'notnull' => false,
+ ]);
+
+ $table->setPrimaryKey(['id']);
+ $this->connection->migrateToSchema($schema);
+ }
+ }
}
diff --git a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
index 76d9dab75ee..d8147035b16 100644
--- a/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/ExpressionBuilderTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\DB\QueryBuilder;
diff --git a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
index 08392b09d8d..d991c78f113 100644
--- a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
@@ -1,21 +1,7 @@
<?php
/**
- * @author Robin Appelman <robin@icewind.nl>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\DB\QueryBuilder;
@@ -50,6 +36,7 @@ class FunctionBuilderTest extends TestCase {
if ($real) {
$this->addDummyData();
$query->where($query->expr()->eq('appid', $query->createNamedParameter('group_concat')));
+ $query->orderBy('configkey', 'asc');
}
$query->select($query->func()->concat(...$arguments));
diff --git a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
index 6e9a7a84925..96cde8ba1f9 100644
--- a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\DB\QueryBuilder;
@@ -326,7 +312,7 @@ class QueryBuilderTest extends \Test\TestCase {
'appid',
$this->queryBuilder->expr()->literal('testFirstResult1')
))
- ->orderBy('appid', 'DESC');
+ ->orderBy('configkey', 'ASC');
$query = $this->queryBuilder->execute();
$rows = $query->fetchAll();
diff --git a/tests/lib/DB/QueryBuilder/QuoteHelperTest.php b/tests/lib/DB/QueryBuilder/QuoteHelperTest.php
index 17e7ac14a02..12984bac3e0 100644
--- a/tests/lib/DB/QueryBuilder/QuoteHelperTest.php
+++ b/tests/lib/DB/QueryBuilder/QuoteHelperTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\DB\QueryBuilder;
diff --git a/tests/lib/DateTimeFormatterTest.php b/tests/lib/DateTimeFormatterTest.php
index 71d98ba7581..fa8124ed35a 100644
--- a/tests/lib/DateTimeFormatterTest.php
+++ b/tests/lib/DateTimeFormatterTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Joas Schilling nickvergessen@owncloud.com
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
@@ -34,7 +33,7 @@ class DateTimeFormatterTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->formatter = new \OC\DateTimeFormatter(new \DateTimeZone('UTC'), \OC::$server->getL10N('lib', 'en'));
+ $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) {
@@ -43,7 +42,7 @@ class DateTimeFormatterTest extends TestCase {
public function formatTimeSpanData() {
$time = 1416916800; // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo
- $deL10N = \OC::$server->getL10N('lib', 'de');
+ $deL10N = \OCP\Util::getL10N('lib', 'de');
return [
['seconds ago', $time, $time],
['in a few seconds', $time + 5 , $time],
@@ -84,7 +83,7 @@ class DateTimeFormatterTest extends TestCase {
public function formatDateSpanData() {
$time = 1416916800; // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo
- $deL10N = \OC::$server->getL10N('lib', 'de');
+ $deL10N = \OCP\Util::getL10N('lib', 'de');
return [
// Normal testing
['today', $this->getTimestampAgo($time, 30, 15), $time],
diff --git a/tests/lib/Diagnostics/EventLoggerTest.php b/tests/lib/Diagnostics/EventLoggerTest.php
index 18cd3a91b1a..e69a27d70b3 100644
--- a/tests/lib/Diagnostics/EventLoggerTest.php
+++ b/tests/lib/Diagnostics/EventLoggerTest.php
@@ -1,30 +1,16 @@
<?php
/**
- * @author Piotr Mrowczynski <piotr@owncloud.com>
- *
- * @copyright Copyright (c) 2017, ownCloud GmbH
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2017 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Diagnostics;
-use Psr\Log\LoggerInterface;
use OC\Diagnostics\EventLogger;
use OC\Log;
use OC\SystemConfig;
+use Psr\Log\LoggerInterface;
use Test\TestCase;
class EventLoggerTest extends TestCase {
diff --git a/tests/lib/Diagnostics/QueryLoggerTest.php b/tests/lib/Diagnostics/QueryLoggerTest.php
index 9a614a4c441..4cc45cf47d4 100644
--- a/tests/lib/Diagnostics/QueryLoggerTest.php
+++ b/tests/lib/Diagnostics/QueryLoggerTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Piotr Mrowczynski <piotr@owncloud.com>
- *
- * @copyright Copyright (c) 2017, ownCloud GmbH
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2017 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Diagnostics;
diff --git a/tests/lib/DirectEditing/ManagerTest.php b/tests/lib/DirectEditing/ManagerTest.php
index 53588093092..3dc2e464c37 100644
--- a/tests/lib/DirectEditing/ManagerTest.php
+++ b/tests/lib/DirectEditing/ManagerTest.php
@@ -1,5 +1,8 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
namespace Test\DirectEditing;
use OC\DirectEditing\Manager;
diff --git a/tests/lib/EmojiHelperTest.php b/tests/lib/EmojiHelperTest.php
index dba7e631e6f..677cb03aae4 100644
--- a/tests/lib/EmojiHelperTest.php
+++ b/tests/lib/EmojiHelperTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020, Georg Ehrke
- *
- * @author Georg Ehrke <oc.list@georgehrke.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php
index 69f78f435cf..81655e2be11 100644
--- a/tests/lib/Encryption/DecryptAllTest.php
+++ b/tests/lib/Encryption/DecryptAllTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Björn Schießle <schiessle@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Encryption;
diff --git a/tests/lib/Encryption/EncryptionWrapperTest.php b/tests/lib/Encryption/EncryptionWrapperTest.php
index 8c357e2a50d..69bf297e21b 100644
--- a/tests/lib/Encryption/EncryptionWrapperTest.php
+++ b/tests/lib/Encryption/EncryptionWrapperTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Björn Schießle <schiessle@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Encryption;
diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php
index a47edb3fdd6..1f6773b1663 100644
--- a/tests/lib/Encryption/Keys/StorageTest.php
+++ b/tests/lib/Encryption/Keys/StorageTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * ownCloud
- *
- * @copyright (C) 2015 ownCloud, Inc.
- *
- * @author Bjoern Schiessle <schiessle@owncloud.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Encryption\Keys;
@@ -53,6 +38,7 @@ class StorageTest extends TestCase {
$this->util = $this->getMockBuilder('OC\Encryption\Util')
->disableOriginalConstructor()
+ ->setMethodsExcept(['getFileKeyDir'])
->getMock();
$this->view = $this->getMockBuilder(View::class)
@@ -583,39 +569,6 @@ class StorageTest extends TestCase {
$this->assertSame($expected, $args[0]);
}
- /**
- * @dataProvider dataTestGetFileKeyDir
- *
- * @param bool $isSystemWideMountPoint
- * @param string $storageRoot
- * @param string $expected
- */
- public function testGetFileKeyDir($isSystemWideMountPoint, $storageRoot, $expected) {
- $path = '/user1/files/foo/bar.txt';
- $owner = 'user1';
- $relativePath = '/foo/bar.txt';
-
- $this->invokePrivate($this->storage, 'root_dir', [$storageRoot]);
-
- $this->util->expects($this->once())->method('isSystemWideMountPoint')
- ->willReturn($isSystemWideMountPoint);
- $this->util->expects($this->once())->method('getUidAndFilename')
- ->with($path)->willReturn([$owner, $relativePath]);
-
- $this->assertSame($expected,
- $this->invokePrivate($this->storage, 'getFileKeyDir', ['OC_DEFAULT_MODULE', $path])
- );
- }
-
- public function dataTestGetFileKeyDir() {
- return [
- [false, '', '/user1/files_encryption/keys/foo/bar.txt/OC_DEFAULT_MODULE/'],
- [true, '', '/files_encryption/keys/foo/bar.txt/OC_DEFAULT_MODULE/'],
- [false, 'newStorageRoot', '/newStorageRoot/user1/files_encryption/keys/foo/bar.txt/OC_DEFAULT_MODULE/'],
- [true, 'newStorageRoot', '/newStorageRoot/files_encryption/keys/foo/bar.txt/OC_DEFAULT_MODULE/'],
- ];
- }
-
/**
* @dataProvider dataTestBackupUserKeys
diff --git a/tests/lib/Encryption/ManagerTest.php b/tests/lib/Encryption/ManagerTest.php
index 4e354ad518c..d092068f6c6 100644
--- a/tests/lib/Encryption/ManagerTest.php
+++ b/tests/lib/Encryption/ManagerTest.php
@@ -1,5 +1,9 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
namespace Test\Encryption;
use OC\Encryption\Manager;
@@ -193,63 +197,63 @@ class ManagerTest extends TestCase {
$this->assertEquals('ID1', $this->manager->getDefaultEncryptionModuleId());
}
-// /**
-// * @expectedException \OC\Encryption\Exceptions\ModuleAlreadyExistsException
-// * @expectedExceptionMessage Id "0" already used by encryption module "TestDummyModule0"
-// */
-// public function testModuleRegistration() {
-// $config = $this->createMock(IConfig::class);
-// $config->expects($this->any())->method('getSystemValueBool')->willReturn(true);
-// $em = $this->createMock(IEncryptionModule::class);
-// $em->expects($this->any())->method('getId')->willReturn(0);
-// $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
-// $m = new Manager($config);
-// $m->registerEncryptionModule($em);
-// $this->assertTrue($m->isEnabled());
-// $m->registerEncryptionModule($em);
-// }
-//
-// public function testModuleUnRegistration() {
-// $config = $this->createMock(IConfig::class);
-// $config->expects($this->any())->method('getSystemValueBool')->willReturn(true);
-// $em = $this->createMock(IEncryptionModule::class);
-// $em->expects($this->any())->method('getId')->willReturn(0);
-// $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
-// $m = new Manager($config);
-// $m->registerEncryptionModule($em);
-// $this->assertTrue($m->isEnabled());
-// $m->unregisterEncryptionModule($em);
-// $this->assertFalse($m->isEnabled());
-// }
-//
-// /**
-// * @expectedException \OC\Encryption\Exceptions\ModuleDoesNotExistsException
-// * @expectedExceptionMessage Module with ID: unknown does not exist.
-// */
-// public function testGetEncryptionModuleUnknown() {
-// $config = $this->createMock(IConfig::class);
-// $config->expects($this->any())->method('getSystemValueBool')->willReturn(true);
-// $em = $this->createMock(IEncryptionModule::class);
-// $em->expects($this->any())->method('getId')->willReturn(0);
-// $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
-// $m = new Manager($config);
-// $m->registerEncryptionModule($em);
-// $this->assertTrue($m->isEnabled());
-// $m->getEncryptionModule('unknown');
-// }
-//
-// public function testGetEncryptionModule() {
-// $config = $this->createMock(IConfig::class);
-// $config->expects($this->any())->method('getSystemValueBool')->willReturn(true);
-// $em = $this->createMock(IEncryptionModule::class);
-// $em->expects($this->any())->method('getId')->willReturn(0);
-// $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
-// $m = new Manager($config);
-// $m->registerEncryptionModule($em);
-// $this->assertTrue($m->isEnabled());
-// $en0 = $m->getEncryptionModule(0);
-// $this->assertEquals(0, $en0->getId());
-// }
+ // /**
+ // * @expectedException \OC\Encryption\Exceptions\ModuleAlreadyExistsException
+ // * @expectedExceptionMessage Id "0" already used by encryption module "TestDummyModule0"
+ // */
+ // public function testModuleRegistration() {
+ // $config = $this->createMock(IConfig::class);
+ // $config->expects($this->any())->method('getSystemValueBool')->willReturn(true);
+ // $em = $this->createMock(IEncryptionModule::class);
+ // $em->expects($this->any())->method('getId')->willReturn(0);
+ // $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
+ // $m = new Manager($config);
+ // $m->registerEncryptionModule($em);
+ // $this->assertTrue($m->isEnabled());
+ // $m->registerEncryptionModule($em);
+ // }
+ //
+ // public function testModuleUnRegistration() {
+ // $config = $this->createMock(IConfig::class);
+ // $config->expects($this->any())->method('getSystemValueBool')->willReturn(true);
+ // $em = $this->createMock(IEncryptionModule::class);
+ // $em->expects($this->any())->method('getId')->willReturn(0);
+ // $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
+ // $m = new Manager($config);
+ // $m->registerEncryptionModule($em);
+ // $this->assertTrue($m->isEnabled());
+ // $m->unregisterEncryptionModule($em);
+ // $this->assertFalse($m->isEnabled());
+ // }
+ //
+ // /**
+ // * @expectedException \OC\Encryption\Exceptions\ModuleDoesNotExistsException
+ // * @expectedExceptionMessage Module with ID: unknown does not exist.
+ // */
+ // public function testGetEncryptionModuleUnknown() {
+ // $config = $this->createMock(IConfig::class);
+ // $config->expects($this->any())->method('getSystemValueBool')->willReturn(true);
+ // $em = $this->createMock(IEncryptionModule::class);
+ // $em->expects($this->any())->method('getId')->willReturn(0);
+ // $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
+ // $m = new Manager($config);
+ // $m->registerEncryptionModule($em);
+ // $this->assertTrue($m->isEnabled());
+ // $m->getEncryptionModule('unknown');
+ // }
+ //
+ // public function testGetEncryptionModule() {
+ // $config = $this->createMock(IConfig::class);
+ // $config->expects($this->any())->method('getSystemValueBool')->willReturn(true);
+ // $em = $this->createMock(IEncryptionModule::class);
+ // $em->expects($this->any())->method('getId')->willReturn(0);
+ // $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0');
+ // $m = new Manager($config);
+ // $m->registerEncryptionModule($em);
+ // $this->assertTrue($m->isEnabled());
+ // $en0 = $m->getEncryptionModule(0);
+ // $this->assertEquals(0, $en0->getId());
+ // }
protected function addNewEncryptionModule(Manager $manager, $id) {
$encryptionModule = $this->createMock(IEncryptionModule::class);
diff --git a/tests/lib/Encryption/UpdateTest.php b/tests/lib/Encryption/UpdateTest.php
index df7d137f0b6..9f431b53d3e 100644
--- a/tests/lib/Encryption/UpdateTest.php
+++ b/tests/lib/Encryption/UpdateTest.php
@@ -1,34 +1,20 @@
<?php
/**
- * @author Björn Schießle <schiessle@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
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 Psr\Log\LoggerInterface;
use Test\TestCase;
-use OC\Encryption\File;
-use OCP\Encryption\IEncryptionModule;
class UpdateTest extends TestCase {
/** @var \OC\Encryption\Update */
diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php
index 8d800cf6f34..813a288a470 100644
--- a/tests/lib/Encryption/UtilTest.php
+++ b/tests/lib/Encryption/UtilTest.php
@@ -1,5 +1,9 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
namespace Test\Encryption;
use OC\Encryption\Util;
@@ -13,6 +17,7 @@ use Test\TestCase;
class UtilTest extends TestCase {
/**
* block size will always be 8192 for a PHP stream
+ *
* @see https://bugs.php.net/bug.php?id=21641
*/
protected int $headerSize = 8192;
@@ -178,4 +183,74 @@ class UtilTest extends TestCase {
['/foo/test.txt.ocTransferId7567.part', '/foo/test.txt'],
];
}
+
+ /**
+ * @dataProvider dataTestParseRawHeader
+ */
+ public function testParseRawHeader($rawHeader, $expected) {
+ $result = $this->util->parseRawHeader($rawHeader);
+ $this->assertSameSize($expected, $result);
+ foreach ($result as $key => $value) {
+ $this->assertArrayHasKey($key, $expected);
+ $this->assertSame($expected[$key], $value);
+ }
+ }
+
+ public function dataTestParseRawHeader() {
+ return [
+ [str_pad('HBEGIN:oc_encryption_module:0:HEND', $this->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)
+ , ['custom_header' => 'foo', Util::HEADER_ENCRYPTION_MODULE_KEY => '0']],
+ [str_pad('HelloWorld', $this->headerSize, '-', STR_PAD_RIGHT), []],
+ ['', []],
+ [str_pad('HBEGIN:oc_encryption_module:0', $this->headerSize, '-', STR_PAD_RIGHT)
+ , []],
+ [str_pad('oc_encryption_module:0:HEND', $this->headerSize, '-', STR_PAD_RIGHT)
+ , []],
+ ];
+ }
+
+ /**
+ * @dataProvider dataTestGetFileKeyDir
+ *
+ * @param bool $isSystemWideMountPoint
+ * @param string $storageRoot
+ * @param string $expected
+ */
+ public function testGetFileKeyDir($isSystemWideMountPoint, $storageRoot, $expected) {
+ $path = '/user1/files/foo/bar.txt';
+ $owner = 'user1';
+ $relativePath = '/foo/bar.txt';
+
+ $util = $this->getMockBuilder(Util::class)
+ ->onlyMethods(['isSystemWideMountPoint', 'getUidAndFilename', 'getKeyStorageRoot'])
+ ->setConstructorArgs([
+ $this->view,
+ $this->userManager,
+ $this->groupManager,
+ $this->config
+ ])
+ ->getMock();
+
+ $util->expects($this->once())->method('getKeyStorageRoot')
+ ->willReturn($storageRoot);
+ $util->expects($this->once())->method('isSystemWideMountPoint')
+ ->willReturn($isSystemWideMountPoint);
+ $util->expects($this->once())->method('getUidAndFilename')
+ ->with($path)->willReturn([$owner, $relativePath]);
+
+ $this->assertSame($expected,
+ $util->getFileKeyDir('OC_DEFAULT_MODULE', $path)
+ );
+ }
+
+ public function dataTestGetFileKeyDir() {
+ return [
+ [false, '', '/user1/files_encryption/keys/foo/bar.txt/OC_DEFAULT_MODULE/'],
+ [true, '', '/files_encryption/keys/foo/bar.txt/OC_DEFAULT_MODULE/'],
+ [false, 'newStorageRoot', '/newStorageRoot/user1/files_encryption/keys/foo/bar.txt/OC_DEFAULT_MODULE/'],
+ [true, 'newStorageRoot', '/newStorageRoot/files_encryption/keys/foo/bar.txt/OC_DEFAULT_MODULE/'],
+ ];
+ }
}
diff --git a/tests/lib/ErrorHandlerTest.php b/tests/lib/ErrorHandlerTest.php
index 468273c4dea..72974a14550 100644
--- a/tests/lib/ErrorHandlerTest.php
+++ b/tests/lib/ErrorHandlerTest.php
@@ -3,24 +3,9 @@
declare(strict_types=1);
/**
- * ownCloud
- *
- * @author Bjoern Schiessle
- * @copyright 2014 Bjoern Schiessle <schiessle@owncloud.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/EventSourceFactoryTest.php b/tests/lib/EventSourceFactoryTest.php
index 67bc900bd4c..c5e22a8fe34 100644
--- a/tests/lib/EventSourceFactoryTest.php
+++ b/tests/lib/EventSourceFactoryTest.php
@@ -1,23 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2023 Daniel Kesselberg <mail@danielkesselberg.de>
- *
- * @author Daniel Kesselberg <mail@danielkesselberg.de>
- *
- * @license AGPL-3.0-or-later
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/Federation/CloudIdManagerTest.php b/tests/lib/Federation/CloudIdManagerTest.php
index 0db36b0524a..40477944019 100644
--- a/tests/lib/Federation/CloudIdManagerTest.php
+++ b/tests/lib/Federation/CloudIdManagerTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Federation;
@@ -124,11 +109,15 @@ class CloudIdManagerTest extends TestCase {
$this->cloudIdManager->resolveCloudId($cloudId);
}
- public function getCloudIdProvider() {
+ public function getCloudIdProvider(): array {
return [
['test', 'example.com', 'test@example.com'],
+ ['test', 'http://example.com', 'test@http://example.com', 'test@example.com'],
+ ['test', null, 'test@http://example.com', 'test@example.com', 'http://example.com', 'http://example.com'],
['test@example.com', 'example.com', 'test@example.com@example.com'],
- ['test@example.com', null, 'test@example.com@example.com'],
+ ['test@example.com', 'https://example.com', 'test@example.com@example.com'],
+ ['test@example.com', null, 'test@example.com@example.com', null, 'https://example.com', 'https://example.com'],
+ ['test@example.com', 'https://example.com/index.php/s/shareToken', 'test@example.com@example.com', null, 'https://example.com', 'https://example.com'],
];
}
@@ -136,28 +125,30 @@ class CloudIdManagerTest extends TestCase {
* @dataProvider getCloudIdProvider
*
* @param string $user
- * @param string $remote
+ * @param null|string $remote
* @param string $id
*/
- public function testGetCloudId($user, $remote, $id) {
+ public function testGetCloudId(string $user, ?string $remote, string $id, ?string $searchCloudId = null, ?string $localHost = 'https://example.com', ?string $expectedRemoteId = null): void {
if ($remote !== null) {
$this->contactsManager->expects($this->any())
->method('search')
- ->with($id, ['CLOUD'])
+ ->with($searchCloudId ?? $id, ['CLOUD'])
->willReturn([
[
- 'CLOUD' => [$id],
+ 'CLOUD' => [$searchCloudId ?? $id],
'FN' => 'Ample Ex',
]
]);
} else {
$this->urlGenerator->expects(self::once())
->method('getAbsoluteUrl')
- ->willReturn('https://example.com');
+ ->willReturn($localHost);
}
+ $expectedRemoteId ??= $remote;
$cloudId = $this->cloudIdManager->getCloudId($user, $remote);
- $this->assertEquals($id, $cloudId->getId());
+ $this->assertEquals($id, $cloudId->getId(), 'Cloud ID');
+ $this->assertEquals($expectedRemoteId, $cloudId->getRemote(), 'Remote URL');
}
}
diff --git a/tests/lib/Federation/CloudIdTest.php b/tests/lib/Federation/CloudIdTest.php
index feb4108efe5..4ac9bd92d64 100644
--- a/tests/lib/Federation/CloudIdTest.php
+++ b/tests/lib/Federation/CloudIdTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Federation;
diff --git a/tests/lib/FileChunkingTest.php b/tests/lib/FileChunkingTest.php
index 23f50a5b6f7..b69154ea1c3 100644
--- a/tests/lib/FileChunkingTest.php
+++ b/tests/lib/FileChunkingTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test;
diff --git a/tests/lib/Files/AppData/AppDataTest.php b/tests/lib/Files/AppData/AppDataTest.php
index d06d7a9a91e..241e49a026f 100644
--- a/tests/lib/Files/AppData/AppDataTest.php
+++ b/tests/lib/Files/AppData/AppDataTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\AppData;
diff --git a/tests/lib/Files/AppData/FactoryTest.php b/tests/lib/Files/AppData/FactoryTest.php
index 8161bc515ec..1aad461e633 100644
--- a/tests/lib/Files/AppData/FactoryTest.php
+++ b/tests/lib/Files/AppData/FactoryTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\AppData;
diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php
index 1b5c8e6e5ff..faecbf54491 100644
--- a/tests/lib/Files/Cache/CacheTest.php
+++ b/tests/lib/Files/Cache/CacheTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Cache;
diff --git a/tests/lib/Files/Cache/HomeCacheTest.php b/tests/lib/Files/Cache/HomeCacheTest.php
index aacb91c675e..986d6df4c17 100644
--- a/tests/lib/Files/Cache/HomeCacheTest.php
+++ b/tests/lib/Files/Cache/HomeCacheTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Cache;
diff --git a/tests/lib/Files/Cache/LocalRootScannerTest.php b/tests/lib/Files/Cache/LocalRootScannerTest.php
index 0a85f000dbc..204621bbd03 100644
--- a/tests/lib/Files/Cache/LocalRootScannerTest.php
+++ b/tests/lib/Files/Cache/LocalRootScannerTest.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Cache;
diff --git a/tests/lib/Files/Cache/MoveFromCacheTraitTest.php b/tests/lib/Files/Cache/MoveFromCacheTraitTest.php
index 6e1430d146b..f0f143f431f 100644
--- a/tests/lib/Files/Cache/MoveFromCacheTraitTest.php
+++ b/tests/lib/Files/Cache/MoveFromCacheTraitTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2016 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Cache;
diff --git a/tests/lib/Files/Cache/PropagatorTest.php b/tests/lib/Files/Cache/PropagatorTest.php
index c1822c90282..8902034db02 100644
--- a/tests/lib/Files/Cache/PropagatorTest.php
+++ b/tests/lib/Files/Cache/PropagatorTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Cache;
diff --git a/tests/lib/Files/Cache/ScannerTest.php b/tests/lib/Files/Cache/ScannerTest.php
index e4c052f6025..bc911baba0c 100644
--- a/tests/lib/Files/Cache/ScannerTest.php
+++ b/tests/lib/Files/Cache/ScannerTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Cache;
@@ -404,4 +403,48 @@ class ScannerTest extends TestCase {
['/sub/folder/foo.txt', false],
];
}
+
+ public function testNoETagUnscannedFolder() {
+ $this->fillTestFolders();
+
+ $this->scanner->scan('');
+
+ $oldFolderEntry = $this->cache->get('folder');
+ // create a new file in a folder by keeping the mtime unchanged, but mark the folder as unscanned
+ $this->storage->file_put_contents('folder/new.txt', 'foo');
+ $this->storage->touch('folder', $oldFolderEntry->getMTime());
+ $this->cache->update($oldFolderEntry->getId(), ['size' => -1]);
+
+ $this->scanner->scan('');
+
+ $this->cache->inCache('folder/new.txt');
+
+ $newFolderEntry = $this->cache->get('folder');
+ $this->assertNotEquals($newFolderEntry->getEtag(), $oldFolderEntry->getEtag());
+ }
+
+ public function testNoETagUnscannedSubFolder() {
+ $this->fillTestFolders();
+ $this->storage->mkdir('folder/sub');
+
+ $this->scanner->scan('');
+
+ $oldFolderEntry1 = $this->cache->get('folder');
+ $oldFolderEntry2 = $this->cache->get('folder/sub');
+ // create a new file in a folder by keeping the mtime unchanged, but mark the folder as unscanned
+ $this->storage->file_put_contents('folder/sub/new.txt', 'foo');
+ $this->storage->touch('folder/sub', $oldFolderEntry1->getMTime());
+
+ // we only mark the direct parent as unscanned, which is the current "notify" behavior
+ $this->cache->update($oldFolderEntry2->getId(), ['size' => -1]);
+
+ $this->scanner->scan('');
+
+ $this->cache->inCache('folder/new.txt');
+
+ $newFolderEntry1 = $this->cache->get('folder');
+ $this->assertNotEquals($newFolderEntry1->getEtag(), $oldFolderEntry1->getEtag());
+ $newFolderEntry2 = $this->cache->get('folder/sub');
+ $this->assertNotEquals($newFolderEntry2->getEtag(), $oldFolderEntry2->getEtag());
+ }
}
diff --git a/tests/lib/Files/Cache/SearchBuilderTest.php b/tests/lib/Files/Cache/SearchBuilderTest.php
index 5eb1a0252f0..57d890fcbcd 100644
--- a/tests/lib/Files/Cache/SearchBuilderTest.php
+++ b/tests/lib/Files/Cache/SearchBuilderTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Cache;
@@ -154,6 +139,7 @@ class SearchBuilderTest extends TestCase {
[new SearchComparison(ISearchComparison::COMPARE_LIKE, 'name', 'foo%'), [0, 1]],
[new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'image/jpg'), [0]],
[new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', 'image/%'), [0, 1]],
+ [new SearchComparison(ISearchComparison::COMPARE_IN, 'mimetype', ['image/jpg', 'image/png']), [0, 1]],
[new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'size', 50),
new SearchComparison(ISearchComparison::COMPARE_LESS_THAN, 'mtime', 125)
diff --git a/tests/lib/Files/Cache/UpdaterLegacyTest.php b/tests/lib/Files/Cache/UpdaterLegacyTest.php
index be0390db15e..cb51afe7d6a 100644
--- a/tests/lib/Files/Cache/UpdaterLegacyTest.php
+++ b/tests/lib/Files/Cache/UpdaterLegacyTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Cache;
@@ -262,14 +261,14 @@ class UpdaterLegacyTest extends \Test\TestCase {
$this->assertIsString($cachedData['etag']);
$this->assertNotSame($oldEtag, $cachedData['etag']);
// rename can cause mtime change - invalid assert
-// $this->assertEquals($mtime, $cachedData['mtime']);
+ // $this->assertEquals($mtime, $cachedData['mtime']);
$cachedData = $view->getFileInfo('folder');
$this->assertIsString($folderCachedData['etag']);
$this->assertIsString($cachedData['etag']);
$this->assertNotSame($oldEtag, $cachedData['etag']);
// rename can cause mtime change - invalid assert
-// $this->assertEquals($mtime, $cachedData['mtime']);
+ // $this->assertEquals($mtime, $cachedData['mtime']);
}
public function testTouch() {
diff --git a/tests/lib/Files/Cache/UpdaterTest.php b/tests/lib/Files/Cache/UpdaterTest.php
index 7e0f6866793..bfc17e64467 100644
--- a/tests/lib/Files/Cache/UpdaterTest.php
+++ b/tests/lib/Files/Cache/UpdaterTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Cache;
diff --git a/tests/lib/Files/Cache/WatcherTest.php b/tests/lib/Files/Cache/WatcherTest.php
index 509b9d6ba2a..d4a44ca6aa0 100644
--- a/tests/lib/Files/Cache/WatcherTest.php
+++ b/tests/lib/Files/Cache/WatcherTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Cache;
diff --git a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
index 8d7e6536418..d0a6f99cb19 100644
--- a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
+++ b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Cache\Wrapper;
@@ -11,6 +10,7 @@ namespace Test\Files\Cache\Wrapper;
use OC\Files\Cache\Wrapper\CacheJail;
use OC\Files\Search\SearchComparison;
use OC\Files\Search\SearchQuery;
+use OC\Files\Storage\Wrapper\Jail;
use OC\User\User;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Search\ISearchComparison;
@@ -218,4 +218,33 @@ class CacheJailTest extends CacheTest {
$this->assertCount(1, $result);
$this->assertEquals('foo/bar/asd', $result[0]['path']);
}
+
+ public function testWatcher() {
+ $storage = new Jail([
+ 'storage' => $this->storage,
+ 'root' => 'foo'
+ ]);
+ $storage->getScanner()->scan('');
+ $storage->file_put_contents('bar', 'asd');
+
+ $this->assertFalse($this->cache->inCache('bar'));
+ $storage->getWatcher()->update('bar', ['mimetype' => 'text/plain']);
+ $this->assertTrue($this->cache->inCache('bar'));
+ }
+
+ public function testWatcherAfterInnerWatcher() {
+ $storage = new Jail([
+ 'storage' => $this->storage,
+ 'root' => 'foo'
+ ]);
+ $storage->getScanner()->scan('');
+ $storage->file_put_contents('bar', 'asd');
+
+ // let the underlying storage create it's watcher first
+ $this->storage->getWatcher();
+
+ $this->assertFalse($this->cache->inCache('bar'));
+ $storage->getWatcher()->update('bar', ['mimetype' => 'text/plain']);
+ $this->assertTrue($this->cache->inCache('bar'));
+ }
}
diff --git a/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php b/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php
index 20c20974c07..d3eb8be7af9 100644
--- a/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php
+++ b/tests/lib/Files/Cache/Wrapper/CachePermissionsMaskTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Cache\Wrapper;
diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php
index ccad4671ae9..13690096d3a 100644
--- a/tests/lib/Files/Config/UserMountCacheTest.php
+++ b/tests/lib/Files/Config/UserMountCacheTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Config;
@@ -11,8 +10,8 @@ namespace Test\Files\Config;
use OC\DB\QueryBuilder\Literal;
use OC\Files\Mount\MountPoint;
use OC\Files\Storage\Storage;
-use OCP\Cache\CappedMemoryCache;
use OC\User\Manager;
+use OCP\Cache\CappedMemoryCache;
use OCP\Diagnostics\IEventLogger;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\ICachedMountInfo;
@@ -84,8 +83,8 @@ class UserMountCacheTest extends TestCase {
}
}
- private function getStorage($storageId) {
- $rootId = $this->createCacheEntry('', $storageId);
+ private function getStorage($storageId, $rootInternalPath = '') {
+ $rootId = $this->createCacheEntry($rootInternalPath, $storageId);
$storageCache = $this->getMockBuilder('\OC\Files\Cache\Storage')
->disableOriginalConstructor()
@@ -118,6 +117,10 @@ class UserMountCacheTest extends TestCase {
$this->invokePrivate($this->cache, 'mountsForUsers', [new CappedMemoryCache()]);
}
+ private function keyForMount(MountPoint $mount): string {
+ return $mount->getStorageRootId().'::'.$mount->getMountPoint();
+ }
+
public function testNewMounts() {
$user = $this->userManager->get('u1');
@@ -131,9 +134,9 @@ class UserMountCacheTest extends TestCase {
$cachedMounts = $this->cache->getMountsForUser($user);
$this->assertCount(1, $cachedMounts);
- $cachedMount = $cachedMounts[0];
+ $cachedMount = $cachedMounts[$this->keyForMount($mount)];
$this->assertEquals('/asd/', $cachedMount->getMountPoint());
- $this->assertEquals($user, $cachedMount->getUser());
+ $this->assertEquals($user->getUID(), $cachedMount->getUser()->getUID());
$this->assertEquals($storage->getCache()->getId(''), $cachedMount->getRootId());
$this->assertEquals($storage->getStorageCache()->getNumericId(), $cachedMount->getStorageId());
}
@@ -155,9 +158,9 @@ class UserMountCacheTest extends TestCase {
$cachedMounts = $this->cache->getMountsForUser($user);
$this->assertCount(1, $cachedMounts);
- $cachedMount = $cachedMounts[0];
+ $cachedMount = $cachedMounts[$this->keyForMount($mount)];
$this->assertEquals('/asd/', $cachedMount->getMountPoint());
- $this->assertEquals($user, $cachedMount->getUser());
+ $this->assertEquals($user->getUID(), $cachedMount->getUser()->getUID());
$this->assertEquals($storage->getCache()->getId(''), $cachedMount->getRootId());
$this->assertEquals($storage->getStorageCache()->getNumericId(), $cachedMount->getStorageId());
}
@@ -200,7 +203,7 @@ class UserMountCacheTest extends TestCase {
$cachedMounts = $this->cache->getMountsForUser($user);
$this->assertCount(1, $cachedMounts);
- $cachedMount = $cachedMounts[0];
+ $cachedMount = $cachedMounts[$this->keyForMount($mount)];
$this->assertEquals('/foo/', $cachedMount->getMountPoint());
}
@@ -223,7 +226,7 @@ class UserMountCacheTest extends TestCase {
$cachedMounts = $this->cache->getMountsForUser($user);
$this->assertCount(1, $cachedMounts);
- $cachedMount = $cachedMounts[0];
+ $cachedMount = $cachedMounts[$this->keyForMount($mount)];
$this->assertEquals(1, $cachedMount->getMountId());
}
@@ -233,7 +236,7 @@ class UserMountCacheTest extends TestCase {
$user3 = $this->userManager->get('u3');
[$storage1, $id1] = $this->getStorage(1);
- [$storage2, $id2] = $this->getStorage(2);
+ [$storage2, $id2] = $this->getStorage(2, 'foo/bar');
$mount1 = new MountPoint($storage1, '/foo/');
$mount2 = new MountPoint($storage2, '/bar/');
@@ -248,15 +251,17 @@ class UserMountCacheTest extends TestCase {
$cachedMounts = $this->cache->getMountsForUser($user1);
$this->assertCount(2, $cachedMounts);
- $this->assertEquals('/foo/', $cachedMounts[0]->getMountPoint());
- $this->assertEquals($user1, $cachedMounts[0]->getUser());
- $this->assertEquals($id1, $cachedMounts[0]->getRootId());
- $this->assertEquals(1, $cachedMounts[0]->getStorageId());
-
- $this->assertEquals('/bar/', $cachedMounts[1]->getMountPoint());
- $this->assertEquals($user1, $cachedMounts[1]->getUser());
- $this->assertEquals($id2, $cachedMounts[1]->getRootId());
- $this->assertEquals(2, $cachedMounts[1]->getStorageId());
+ $this->assertEquals('/foo/', $cachedMounts[$this->keyForMount($mount1)]->getMountPoint());
+ $this->assertEquals($user1->getUID(), $cachedMounts[$this->keyForMount($mount1)]->getUser()->getUID());
+ $this->assertEquals($id1, $cachedMounts[$this->keyForMount($mount1)]->getRootId());
+ $this->assertEquals(1, $cachedMounts[$this->keyForMount($mount1)]->getStorageId());
+ $this->assertEquals('', $cachedMounts[$this->keyForMount($mount1)]->getRootInternalPath());
+
+ $this->assertEquals('/bar/', $cachedMounts[$this->keyForMount($mount2)]->getMountPoint());
+ $this->assertEquals($user1->getUID(), $cachedMounts[$this->keyForMount($mount2)]->getUser()->getUID());
+ $this->assertEquals($id2, $cachedMounts[$this->keyForMount($mount2)]->getRootId());
+ $this->assertEquals(2, $cachedMounts[$this->keyForMount($mount2)]->getStorageId());
+ $this->assertEquals('foo/bar', $cachedMounts[$this->keyForMount($mount2)]->getRootInternalPath());
$cachedMounts = $this->cache->getMountsForUser($user3);
$this->assertEmpty($cachedMounts);
@@ -282,12 +287,12 @@ class UserMountCacheTest extends TestCase {
$this->assertCount(2, $cachedMounts);
$this->assertEquals('/bar/', $cachedMounts[0]->getMountPoint());
- $this->assertEquals($user1, $cachedMounts[0]->getUser());
+ $this->assertEquals($user1->getUID(), $cachedMounts[0]->getUser()->getUID());
$this->assertEquals($id2, $cachedMounts[0]->getRootId());
$this->assertEquals(2, $cachedMounts[0]->getStorageId());
$this->assertEquals('/bar/', $cachedMounts[1]->getMountPoint());
- $this->assertEquals($user2, $cachedMounts[1]->getUser());
+ $this->assertEquals($user2->getUID(), $cachedMounts[1]->getUser()->getUID());
$this->assertEquals($id2, $cachedMounts[1]->getRootId());
$this->assertEquals(2, $cachedMounts[1]->getStorageId());
}
@@ -312,12 +317,12 @@ class UserMountCacheTest extends TestCase {
$this->assertCount(2, $cachedMounts);
$this->assertEquals('/bar/', $cachedMounts[0]->getMountPoint());
- $this->assertEquals($user1, $cachedMounts[0]->getUser());
+ $this->assertEquals($user1->getUID(), $cachedMounts[0]->getUser()->getUID());
$this->assertEquals($id2, $cachedMounts[0]->getRootId());
$this->assertEquals(2, $cachedMounts[0]->getStorageId());
$this->assertEquals('/bar/', $cachedMounts[1]->getMountPoint());
- $this->assertEquals($user2, $cachedMounts[1]->getUser());
+ $this->assertEquals($user2->getUID(), $cachedMounts[1]->getUser()->getUID());
$this->assertEquals($id2, $cachedMounts[1]->getRootId());
$this->assertEquals(2, $cachedMounts[1]->getStorageId());
}
@@ -372,7 +377,7 @@ class UserMountCacheTest extends TestCase {
$this->assertCount(1, $cachedMounts);
$this->assertEquals('/foo/', $cachedMounts[0]->getMountPoint());
- $this->assertEquals($user1, $cachedMounts[0]->getUser());
+ $this->assertEquals($user1->getUID(), $cachedMounts[0]->getUser()->getUID());
$this->assertEquals($rootId, $cachedMounts[0]->getRootId());
$this->assertEquals(2, $cachedMounts[0]->getStorageId());
}
@@ -394,7 +399,7 @@ class UserMountCacheTest extends TestCase {
$this->assertCount(1, $cachedMounts);
$this->assertEquals('/foo/', $cachedMounts[0]->getMountPoint());
- $this->assertEquals($user1, $cachedMounts[0]->getUser());
+ $this->assertEquals($user1->getUID(), $cachedMounts[0]->getUser()->getUID());
$this->assertEquals($rootId, $cachedMounts[0]->getRootId());
$this->assertEquals(2, $cachedMounts[0]->getStorageId());
$this->assertEquals('foo/bar', $cachedMounts[0]->getInternalPath());
@@ -427,7 +432,7 @@ class UserMountCacheTest extends TestCase {
$this->assertCount(1, $cachedMounts);
$this->assertEquals('/', $cachedMounts[0]->getMountPoint());
- $this->assertEquals($user1, $cachedMounts[0]->getUser());
+ $this->assertEquals($user1->getUID(), $cachedMounts[0]->getUser()->getUID());
$this->assertEquals($folderId, $cachedMounts[0]->getRootId());
$this->assertEquals(2, $cachedMounts[0]->getStorageId());
$this->assertEquals('foo', $cachedMounts[0]->getRootInternalPath());
@@ -521,7 +526,7 @@ class UserMountCacheTest extends TestCase {
$cachedMounts = $this->cache->getMountsForUser($user1);
$this->assertCount(1, $cachedMounts);
- $this->assertEquals('', $cachedMounts[0]->getMountProvider());
+ $this->assertEquals('', $cachedMounts[$this->keyForMount($mount1)]->getMountProvider());
$mount1 = new MountPoint($storage1, '/foo/', null, null, null, null, 'dummy');
$this->cache->registerMounts($user1, [$mount1], ['dummy']);
@@ -530,6 +535,6 @@ class UserMountCacheTest extends TestCase {
$cachedMounts = $this->cache->getMountsForUser($user1);
$this->assertCount(1, $cachedMounts);
- $this->assertEquals('dummy', $cachedMounts[0]->getMountProvider());
+ $this->assertEquals('dummy', $cachedMounts[$this->keyForMount($mount1)]->getMountProvider());
}
}
diff --git a/tests/lib/Files/EtagTest.php b/tests/lib/Files/EtagTest.php
index b9583a6ac7c..a109a17d250 100644
--- a/tests/lib/Files/EtagTest.php
+++ b/tests/lib/Files/EtagTest.php
@@ -1,16 +1,15 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files;
use OC\Files\Filesystem;
-use OCP\EventDispatcher\IEventDispatcher;
use OCA\Files_Sharing\AppInfo\Application;
+use OCP\EventDispatcher\IEventDispatcher;
use Psr\Log\LoggerInterface;
/**
diff --git a/tests/lib/Files/FileInfoTest.php b/tests/lib/Files/FileInfoTest.php
index fd2b506beb9..bc4a25ef622 100644
--- a/tests/lib/Files/FileInfoTest.php
+++ b/tests/lib/Files/FileInfoTest.php
@@ -1,14 +1,14 @@
<?php
/**
- * Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files;
use OC\Files\FileInfo;
+use OC\Files\Mount\HomeMountPoint;
+use OC\Files\Mount\MountPoint;
use OC\Files\Storage\Home;
use OC\Files\Storage\Temporary;
use OCP\IConfig;
@@ -33,19 +33,27 @@ class FileInfoTest extends TestCase {
->willReturn('foo');
$user->method('getHome')
->willReturn('foo');
+ $storage = new Home(['user' => $user]);
$fileInfo = new FileInfo(
'',
- new Home(['user' => $user]),
- '', [], null);
+ $storage,
+ '',
+ [],
+ new HomeMountPoint($user, $storage, '/foo/files')
+ );
$this->assertFalse($fileInfo->isMounted());
}
public function testIsMountedNonHomeStorage() {
+ $storage = new Temporary();
$fileInfo = new FileInfo(
'',
- new Temporary(),
- '', [], null);
+ $storage,
+ '',
+ [],
+ new MountPoint($storage, '/foo/files/bar')
+ );
$this->assertTrue($fileInfo->isMounted());
}
}
diff --git a/tests/lib/Files/FilesystemTest.php b/tests/lib/Files/FilesystemTest.php
index 96fcab77474..4ab0456a810 100644
--- a/tests/lib/Files/FilesystemTest.php
+++ b/tests/lib/Files/FilesystemTest.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Robin Appelman
- * @copyright 2012 Robin Appelman icewind@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files;
@@ -325,14 +310,14 @@ class FilesystemTest extends \Test\TestCase {
$rootView->mkdir('/' . $user);
$rootView->mkdir('/' . $user . '/files');
-// \OC\Files\Filesystem::file_put_contents('/foo', 'foo');
+ // \OC\Files\Filesystem::file_put_contents('/foo', 'foo');
\OC\Files\Filesystem::mkdir('/bar');
-// \OC\Files\Filesystem::file_put_contents('/bar//foo', 'foo');
+ // \OC\Files\Filesystem::file_put_contents('/bar//foo', 'foo');
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
file_put_contents($tmpFile, 'foo');
$fh = fopen($tmpFile, 'r');
-// \OC\Files\Filesystem::file_put_contents('/bar//foo', $fh);
+ // \OC\Files\Filesystem::file_put_contents('/bar//foo', $fh);
}
/**
diff --git a/tests/lib/Files/Mount/CacheMountProviderTest.php b/tests/lib/Files/Mount/CacheMountProviderTest.php
new file mode 100644
index 00000000000..003fc40eafc
--- /dev/null
+++ b/tests/lib/Files/Mount/CacheMountProviderTest.php
@@ -0,0 +1,92 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace Test\Files\Mount;
+
+use OC\Files\Mount\CacheMountProvider;
+use OC\Files\Storage\StorageFactory;
+use OCP\Files\Storage\IStorageFactory;
+use OCP\IConfig;
+use OCP\IUser;
+use Test\TestCase;
+
+class CacheMountProviderTestStream {
+ public static $statCounter = 0;
+ public static $mkdirCounter = 0;
+
+ public $context;
+
+ public function mkdir(string $path, int $mode, int $options): bool {
+ self::$mkdirCounter++;
+ return true;
+ }
+
+ public function url_stat(string $path, int $flags): array|false {
+ self::$statCounter++;
+ return false;
+ }
+}
+
+class CacheMountProviderTest extends TestCase {
+ private IConfig $config;
+ private IUser $user;
+ private IStorageFactory $storageFactory;
+
+ protected function setUp(): void {
+ $this->config = $this->createMock(IConfig::class);
+ $this->user = $this->createMock(IUser::class);
+ $this->storageFactory = new StorageFactory();
+ stream_wrapper_register('cachemountprovidertest', CacheMountProviderTestStream::class);
+ }
+
+ protected function tearDown(): void {
+ stream_wrapper_unregister('cachemountprovidertest');
+ }
+
+ public function testGetMountsForUser(): void {
+ $provider = new CacheMountProvider($this->config);
+
+ $this->assertCount(0, $provider->getMountsForUser($this->user, $this->storageFactory));
+ }
+
+ public function testGetMountsForUserCacheDir(): void {
+ $this->config->expects($this->exactly(1))
+ ->method('getSystemValueString')
+ ->willReturnMap([
+ ['cache_path', '', 'cachemountprovidertest:////cache_path'],
+ ]);
+ $this->user->method('getUID')
+ ->willReturn('bob');
+
+ $provider = new CacheMountProvider($this->config);
+ $mounts = $provider->getMountsForUser($this->user, $this->storageFactory);
+
+ $this->assertCount(2, $mounts);
+ $this->assertEquals(1, CacheMountProviderTestStream::$statCounter);
+ $this->assertEquals(2, CacheMountProviderTestStream::$mkdirCounter);
+
+ $cacheMountProvider = $mounts[0];
+ $this->assertEquals('/bob/cache/', $cacheMountProvider->getMountPoint());
+
+ $cacheStorage = $cacheMountProvider->getStorage();
+ $this->assertEquals('local::cachemountprovidertest://cache_path/bob/', $cacheStorage->getId());
+
+ $uploadsMountProvider = $mounts[1];
+ $this->assertEquals('/bob/uploads/', $uploadsMountProvider->getMountPoint());
+
+ $uploadsStorage = $uploadsMountProvider->getStorage();
+ $this->assertEquals('local::cachemountprovidertest://cache_path/bob/uploads/', $uploadsStorage->getId());
+
+ $cacheStorage->mkdir('foobar');
+ $this->assertEquals(3, CacheMountProviderTestStream::$mkdirCounter);
+
+ $uploadsStorage->mkdir('foobar');
+ $this->assertEquals(4, CacheMountProviderTestStream::$mkdirCounter);
+ }
+}
diff --git a/tests/lib/Files/Mount/ManagerTest.php b/tests/lib/Files/Mount/ManagerTest.php
index f69f8b239bb..f8adb2bf1cf 100644
--- a/tests/lib/Files/Mount/ManagerTest.php
+++ b/tests/lib/Files/Mount/ManagerTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Mount;
diff --git a/tests/lib/Files/Mount/MountPointTest.php b/tests/lib/Files/Mount/MountPointTest.php
index 106a8f9a932..189667df276 100644
--- a/tests/lib/Files/Mount/MountPointTest.php
+++ b/tests/lib/Files/Mount/MountPointTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Mount;
diff --git a/tests/lib/Files/Mount/MountTest.php b/tests/lib/Files/Mount/MountTest.php
index 340e6931c1d..0b4c6a214f3 100644
--- a/tests/lib/Files/Mount/MountTest.php
+++ b/tests/lib/Files/Mount/MountTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Mount;
diff --git a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
index e53069ee2b8..9b6aaeccfeb 100644
--- a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
+++ b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
@@ -1,5 +1,9 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
namespace Test\Files\Mount;
use OC\Files\Mount\ObjectHomeMountProvider;
diff --git a/tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php b/tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php
index da9ba8bacaf..b22224aa7db 100644
--- a/tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php
+++ b/tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020, Morris Jobke <hey@morrisjobke.de>
- *
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Mount;
diff --git a/tests/lib/Files/Mount/RootMountProviderTest.php b/tests/lib/Files/Mount/RootMountProviderTest.php
index e5eaabf93be..4a5048d2863 100644
--- a/tests/lib/Files/Mount/RootMountProviderTest.php
+++ b/tests/lib/Files/Mount/RootMountProviderTest.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2022 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Mount;
diff --git a/tests/lib/Files/Node/FileTest.php b/tests/lib/Files/Node/FileTest.php
index 218e2531727..35c2443aeff 100644
--- a/tests/lib/Files/Node/FileTest.php
+++ b/tests/lib/Files/Node/FileTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Node;
@@ -39,7 +38,7 @@ class FileTest extends NodeTest {
public function testGetContent() {
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$hook = function ($file) {
@@ -69,7 +68,7 @@ class FileTest extends NodeTest {
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
@@ -88,7 +87,7 @@ class FileTest extends NodeTest {
public function testPutContent() {
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
@@ -115,7 +114,7 @@ class FileTest extends NodeTest {
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$this->view->expects($this->once())
@@ -130,7 +129,7 @@ class FileTest extends NodeTest {
public function testGetMimeType() {
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$this->view->expects($this->once())
@@ -154,7 +153,8 @@ class FileTest extends NodeTest {
$this->userMountCache,
$this->logger,
$this->userManager,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->cacheFactory,
);
$hook = function ($file) {
@@ -190,7 +190,8 @@ class FileTest extends NodeTest {
$this->userMountCache,
$this->logger,
$this->userManager,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->cacheFactory,
);
$hooksCalled = 0;
$hook = function ($file) use (&$hooksCalled) {
@@ -230,7 +231,8 @@ class FileTest extends NodeTest {
$this->userMountCache,
$this->logger,
$this->userManager,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->cacheFactory,
);
$hook = function ($file) {
throw new \Exception('Hooks are not supposed to be called');
@@ -256,7 +258,8 @@ class FileTest extends NodeTest {
$this->userMountCache,
$this->logger,
$this->userManager,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->cacheFactory,
);
$hook = function () {
throw new \Exception('Hooks are not supposed to be called');
@@ -282,7 +285,8 @@ class FileTest extends NodeTest {
$this->userMountCache,
$this->logger,
$this->userManager,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->cacheFactory,
);
$hook = function () {
throw new \Exception('Hooks are not supposed to be called');
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php
index 0bcf69c5c13..546c9f84a1a 100644
--- a/tests/lib/Files/Node/FolderTest.php
+++ b/tests/lib/Files/Node/FolderTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Node;
@@ -68,7 +67,7 @@ class FolderTest extends NodeTest {
* @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
*/
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -101,7 +100,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -120,7 +119,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -140,7 +139,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -158,7 +157,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -182,7 +181,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -209,7 +208,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->method('getUser')
->willReturn($this->user);
@@ -226,7 +225,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -253,7 +252,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->method('getUser')
->willReturn($this->user);
@@ -270,7 +269,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->method('getUser')
->willReturn($this->user);
@@ -287,7 +286,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->method('getUser')
->willReturn($this->user);
@@ -328,7 +327,7 @@ class FolderTest extends NodeTest {
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -368,7 +367,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->method('getUser')
->willReturn($this->user);
@@ -408,7 +407,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -478,7 +477,7 @@ class FolderTest extends NodeTest {
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setMethods(['getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
$mount = new MountPoint($storage, '/bar');
@@ -525,7 +524,7 @@ class FolderTest extends NodeTest {
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setMethods(['getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
$mount = new MountPoint($storage, '/bar');
@@ -568,7 +567,7 @@ class FolderTest extends NodeTest {
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setMethods(['getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
$mount = new MountPoint($storage, '/bar');
@@ -610,7 +609,7 @@ class FolderTest extends NodeTest {
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setMethods(['getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
$mount1 = new MountPoint($storage, '/bar');
@@ -672,7 +671,7 @@ class FolderTest extends NodeTest {
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$view->expects($this->any())
@@ -697,7 +696,7 @@ class FolderTest extends NodeTest {
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->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 */
$folderInfo = $this->getMockBuilder(FileInfo::class)
@@ -762,7 +761,7 @@ class FolderTest extends NodeTest {
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->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 */
$folderInfo = $this->getMockBuilder(FileInfo::class)
@@ -826,7 +825,7 @@ class FolderTest extends NodeTest {
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->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 */
$folderInfo = $this->getMockBuilder(FileInfo::class)
@@ -910,7 +909,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
->method('getUser')
diff --git a/tests/lib/Files/Node/HookConnectorTest.php b/tests/lib/Files/Node/HookConnectorTest.php
index 0501c175a5f..7cc2da516bb 100644
--- a/tests/lib/Files/Node/HookConnectorTest.php
+++ b/tests/lib/Files/Node/HookConnectorTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Node;
@@ -13,6 +12,7 @@ use OC\Files\Node\HookConnector;
use OC\Files\Node\Root;
use OC\Files\Storage\Temporary;
use OC\Files\View;
+use OC\Memcache\ArrayCache;
use OCP\EventDispatcher\GenericEvent as APIGenericEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\Node\AbstractNodeEvent;
@@ -30,6 +30,7 @@ use OCP\Files\Events\Node\NodeRenamedEvent;
use OCP\Files\Events\Node\NodeTouchedEvent;
use OCP\Files\Events\Node\NodeWrittenEvent;
use OCP\Files\Node;
+use OCP\ICacheFactory;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
@@ -51,6 +52,8 @@ class HookConnectorTest extends TestCase {
/** @var IEventDispatcher */
protected $eventDispatcher;
+ private LoggerInterface $logger;
+
/** @var View */
private $view;
@@ -67,6 +70,11 @@ class HookConnectorTest extends TestCase {
// this will setup the FS
$this->loginAsUser($this->userId);
$this->registerMount($this->userId, new Temporary(), '/' . $this->userId . '/files/');
+ $cacheFactory = $this->createMock(ICacheFactory::class);
+ $cacheFactory->method('createLocal')
+ ->willReturnCallback(function () {
+ return new ArrayCache();
+ });
$this->view = new View();
$this->root = new Root(
Filesystem::getMountManager(),
@@ -75,9 +83,11 @@ class HookConnectorTest extends TestCase {
\OC::$server->getUserMountCache(),
$this->createMock(LoggerInterface::class),
$this->createMock(IUserManager::class),
- $this->createMock(IEventDispatcher::class)
+ $this->createMock(IEventDispatcher::class),
+ $cacheFactory,
);
$this->eventDispatcher = \OC::$server->query(IEventDispatcher::class);
+ $this->logger = \OC::$server->query(LoggerInterface::class);
}
protected function tearDown(): void {
@@ -143,7 +153,7 @@ class HookConnectorTest extends TestCase {
* @dataProvider viewToNodeProvider
*/
public function testViewToNode(callable $operation, $expectedHook, $expectedLegacyEvent, $expectedEvent) {
- $connector = new HookConnector($this->root, $this->view, $this->eventDispatcher);
+ $connector = new HookConnector($this->root, $this->view, $this->eventDispatcher, $this->logger);
$connector->viewToNode();
$hookCalled = false;
/** @var Node $hookNode */
@@ -212,7 +222,7 @@ class HookConnectorTest extends TestCase {
* @dataProvider viewToNodeProviderCopyRename
*/
public function testViewToNodeCopyRename(callable $operation, $expectedHook, $expectedLegacyEvent, $expectedEvent) {
- $connector = new HookConnector($this->root, $this->view, $this->eventDispatcher);
+ $connector = new HookConnector($this->root, $this->view, $this->eventDispatcher, $this->logger);
$connector->viewToNode();
$hookCalled = false;
/** @var Node $hookSourceNode */
@@ -267,7 +277,7 @@ class HookConnectorTest extends TestCase {
}
public function testPostDeleteMeta() {
- $connector = new HookConnector($this->root, $this->view, $this->eventDispatcher);
+ $connector = new HookConnector($this->root, $this->view, $this->eventDispatcher, $this->logger);
$connector->viewToNode();
$hookCalled = false;
/** @var Node $hookNode */
diff --git a/tests/lib/Files/Node/IntegrationTest.php b/tests/lib/Files/Node/IntegrationTest.php
index 5ef5a134e1b..7d87cdb5dd0 100644
--- a/tests/lib/Files/Node/IntegrationTest.php
+++ b/tests/lib/Files/Node/IntegrationTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Node;
@@ -11,8 +10,10 @@ namespace Test\Files\Node;
use OC\Files\Node\Root;
use OC\Files\Storage\Temporary;
use OC\Files\View;
+use OC\Memcache\ArrayCache;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Mount\IMountManager;
+use OCP\ICacheFactory;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
use Test\Traits\UserTrait;
@@ -52,6 +53,11 @@ class IntegrationTest extends \Test\TestCase {
$user = $this->createUser($this->getUniqueID('user'), '');
$this->loginAsUser($user->getUID());
+ $cacheFactory = $this->createMock(ICacheFactory::class);
+ $cacheFactory->method('createLocal')
+ ->willReturnCallback(function () {
+ return new ArrayCache();
+ });
$this->view = new View();
$this->root = new Root(
@@ -61,7 +67,8 @@ class IntegrationTest extends \Test\TestCase {
\OC::$server->getUserMountCache(),
$this->createMock(LoggerInterface::class),
$this->createMock(IUserManager::class),
- $this->createMock(IEventDispatcher::class)
+ $this->createMock(IEventDispatcher::class),
+ $cacheFactory,
);
$storage = new Temporary([]);
$subStorage = new Temporary([]);
diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php
index b63d287a191..b00d9e1b4de 100644
--- a/tests/lib/Files/Node/NodeTest.php
+++ b/tests/lib/Files/Node/NodeTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Node;
@@ -11,12 +10,14 @@ namespace Test\Files\Node;
use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
use OC\Files\View;
+use OC\Memcache\ArrayCache;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\Storage;
+use OCP\ICacheFactory;
use OCP\IUser;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
@@ -43,6 +44,8 @@ abstract class NodeTest extends \Test\TestCase {
protected $userManager;
/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
protected $eventDispatcher;
+ /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
+ protected $cacheFactory;
protected function setUp(): void {
parent::setUp();
@@ -63,8 +66,13 @@ abstract class NodeTest extends \Test\TestCase {
$this->logger = $this->createMock(LoggerInterface::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
+ $this->cacheFactory = $this->createMock(ICacheFactory::class);
+ $this->cacheFactory->method('createLocal')
+ ->willReturnCallback(function () {
+ return new ArrayCache();
+ });
$this->root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->eventDispatcher])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
}
@@ -174,7 +182,8 @@ abstract class NodeTest extends \Test\TestCase {
$this->userMountCache,
$this->logger,
$this->userManager,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->cacheFactory,
);
$root->listen('\OC\Files', 'preDelete', $preListener);
@@ -422,7 +431,8 @@ abstract class NodeTest extends \Test\TestCase {
$this->userMountCache,
$this->logger,
$this->userManager,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->cacheFactory,
);
$root->listen('\OC\Files', 'preTouch', $preListener);
$root->listen('\OC\Files', 'postTouch', $postListener);
@@ -481,8 +491,7 @@ abstract class NodeTest extends \Test\TestCase {
$parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar');
$newNode = $this->createTestNode($this->root, $this->view, '/bar/asd');
- $this->root->expects($this->exactly(2))
- ->method('get')
+ $this->root->method('get')
->willReturnMap([
['/bar/asd', $newNode],
['/bar', $parentNode]
@@ -600,7 +609,7 @@ abstract class NodeTest extends \Test\TestCase {
public function testMoveCopyHooks($operationMethod, $viewMethod, $preHookName, $postHookName) {
/** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->setMethods(['get'])
->getMock();
diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php
index aab658c3c36..9b3139cf78b 100644
--- a/tests/lib/Files/Node/RootTest.php
+++ b/tests/lib/Files/Node/RootTest.php
@@ -1,19 +1,20 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Node;
-use OCP\Cache\CappedMemoryCache;
use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
use OC\Files\Node\Folder;
use OC\Files\View;
+use OC\Memcache\ArrayCache;
+use OCP\Cache\CappedMemoryCache;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\ICacheFactory;
use OCP\IUser;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
@@ -36,6 +37,8 @@ class RootTest extends \Test\TestCase {
private $userManager;
/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
private $eventDispatcher;
+ /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
+ protected $cacheFactory;
protected function setUp(): void {
parent::setUp();
@@ -50,6 +53,11 @@ class RootTest extends \Test\TestCase {
$this->logger = $this->createMock(LoggerInterface::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
+ $this->cacheFactory = $this->createMock(ICacheFactory::class);
+ $this->cacheFactory->method('createLocal')
+ ->willReturnCallback(function () {
+ return new ArrayCache();
+ });
}
/**
@@ -82,7 +90,8 @@ class RootTest extends \Test\TestCase {
$this->userMountCache,
$this->logger,
$this->userManager,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->cacheFactory,
);
$view->expects($this->once())
@@ -114,7 +123,8 @@ class RootTest extends \Test\TestCase {
$this->userMountCache,
$this->logger,
$this->userManager,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->cacheFactory,
);
$view->expects($this->once())
@@ -138,7 +148,8 @@ class RootTest extends \Test\TestCase {
$this->userMountCache,
$this->logger,
$this->userManager,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->cacheFactory,
);
$root->get('/../foo');
@@ -156,7 +167,8 @@ class RootTest extends \Test\TestCase {
$this->userMountCache,
$this->logger,
$this->userManager,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->cacheFactory,
);
$root->get('/bar/foo');
@@ -170,7 +182,8 @@ class RootTest extends \Test\TestCase {
$this->userMountCache,
$this->logger,
$this->userManager,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->cacheFactory,
);
$user = $this->createMock(IUser::class);
$user
@@ -211,7 +224,8 @@ class RootTest extends \Test\TestCase {
$this->userMountCache,
$this->logger,
$this->userManager,
- $this->eventDispatcher
+ $this->eventDispatcher,
+ $this->cacheFactory,
);
$this->userManager
->expects($this->once())
diff --git a/tests/lib/Files/ObjectStore/AzureTest.php b/tests/lib/Files/ObjectStore/AzureTest.php
index 054dc36cce4..5d4234532a6 100644
--- a/tests/lib/Files/ObjectStore/AzureTest.php
+++ b/tests/lib/Files/ObjectStore/AzureTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\ObjectStore;
diff --git a/tests/lib/Files/ObjectStore/FailDeleteObjectStore.php b/tests/lib/Files/ObjectStore/FailDeleteObjectStore.php
index 5160abe574f..b84ee1a1b64 100644
--- a/tests/lib/Files/ObjectStore/FailDeleteObjectStore.php
+++ b/tests/lib/Files/ObjectStore/FailDeleteObjectStore.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\ObjectStore;
@@ -40,7 +25,7 @@ class FailDeleteObjectStore implements IObjectStore {
return $this->objectStore->readObject($urn);
}
- public function writeObject($urn, $stream, string $mimetype = null) {
+ public function writeObject($urn, $stream, ?string $mimetype = null) {
return $this->objectStore->writeObject($urn, $stream, $mimetype);
}
diff --git a/tests/lib/Files/ObjectStore/FailWriteObjectStore.php b/tests/lib/Files/ObjectStore/FailWriteObjectStore.php
index 559d004cd0c..b84b123244e 100644
--- a/tests/lib/Files/ObjectStore/FailWriteObjectStore.php
+++ b/tests/lib/Files/ObjectStore/FailWriteObjectStore.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\ObjectStore;
@@ -40,7 +25,7 @@ class FailWriteObjectStore implements IObjectStore {
return $this->objectStore->readObject($urn);
}
- public function writeObject($urn, $stream, string $mimetype = null) {
+ public function writeObject($urn, $stream, ?string $mimetype = null) {
// emulate a failed write that didn't throw an error
return true;
}
diff --git a/tests/lib/Files/ObjectStore/LocalTest.php b/tests/lib/Files/ObjectStore/LocalTest.php
index ceb21428e4b..99c5b61534f 100644
--- a/tests/lib/Files/ObjectStore/LocalTest.php
+++ b/tests/lib/Files/ObjectStore/LocalTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\ObjectStore;
diff --git a/tests/lib/Files/ObjectStore/MapperTest.php b/tests/lib/Files/ObjectStore/MapperTest.php
index dbe5fe5d32f..19269f13355 100644
--- a/tests/lib/Files/ObjectStore/MapperTest.php
+++ b/tests/lib/Files/ObjectStore/MapperTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Files\ObjectStore;
diff --git a/tests/lib/Files/ObjectStore/ObjectStoreScannerTest.php b/tests/lib/Files/ObjectStore/ObjectStoreScannerTest.php
index 02d72defa92..425dc8c2581 100644
--- a/tests/lib/Files/ObjectStore/ObjectStoreScannerTest.php
+++ b/tests/lib/Files/ObjectStore/ObjectStoreScannerTest.php
@@ -1,13 +1,7 @@
<?php
/**
- * ownCloud
- *
- * @author Joas Schilling
- * @copyright 2015 Joas Schilling nickvergessen@owncloud.com
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\ObjectStore;
diff --git a/tests/lib/Files/ObjectStore/ObjectStoreStorageOverwrite.php b/tests/lib/Files/ObjectStore/ObjectStoreStorageOverwrite.php
index b85f6289c94..6eaffb6961c 100644
--- a/tests/lib/Files/ObjectStore/ObjectStoreStorageOverwrite.php
+++ b/tests/lib/Files/ObjectStore/ObjectStoreStorageOverwrite.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\ObjectStore;
@@ -30,7 +15,7 @@ use OCP\Files\ObjectStore\IObjectStore;
* Allow overwriting the object store instance for test purposes
*/
class ObjectStoreStorageOverwrite extends ObjectStoreStorage {
- public function setObjectStore(IObjectStore $objectStore) {
+ public function setObjectStore(IObjectStore $objectStore): void {
$this->objectStore = $objectStore;
}
@@ -38,7 +23,7 @@ class ObjectStoreStorageOverwrite extends ObjectStoreStorage {
return $this->objectStore;
}
- public function setValidateWrites(bool $validate) {
+ public function setValidateWrites(bool $validate): void {
$this->validateWrites = $validate;
}
}
diff --git a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php
index 1bebaf6c4ba..8ffd27f0069 100644
--- a/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php
+++ b/tests/lib/Files/ObjectStore/ObjectStoreStorageTest.php
@@ -1,21 +1,8 @@
<?php
/**
- * @author Jörn Friedrich Dreyer
- * @copyright (c) 2014 Jörn Friedrich Dreyer <jfd@owncloud.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\ObjectStore;
@@ -237,4 +224,42 @@ class ObjectStoreStorageTest extends Storage {
$this->assertEquals('2', $this->instance->file_get_contents('b/target/sub/2.txt'));
$this->assertEquals('3', $this->instance->file_get_contents('b/target/sub/3.txt'));
}
+
+ public function testCopyPreservesPermissions() {
+ $cache = $this->instance->getCache();
+
+ $this->instance->file_put_contents('test.txt', 'foo');
+ $this->assertTrue($cache->inCache('test.txt'));
+
+ $cache->update($cache->getId('test.txt'), ['permissions' => \OCP\Constants::PERMISSION_READ]);
+ $this->assertEquals(\OCP\Constants::PERMISSION_READ, $this->instance->getPermissions('test.txt'));
+
+ $this->assertTrue($this->instance->copy('test.txt', 'new.txt'));
+
+ $this->assertTrue($cache->inCache('new.txt'));
+ $this->assertEquals(\OCP\Constants::PERMISSION_READ, $this->instance->getPermissions('new.txt'));
+ }
+
+ /**
+ * Test that copying files will drop permissions like local storage does
+ * TODO: Drop this and fix local storage
+ */
+ public function testCopyGrantsPermissions() {
+ $config['objectstore'] = $this->objectStorage;
+ $config['handleCopiesAsOwned'] = true;
+ $instance = new ObjectStoreStorageOverwrite($config);
+
+ $cache = $instance->getCache();
+
+ $instance->file_put_contents('test.txt', 'foo');
+ $this->assertTrue($cache->inCache('test.txt'));
+
+ $cache->update($cache->getId('test.txt'), ['permissions' => \OCP\Constants::PERMISSION_READ]);
+ $this->assertEquals(\OCP\Constants::PERMISSION_READ, $instance->getPermissions('test.txt'));
+
+ $this->assertTrue($instance->copy('test.txt', 'new.txt'));
+
+ $this->assertTrue($cache->inCache('new.txt'));
+ $this->assertEquals(\OCP\Constants::PERMISSION_ALL, $instance->getPermissions('new.txt'));
+ }
}
diff --git a/tests/lib/Files/ObjectStore/ObjectStoreTest.php b/tests/lib/Files/ObjectStore/ObjectStoreTest.php
index c5580e4a2bf..74f047a8663 100644
--- a/tests/lib/Files/ObjectStore/ObjectStoreTest.php
+++ b/tests/lib/Files/ObjectStore/ObjectStoreTest.php
@@ -1,23 +1,8 @@
<?php
/**
- * @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\ObjectStore;
diff --git a/tests/lib/Files/ObjectStore/S3Test.php b/tests/lib/Files/ObjectStore/S3Test.php
index fd451dc3c01..cc3e91a4586 100644
--- a/tests/lib/Files/ObjectStore/S3Test.php
+++ b/tests/lib/Files/ObjectStore/S3Test.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\ObjectStore;
@@ -25,7 +10,7 @@ use Icewind\Streams\Wrapper;
use OC\Files\ObjectStore\S3;
class MultiPartUploadS3 extends S3 {
- public function writeObject($urn, $stream, string $mimetype = null) {
+ public function writeObject($urn, $stream, ?string $mimetype = null) {
$this->getConnection()->upload($this->bucket, $urn, $stream, 'private', [
'mup_threshold' => 1,
]);
@@ -106,29 +91,30 @@ class S3Test extends ObjectStoreTest {
}
public function assertNoUpload($objectUrn) {
+ /** @var \OC\Files\ObjectStore\S3 */
$s3 = $this->getInstance();
$s3client = $s3->getConnection();
$uploads = $s3client->listMultipartUploads([
'Bucket' => $s3->getBucket(),
'Prefix' => $objectUrn,
]);
- $this->assertArrayNotHasKey('Uploads', $uploads);
+ $this->assertArrayNotHasKey('Uploads', $uploads, 'Assert is not uploaded');
}
public function testEmptyUpload() {
$s3 = $this->getInstance();
$emptyStream = fopen("php://memory", "r");
- fwrite($emptyStream, null);
+ fwrite($emptyStream, '');
$s3->writeObject('emptystream', $emptyStream);
$this->assertNoUpload('emptystream');
- $this->assertTrue($s3->objectExists('emptystream'));
+ $this->assertTrue($s3->objectExists('emptystream'), 'Object exists on S3');
$thrown = false;
try {
- self::assertFalse($s3->readObject('emptystream'));
+ self::assertFalse($s3->readObject('emptystream'), 'Reading empty stream object should return false');
} catch (\Exception $e) {
// An exception is expected here since 0 byte files are wrapped
// to be read from an empty memory stream in the ObjectStoreStorage
@@ -163,20 +149,20 @@ class S3Test extends ObjectStoreTest {
$s3->writeObject('testfilesizes', $sourceStream);
$this->assertNoUpload('testfilesizes');
- self::assertTrue($s3->objectExists('testfilesizes'));
+ self::assertTrue($s3->objectExists('testfilesizes'), 'Object exists on S3');
$result = $s3->readObject('testfilesizes');
// compare first 100 bytes
- self::assertEquals(str_repeat('A', 100), fread($result, 100));
+ self::assertEquals(str_repeat('A', 100), fread($result, 100), 'Compare first 100 bytes');
- // compare 100 bytes
+ // compare last 100 bytes
fseek($result, $size - 100);
- self::assertEquals(str_repeat('A', 100), fread($result, 100));
+ self::assertEquals(str_repeat('A', 100), fread($result, 100), 'Compare last 100 bytes');
// end of file reached
fseek($result, $size);
- self::assertTrue(feof($result));
+ self::assertTrue(feof($result), 'End of file reached');
$this->assertNoUpload('testfilesizes');
}
diff --git a/tests/lib/Files/ObjectStore/SwiftTest.php b/tests/lib/Files/ObjectStore/SwiftTest.php
index 1ea55a84628..8c9a0d524ed 100644
--- a/tests/lib/Files/ObjectStore/SwiftTest.php
+++ b/tests/lib/Files/ObjectStore/SwiftTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\ObjectStore;
@@ -38,4 +24,8 @@ class SwiftTest extends ObjectStoreTest {
return new Swift($config['arguments']);
}
+
+ public function testFseekSize() {
+ $this->markTestSkipped('Swift does not support seeking at the moment');
+ }
}
diff --git a/tests/lib/Files/PathVerificationTest.php b/tests/lib/Files/PathVerificationTest.php
index ededab14d0b..4addd583354 100644
--- a/tests/lib/Files/PathVerificationTest.php
+++ b/tests/lib/Files/PathVerificationTest.php
@@ -1,9 +1,9 @@
<?php
/**
- * Copyright (c) 2015 Thomas Müller <deepdiver@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file. */
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
namespace Test\Files;
diff --git a/tests/lib/Files/Search/QueryOptimizer/CombinedTests.php b/tests/lib/Files/Search/QueryOptimizer/CombinedTests.php
new file mode 100644
index 00000000000..5c7c01da926
--- /dev/null
+++ b/tests/lib/Files/Search/QueryOptimizer/CombinedTests.php
@@ -0,0 +1,194 @@
+<?php
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace Test\Files\Search\QueryOptimizer;
+
+use OC\Files\Search\QueryOptimizer\QueryOptimizer;
+use OC\Files\Search\SearchBinaryOperator;
+use OC\Files\Search\SearchComparison;
+use OCP\Files\Search\ISearchBinaryOperator;
+use OCP\Files\Search\ISearchComparison;
+use Test\TestCase;
+
+class CombinedTests extends TestCase {
+ private QueryOptimizer $optimizer;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->optimizer = new QueryOptimizer();
+ }
+
+ public function testBasicOrOfAnds() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "asd"),
+ ])
+ ]
+ );
+ $this->assertEquals('((storage eq 1 and path eq "foo") or (storage eq 1 and path eq "bar") or (storage eq 1 and path eq "asd"))', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+
+ $this->assertEquals('(storage eq 1 and path in ["foo","bar","asd"])', $operator->__toString());
+ }
+
+ public function testComplexSearchPattern1() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 2),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "201"),
+ new SearchComparison(ISearchComparison::COMPARE_LIKE, "path", "201/%"),
+ ]),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 3),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "301"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 4),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "401"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 3),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "302"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 4),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "402"),
+ ]),
+ ]
+ );
+ $this->assertEquals('((storage eq 1) or (storage eq 2 and (path eq "201" or path like "201\/%")) or (storage eq 3 and path eq "301") or (storage eq 4 and path eq "401") or (storage eq 3 and path eq "302") or (storage eq 4 and path eq "402"))', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+
+ $this->assertEquals('(storage eq 1 or (storage eq 2 and (path eq "201" or path like "201\/%")) or (storage eq 3 and path in ["301","302"]) or (storage eq 4 and path in ["401","402"]))', $operator->__toString());
+ }
+
+ public function testComplexSearchPattern2() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 2),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "201"),
+ new SearchComparison(ISearchComparison::COMPARE_LIKE, "path", "201/%"),
+ ]),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 3),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "301"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 4),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "401"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 3),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "302"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 4),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "402"),
+ ]),
+ ]
+ );
+ $this->assertEquals('(storage eq 1 or (storage eq 2 and (path eq "201" or path like "201\/%")) or (storage eq 3 and path eq "301") or (storage eq 4 and path eq "401") or (storage eq 3 and path eq "302") or (storage eq 4 and path eq "402"))', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+
+ $this->assertEquals('(storage eq 1 or (storage eq 2 and (path eq "201" or path like "201\/%")) or (storage eq 3 and path in ["301","302"]) or (storage eq 4 and path in ["401","402"]))', $operator->__toString());
+ }
+
+ public function testApplySearchConstraints1() {
+ $operator = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "mimetype", "image/png"),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "mimetype", "image/jpeg"),
+ ]),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "files"),
+ new SearchComparison(ISearchComparison::COMPARE_LIKE, "path", "files/%"),
+ ]),
+ ]),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 2),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 3),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "files/301"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 3),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "files/302"),
+ ]),
+ ]),
+ ]);
+ $this->assertEquals('(((mimetype eq "image\/png" or mimetype eq "image\/jpeg")) and ((storage eq 1 and (path eq "files" or path like "files\/%")) or storage eq 2 or (storage eq 3 and path eq "files\/301") or (storage eq 3 and path eq "files\/302")))', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+
+ $this->assertEquals('(mimetype in ["image\/png","image\/jpeg"] and ((storage eq 1 and (path eq "files" or path like "files\/%")) or storage eq 2 or (storage eq 3 and path in ["files\/301","files\/302"])))', $operator->__toString());
+ }
+
+ public function testApplySearchConstraints2() {
+ $operator = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "mimetype", "image/png"),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "mimetype", "image/jpeg"),
+ ]),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "files"),
+ new SearchComparison(ISearchComparison::COMPARE_LIKE, "path", "files/%"),
+ ]),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 2),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 3),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "files/301"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 3),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "files/302"),
+ ]),
+ ]),
+ ]);
+ $this->assertEquals('(((mimetype eq "image\/png" or mimetype eq "image\/jpeg")) and ((storage eq 1 and (path eq "files" or path like "files\/%")) or (storage eq 2) or (storage eq 3 and path eq "files\/301") or (storage eq 3 and path eq "files\/302")))', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+
+ $this->assertEquals('(mimetype in ["image\/png","image\/jpeg"] and ((storage eq 1 and (path eq "files" or path like "files\/%")) or storage eq 2 or (storage eq 3 and path in ["files\/301","files\/302"])))', $operator->__toString());
+ }
+}
diff --git a/tests/lib/Files/Search/QueryOptimizer/FlattenNestedBoolTest.php b/tests/lib/Files/Search/QueryOptimizer/FlattenNestedBoolTest.php
new file mode 100644
index 00000000000..538ffc65f02
--- /dev/null
+++ b/tests/lib/Files/Search/QueryOptimizer/FlattenNestedBoolTest.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace Test\Files\Search\QueryOptimizer;
+
+use OC\Files\Search\QueryOptimizer\FlattenNestedBool;
+use OC\Files\Search\QueryOptimizer\FlattenSingleArgumentBinaryOperation;
+use OC\Files\Search\SearchBinaryOperator;
+use OC\Files\Search\SearchComparison;
+use OCP\Files\Search\ISearchBinaryOperator;
+use OCP\Files\Search\ISearchComparison;
+use Test\TestCase;
+
+class FlattenNestedBoolTest extends TestCase {
+ private $optimizer;
+ private $simplifier;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->optimizer = new FlattenNestedBool();
+ $this->simplifier = new FlattenSingleArgumentBinaryOperation();
+ }
+
+ public function testOrs() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "asd"),
+ ])
+ ]
+ );
+ $this->assertEquals('(path eq "foo" or (path eq "bar" or path eq "asd"))', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+ $this->simplifier->processOperator($operator);
+
+ $this->assertEquals('(path eq "foo" or path eq "bar" or path eq "asd")', $operator->__toString());
+ }
+}
diff --git a/tests/lib/Files/Search/QueryOptimizer/MergeDistributiveOperationsTest.php b/tests/lib/Files/Search/QueryOptimizer/MergeDistributiveOperationsTest.php
new file mode 100644
index 00000000000..abc9eca9a54
--- /dev/null
+++ b/tests/lib/Files/Search/QueryOptimizer/MergeDistributiveOperationsTest.php
@@ -0,0 +1,163 @@
+<?php
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace Test\Files\Search\QueryOptimizer;
+
+use OC\Files\Search\QueryOptimizer\FlattenSingleArgumentBinaryOperation;
+use OC\Files\Search\QueryOptimizer\MergeDistributiveOperations;
+use OC\Files\Search\SearchBinaryOperator;
+use OC\Files\Search\SearchComparison;
+use OCP\Files\Search\ISearchBinaryOperator;
+use OCP\Files\Search\ISearchComparison;
+use Test\TestCase;
+
+class MergeDistributiveOperationsTest extends TestCase {
+ private $optimizer;
+ private $simplifier;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->optimizer = new MergeDistributiveOperations();
+ $this->simplifier = new FlattenSingleArgumentBinaryOperation();
+ }
+
+ public function testBasicOrOfAnds() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "asd"),
+ ])
+ ]
+ );
+ $this->assertEquals('((storage eq 1 and path eq "foo") or (storage eq 1 and path eq "bar") or (storage eq 1 and path eq "asd"))', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+ $this->simplifier->processOperator($operator);
+
+ $this->assertEquals('(storage eq 1 and (path eq "foo" or path eq "bar" or path eq "asd"))', $operator->__toString());
+ }
+
+ public function testDontTouchIfNotSame() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 2),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 3),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "asd"),
+ ])
+ ]
+ );
+ $this->assertEquals('((storage eq 1 and path eq "foo") or (storage eq 2 and path eq "bar") or (storage eq 3 and path eq "asd"))', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+ $this->simplifier->processOperator($operator);
+
+ $this->assertEquals('((storage eq 1 and path eq "foo") or (storage eq 2 and path eq "bar") or (storage eq 3 and path eq "asd"))', $operator->__toString());
+ }
+
+ public function testMergePartial() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 2),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "asd"),
+ ])
+ ]
+ );
+ $this->assertEquals('((storage eq 1 and path eq "foo") or (storage eq 1 and path eq "bar") or (storage eq 2 and path eq "asd"))', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+ $this->simplifier->processOperator($operator);
+
+ $this->assertEquals('((storage eq 1 and (path eq "foo" or path eq "bar")) or (storage eq 2 and path eq "asd"))', $operator->__toString());
+ }
+
+ public function testOptimizeInside() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_AND,
+ [
+ new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "asd"),
+ ])
+ ]
+ ),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "mimetype", "text")
+ ]
+ );
+ $this->assertEquals('(((storage eq 1 and path eq "foo") or (storage eq 1 and path eq "bar") or (storage eq 1 and path eq "asd")) and mimetype eq "text")', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+ $this->simplifier->processOperator($operator);
+
+ $this->assertEquals('((storage eq 1 and (path eq "foo" or path eq "bar" or path eq "asd")) and mimetype eq "text")', $operator->__toString());
+ }
+
+ public function testMoveInnerOperations() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"),
+ ]),
+ new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "asd"),
+ new SearchComparison(ISearchComparison::COMPARE_GREATER_THAN, "size", "100"),
+ ])
+ ]
+ );
+ $this->assertEquals('((storage eq 1 and path eq "foo") or (storage eq 1 and path eq "bar") or (storage eq 1 and path eq "asd" and size gt "100"))', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+ $this->simplifier->processOperator($operator);
+
+ $this->assertEquals('(storage eq 1 and (path eq "foo" or path eq "bar" or (path eq "asd" and size gt "100")))', $operator->__toString());
+ }
+}
diff --git a/tests/lib/Files/Search/QueryOptimizer/OrEqualsToInTest.php b/tests/lib/Files/Search/QueryOptimizer/OrEqualsToInTest.php
new file mode 100644
index 00000000000..5ea27eb88b9
--- /dev/null
+++ b/tests/lib/Files/Search/QueryOptimizer/OrEqualsToInTest.php
@@ -0,0 +1,123 @@
+<?php
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace Test\Files\Search\QueryOptimizer;
+
+use OC\Files\Search\QueryOptimizer\FlattenSingleArgumentBinaryOperation;
+use OC\Files\Search\QueryOptimizer\OrEqualsToIn;
+use OC\Files\Search\SearchBinaryOperator;
+use OC\Files\Search\SearchComparison;
+use OCP\Files\Search\ISearchBinaryOperator;
+use OCP\Files\Search\ISearchComparison;
+use Test\TestCase;
+
+class OrEqualsToInTest extends TestCase {
+ private $optimizer;
+ private $simplifier;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->optimizer = new OrEqualsToIn();
+ $this->simplifier = new FlattenSingleArgumentBinaryOperation();
+ }
+
+ public function testOrs() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "asd"),
+ ]
+ );
+ $this->assertEquals('(path eq "foo" or path eq "bar" or path eq "asd")', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+ $this->simplifier->processOperator($operator);
+
+ $this->assertEquals('path in ["foo","bar","asd"]', $operator->__toString());
+ }
+
+ public function testOrsMultipleFields() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "fileid", 1),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "fileid", 2),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "mimetype", "asd"),
+ ]
+ );
+ $this->assertEquals('(path eq "foo" or path eq "bar" or fileid eq 1 or fileid eq 2 or mimetype eq "asd")', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+ $this->simplifier->processOperator($operator);
+
+ $this->assertEquals('(path in ["foo","bar"] or fileid in [1,2] or mimetype eq "asd")', $operator->__toString());
+ }
+
+ public function testPreserveHints() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "asd"),
+ ]
+ );
+ foreach ($operator->getArguments() as $argument) {
+ $argument->setQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, false);
+ }
+ $this->assertEquals('(path eq "foo" or path eq "bar" or path eq "asd")', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+ $this->simplifier->processOperator($operator);
+
+ $this->assertEquals('path in ["foo","bar","asd"]', $operator->__toString());
+ $this->assertEquals(false, $operator->getQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, true));
+ }
+
+ public function testOrSomeEq() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"),
+ new SearchComparison(ISearchComparison::COMPARE_LIKE, "path", "foo%"),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"),
+ ]
+ );
+ $this->assertEquals('(path eq "foo" or path like "foo%" or path eq "bar")', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+ $this->simplifier->processOperator($operator);
+
+ $this->assertEquals('(path in ["foo","bar"] or path like "foo%")', $operator->__toString());
+ }
+
+ public function testOrsInside() {
+ $operator = new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_AND,
+ [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "mimetype", "text"),
+ new SearchBinaryOperator(
+ ISearchBinaryOperator::OPERATOR_OR,
+ [
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"),
+ new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "asd"),
+ ]
+ )
+ ]
+ );
+ $this->assertEquals('(mimetype eq "text" and (path eq "foo" or path eq "bar" or path eq "asd"))', $operator->__toString());
+
+ $this->optimizer->processOperator($operator);
+ $this->simplifier->processOperator($operator);
+
+ $this->assertEquals('(mimetype eq "text" and path in ["foo","bar","asd"])', $operator->__toString());
+ }
+}
diff --git a/tests/lib/Files/Search/SearchIntegrationTest.php b/tests/lib/Files/Search/SearchIntegrationTest.php
new file mode 100644
index 00000000000..b24f927219e
--- /dev/null
+++ b/tests/lib/Files/Search/SearchIntegrationTest.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace Test\Files\Search;
+
+use OC\Files\Search\SearchBinaryOperator;
+use OC\Files\Search\SearchComparison;
+use OC\Files\Search\SearchQuery;
+use OC\Files\Storage\Temporary;
+use OCP\Files\Search\ISearchBinaryOperator;
+use OCP\Files\Search\ISearchComparison;
+use Test\TestCase;
+
+/**
+ * @group DB
+ */
+class SearchIntegrationTest extends TestCase {
+ private $cache;
+ private $storage;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->storage = new Temporary([]);
+ $this->cache = $this->storage->getCache();
+ $this->storage->getScanner()->scan('');
+ }
+
+
+ public function testThousandAndOneFilters() {
+ $id = $this->cache->put("file10", ['size' => 1, 'mtime' => 50, 'mimetype' => 'foo/folder']);
+
+ $comparisons = [];
+ for($i = 1; $i <= 1001; $i++) {
+ $comparisons[] = new SearchComparison(ISearchComparison::COMPARE_EQUAL, "name", "file$i");
+ }
+ $operator = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, $comparisons);
+ $query = new SearchQuery($operator, 10, 0, []);
+
+ $results = $this->cache->searchQuery($query);
+
+ $this->assertCount(1, $results);
+ $this->assertEquals($id, $results[0]->getId());
+ }
+}
diff --git a/tests/lib/Files/SimpleFS/InMemoryFileTest.php b/tests/lib/Files/SimpleFS/InMemoryFileTest.php
index 0ba1a9ddc9f..dfd6c44ac7e 100644
--- a/tests/lib/Files/SimpleFS/InMemoryFileTest.php
+++ b/tests/lib/Files/SimpleFS/InMemoryFileTest.php
@@ -3,23 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018, Michael Weimann <mail@michael-weimann.eu>
- *
- * @author Michael Weimann <mail@michael-weimann.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\File\SimpleFS;
diff --git a/tests/lib/Files/SimpleFS/SimpleFileTest.php b/tests/lib/Files/SimpleFS/SimpleFileTest.php
index def570edf99..6dbd663068e 100644
--- a/tests/lib/Files/SimpleFS/SimpleFileTest.php
+++ b/tests/lib/Files/SimpleFS/SimpleFileTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\File\SimpleFS;
diff --git a/tests/lib/Files/SimpleFS/SimpleFolderTest.php b/tests/lib/Files/SimpleFS/SimpleFolderTest.php
index 9710b6f438b..139a6cb703c 100644
--- a/tests/lib/Files/SimpleFS/SimpleFolderTest.php
+++ b/tests/lib/Files/SimpleFS/SimpleFolderTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\File\SimpleFS;
diff --git a/tests/lib/Files/Storage/CommonTest.php b/tests/lib/Files/Storage/CommonTest.php
index 0900765c510..bd22d93fb69 100644
--- a/tests/lib/Files/Storage/CommonTest.php
+++ b/tests/lib/Files/Storage/CommonTest.php
@@ -1,29 +1,15 @@
<?php
/**
- * ownCloud
- *
- * @author Robin Appelman
- * @copyright 2012 Robin Appelman icewind@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Storage;
use OC\Files\Storage\Wrapper\Jail;
use OC\Files\Storage\Wrapper\Wrapper;
+use OCP\Files\InvalidPathException;
use PHPUnit\Framework\MockObject\MockObject;
/**
@@ -39,22 +25,66 @@ class CommonTest extends Storage {
*/
private $tmpDir;
+ private array $invalidCharsBackup;
+
protected function setUp(): void {
parent::setUp();
$this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
$this->instance = new \OC\Files\Storage\CommonTest(['datadir' => $this->tmpDir]);
+ $this->invalidCharsBackup = \OC::$server->getConfig()->getSystemValue('forbidden_chars', []);
}
protected function tearDown(): void {
\OC_Helper::rmdirr($this->tmpDir);
+ \OC::$server->getConfig()->setSystemValue('forbidden_chars', $this->invalidCharsBackup);
parent::tearDown();
}
+ /**
+ * @dataProvider dataVerifyPath
+ */
+ public function testVerifyPath(string $filename, array $additionalChars, bool $throws) {
+ /** @var \OC\Files\Storage\CommonTest|MockObject $instance */
+ $instance = $this->getMockBuilder(\OC\Files\Storage\CommonTest::class)
+ ->onlyMethods(['copyFromStorage', 'rmdir', 'unlink'])
+ ->setConstructorArgs([['datadir' => $this->tmpDir]])
+ ->getMock();
+ $instance->method('copyFromStorage')
+ ->willThrowException(new \Exception('copy'));
+
+ \OC::$server->getConfig()->setSystemValue('forbidden_chars', $additionalChars);
+
+ if ($throws) {
+ $this->expectException(InvalidPathException::class);
+ } else {
+ $this->expectNotToPerformAssertions();
+ }
+ $instance->verifyPath('/', $filename);
+ }
+
+ public function dataVerifyPath(): array {
+ return [
+ // slash is always forbidden
+ 'invalid slash' => ['a/b.txt', [], true],
+ // backslash is also forbidden
+ 'invalid backslash' => ['a\\b.txt', [], true],
+ // by default colon is not forbidden
+ 'valid name' => ['a: b.txt', [], false],
+ // colon can be added to the list of forbidden character
+ 'invalid custom character' => ['a: b.txt', [':'], true],
+ // make sure to not split the list entries as they migh contain Unicode sequences
+ // in this example the "face in clouds" emoji contains the clouds emoji so only having clouds is ok
+ 'valid unicode sequence' => ['🌫️.txt', ['😶‍🌫️'], false],
+ // This is the reverse: clouds are forbidden -> so is also the face in the clouds emoji
+ 'valid unicode sequence' => ['😶‍🌫️.txt', ['🌫️'], true],
+ ];
+ }
+
public function testMoveFromStorageWrapped() {
/** @var \OC\Files\Storage\CommonTest|MockObject $instance */
$instance = $this->getMockBuilder(\OC\Files\Storage\CommonTest::class)
- ->setMethods(['copyFromStorage', 'rmdir', 'unlink'])
+ ->onlyMethods(['copyFromStorage', 'rmdir', 'unlink'])
->setConstructorArgs([['datadir' => $this->tmpDir]])
->getMock();
$instance->method('copyFromStorage')
@@ -72,7 +102,7 @@ class CommonTest extends Storage {
public function testMoveFromStorageJailed() {
/** @var \OC\Files\Storage\CommonTest|MockObject $instance */
$instance = $this->getMockBuilder(\OC\Files\Storage\CommonTest::class)
- ->setMethods(['copyFromStorage', 'rmdir', 'unlink'])
+ ->onlyMethods(['copyFromStorage', 'rmdir', 'unlink'])
->setConstructorArgs([['datadir' => $this->tmpDir]])
->getMock();
$instance->method('copyFromStorage')
@@ -95,7 +125,7 @@ class CommonTest extends Storage {
public function testMoveFromStorageNestedJail() {
/** @var \OC\Files\Storage\CommonTest|MockObject $instance */
$instance = $this->getMockBuilder(\OC\Files\Storage\CommonTest::class)
- ->setMethods(['copyFromStorage', 'rmdir', 'unlink'])
+ ->onlyMethods(['copyFromStorage', 'rmdir', 'unlink'])
->setConstructorArgs([['datadir' => $this->tmpDir]])
->getMock();
$instance->method('copyFromStorage')
diff --git a/tests/lib/Files/Storage/CopyDirectoryTest.php b/tests/lib/Files/Storage/CopyDirectoryTest.php
index 25bdb016ead..6133361c626 100644
--- a/tests/lib/Files/Storage/CopyDirectoryTest.php
+++ b/tests/lib/Files/Storage/CopyDirectoryTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Robin Appelman <icewind@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Files\Storage;
diff --git a/tests/lib/Files/Storage/HomeTest.php b/tests/lib/Files/Storage/HomeTest.php
index d5feb40840f..c3111e74259 100644
--- a/tests/lib/Files/Storage/HomeTest.php
+++ b/tests/lib/Files/Storage/HomeTest.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Robin Appelman
- * @copyright 2012 Robin Appelman icewind@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Storage;
diff --git a/tests/lib/Files/Storage/LocalTest.php b/tests/lib/Files/Storage/LocalTest.php
index e324d2b28db..efe5dd04e47 100644
--- a/tests/lib/Files/Storage/LocalTest.php
+++ b/tests/lib/Files/Storage/LocalTest.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Robin Appelman
- * @copyright 2012 Robin Appelman icewind@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Storage;
@@ -139,4 +124,15 @@ class LocalTest extends Storage {
umask($oldMask);
$this->assertTrue($this->instance->isUpdatable('test.txt'));
}
+
+ public function testUnavailableExternal() {
+ $this->expectException(\OCP\Files\StorageNotAvailableException::class);
+ $this->instance = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir . '/unexist', 'isExternal' => true]);
+ }
+
+ public function testUnavailableNonExternal() {
+ $this->instance = new \OC\Files\Storage\Local(['datadir' => $this->tmpDir . '/unexist']);
+ // no exception thrown
+ $this->assertNotNull($this->instance);
+ }
}
diff --git a/tests/lib/Files/Storage/Storage.php b/tests/lib/Files/Storage/Storage.php
index a646fd5fd0b..0a170a0e7d5 100644
--- a/tests/lib/Files/Storage/Storage.php
+++ b/tests/lib/Files/Storage/Storage.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Robin Appelman
- * @copyright 2012 Robin Appelman icewind@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Storage;
@@ -94,12 +79,13 @@ abstract class Storage extends \Test\TestCase {
$dirEntry = $content[0];
unset($dirEntry['scan_permissions']);
unset($dirEntry['etag']);
+ $this->assertLessThanOrEqual(1, abs($dirEntry['mtime'] - $this->instance->filemtime($directory)));
+ unset($dirEntry['mtime']);
+ unset($dirEntry['storage_mtime']);
$this->assertEquals([
'name' => $directory,
'mimetype' => $this->instance->getMimeType($directory),
- 'mtime' => $this->instance->filemtime($directory),
'size' => -1,
- 'storage_mtime' => $this->instance->filemtime($directory),
'permissions' => $this->instance->getPermissions($directory),
], $dirEntry);
diff --git a/tests/lib/Files/Storage/StorageFactoryTest.php b/tests/lib/Files/Storage/StorageFactoryTest.php
index 20b51cdda22..ee23f6199c9 100644
--- a/tests/lib/Files/Storage/StorageFactoryTest.php
+++ b/tests/lib/Files/Storage/StorageFactoryTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Storage;
diff --git a/tests/lib/Files/Storage/Wrapper/AvailabilityTest.php b/tests/lib/Files/Storage/Wrapper/AvailabilityTest.php
index 7d5d7d31808..ef7b457636c 100644
--- a/tests/lib/Files/Storage/Wrapper/AvailabilityTest.php
+++ b/tests/lib/Files/Storage/Wrapper/AvailabilityTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Files\Storage\Wrapper;
diff --git a/tests/lib/Files/Storage/Wrapper/EncodingTest.php b/tests/lib/Files/Storage/Wrapper/EncodingTest.php
index 0901edf83fa..bc9355d7bfb 100644
--- a/tests/lib/Files/Storage/Wrapper/EncodingTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncodingTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2016 Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Storage\Wrapper;
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index 11be0c60fbd..a6e0260fde6 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -1,5 +1,9 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
namespace Test\Files\Storage\Wrapper;
use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
@@ -422,9 +426,9 @@ class EncryptionTest extends Storage {
* @param boolean $renameKeysReturn
*/
public function testRename($source,
- $target,
- $encryptionEnabled,
- $renameKeysReturn) {
+ $target,
+ $encryptionEnabled,
+ $renameKeysReturn) {
if ($encryptionEnabled) {
$this->keyStore
->expects($this->once())
@@ -601,19 +605,19 @@ class EncryptionTest extends Storage {
$this->encryptionManager, $util, $this->logger, $this->file, null, $this->keyStore, $this->update, $this->mountManager, $this->arrayCache
]
)
- ->setMethods(['getCache','readFirstBlock', 'parseRawHeader'])
+ ->setMethods(['getCache', 'readFirstBlock'])
->getMock();
- $instance->expects($this->once())->method('getCache')->willReturn($cache);
+ $instance->method('getCache')->willReturn($cache);
- $instance->expects($this->once())->method(('parseRawHeader'))
+ $util->method('parseRawHeader')
->willReturn([Util::HEADER_ENCRYPTION_MODULE_KEY => 'OC_DEFAULT_MODULE']);
if ($strippedPathExists) {
- $instance->expects($this->once())->method('readFirstBlock')
+ $instance->method('readFirstBlock')
->with($strippedPath)->willReturn('');
} else {
- $instance->expects($this->once())->method('readFirstBlock')
+ $instance->method('readFirstBlock')
->with($path)->willReturn('');
}
@@ -679,11 +683,13 @@ class EncryptionTest extends Storage {
$this->encryptionManager, $util, $this->logger, $this->file, null, $this->keyStore, $this->update, $this->mountManager, $this->arrayCache
]
)
- ->setMethods(['readFirstBlock', 'parseRawHeader', 'getCache'])
+ ->setMethods(['readFirstBlock', 'getCache'])
->getMock();
- $instance->expects($this->any())->method(('parseRawHeader'))->willReturn($header);
- $instance->expects($this->once())->method('getCache')->willReturn($cache);
+ $instance->method('readFirstBlock')->willReturn('');
+
+ $util->method(('parseRawHeader'))->willReturn($header);
+ $instance->method('getCache')->willReturn($cache);
$result = $this->invokePrivate($instance, 'getHeader', ['test.txt']);
$this->assertSameSize($expected, $result);
@@ -702,44 +708,6 @@ class EncryptionTest extends Storage {
];
}
- /**
- * @dataProvider dataTestParseRawHeader
- */
- public function testParseRawHeader($rawHeader, $expected) {
- $instance = new \OC\Files\Storage\Wrapper\Encryption(
- [
- 'storage' => $this->sourceStorage,
- 'root' => 'foo',
- 'mountPoint' => '/',
- 'mount' => $this->mount
- ],
- $this->encryptionManager, $this->util, $this->logger, $this->file, null, $this->keyStore, $this->update, $this->mountManager, $this->arrayCache
-
- );
-
- $result = $this->invokePrivate($instance, 'parseRawHeader', [$rawHeader]);
- $this->assertSameSize($expected, $result);
- foreach ($result as $key => $value) {
- $this->assertArrayHasKey($key, $expected);
- $this->assertSame($expected[$key], $value);
- }
- }
-
- public function dataTestParseRawHeader() {
- return [
- [str_pad('HBEGIN:oc_encryption_module:0:HEND', $this->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)
- , ['custom_header' => 'foo', Util::HEADER_ENCRYPTION_MODULE_KEY => '0']],
- [str_pad('HelloWorld', $this->headerSize, '-', STR_PAD_RIGHT), []],
- ['', []],
- [str_pad('HBEGIN:oc_encryption_module:0', $this->headerSize, '-', STR_PAD_RIGHT)
- , []],
- [str_pad('oc_encryption_module:0:HEND', $this->headerSize, '-', STR_PAD_RIGHT)
- , []],
- ];
- }
-
public function dataCopyBetweenStorage() {
return [
[true, true, true],
@@ -826,10 +794,10 @@ class EncryptionTest extends Storage {
->method('isEnabled')
->willReturn($encryptionEnabled);
// FIXME can not overwrite the return after definition
-// $this->mount->expects($this->at(0))
-// ->method('getOption')
-// ->with('encrypt', true)
-// ->willReturn($mountPointEncryptionEnabled);
+ // $this->mount->expects($this->at(0))
+ // ->method('getOption')
+ // ->with('encrypt', true)
+ // ->willReturn($mountPointEncryptionEnabled);
global $mockedMountPointEncryptionEnabled;
$mockedMountPointEncryptionEnabled = $mountPointEncryptionEnabled;
diff --git a/tests/lib/Files/Storage/Wrapper/JailTest.php b/tests/lib/Files/Storage/Wrapper/JailTest.php
index 148bd3a4f30..c48f52ecce7 100644
--- a/tests/lib/Files/Storage/Wrapper/JailTest.php
+++ b/tests/lib/Files/Storage/Wrapper/JailTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Storage\Wrapper;
diff --git a/tests/lib/Files/Storage/Wrapper/KnownMtimeTest.php b/tests/lib/Files/Storage/Wrapper/KnownMtimeTest.php
new file mode 100644
index 00000000000..ccc95de1002
--- /dev/null
+++ b/tests/lib/Files/Storage/Wrapper/KnownMtimeTest.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace lib\Files\Storage\Wrapper;
+
+use OC\Files\Storage\Temporary;
+use OC\Files\Storage\Wrapper\KnownMtime;
+use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Clock\ClockInterface;
+use Test\Files\Storage\Storage;
+
+/**
+ * @group DB
+ */
+class KnownMtimeTest extends Storage {
+ /** @var Temporary */
+ private $sourceStorage;
+
+ /** @var ClockInterface|MockObject */
+ private $clock;
+ private int $fakeTime = 0;
+
+ protected function setUp(): void {
+ parent::setUp();
+ $this->fakeTime = 0;
+ $this->sourceStorage = new Temporary([]);
+ $this->clock = $this->createMock(ClockInterface::class);
+ $this->clock->method('now')->willReturnCallback(function () {
+ if ($this->fakeTime) {
+ return new \DateTimeImmutable("@{$this->fakeTime}");
+ } else {
+ return new \DateTimeImmutable();
+ }
+ });
+ $this->instance = $this->getWrappedStorage();
+ }
+
+ protected function tearDown(): void {
+ $this->sourceStorage->cleanUp();
+ parent::tearDown();
+ }
+
+ protected function getWrappedStorage() {
+ return new KnownMtime([
+ 'storage' => $this->sourceStorage,
+ 'clock' => $this->clock,
+ ]);
+ }
+
+ public function testNewerKnownMtime() {
+ $future = time() + 1000;
+ $this->fakeTime = $future;
+
+ $this->instance->file_put_contents('foo.txt', 'bar');
+
+ // fuzzy match since the clock might have ticked
+ $this->assertLessThan(2, abs(time() - $this->sourceStorage->filemtime('foo.txt')));
+ $this->assertEquals($this->sourceStorage->filemtime('foo.txt'), $this->sourceStorage->stat('foo.txt')['mtime']);
+ $this->assertEquals($this->sourceStorage->filemtime('foo.txt'), $this->sourceStorage->getMetaData('foo.txt')['mtime']);
+
+ $this->assertEquals($future, $this->instance->filemtime('foo.txt'));
+ $this->assertEquals($future, $this->instance->stat('foo.txt')['mtime']);
+ $this->assertEquals($future, $this->instance->getMetaData('foo.txt')['mtime']);
+ }
+}
diff --git a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php
index ea01a0e3e94..0b2d444700a 100644
--- a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php
+++ b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Storage\Wrapper;
diff --git a/tests/lib/Files/Storage/Wrapper/QuotaTest.php b/tests/lib/Files/Storage/Wrapper/QuotaTest.php
index 82b3e3556cb..b24b44c6a56 100644
--- a/tests/lib/Files/Storage/Wrapper/QuotaTest.php
+++ b/tests/lib/Files/Storage/Wrapper/QuotaTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Storage\Wrapper;
diff --git a/tests/lib/Files/Storage/Wrapper/WrapperTest.php b/tests/lib/Files/Storage/Wrapper/WrapperTest.php
index b9bb54e09b2..0244c78da8b 100644
--- a/tests/lib/Files/Storage/Wrapper/WrapperTest.php
+++ b/tests/lib/Files/Storage/Wrapper/WrapperTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Storage\Wrapper;
diff --git a/tests/lib/Files/Stream/DummyEncryptionWrapper.php b/tests/lib/Files/Stream/DummyEncryptionWrapper.php
index 223e8256cd2..211050905bd 100644
--- a/tests/lib/Files/Stream/DummyEncryptionWrapper.php
+++ b/tests/lib/Files/Stream/DummyEncryptionWrapper.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Björn Schießle <schiessle@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Files\Stream;
diff --git a/tests/lib/Files/Stream/EncryptionTest.php b/tests/lib/Files/Stream/EncryptionTest.php
index 8cdb379512a..b6650b56a85 100644
--- a/tests/lib/Files/Stream/EncryptionTest.php
+++ b/tests/lib/Files/Stream/EncryptionTest.php
@@ -1,5 +1,9 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
namespace Test\Files\Stream;
use OC\Files\Cache\CacheEntry;
@@ -78,13 +82,13 @@ class EncryptionTest extends \Test\TestCase {
* @dataProvider dataProviderStreamOpen()
*/
public function testStreamOpen($isMasterKeyUsed,
- $mode,
- $fullPath,
- $fileExists,
- $expectedSharePath,
- $expectedSize,
- $expectedUnencryptedSize,
- $expectedReadOnly) {
+ $mode,
+ $fullPath,
+ $fileExists,
+ $expectedSharePath,
+ $expectedSize,
+ $expectedUnencryptedSize,
+ $expectedReadOnly) {
// build mocks
$encryptionModuleMock = $this->getMockBuilder('\OCP\Encryption\IEncryptionModule')
->disableOriginalConstructor()->getMock();
diff --git a/tests/lib/Files/Stream/HashWrapperTest.php b/tests/lib/Files/Stream/HashWrapperTest.php
index e4bee18070d..686fcbec82a 100644
--- a/tests/lib/Files/Stream/HashWrapperTest.php
+++ b/tests/lib/Files/Stream/HashWrapperTest.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Stream;
diff --git a/tests/lib/Files/Stream/QuotaTest.php b/tests/lib/Files/Stream/QuotaTest.php
index 69cd322a2b3..17ad14b7e44 100644
--- a/tests/lib/Files/Stream/QuotaTest.php
+++ b/tests/lib/Files/Stream/QuotaTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Stream;
diff --git a/tests/lib/Files/Type/DetectionTest.php b/tests/lib/Files/Type/DetectionTest.php
index 079117f5622..e647fa064d4 100644
--- a/tests/lib/Files/Type/DetectionTest.php
+++ b/tests/lib/Files/Type/DetectionTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Files\Type;
diff --git a/tests/lib/Files/Type/LoaderTest.php b/tests/lib/Files/Type/LoaderTest.php
index fd3ec552dd2..cd2788bd208 100644
--- a/tests/lib/Files/Type/LoaderTest.php
+++ b/tests/lib/Files/Type/LoaderTest.php
@@ -1,37 +1,22 @@
<?php
/**
- * @author Robin McCorkell <rmccorkell@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Files\Type;
use OC\Files\Type\Loader;
use OCP\IDBConnection;
+use Test\TestCase;
-class LoaderTest extends \Test\TestCase {
- /** @var IDBConnection */
- protected $db;
- /** @var Loader */
- protected $loader;
+class LoaderTest extends TestCase {
+ protected IDBConnection $db;
+ protected Loader $loader;
protected function setUp(): void {
- $this->db = \OC::$server->getDatabaseConnection();
+ $this->db = \OC::$server->get(IDBConnection::class);
$this->loader = new Loader($this->db);
}
diff --git a/tests/lib/Files/Utils/ScannerTest.php b/tests/lib/Files/Utils/ScannerTest.php
index eb0b9938886..c3ba696ac5c 100644
--- a/tests/lib/Files/Utils/ScannerTest.php
+++ b/tests/lib/Files/Utils/ScannerTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Utils;
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index 2bf483df7d7..43a25150eaf 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -1,13 +1,12 @@
<?php
/**
- * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file. */
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
namespace Test\Files;
-use OCP\Cache\CappedMemoryCache;
use OC\Files\Cache\Watcher;
use OC\Files\Filesystem;
use OC\Files\Mount\MountPoint;
@@ -16,6 +15,8 @@ use OC\Files\Storage\Common;
use OC\Files\Storage\Storage;
use OC\Files\Storage\Temporary;
use OC\Files\View;
+use OC\Share20\ShareDisableChecker;
+use OCP\Cache\CappedMemoryCache;
use OCP\Constants;
use OCP\Files\Config\IMountProvider;
use OCP\Files\FileInfo;
@@ -25,6 +26,7 @@ use OCP\Files\Storage\IStorage;
use OCP\IDBConnection;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
+use OCP\Share\IManager as IShareManager;
use OCP\Share\IShare;
use OCP\Util;
use Test\HookHelper;
@@ -296,7 +298,7 @@ class ViewTest extends \Test\TestCase {
*/
public function testRemoveSharePermissionWhenSharingDisabledForUser($excludeGroups, $excludeGroupsList, $expectedShareable) {
// Reset sharing disabled for users cache
- self::invokePrivate(\OC::$server->getShareManager(), 'sharingDisabledForUsersCache', [new CappedMemoryCache()]);
+ self::invokePrivate(\OC::$server->get(ShareDisableChecker::class), 'sharingDisabledForUsersCache', [new CappedMemoryCache()]);
$config = \OC::$server->getConfig();
$oldExcludeGroupsFlag = $config->getAppValue('core', 'shareapi_exclude_groups', 'no');
@@ -321,7 +323,7 @@ class ViewTest extends \Test\TestCase {
$config->setAppValue('core', 'shareapi_exclude_groups_list', $oldExcludeGroupsList);
// Reset sharing disabled for users cache
- self::invokePrivate(\OC::$server->getShareManager(), 'sharingDisabledForUsersCache', [new CappedMemoryCache()]);
+ self::invokePrivate(\OC::$server->get(ShareDisableChecker::class), 'sharingDisabledForUsersCache', [new CappedMemoryCache()]);
}
public function testCacheIncompleteFolder() {
@@ -1387,7 +1389,7 @@ class ViewTest extends \Test\TestCase {
* Test that locks are on mount point paths instead of mount root
*/
public function testLockLocalMountPointPathInsteadOfStorageRoot() {
- $lockingProvider = \OC::$server->getLockingProvider();
+ $lockingProvider = \OC::$server->get(ILockingProvider::class);
$view = new View('/testuser/files/');
$storage = new Temporary([]);
Filesystem::mount($storage, [], '/');
@@ -1417,7 +1419,7 @@ class ViewTest extends \Test\TestCase {
* Test that locks are on mount point paths and also mount root when requested
*/
public function testLockStorageRootButNotLocalMountPoint() {
- $lockingProvider = \OC::$server->getLockingProvider();
+ $lockingProvider = \OC::$server->get(ILockingProvider::class);
$view = new View('/testuser/files/');
$storage = new Temporary([]);
Filesystem::mount($storage, [], '/');
@@ -1447,7 +1449,7 @@ class ViewTest extends \Test\TestCase {
* Test that locks are on mount point paths and also mount root when requested
*/
public function testLockMountPointPathFailReleasesBoth() {
- $lockingProvider = \OC::$server->getLockingProvider();
+ $lockingProvider = \OC::$server->get(ILockingProvider::class);
$view = new View('/testuser/files/');
$storage = new Temporary([]);
Filesystem::mount($storage, [], '/');
@@ -1683,14 +1685,12 @@ class ViewTest extends \Test\TestCase {
$userFolder = \OC::$server->getUserFolder($this->user);
$shareDir = $userFolder->get('shareddir');
- $shareManager = \OC::$server->getShareManager();
+ $shareManager = \OC::$server->get(IShareManager::class);
$share = $shareManager->newShare();
$share->setSharedWith('test2')
->setSharedBy($this->user)
->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_READ)
- ->setId(42)
- ->setProviderId('foo')
->setNode($shareDir);
$shareManager->createShare($share);
diff --git a/tests/lib/GlobalScale/ConfigTest.php b/tests/lib/GlobalScale/ConfigTest.php
index 826a57a2b30..b64a3bf2224 100644
--- a/tests/lib/GlobalScale/ConfigTest.php
+++ b/tests/lib/GlobalScale/ConfigTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\GlobalScale;
diff --git a/tests/lib/Group/Backend.php b/tests/lib/Group/Backend.php
index 541ed78719b..7eb71d0f22c 100644
--- a/tests/lib/Group/Backend.php
+++ b/tests/lib/Group/Backend.php
@@ -1,27 +1,8 @@
<?php
/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Felix Moeller <mail@felixmoeller.de>
- * @author Joas Schilling <nickvergessen@owncloud.com>
- * @author Robin Appelman <icewind@owncloud.com>
- * @author Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Group;
diff --git a/tests/lib/Group/DatabaseTest.php b/tests/lib/Group/DatabaseTest.php
index 586d77e0ec0..593fbe60bf9 100644
--- a/tests/lib/Group/DatabaseTest.php
+++ b/tests/lib/Group/DatabaseTest.php
@@ -1,26 +1,8 @@
<?php
/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Joas Schilling <nickvergessen@owncloud.com>
- * @author Robin Appelman <icewind@owncloud.com>
- * @author Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Group;
@@ -36,10 +18,8 @@ class DatabaseTest extends Backend {
/**
* get a new unique group name
* test cases can override this in order to clean up created groups
- *
- * @return string
*/
- public function getGroupName($name = null) {
+ public function getGroupName($name = null): string {
$name = parent::getGroupName($name);
$this->groups[] = $name;
return $name;
@@ -57,12 +37,22 @@ class DatabaseTest extends Backend {
parent::tearDown();
}
- public function testAddDoubleNoCache() {
+ public function testAddDoubleNoCache(): void {
$group = $this->getGroupName();
$this->backend->createGroup($group);
$backend = new \OC\Group\Database();
- $this->assertFalse($backend->createGroup($group));
+ $this->assertNull($backend->createGroup($group));
+ }
+
+ public function testAddLongGroupName(): void {
+ $groupName = $this->getUniqueID('test_', 100);
+
+ $gidCreated = $this->backend->createGroup($groupName);
+ $this->assertEquals(64, strlen($gidCreated));
+
+ $group = $this->backend->getGroupDetails($gidCreated);
+ $this->assertEquals(['displayName' => $groupName], $group);
}
}
diff --git a/tests/lib/Group/Dummy.php b/tests/lib/Group/Dummy.php
index d2d8b6332dd..4ba885c6cdd 100644
--- a/tests/lib/Group/Dummy.php
+++ b/tests/lib/Group/Dummy.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Robin Appelman
- * @copyright 2012 Robin Appelman icewind@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Group;
diff --git a/tests/lib/Group/GroupTest.php b/tests/lib/Group/GroupTest.php
index 58bb1c4133b..9ca178d4a41 100644
--- a/tests/lib/Group/GroupTest.php
+++ b/tests/lib/Group/GroupTest.php
@@ -1,10 +1,9 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Group;
diff --git a/tests/lib/Group/ManagerTest.php b/tests/lib/Group/ManagerTest.php
index 2887d14acaa..81fd77cc78a 100644
--- a/tests/lib/Group/ManagerTest.php
+++ b/tests/lib/Group/ManagerTest.php
@@ -1,34 +1,19 @@
<?php
/**
- * @author Robin Appelman <icewind@owncloud.com>
- * @author Vincent Petry <pvince81@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud GmbH.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Group;
use OC\Group\Database;
-use OC\User\User;
use OC\User\Manager;
+use OC\User\User;
use OCP\EventDispatcher\IEventDispatcher;
-use OCP\GroupInterface;
use OCP\Group\Backend\ISearchableGroupBackend;
+use OCP\GroupInterface;
use OCP\ICacheFactory;
use OCP\IUser;
use PHPUnit\Framework\MockObject\MockObject;
@@ -92,6 +77,7 @@ class ManagerTest extends TestCase {
'inGroup',
'getGroups',
'groupExists',
+ 'groupsExists',
'usersInGroup',
'createGroup',
'addToGroup',
@@ -240,6 +226,30 @@ class ManagerTest extends TestCase {
$this->assertEquals(null, $group);
}
+ public function testCreateTooLong() {
+ /**@var \PHPUnit\Framework\MockObject\MockObject|\OC\Group\Backend $backend */
+ $backendGroupCreated = false;
+ $backend = $this->getTestBackend(
+ GroupInterface::ADD_TO_GROUP |
+ GroupInterface::REMOVE_FROM_GOUP |
+ GroupInterface::COUNT_USERS |
+ GroupInterface::CREATE_GROUP |
+ GroupInterface::DELETE_GROUP |
+ GroupInterface::GROUP_DETAILS
+ );
+ $groupName = str_repeat('x', 256);
+ $backend->expects($this->any())
+ ->method('groupExists')
+ ->with($groupName)
+ ->willReturn(false);
+
+ $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger, $this->cache);
+ $manager->addBackend($backend);
+
+ $this->expectException(\Exception::class);
+ $group = $manager->createGroup($groupName);
+ }
+
public function testCreateExists() {
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Group\Backend $backend */
$backend = $this->getTestBackend();
@@ -361,10 +371,12 @@ class ManagerTest extends TestCase {
->method('getGroups')
->with('1')
->willReturn(['group1']);
+ $backend->expects($this->never())
+ ->method('groupExists');
$backend->expects($this->once())
- ->method('groupExists')
- ->with('group1')
- ->willReturn(false);
+ ->method('getGroupsDetails')
+ ->with(['group1'])
+ ->willReturn([]);
/** @var \OC\User\Manager $userManager */
$userManager = $this->createMock(Manager::class);
diff --git a/tests/lib/Group/MetaDataTest.php b/tests/lib/Group/MetaDataTest.php
index 7ad6d631b4e..2ae33c63a25 100644
--- a/tests/lib/Group/MetaDataTest.php
+++ b/tests/lib/Group/MetaDataTest.php
@@ -1,23 +1,8 @@
<?php
/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Group;
diff --git a/tests/lib/HelperStorageTest.php b/tests/lib/HelperStorageTest.php
index 0643c4b68a4..ddf32d94724 100644
--- a/tests/lib/HelperStorageTest.php
+++ b/tests/lib/HelperStorageTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/HookHelper.php b/tests/lib/HookHelper.php
index 5e040724d90..8b7d17a6766 100644
--- a/tests/lib/HookHelper.php
+++ b/tests/lib/HookHelper.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/Hooks/BasicEmitterTest.php b/tests/lib/Hooks/BasicEmitterTest.php
index 01ae4d4f28b..82e5a64ecae 100644
--- a/tests/lib/Hooks/BasicEmitterTest.php
+++ b/tests/lib/Hooks/BasicEmitterTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Hooks;
diff --git a/tests/lib/Http/Client/ClientServiceTest.php b/tests/lib/Http/Client/ClientServiceTest.php
index 40da0a2111c..a50428e514a 100644
--- a/tests/lib/Http/Client/ClientServiceTest.php
+++ b/tests/lib/Http/Client/ClientServiceTest.php
@@ -3,17 +3,16 @@
declare(strict_types=1);
/**
- * Copyright (c) 2015 Lukas Reschke <lukas@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Http\Client;
use GuzzleHttp\Client as GuzzleClient;
-use GuzzleHttp\HandlerStack;
use GuzzleHttp\Handler\CurlHandler;
+use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use OC\Http\Client\Client;
use OC\Http\Client\ClientService;
@@ -32,6 +31,9 @@ class ClientServiceTest extends \Test\TestCase {
public function testNewClient(): void {
/** @var IConfig $config */
$config = $this->createMock(IConfig::class);
+ $config->method('getSystemValueBool')
+ ->with('dns_pinning', true)
+ ->willReturn(true);
/** @var ICertificateManager $certificateManager */
$certificateManager = $this->createMock(ICertificateManager::class);
$dnsPinMiddleware = $this->createMock(DnsPinMiddleware::class);
@@ -74,4 +76,52 @@ class ClientServiceTest extends \Test\TestCase {
$clientService->newClient()
);
}
+
+ public function testDisableDnsPinning(): void {
+ /** @var IConfig $config */
+ $config = $this->createMock(IConfig::class);
+ $config->method('getSystemValueBool')
+ ->with('dns_pinning', true)
+ ->willReturn(false);
+ /** @var ICertificateManager $certificateManager */
+ $certificateManager = $this->createMock(ICertificateManager::class);
+ $dnsPinMiddleware = $this->createMock(DnsPinMiddleware::class);
+ $dnsPinMiddleware
+ ->expects($this->never())
+ ->method('addDnsPinning')
+ ->willReturn(function () {
+ });
+ $remoteHostValidator = $this->createMock(IRemoteHostValidator::class);
+ $eventLogger = $this->createMock(IEventLogger::class);
+ $logger = $this->createMock(LoggerInterface::class);
+
+ $clientService = new ClientService(
+ $config,
+ $certificateManager,
+ $dnsPinMiddleware,
+ $remoteHostValidator,
+ $eventLogger,
+ $logger,
+ );
+
+ $handler = new CurlHandler();
+ $stack = HandlerStack::create($handler);
+ $stack->push(Middleware::tap(function (RequestInterface $request) use ($eventLogger) {
+ $eventLogger->start('http:request', $request->getMethod() . " request to " . $request->getRequestTarget());
+ }, function () use ($eventLogger) {
+ $eventLogger->end('http:request');
+ }), 'event logger');
+ $guzzleClient = new GuzzleClient(['handler' => $stack]);
+
+ $this->assertEquals(
+ new Client(
+ $config,
+ $certificateManager,
+ $guzzleClient,
+ $remoteHostValidator,
+ $logger,
+ ),
+ $clientService->newClient()
+ );
+ }
}
diff --git a/tests/lib/Http/Client/ClientTest.php b/tests/lib/Http/Client/ClientTest.php
index 3cef9d75986..9c5bf1a6eb2 100644
--- a/tests/lib/Http/Client/ClientTest.php
+++ b/tests/lib/Http/Client/ClientTest.php
@@ -3,10 +3,9 @@
declare(strict_types=1);
/**
- * Copyright (c) 2015 Lukas Reschke <lukas@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Http\Client;
@@ -149,6 +148,7 @@ class ClientTest extends \Test\TestCase {
['https://service.localhost'],
['!@#$', true], // test invalid url
['https://normal.host.com'],
+ ['https://com.one-.nextcloud-one.com'],
];
}
diff --git a/tests/lib/Http/Client/DnsPinMiddlewareTest.php b/tests/lib/Http/Client/DnsPinMiddlewareTest.php
new file mode 100644
index 00000000000..d265ce3e71c
--- /dev/null
+++ b/tests/lib/Http/Client/DnsPinMiddlewareTest.php
@@ -0,0 +1,546 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace lib\Http\Client;
+
+use GuzzleHttp\Handler\MockHandler;
+use GuzzleHttp\HandlerStack;
+use GuzzleHttp\Psr7\Request;
+use GuzzleHttp\Psr7\Response;
+use OC\Http\Client\DnsPinMiddleware;
+use OC\Http\Client\NegativeDnsCache;
+use OC\Memcache\NullCache;
+use OC\Net\IpAddressClassifier;
+use OCP\Http\Client\LocalServerException;
+use OCP\ICacheFactory;
+use Psr\Http\Message\RequestInterface;
+use Test\TestCase;
+
+class DnsPinMiddlewareTest extends TestCase {
+ private DnsPinMiddleware $dnsPinMiddleware;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $cacheFactory = $this->createMock(ICacheFactory::class);
+ $cacheFactory
+ ->method('createLocal')
+ ->willReturn(new NullCache());
+
+ $ipAddressClassifier = new IpAddressClassifier();
+ $negativeDnsCache = new NegativeDnsCache($cacheFactory);
+
+ $this->dnsPinMiddleware = $this->getMockBuilder(DnsPinMiddleware::class)
+ ->setConstructorArgs([$negativeDnsCache, $ipAddressClassifier])
+ ->onlyMethods(['dnsGetRecord'])
+ ->getMock();
+ }
+
+ public function testPopulateDnsCacheIPv4() {
+ $mockHandler = new MockHandler([
+ static function (RequestInterface $request, array $options) {
+ self::arrayHasKey('curl', $options);
+ self::arrayHasKey(CURLOPT_RESOLVE, $options['curl']);
+ self::assertEquals([
+ 'www.example.com:80:1.1.1.1',
+ 'www.example.com:443:1.1.1.1'
+ ], $options['curl'][CURLOPT_RESOLVE]);
+ return new Response(200);
+ },
+ ]);
+
+ $this->dnsPinMiddleware
+ ->method('dnsGetRecord')
+ ->willReturnCallback(function (string $hostname, int $type) {
+ // example.com SOA
+ if ($hostname === 'example.com') {
+ return match ($type) {
+ DNS_SOA => [
+ [
+ 'host' => 'example.com',
+ 'class' => 'IN',
+ 'ttl' => 7079,
+ 'type' => 'SOA',
+ 'minimum-ttl' => 3600,
+ ]
+ ],
+ };
+ }
+
+ // example.com A, AAAA, CNAME
+ if ($hostname === 'www.example.com') {
+ return match ($type) {
+ DNS_A => [],
+ DNS_AAAA => [],
+ DNS_CNAME => [
+ [
+ 'host' => 'www.example.com',
+ 'class' => 'IN',
+ 'ttl' => 1800,
+ 'type' => 'A',
+ 'target' => 'www.example.net'
+ ]
+ ],
+ };
+ }
+
+ // example.net SOA
+ if ($hostname === 'example.net') {
+ return match ($type) {
+ DNS_SOA => [
+ [
+ 'host' => 'example.net',
+ 'class' => 'IN',
+ 'ttl' => 7079,
+ 'type' => 'SOA',
+ 'minimum-ttl' => 3600,
+ ]
+ ],
+ };
+ }
+
+ // example.net A, AAAA, CNAME
+ if ($hostname === 'www.example.net') {
+ return match ($type) {
+ DNS_A => [
+ [
+ 'host' => 'www.example.net',
+ 'class' => 'IN',
+ 'ttl' => 1800,
+ 'type' => 'A',
+ 'ip' => '1.1.1.1'
+ ]
+ ],
+ DNS_AAAA => [],
+ DNS_CNAME => [],
+ };
+ }
+
+ return false;
+ });
+
+ $stack = new HandlerStack($mockHandler);
+ $stack->push($this->dnsPinMiddleware->addDnsPinning());
+ $handler = $stack->resolve();
+
+ $handler(
+ new Request('GET', 'https://www.example.com'),
+ ['nextcloud' => ['allow_local_address' => false]]
+ );
+ }
+
+ public function testPopulateDnsCacheIPv6() {
+ $mockHandler = new MockHandler([
+ static function (RequestInterface $request, array $options) {
+ self::arrayHasKey('curl', $options);
+ self::arrayHasKey(CURLOPT_RESOLVE, $options['curl']);
+ self::assertEquals([
+ 'www.example.com:80:1.1.1.1,1.0.0.1,2606:4700:4700::1111,2606:4700:4700::1001',
+ 'www.example.com:443:1.1.1.1,1.0.0.1,2606:4700:4700::1111,2606:4700:4700::1001'
+ ], $options['curl'][CURLOPT_RESOLVE]);
+ return new Response(200);
+ },
+ ]);
+
+ $this->dnsPinMiddleware
+ ->method('dnsGetRecord')
+ ->willReturnCallback(function (string $hostname, int $type) {
+ // example.com SOA
+ if ($hostname === 'example.com') {
+ return match ($type) {
+ DNS_SOA => [
+ [
+ 'host' => 'example.com',
+ 'class' => 'IN',
+ 'ttl' => 7079,
+ 'type' => 'SOA',
+ 'minimum-ttl' => 3600,
+ ]
+ ],
+ };
+ }
+
+ // example.com A, AAAA, CNAME
+ if ($hostname === 'www.example.com') {
+ return match ($type) {
+ DNS_A => [],
+ DNS_AAAA => [],
+ DNS_CNAME => [
+ [
+ 'host' => 'www.example.com',
+ 'class' => 'IN',
+ 'ttl' => 1800,
+ 'type' => 'A',
+ 'target' => 'www.example.net'
+ ]
+ ],
+ };
+ }
+
+ // example.net SOA
+ if ($hostname === 'example.net') {
+ return match ($type) {
+ DNS_SOA => [
+ [
+ 'host' => 'example.net',
+ 'class' => 'IN',
+ 'ttl' => 7079,
+ 'type' => 'SOA',
+ 'minimum-ttl' => 3600,
+ ]
+ ],
+ };
+ }
+
+ // example.net A, AAAA, CNAME
+ if ($hostname === 'www.example.net') {
+ return match ($type) {
+ DNS_A => [
+ [
+ 'host' => 'www.example.net',
+ 'class' => 'IN',
+ 'ttl' => 1800,
+ 'type' => 'A',
+ 'ip' => '1.1.1.1'
+ ],
+ [
+ 'host' => 'www.example.net',
+ 'class' => 'IN',
+ 'ttl' => 1800,
+ 'type' => 'A',
+ 'ip' => '1.0.0.1'
+ ],
+ ],
+ DNS_AAAA => [
+ [
+ 'host' => 'www.example.net',
+ 'class' => 'IN',
+ 'ttl' => 1800,
+ 'type' => 'AAAA',
+ 'ip' => '2606:4700:4700::1111'
+ ],
+ [
+ 'host' => 'www.example.net',
+ 'class' => 'IN',
+ 'ttl' => 1800,
+ 'type' => 'AAAA',
+ 'ip' => '2606:4700:4700::1001'
+ ],
+ ],
+ DNS_CNAME => [],
+ };
+ }
+
+ return false;
+ });
+
+ $stack = new HandlerStack($mockHandler);
+ $stack->push($this->dnsPinMiddleware->addDnsPinning());
+ $handler = $stack->resolve();
+
+ $handler(
+ new Request('GET', 'https://www.example.com'),
+ ['nextcloud' => ['allow_local_address' => false]]
+ );
+ }
+
+ public function testAllowLocalAddress() {
+ $mockHandler = new MockHandler([
+ static function (RequestInterface $request, array $options) {
+ self::assertArrayNotHasKey('curl', $options);
+ return new Response(200);
+ },
+ ]);
+
+ $stack = new HandlerStack($mockHandler);
+ $stack->push($this->dnsPinMiddleware->addDnsPinning());
+ $handler = $stack->resolve();
+
+ $handler(
+ new Request('GET', 'https://www.example.com'),
+ ['nextcloud' => ['allow_local_address' => true]]
+ );
+ }
+
+ public function testRejectIPv4() {
+ $this->expectException(LocalServerException::class);
+ $this->expectExceptionMessage('violates local access rules');
+
+ $mockHandler = new MockHandler([
+ static function (RequestInterface $request, array $options) {
+ // The handler should not be called
+ },
+ ]);
+
+ $this->dnsPinMiddleware
+ ->method('dnsGetRecord')
+ ->willReturnCallback(function (string $hostname, int $type) {
+ return match ($type) {
+ DNS_SOA => [
+ [
+ 'host' => 'example.com',
+ 'class' => 'IN',
+ 'ttl' => 7079,
+ 'type' => 'SOA',
+ 'minimum-ttl' => 3600,
+ ]
+ ],
+ DNS_A => [
+ [
+ 'host' => 'example.com',
+ 'class' => 'IN',
+ 'ttl' => 1800,
+ 'type' => 'A',
+ 'ip' => '192.168.0.1'
+ ]
+ ],
+ DNS_AAAA => [],
+ DNS_CNAME => [],
+ };
+ });
+
+ $stack = new HandlerStack($mockHandler);
+ $stack->push($this->dnsPinMiddleware->addDnsPinning());
+ $handler = $stack->resolve();
+
+ $handler(
+ new Request('GET', 'https://www.example.com'),
+ ['nextcloud' => ['allow_local_address' => false]]
+ );
+ }
+
+ public function testRejectIPv6() {
+ $this->expectException(LocalServerException::class);
+ $this->expectExceptionMessage('violates local access rules');
+
+ $mockHandler = new MockHandler([
+ static function (RequestInterface $request, array $options) {
+ // The handler should not be called
+ },
+ ]);
+
+ $this->dnsPinMiddleware
+ ->method('dnsGetRecord')
+ ->willReturnCallback(function (string $hostname, int $type) {
+ return match ($type) {
+ DNS_SOA => [
+ [
+ 'host' => 'example.com',
+ 'class' => 'IN',
+ 'ttl' => 7079,
+ 'type' => 'SOA',
+ 'minimum-ttl' => 3600,
+ ]
+ ],
+ DNS_A => [],
+ DNS_AAAA => [
+ [
+ 'host' => 'ipv6.example.com',
+ 'class' => 'IN',
+ 'ttl' => 1800,
+ 'type' => 'AAAA',
+ 'ipv6' => 'fd12:3456:789a:1::1'
+ ]
+ ],
+ DNS_CNAME => [],
+ };
+ });
+
+ $stack = new HandlerStack($mockHandler);
+ $stack->push($this->dnsPinMiddleware->addDnsPinning());
+ $handler = $stack->resolve();
+
+ $handler(
+ new Request('GET', 'https://ipv6.example.com'),
+ ['nextcloud' => ['allow_local_address' => false]]
+ );
+ }
+
+ public function testRejectCanonicalName() {
+ $this->expectException(LocalServerException::class);
+ $this->expectExceptionMessage('violates local access rules');
+
+ $mockHandler = new MockHandler([
+ static function (RequestInterface $request, array $options) {
+ // The handler should not be called
+ },
+ ]);
+
+ $this->dnsPinMiddleware
+ ->method('dnsGetRecord')
+ ->willReturnCallback(function (string $hostname, int $type) {
+ // example.com SOA
+ if ($hostname === 'example.com') {
+ return match ($type) {
+ DNS_SOA => [
+ [
+ 'host' => 'example.com',
+ 'class' => 'IN',
+ 'ttl' => 7079,
+ 'type' => 'SOA',
+ 'minimum-ttl' => 3600,
+ ]
+ ],
+ };
+ }
+
+ // example.com A, AAAA, CNAME
+ if ($hostname === 'www.example.com') {
+ return match ($type) {
+ DNS_A => [],
+ DNS_AAAA => [],
+ DNS_CNAME => [
+ [
+ 'host' => 'www.example.com',
+ 'class' => 'IN',
+ 'ttl' => 1800,
+ 'type' => 'A',
+ 'target' => 'www.example.net'
+ ]
+ ],
+ };
+ }
+
+ // example.net SOA
+ if ($hostname === 'example.net') {
+ return match ($type) {
+ DNS_SOA => [
+ [
+ 'host' => 'example.net',
+ 'class' => 'IN',
+ 'ttl' => 7079,
+ 'type' => 'SOA',
+ 'minimum-ttl' => 3600,
+ ]
+ ],
+ };
+ }
+
+ // example.net A, AAAA, CNAME
+ if ($hostname === 'www.example.net') {
+ return match ($type) {
+ DNS_A => [
+ [
+ 'host' => 'www.example.net',
+ 'class' => 'IN',
+ 'ttl' => 1800,
+ 'type' => 'A',
+ 'ip' => '192.168.0.2'
+ ]
+ ],
+ DNS_AAAA => [],
+ DNS_CNAME => [],
+ };
+ }
+
+ return false;
+ });
+
+ $stack = new HandlerStack($mockHandler);
+ $stack->push($this->dnsPinMiddleware->addDnsPinning());
+ $handler = $stack->resolve();
+
+ $handler(
+ new Request('GET', 'https://www.example.com'),
+ ['nextcloud' => ['allow_local_address' => false]]
+ );
+ }
+
+ public function testRejectFaultyResponse() {
+ $this->expectException(LocalServerException::class);
+ $this->expectExceptionMessage('No DNS record found for www.example.com');
+
+ $mockHandler = new MockHandler([
+ static function (RequestInterface $request, array $options) {
+ // The handler should not be called
+ },
+ ]);
+
+ $this->dnsPinMiddleware
+ ->method('dnsGetRecord')
+ ->willReturnCallback(function (string $hostname, int $type) {
+ return false;
+ });
+
+ $stack = new HandlerStack($mockHandler);
+ $stack->push($this->dnsPinMiddleware->addDnsPinning());
+ $handler = $stack->resolve();
+
+ $handler(
+ new Request('GET', 'https://www.example.com'),
+ ['nextcloud' => ['allow_local_address' => false]]
+ );
+ }
+
+ public function testIgnoreSubdomainForSoaQuery() {
+ $mockHandler = new MockHandler([
+ static function (RequestInterface $request, array $options) {
+ // The handler should not be called
+ },
+ ]);
+
+ $dnsQueries = [];
+
+ $this->dnsPinMiddleware
+ ->method('dnsGetRecord')
+ ->willReturnCallback(function (string $hostname, int $type) use (&$dnsQueries) {
+ // log query
+ $dnsQueries[] = $hostname . $type;
+
+ // example.com SOA
+ if ($hostname === 'example.com') {
+ return match ($type) {
+ DNS_SOA => [
+ [
+ 'host' => 'example.com',
+ 'class' => 'IN',
+ 'ttl' => 7079,
+ 'type' => 'SOA',
+ 'minimum-ttl' => 3600,
+ ]
+ ],
+ };
+ }
+
+ // example.net A, AAAA, CNAME
+ if ($hostname === 'subsubdomain.subdomain.example.com') {
+ return match ($type) {
+ DNS_A => [
+ [
+ 'host' => 'subsubdomain.subdomain.example.com',
+ 'class' => 'IN',
+ 'ttl' => 1800,
+ 'type' => 'A',
+ 'ip' => '1.1.1.1'
+ ]
+ ],
+ DNS_AAAA => [],
+ DNS_CNAME => [],
+ };
+ }
+
+ return false;
+ });
+
+ $stack = new HandlerStack($mockHandler);
+ $stack->push($this->dnsPinMiddleware->addDnsPinning());
+ $handler = $stack->resolve();
+
+ $handler(
+ new Request('GET', 'https://subsubdomain.subdomain.example.com'),
+ ['nextcloud' => ['allow_local_address' => false]]
+ );
+
+ $this->assertCount(4, $dnsQueries);
+ $this->assertContains('example.com' . DNS_SOA, $dnsQueries);
+ $this->assertContains('subsubdomain.subdomain.example.com' . DNS_A, $dnsQueries);
+ $this->assertContains('subsubdomain.subdomain.example.com' . DNS_AAAA, $dnsQueries);
+ $this->assertContains('subsubdomain.subdomain.example.com' . DNS_CNAME, $dnsQueries);
+ }
+}
diff --git a/tests/lib/Http/Client/NegativeDnsCacheTest.php b/tests/lib/Http/Client/NegativeDnsCacheTest.php
index b36524acf90..af0575b0cd7 100644
--- a/tests/lib/Http/Client/NegativeDnsCacheTest.php
+++ b/tests/lib/Http/Client/NegativeDnsCacheTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2021, Lukas Reschke <lukas@statuscode.ch>
- *
- * @author Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Http\Client;
diff --git a/tests/lib/Http/Client/ResponseTest.php b/tests/lib/Http/Client/ResponseTest.php
index 1384e4e732c..c0d9770e2fb 100644
--- a/tests/lib/Http/Client/ResponseTest.php
+++ b/tests/lib/Http/Client/ResponseTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Lukas Reschke <lukas@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Http\Client;
diff --git a/tests/lib/Http/WellKnown/GenericResponseTest.php b/tests/lib/Http/WellKnown/GenericResponseTest.php
index 1e84a509c1b..f35f43221b8 100644
--- a/tests/lib/Http/WellKnown/GenericResponseTest.php
+++ b/tests/lib/Http/WellKnown/GenericResponseTest.php
@@ -2,25 +2,9 @@
declare(strict_types=1);
-/*
- * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Tests\Http\WellKnown;
diff --git a/tests/lib/Http/WellKnown/JrdResponseTest.php b/tests/lib/Http/WellKnown/JrdResponseTest.php
index f540ac1862e..0f500f96eef 100644
--- a/tests/lib/Http/WellKnown/JrdResponseTest.php
+++ b/tests/lib/Http/WellKnown/JrdResponseTest.php
@@ -2,25 +2,9 @@
declare(strict_types=1);
-/*
- * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Http\WellKnown;
diff --git a/tests/lib/Http/WellKnown/RequestManagerTest.php b/tests/lib/Http/WellKnown/RequestManagerTest.php
index d3fd487aa60..1ee2fa1139d 100644
--- a/tests/lib/Http/WellKnown/RequestManagerTest.php
+++ b/tests/lib/Http/WellKnown/RequestManagerTest.php
@@ -2,25 +2,9 @@
declare(strict_types=1);
-/*
- * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Http\WellKnown;
diff --git a/tests/lib/ImageTest.php b/tests/lib/ImageTest.php
index f4da0275c2d..6028f1b89fa 100644
--- a/tests/lib/ImageTest.php
+++ b/tests/lib/ImageTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
@@ -149,8 +148,7 @@ class ImageTest extends \Test\TestCase {
$img = new \OC_Image(null, null, $config);
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.jpg');
$raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
- /** @psalm-suppress InvalidScalarArgument */
- imageinterlace($raw, (PHP_VERSION_ID >= 80000 ? true : 1));
+ imageinterlace($raw, true);
ob_start();
imagejpeg($raw, null, 80);
$expected = ob_get_clean();
diff --git a/tests/lib/InfoXmlTest.php b/tests/lib/InfoXmlTest.php
index f613138bf87..702eca4c0ce 100644
--- a/tests/lib/InfoXmlTest.php
+++ b/tests/lib/InfoXmlTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/InitialStateServiceTest.php b/tests/lib/InitialStateServiceTest.php
index 554478e123f..a919832d3e4 100644
--- a/tests/lib/InitialStateServiceTest.php
+++ b/tests/lib/InitialStateServiceTest.php
@@ -3,36 +3,20 @@
declare(strict_types=1);
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
+use JsonSerializable;
use OC\AppFramework\Bootstrap\Coordinator;
+use OC\InitialStateService;
use OCP\IServerContainer;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
-use function json_encode;
-use JsonSerializable;
-use OC\InitialStateService;
use stdClass;
+use function json_encode;
class InitialStateServiceTest extends TestCase {
/** @var InitialStateService */
diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php
index 60c8ac1cc94..3a62a57fdab 100644
--- a/tests/lib/InstallerTest.php
+++ b/tests/lib/InstallerTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Georg Ehrke <georg@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
@@ -51,7 +50,7 @@ class InstallerTest extends TestCase {
$this->appstore = $config->setSystemValue('appstoreenabled', true);
$config->setSystemValue('appstoreenabled', true);
$installer = new Installer(
- \OC::$server->getAppFetcher(),
+ \OC::$server->get(AppFetcher::class),
\OC::$server->getHTTPClientService(),
\OC::$server->getTempManager(),
\OC::$server->get(LoggerInterface::class),
@@ -74,7 +73,7 @@ class InstallerTest extends TestCase {
protected function tearDown(): void {
$installer = new Installer(
- \OC::$server->getAppFetcher(),
+ \OC::$server->get(AppFetcher::class),
\OC::$server->getHTTPClientService(),
\OC::$server->getTempManager(),
\OC::$server->get(LoggerInterface::class),
@@ -98,7 +97,7 @@ class InstallerTest extends TestCase {
// Install app
$installer = new Installer(
- \OC::$server->getAppFetcher(),
+ \OC::$server->get(AppFetcher::class),
\OC::$server->getHTTPClientService(),
\OC::$server->getTempManager(),
\OC::$server->get(LoggerInterface::class),
@@ -576,30 +575,30 @@ MPLX6f5V9tCJtlH6ztmEcDROfvuVc0U3rEhqx2hphoyo+MZrPFpdcJL8KkIdMKbY
],
];
$this->appFetcher
- ->expects($this->atLeastOnce())
+ ->expects($this->once())
->method('get')
- ->willReturnOnConsecutiveCalls($appArray);
+ ->willReturn($appArray);
$realTmpFile = \OC::$server->getTempManager()->getTemporaryFile('.tar.gz');
copy(__DIR__ . '/../data/testapp.tar.gz', $realTmpFile);
$this->tempManager
- ->expects($this->atLeastOnce())
+ ->expects($this->once())
->method('getTemporaryFile')
->with('.tar.gz')
- ->willReturnOnConsecutiveCalls($realTmpFile);
+ ->willReturn($realTmpFile);
$realTmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
$this->tempManager
- ->expects($this->atLeastOnce())
+ ->expects($this->once())
->method('getTemporaryFolder')
- ->willReturnOnConsecutiveCalls($realTmpFolder);
+ ->willReturn($realTmpFolder);
$client = $this->createMock(IClient::class);
$client
->expects($this->once())
->method('get')
->with('https://example.com', ['sink' => $realTmpFile, 'timeout' => 120]);
$this->clientService
- ->expects($this->atLeastOnce())
+ ->expects($this->once())
->method('newClient')
- ->willReturnOnConsecutiveCalls($client);
+ ->willReturn($client);
$installer = $this->getInstaller();
$installer->downloadApp('testapp');
@@ -610,6 +609,14 @@ MPLX6f5V9tCJtlH6ztmEcDROfvuVc0U3rEhqx2hphoyo+MZrPFpdcJL8KkIdMKbY
public function testDownloadAppWithDowngrade() {
+ // Use previous test to download the application in version 0.9
+ $this->testDownloadAppSuccessful();
+
+ // Reset mocks
+ $this->appFetcher = $this->createMock(AppFetcher::class);
+ $this->clientService = $this->createMock(IClientService::class);
+ $this->tempManager = $this->createMock(ITempManager::class);
+
$this->expectException(\Exception::class);
$this->expectExceptionMessage('App for id testapp has version 0.9 and tried to update to lower version 0.8');
@@ -662,19 +669,19 @@ JXhrdaWDZ8fzpUjugrtC3qslsqL0dzgU37anS3HwrT8=',
],
];
$this->appFetcher
- ->expects($this->at(1))
+ ->expects($this->once())
->method('get')
->willReturn($appArray);
$realTmpFile = \OC::$server->getTempManager()->getTemporaryFile('.tar.gz');
copy(__DIR__ . '/../data/testapp.0.8.tar.gz', $realTmpFile);
$this->tempManager
- ->expects($this->at(2))
+ ->expects($this->once())
->method('getTemporaryFile')
->with('.tar.gz')
->willReturn($realTmpFile);
$realTmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
$this->tempManager
- ->expects($this->at(3))
+ ->expects($this->once())
->method('getTemporaryFolder')
->willReturn($realTmpFolder);
$client = $this->createMock(IClient::class);
@@ -683,10 +690,9 @@ JXhrdaWDZ8fzpUjugrtC3qslsqL0dzgU37anS3HwrT8=',
->method('get')
->with('https://example.com', ['sink' => $realTmpFile, 'timeout' => 120]);
$this->clientService
- ->expects($this->at(1))
+ ->expects($this->once())
->method('newClient')
->willReturn($client);
- $this->testDownloadAppSuccessful();
$this->assertTrue(file_exists(__DIR__ . '/../../apps/testapp/appinfo/info.xml'));
$this->assertEquals('0.9', \OC_App::getAppVersionByPath(__DIR__ . '/../../apps/testapp/'));
diff --git a/tests/lib/IntegrityCheck/CheckerTest.php b/tests/lib/IntegrityCheck/CheckerTest.php
index 203e7e97227..21714e96f01 100644
--- a/tests/lib/IntegrityCheck/CheckerTest.php
+++ b/tests/lib/IntegrityCheck/CheckerTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\IntegrityCheck;
@@ -28,6 +14,7 @@ use OC\IntegrityCheck\Helpers\EnvironmentHelper;
use OC\IntegrityCheck\Helpers\FileAccessHelper;
use OC\Memcache\NullCache;
use OCP\App\IAppManager;
+use OCP\IAppConfig;
use OCP\ICacheFactory;
use OCP\IConfig;
use phpseclib\Crypt\RSA;
@@ -45,6 +32,8 @@ class CheckerTest extends TestCase {
private $fileAccessHelper;
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
private $config;
+ /** @var IAppConfig|\PHPUnit\Framework\MockObject\MockObject */
+ private $appConfig;
/** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
private $cacheFactory;
/** @var IAppManager|\PHPUnit\Framework\MockObject\MockObject */
@@ -58,6 +47,7 @@ class CheckerTest extends TestCase {
$this->fileAccessHelper = $this->createMock(FileAccessHelper::class);
$this->appLocator = $this->createMock(AppLocator::class);
$this->config = $this->createMock(IConfig::class);
+ $this->appConfig = $this->createMock(IAppConfig::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->appManager = $this->createMock(IAppManager::class);
$this->mimeTypeDetector = $this->createMock(\OC\Files\Type\Detection::class);
@@ -76,6 +66,7 @@ class CheckerTest extends TestCase {
$this->fileAccessHelper,
$this->appLocator,
$this->config,
+ $this->appConfig,
$this->cacheFactory,
$this->appManager,
$this->mimeTypeDetector
@@ -1025,6 +1016,7 @@ class CheckerTest extends TestCase {
$this->fileAccessHelper,
$this->appLocator,
$this->config,
+ $this->appConfig,
$this->cacheFactory,
$this->appManager,
$this->mimeTypeDetector,
@@ -1089,9 +1081,9 @@ class CheckerTest extends TestCase {
true,
false,
);
- $this->config
+ $this->appConfig
->expects($this->once())
- ->method('deleteAppValue')
+ ->method('deleteKey')
->with('core', 'oc.integritycheck.checker');
$this->checker->runInstanceVerification();
diff --git a/tests/lib/IntegrityCheck/Helpers/AppLocatorTest.php b/tests/lib/IntegrityCheck/Helpers/AppLocatorTest.php
index cf5899b663b..a86507f6bb2 100644
--- a/tests/lib/IntegrityCheck/Helpers/AppLocatorTest.php
+++ b/tests/lib/IntegrityCheck/Helpers/AppLocatorTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\IntegrityCheck\Helpers;
diff --git a/tests/lib/IntegrityCheck/Helpers/EnvironmentHelperTest.php b/tests/lib/IntegrityCheck/Helpers/EnvironmentHelperTest.php
index 767cdf3aaab..001733309a3 100644
--- a/tests/lib/IntegrityCheck/Helpers/EnvironmentHelperTest.php
+++ b/tests/lib/IntegrityCheck/Helpers/EnvironmentHelperTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\IntegrityCheck\Helpers;
diff --git a/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php b/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php
index c4d724a3654..ea90b611f5e 100644
--- a/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php
+++ b/tests/lib/IntegrityCheck/Helpers/FileAccessHelperTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\IntegrityCheck\Helpers;
diff --git a/tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php b/tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php
index 370b50a56e2..14cc8851178 100644
--- a/tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php
+++ b/tests/lib/IntegrityCheck/Iterator/ExcludeFileByNameFilterIteratorTest.php
@@ -1,24 +1,9 @@
<?php
/**
- * @author Victor Dubiniuk <dubiniuk@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace Test\IntegrityCheck\Iterator;
use OC\IntegrityCheck\Iterator\ExcludeFileByNameFilterIterator;
diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php
index 2db1e0302e8..771ce75d3e9 100644
--- a/tests/lib/L10N/FactoryTest.php
+++ b/tests/lib/L10N/FactoryTest.php
@@ -3,16 +3,17 @@
declare(strict_types=1);
/**
- * Copyright (c) 2016 Joas Schilling <nickvergessen@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\L10N;
use OC\L10N\Factory;
use OC\L10N\LanguageNotFoundException;
+use OCP\App\AppPathNotFoundException;
+use OCP\App\IAppManager;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IRequest;
@@ -38,6 +39,9 @@ class FactoryTest extends TestCase {
/** @var string */
protected $serverRoot;
+ /** @var IAppManager|MockObject */
+ protected IAppManager $appManager;
+
protected function setUp(): void {
parent::setUp();
@@ -45,6 +49,7 @@ class FactoryTest extends TestCase {
$this->request = $this->createMock(IRequest::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
+ $this->appManager = $this->createMock(IAppManager::class);
$this->serverRoot = \OC::$SERVERROOT;
@@ -76,12 +81,13 @@ class FactoryTest extends TestCase {
$this->userSession,
$this->cacheFactory,
$this->serverRoot,
+ $this->appManager,
])
->setMethods($methods)
->getMock();
}
- return new Factory($this->config, $this->request, $this->userSession, $this->cacheFactory, $this->serverRoot);
+ return new Factory($this->config, $this->request, $this->userSession, $this->cacheFactory, $this->serverRoot, $this->appManager);
}
public function dataFindAvailableLanguages(): array {
@@ -402,7 +408,7 @@ class FactoryTest extends TestCase {
public function dataGetL10nFilesForApp(): array {
return [
- [null, 'de', [\OC::$SERVERROOT . '/core/l10n/de.json']],
+ ['', 'de', [\OC::$SERVERROOT . '/core/l10n/de.json']],
['core', 'ru', [\OC::$SERVERROOT . '/core/l10n/ru.json']],
['lib', 'ru', [\OC::$SERVERROOT . '/lib/l10n/ru.json']],
['settings', 'de', [\OC::$SERVERROOT . '/apps/settings/l10n/de.json']],
@@ -415,17 +421,28 @@ class FactoryTest extends TestCase {
/**
* @dataProvider dataGetL10nFilesForApp
*
- * @param string|null $app
+ * @param string $app
* @param string $expected
*/
public function testGetL10nFilesForApp($app, $lang, $expected): void {
$factory = $this->getFactory();
+ if (in_array($app, ['settings','files'])) {
+ $this->appManager
+ ->method('getAppPath')
+ ->with($app)
+ ->willReturn(\OC::$SERVERROOT . '/apps/' . $app);
+ } else {
+ $this->appManager
+ ->method('getAppPath')
+ ->with($app)
+ ->willThrowException(new AppPathNotFoundException());
+ }
self::assertSame($expected, $this->invokePrivate($factory, 'getL10nFilesForApp', [$app, $lang]));
}
public function dataFindL10NDir(): array {
return [
- [null, \OC::$SERVERROOT . '/core/l10n/'],
+ ['', \OC::$SERVERROOT . '/core/l10n/'],
['core', \OC::$SERVERROOT . '/core/l10n/'],
['lib', \OC::$SERVERROOT . '/lib/l10n/'],
['settings', \OC::$SERVERROOT . '/apps/settings/l10n/'],
@@ -437,11 +454,22 @@ class FactoryTest extends TestCase {
/**
* @dataProvider dataFindL10NDir
*
- * @param string|null $app
+ * @param string $app
* @param string $expected
*/
public function testFindL10NDir($app, $expected): void {
$factory = $this->getFactory();
+ if (in_array($app, ['settings','files'])) {
+ $this->appManager
+ ->method('getAppPath')
+ ->with($app)
+ ->willReturn(\OC::$SERVERROOT . '/apps/' . $app);
+ } else {
+ $this->appManager
+ ->method('getAppPath')
+ ->with($app)
+ ->willThrowException(new AppPathNotFoundException());
+ }
self::assertSame($expected, $this->invokePrivate($factory, 'findL10nDir', [$app]));
}
@@ -683,7 +711,7 @@ class FactoryTest extends TestCase {
/**
* @dataProvider languageIteratorRequestProvider
*/
- public function testGetLanguageIterator(bool $hasSession, IUser $iUserMock = null): void {
+ public function testGetLanguageIterator(bool $hasSession, ?IUser $iUserMock = null): void {
$factory = $this->getFactory();
if ($iUserMock === null) {
diff --git a/tests/lib/L10N/L10nTest.php b/tests/lib/L10N/L10nTest.php
index 21be2bbf395..38d0a5626b0 100644
--- a/tests/lib/L10N/L10nTest.php
+++ b/tests/lib/L10N/L10nTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2016 Joas Schilling <nickvergessen@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\L10N;
@@ -11,6 +10,7 @@ namespace Test\L10N;
use DateTime;
use OC\L10N\Factory;
use OC\L10N\L10N;
+use OCP\App\IAppManager;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IRequest;
@@ -35,7 +35,8 @@ class L10nTest extends TestCase {
/** @var IUserSession $userSession */
$userSession = $this->createMock(IUserSession::class);
$cacheFactory = $this->createMock(ICacheFactory::class);
- return new Factory($config, $request, $userSession, $cacheFactory, \OC::$SERVERROOT);
+ $appManager = $this->createMock(IAppManager::class);
+ return new Factory($config, $request, $userSession, $cacheFactory, \OC::$SERVERROOT, $appManager);
}
public function testSimpleTranslationWithTrailingColon(): void {
@@ -202,12 +203,12 @@ class L10nTest extends TestCase {
}
public function testServiceGetLanguageCode() {
- $l = \OC::$server->getL10N('lib', 'de');
+ $l = \OCP\Util::getL10N('lib', 'de');
$this->assertEquals('de', $l->getLanguageCode());
}
public function testWeekdayName() {
- $l = \OC::$server->getL10N('lib', 'de');
+ $l = \OCP\Util::getL10N('lib', 'de');
$this->assertEquals('Mo.', $l->l('weekdayName', new \DateTime('2017-11-6'), ['width' => 'abbreviated']));
}
diff --git a/tests/lib/L10N/LanguageIteratorTest.php b/tests/lib/L10N/LanguageIteratorTest.php
index 1d5335cebaa..02c17a842d3 100644
--- a/tests/lib/L10N/LanguageIteratorTest.php
+++ b/tests/lib/L10N/LanguageIteratorTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2018 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\L10N;
diff --git a/tests/lib/LargeFileHelperGetFileSizeTest.php b/tests/lib/LargeFileHelperGetFileSizeTest.php
index 6fa2555b6d0..b239c10e20a 100644
--- a/tests/lib/LargeFileHelperGetFileSizeTest.php
+++ b/tests/lib/LargeFileHelperGetFileSizeTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Andreas Fischer <bantu@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/LargeFileHelperTest.php b/tests/lib/LargeFileHelperTest.php
index 3cc9d13d74c..9008a42f77e 100644
--- a/tests/lib/LargeFileHelperTest.php
+++ b/tests/lib/LargeFileHelperTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Andreas Fischer <bantu@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/LegacyHelperTest.php b/tests/lib/LegacyHelperTest.php
index 08380dd50c9..7d6be9dea7e 100644
--- a/tests/lib/LegacyHelperTest.php
+++ b/tests/lib/LegacyHelperTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Lukas Reschke <lukas@statuscode.ch>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/Lock/DBLockingProviderTest.php b/tests/lib/Lock/DBLockingProviderTest.php
index 860e8d73cf0..356b55f577e 100644
--- a/tests/lib/Lock/DBLockingProviderTest.php
+++ b/tests/lib/Lock/DBLockingProviderTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Robin Appelman <icewind@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Lock;
diff --git a/tests/lib/Lock/LockingProvider.php b/tests/lib/Lock/LockingProvider.php
index 93eba367af2..2aa3980542b 100644
--- a/tests/lib/Lock/LockingProvider.php
+++ b/tests/lib/Lock/LockingProvider.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Robin Appelman <icewind@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Lock;
diff --git a/tests/lib/Lock/MemcacheLockingProviderTest.php b/tests/lib/Lock/MemcacheLockingProviderTest.php
index b67be799d59..a698be65aaf 100644
--- a/tests/lib/Lock/MemcacheLockingProviderTest.php
+++ b/tests/lib/Lock/MemcacheLockingProviderTest.php
@@ -1,27 +1,14 @@
<?php
/**
- * @author Robin Appelman <icewind@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Lock;
use OC\Memcache\ArrayCache;
+use OCP\AppFramework\Utility\ITimeFactory;
class MemcacheLockingProviderTest extends LockingProvider {
/**
@@ -34,7 +21,8 @@ class MemcacheLockingProviderTest extends LockingProvider {
*/
protected function getInstance() {
$this->memcache = new ArrayCache();
- return new \OC\Lock\MemcacheLockingProvider($this->memcache);
+ $timeProvider = \OC::$server->get(ITimeFactory::class);
+ return new \OC\Lock\MemcacheLockingProvider($this->memcache, $timeProvider);
}
protected function tearDown(): void {
diff --git a/tests/lib/Lock/NonCachingDBLockingProviderTest.php b/tests/lib/Lock/NonCachingDBLockingProviderTest.php
index 349a175b566..5750d02fc4e 100644
--- a/tests/lib/Lock/NonCachingDBLockingProviderTest.php
+++ b/tests/lib/Lock/NonCachingDBLockingProviderTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Lock;
diff --git a/tests/lib/Lockdown/Filesystem/NoFSTest.php b/tests/lib/Lockdown/Filesystem/NoFSTest.php
index 4c0645447ec..08429228647 100644
--- a/tests/lib/Lockdown/Filesystem/NoFSTest.php
+++ b/tests/lib/Lockdown/Filesystem/NoFSTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016, Robin Appelman <robin@icewind.nl>
- *
- * @author Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Lockdown\Filesystem;
@@ -39,7 +22,7 @@ class NoFSTest extends \Test\TestCase {
$token->setScope([
'filesystem' => true
]);
- \OC::$server->getLockdownManager()->setToken($token);
+ \OC::$server->get('LockdownManager')->setToken($token);
parent::tearDown();
}
@@ -50,7 +33,7 @@ class NoFSTest extends \Test\TestCase {
'filesystem' => false
]);
- \OC::$server->getLockdownManager()->setToken($token);
+ \OC::$server->get('LockdownManager')->setToken($token);
$this->createUser('foo', 'var');
}
diff --git a/tests/lib/Lockdown/Filesystem/NullCacheTest.php b/tests/lib/Lockdown/Filesystem/NullCacheTest.php
index 0f979350bac..eda4e10b1a6 100644
--- a/tests/lib/Lockdown/Filesystem/NullCacheTest.php
+++ b/tests/lib/Lockdown/Filesystem/NullCacheTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Lockdown\Filesystem;
diff --git a/tests/lib/Lockdown/Filesystem/NullStorageTest.php b/tests/lib/Lockdown/Filesystem/NullStorageTest.php
index b46066ac536..727ccb83e21 100644
--- a/tests/lib/Lockdown/Filesystem/NullStorageTest.php
+++ b/tests/lib/Lockdown/Filesystem/NullStorageTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Lockdown\Filesystem;
diff --git a/tests/lib/Lockdown/LockdownManagerTest.php b/tests/lib/Lockdown/LockdownManagerTest.php
index 9b05ea0e6a5..5ff5a84e800 100644
--- a/tests/lib/Lockdown/LockdownManagerTest.php
+++ b/tests/lib/Lockdown/LockdownManagerTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Lockdown;
diff --git a/tests/lib/Log/ExceptionSerializerTest.php b/tests/lib/Log/ExceptionSerializerTest.php
index 209214a6832..1ec422fb53d 100644
--- a/tests/lib/Log/ExceptionSerializerTest.php
+++ b/tests/lib/Log/ExceptionSerializerTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2021 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\Log;
diff --git a/tests/lib/Log/FileTest.php b/tests/lib/Log/FileTest.php
index 703c4280f24..37219b5c2b1 100644
--- a/tests/lib/Log/FileTest.php
+++ b/tests/lib/Log/FileTest.php
@@ -1,20 +1,8 @@
<?php
/**
*
- * @author Thomas Citharel <nextcloud@tcit.fr>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Log;
diff --git a/tests/lib/Log/LogFactoryTest.php b/tests/lib/Log/LogFactoryTest.php
index 91ff79369bf..c1232f7b28d 100644
--- a/tests/lib/Log/LogFactoryTest.php
+++ b/tests/lib/Log/LogFactoryTest.php
@@ -1,25 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2018 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Johannes Ernst <jernst@indiecomputing.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Log;
diff --git a/tests/lib/LoggerTest.php b/tests/lib/LoggerTest.php
index 367c34752c1..f4bc9de904d 100644
--- a/tests/lib/LoggerTest.php
+++ b/tests/lib/LoggerTest.php
@@ -1,12 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @author Thomas Citharel <nextcloud@tcit.fr>
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/Mail/EMailTemplateTest.php b/tests/lib/Mail/EMailTemplateTest.php
index 284c53e73b8..a12cf82ab50 100644
--- a/tests/lib/Mail/EMailTemplateTest.php
+++ b/tests/lib/Mail/EMailTemplateTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2017, Morris Jobke <hey@morrisjobke.de>
- *
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Mail;
diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php
index 5ffba939284..baa44975333 100644
--- a/tests/lib/Mail/MailerTest.php
+++ b/tests/lib/Mail/MailerTest.php
@@ -1,12 +1,8 @@
<?php
/**
- * Copyright (c) 2014-2015 Lukas Reschke <lukas@owncloud.com>
- *
- * @author Arne Hamann <github@arne.email>
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Mail;
@@ -21,13 +17,13 @@ use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use OCP\Mail\Events\BeforeMessageSent;
-use Psr\Log\LoggerInterface;
-use Test\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
use Symfony\Component\Mailer\Mailer as SymfonyMailer;
-use Symfony\Component\Mime\Email;
-use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
use Symfony\Component\Mailer\Transport\SendmailTransport;
+use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
+use Symfony\Component\Mime\Email;
+use Test\TestCase;
class MailerTest extends TestCase {
/** @var IConfig|MockObject */
@@ -72,7 +68,7 @@ class MailerTest extends TestCase {
public function sendmailModeProvider(): array {
return [
'smtp' => ['smtp', ' -bs'],
- 'pipe' => ['pipe', ' -t'],
+ 'pipe' => ['pipe', ' -t -i'],
];
}
diff --git a/tests/lib/Mail/MessageTest.php b/tests/lib/Mail/MessageTest.php
index 2becc4d2081..84c30a962fa 100644
--- a/tests/lib/Mail/MessageTest.php
+++ b/tests/lib/Mail/MessageTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Mail;
@@ -11,13 +10,13 @@ namespace Test\Mail;
use OC\Mail\Message;
use OCP\Mail\Headers\AutoSubmitted;
use OCP\Mail\IEMailTemplate;
+use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;
use Symfony\Component\Mime\Exception\RfcComplianceException;
use Symfony\Component\Mime\Header\HeaderInterface;
use Symfony\Component\Mime\Header\Headers;
use Test\TestCase;
-use PHPUnit\Framework\MockObject\MockObject;
class MessageTest extends TestCase {
/** @var Email */
diff --git a/tests/lib/Memcache/APCuTest.php b/tests/lib/Memcache/APCuTest.php
index 3568b8a4622..c13d30da136 100644
--- a/tests/lib/Memcache/APCuTest.php
+++ b/tests/lib/Memcache/APCuTest.php
@@ -1,10 +1,9 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Memcache;
diff --git a/tests/lib/Memcache/ArrayCacheTest.php b/tests/lib/Memcache/ArrayCacheTest.php
index 47a39a82d5d..42b548355eb 100644
--- a/tests/lib/Memcache/ArrayCacheTest.php
+++ b/tests/lib/Memcache/ArrayCacheTest.php
@@ -1,10 +1,9 @@
<?php
/**
- * Copyright (c) 2015 Joas Schilling <nickvergessen@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Memcache;
diff --git a/tests/lib/Memcache/Cache.php b/tests/lib/Memcache/Cache.php
index ab316738c9c..efdaffc94eb 100644
--- a/tests/lib/Memcache/Cache.php
+++ b/tests/lib/Memcache/Cache.php
@@ -1,10 +1,9 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Memcache;
diff --git a/tests/lib/Memcache/CasTraitTest.php b/tests/lib/Memcache/CasTraitTest.php
index f077cf143b3..1c09a0e08f8 100644
--- a/tests/lib/Memcache/CasTraitTest.php
+++ b/tests/lib/Memcache/CasTraitTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Robin Appelman <icewind@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Memcache;
diff --git a/tests/lib/Memcache/FactoryTest.php b/tests/lib/Memcache/FactoryTest.php
index 9cdd7058ffa..5a1509eb3d9 100644
--- a/tests/lib/Memcache/FactoryTest.php
+++ b/tests/lib/Memcache/FactoryTest.php
@@ -1,29 +1,15 @@
<?php
/**
- * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Memcache;
use OC\Memcache\NullCache;
-use Psr\Log\LoggerInterface;
use OCP\Profiler\IProfiler;
+use Psr\Log\LoggerInterface;
class Test_Factory_Available_Cache1 extends NullCache {
public function __construct($prefix = '') {
@@ -140,4 +126,15 @@ class FactoryTest extends \Test\TestCase {
$profiler = $this->getMockBuilder(IProfiler::class)->getMock();
new \OC\Memcache\Factory('abc', $logger, $profiler, $localCache, $distributedCache);
}
+
+ public function testCreateInMemory(): void {
+ $logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
+ $profiler = $this->getMockBuilder(IProfiler::class)->getMock();
+ $factory = new \OC\Memcache\Factory('abc', $logger, $profiler, null, null, null);
+
+ $cache = $factory->createInMemory();
+ $cache->set('test', 48);
+
+ self::assertSame(48, $cache->get('test'));
+ }
}
diff --git a/tests/lib/Memcache/MemcachedTest.php b/tests/lib/Memcache/MemcachedTest.php
index 24cf0ba7af3..48f93a45ed9 100644
--- a/tests/lib/Memcache/MemcachedTest.php
+++ b/tests/lib/Memcache/MemcachedTest.php
@@ -1,10 +1,9 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Memcache;
diff --git a/tests/lib/Memcache/RedisTest.php b/tests/lib/Memcache/RedisTest.php
index b94b69a5e6a..8df286b2f93 100644
--- a/tests/lib/Memcache/RedisTest.php
+++ b/tests/lib/Memcache/RedisTest.php
@@ -1,19 +1,25 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Memcache;
+use OC\Memcache\Redis;
+
/**
* @group Memcache
* @group Redis
*/
class RedisTest extends Cache {
+ /**
+ * @var Redis cache;
+ */
+ protected $instance;
+
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
@@ -62,4 +68,18 @@ class RedisTest extends Cache {
$this->assertEquals(sha1($script[0]), $script[1]);
}
}
+
+ public function testCasTtlNotChanged() {
+ $this->instance->set('foo', 'bar', 50);
+ $this->assertTrue($this->instance->compareSetTTL('foo', 'bar', 100));
+ // allow for 1s of inaccuracy due to time moving forward
+ $this->assertLessThan(1, 100 - $this->instance->getTTL('foo'));
+ }
+
+ public function testCasTtlChanged() {
+ $this->instance->set('foo', 'bar1', 50);
+ $this->assertFalse($this->instance->compareSetTTL('foo', 'bar', 100));
+ // allow for 1s of inaccuracy due to time moving forward
+ $this->assertLessThan(1, 50 - $this->instance->getTTL('foo'));
+ }
}
diff --git a/tests/lib/MemoryInfoTest.php b/tests/lib/MemoryInfoTest.php
index 1a983f19ece..fb9c9ac7bd4 100644
--- a/tests/lib/MemoryInfoTest.php
+++ b/tests/lib/MemoryInfoTest.php
@@ -3,23 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018, Michael Weimann (<mail@michael-weimann.eu>)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/Metadata/FileMetadataMapperTest.php b/tests/lib/Metadata/FileMetadataMapperTest.php
deleted file mode 100644
index 4f7708ab9a9..00000000000
--- a/tests/lib/Metadata/FileMetadataMapperTest.php
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright 2022 Carl Schwan <carl@carlschwan.eu>
- * @license AGPL-3.0-or-later
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace Test\Metadata;
-
-use OC\Metadata\FileMetadataMapper;
-use OC\Metadata\FileMetadata;
-use PHPUnit\Framework\MockObject\MockObject;
-
-/**
- * @group DB
- * @package Test\DB\QueryBuilder
- */
-class FileMetadataMapperTest extends \Test\TestCase {
- /** @var IDBConnection */
- protected $connection;
-
- /** @var SystemConfig|MockObject */
- protected $config;
-
- /** @var FileMetadataMapper|MockObject */
- protected $mapper;
-
- protected function setUp(): void {
- parent::setUp();
-
- $this->connection = \OC::$server->getDatabaseConnection();
- $this->mapper = new FileMetadataMapper($this->connection);
- }
-
- public function testFindForGroupForFiles() {
- $file1 = new FileMetadata();
- $file1->setId(1);
- $file1->setGroupName('size');
- $file1->setArrayAsValue([]);
-
- $file2 = new FileMetadata();
- $file2->setId(2);
- $file2->setGroupName('size');
- $file2->setArrayAsValue(['width' => 293, 'height' => 23]);
-
- // not added, it's the default
- $file3 = new FileMetadata();
- $file3->setId(3);
- $file3->setGroupName('size');
- $file3->setArrayAsValue([]);
-
- $file4 = new FileMetadata();
- $file4->setId(4);
- $file4->setGroupName('size');
- $file4->setArrayAsValue(['complex' => ["yes", "maybe" => 34.0]]);
-
- $this->mapper->insert($file1);
- $this->mapper->insert($file2);
- $this->mapper->insert($file4);
-
- $files = $this->mapper->findForGroupForFiles([1, 2, 3, 4], 'size');
-
- $this->assertEquals($files[1]->getValue(), $file1->getValue());
- $this->assertEquals($files[2]->getValue(), $file2->getValue());
- $this->assertEquals($files[3]->getDecodedValue(), $file3->getDecodedValue());
- $this->assertEquals($files[4]->getValue(), $file4->getValue());
-
- $this->mapper->clear(1);
- $this->mapper->clear(2);
- $this->mapper->clear(4);
- }
-}
diff --git a/tests/lib/Migration/BackgroundRepairTest.php b/tests/lib/Migration/BackgroundRepairTest.php
index 2e68924a96d..2744ac5cefb 100644
--- a/tests/lib/Migration/BackgroundRepairTest.php
+++ b/tests/lib/Migration/BackgroundRepairTest.php
@@ -1,35 +1,21 @@
<?php
/**
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Migration;
-use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\EventDispatcher\IEventDispatcher;
-use OCP\Migration\IOutput;
-use OCP\Migration\IRepairStep;
use OC\BackgroundJob\JobList;
use OC\Migration\BackgroundRepair;
use OC\NeedsUpdateException;
+use OC\Repair;
use OC\Repair\Events\RepairStepEvent;
-use PHPUnit\Framework\MockObject\MockObject;
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Migration\IOutput;
+use OCP\Migration\IRepairStep;
use Psr\Log\LoggerInterface;
use Test\TestCase;
@@ -57,20 +43,12 @@ class TestRepairStep implements IRepairStep {
}
class BackgroundRepairTest extends TestCase {
- /** @var JobList|MockObject */
- private $jobList;
-
- /** @var BackgroundRepair|MockObject */
- private $job;
-
- /** @var LoggerInterface|MockObject */
- private $logger;
-
- /** @var IEventDispatcher|MockObject $dispatcher */
- private $dispatcher;
-
- /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject $dispatcher */
- private $time;
+ private JobList $jobList;
+ private BackgroundRepair $job;
+ private LoggerInterface $logger;
+ private IEventDispatcher $dispatcher;
+ private ITimeFactory $time;
+ private Repair $repair;
protected function setUp(): void {
parent::setUp();
@@ -85,8 +63,9 @@ class BackgroundRepairTest extends TestCase {
$this->time = $this->createMock(ITimeFactory::class);
$this->time->method('getTime')
->willReturn(999999);
+ $this->repair = new Repair($this->dispatcher, $this->logger);
$this->job = $this->getMockBuilder(BackgroundRepair::class)
- ->setConstructorArgs([$this->dispatcher, $this->time, $this->logger, $this->jobList])
+ ->setConstructorArgs([$this->repair, $this->time, $this->logger, $this->jobList])
->setMethods(['loadApp'])
->getMock();
}
diff --git a/tests/lib/NaturalSortTest.php b/tests/lib/NaturalSortTest.php
index 9474d5c077c..a053687eaf9 100644
--- a/tests/lib/NaturalSortTest.php
+++ b/tests/lib/NaturalSortTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Vincent Petry <PVince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/NavigationManagerTest.php b/tests/lib/NavigationManagerTest.php
index d5c827fe1cb..1899fdd9443 100644
--- a/tests/lib/NavigationManagerTest.php
+++ b/tests/lib/NavigationManagerTest.php
@@ -1,13 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Joas Schilling
- * @copyright 2015 Joas Schilling nickvergessen@owncloud.com
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
@@ -95,7 +90,7 @@ class NavigationManagerTest extends TestCase {
//'icon' => 'optional',
'href' => 'url',
'active' => true,
- 'unread' => 0
+ 'unread' => 0,
],
'entry id2' => [
'id' => 'entry id',
@@ -106,7 +101,8 @@ class NavigationManagerTest extends TestCase {
'active' => false,
'type' => 'link',
'classes' => '',
- 'unread' => 0
+ 'unread' => 0,
+ 'default' => true,
]
]
];
@@ -215,23 +211,27 @@ class NavigationManagerTest extends TestCase {
return vsprintf($text, $parameters);
});
+ /* Return default value */
+ $this->config->method('getUserValue')
+ ->willReturnArgument(3);
+
$this->appManager->expects($this->any())
->method('isEnabledForUser')
->with('theming')
->willReturn(true);
- $this->appManager->expects($this->once())->method('getAppInfo')->with('test')->willReturn($navigation);
- /*
+ $this->appManager->expects($this->once())
+ ->method('getAppInfo')
+ ->with('test')
+ ->willReturn($navigation);
+ $this->urlGenerator->expects($this->any())
+ ->method('imagePath')
+ ->willReturnCallback(function ($appName, $file) {
+ return "/apps/$appName/img/$file";
+ });
$this->appManager->expects($this->any())
- ->method('getAppInfo')
- ->will($this->returnValueMap([
- ['test', null, null, $navigation],
- ['theming', null, null, null],
- ]));
- */
+ ->method('getAppIcon')
+ ->willReturnCallback(fn (string $appName) => "/apps/$appName/img/app.svg");
$this->l10nFac->expects($this->any())->method('get')->willReturn($l);
- $this->urlGenerator->expects($this->any())->method('imagePath')->willReturnCallback(function ($appName, $file) {
- return "/apps/$appName/img/$file";
- });
$this->urlGenerator->expects($this->any())->method('linkToRoute')->willReturnCallback(function ($route) {
if ($route === 'core.login.logout') {
return 'https://example.com/logout';
@@ -271,6 +271,17 @@ class NavigationManagerTest extends TestCase {
]
];
$defaults = [
+ 'profile' => [
+ 'type' => 'settings',
+ 'id' => 'profile',
+ 'order' => 1,
+ 'href' => '/apps/test/',
+ 'name' => 'View profile',
+ 'icon' => '',
+ 'active' => false,
+ 'classes' => '',
+ 'unread' => 0,
+ ],
'accessibility_settings' => [
'type' => 'settings',
'id' => 'accessibility_settings',
@@ -334,6 +345,7 @@ class NavigationManagerTest extends TestCase {
return [
'minimalistic' => [
array_merge(
+ ['profile' => $defaults['profile']],
['accessibility_settings' => $defaults['accessibility_settings']],
['settings' => $defaults['settings']],
['test' => [
@@ -345,7 +357,9 @@ class NavigationManagerTest extends TestCase {
'active' => false,
'type' => 'link',
'classes' => '',
- 'unread' => 0
+ 'unread' => 0,
+ 'default' => true,
+ 'app' => 'test',
]],
['logout' => $defaults['logout']]
),
@@ -357,6 +371,7 @@ class NavigationManagerTest extends TestCase {
],
'minimalistic-settings' => [
array_merge(
+ ['profile' => $defaults['profile']],
['accessibility_settings' => $defaults['accessibility_settings']],
['settings' => $defaults['settings']],
['test' => [
@@ -368,7 +383,7 @@ class NavigationManagerTest extends TestCase {
'active' => false,
'type' => 'settings',
'classes' => '',
- 'unread' => 0
+ 'unread' => 0,
]],
['logout' => $defaults['logout']]
),
@@ -378,8 +393,49 @@ class NavigationManagerTest extends TestCase {
],
]]
],
+ 'with-multiple' => [
+ array_merge(
+ ['profile' => $defaults['profile']],
+ ['accessibility_settings' => $defaults['accessibility_settings']],
+ ['settings' => $defaults['settings']],
+ ['test' => [
+ 'id' => 'test',
+ 'order' => 100,
+ 'href' => '/apps/test/',
+ 'icon' => '/apps/test/img/app.svg',
+ 'name' => 'Test',
+ 'active' => false,
+ 'type' => 'link',
+ 'classes' => '',
+ 'unread' => 0,
+ 'default' => false,
+ 'app' => 'test',
+ ],
+ 'test1' => [
+ 'id' => 'test1',
+ 'order' => 50,
+ 'href' => '/apps/test/',
+ 'icon' => '/apps/test/img/app.svg',
+ 'name' => 'Other test',
+ 'active' => false,
+ 'type' => 'link',
+ 'classes' => '',
+ 'unread' => 0,
+ 'default' => true, // because of order
+ 'app' => 'test',
+ ]],
+ ['logout' => $defaults['logout']]
+ ),
+ ['navigations' => [
+ 'navigation' => [
+ ['route' => 'test.page.index', 'name' => 'Test'],
+ ['route' => 'test.page.index', 'name' => 'Other test', 'order' => 50],
+ ]
+ ]]
+ ],
'admin' => [
array_merge(
+ ['profile' => $defaults['profile']],
$adminSettings,
$apps,
['test' => [
@@ -391,7 +447,9 @@ class NavigationManagerTest extends TestCase {
'active' => false,
'type' => 'link',
'classes' => '',
- 'unread' => 0
+ 'unread' => 0,
+ 'default' => true,
+ 'app' => 'test',
]],
['logout' => $defaults['logout']]
),
@@ -404,6 +462,7 @@ class NavigationManagerTest extends TestCase {
],
'no name' => [
array_merge(
+ ['profile' => $defaults['profile']],
$adminSettings,
$apps,
['logout' => $defaults['logout']]
@@ -417,12 +476,85 @@ class NavigationManagerTest extends TestCase {
],
'no admin' => [
$defaults,
- ['navigations' => [[
- '@attributes' => ['role' => 'admin'],
- 'route' => 'test.page.index',
- 'name' => 'Test'
- ]]]
+ ['navigations' => [
+ 'navigation' => [
+ ['@attributes' => ['role' => 'admin'], 'route' => 'test.page.index', 'name' => 'Test']
+ ],
+ ]],
]
];
}
+
+ public function testWithAppManagerAndApporder() {
+ $l = $this->createMock(IL10N::class);
+ $l->expects($this->any())->method('t')->willReturnCallback(function ($text, $parameters = []) {
+ return vsprintf($text, $parameters);
+ });
+
+ $testOrder = 12;
+ $expected = [
+ 'test' => [
+ 'type' => 'link',
+ 'id' => 'test',
+ 'order' => $testOrder,
+ 'href' => '/apps/test/',
+ 'name' => 'Test',
+ 'icon' => '/apps/test/img/app.svg',
+ 'active' => false,
+ 'classes' => '',
+ 'unread' => 0,
+ 'default' => true,
+ 'app' => 'test',
+ ],
+ ];
+ $navigation = ['navigations' => [
+ 'navigation' => [
+ ['route' => 'test.page.index', 'name' => 'Test']
+ ],
+ ]];
+
+ $this->config->method('getUserValue')
+ ->willReturnCallback(
+ function (string $userId, string $appName, string $key, mixed $default = '') use ($testOrder) {
+ $this->assertEquals('user001', $userId);
+ if ($key === 'apporder') {
+ return json_encode(['test' => ['app' => 'test', 'order' => $testOrder]]);
+ }
+ return $default;
+ }
+ );
+
+ $this->appManager->expects($this->any())
+ ->method('isEnabledForUser')
+ ->with('theming')
+ ->willReturn(true);
+ $this->appManager->expects($this->once())->method('getAppInfo')->with('test')->willReturn($navigation);
+ $this->appManager->expects($this->once())->method('getAppIcon')->with('test')->willReturn('/apps/test/img/app.svg');
+ $this->l10nFac->expects($this->any())->method('get')->willReturn($l);
+ $this->urlGenerator->expects($this->any())->method('imagePath')->willReturnCallback(function ($appName, $file) {
+ return "/apps/$appName/img/$file";
+ });
+ $this->urlGenerator->expects($this->any())->method('linkToRoute')->willReturnCallback(function ($route) {
+ if ($route === 'core.login.logout') {
+ return 'https://example.com/logout';
+ }
+ return '/apps/test/';
+ });
+ $user = $this->createMock(IUser::class);
+ $user->expects($this->any())->method('getUID')->willReturn('user001');
+ $this->userSession->expects($this->any())->method('getUser')->willReturn($user);
+ $this->userSession->expects($this->any())->method('isLoggedIn')->willReturn(true);
+ $this->appManager->expects($this->any())
+ ->method('getEnabledAppsForUser')
+ ->with($user)
+ ->willReturn(['test']);
+ $this->groupManager->expects($this->any())->method('isAdmin')->willReturn(false);
+ $subadmin = $this->createMock(SubAdmin::class);
+ $subadmin->expects($this->any())->method('isSubAdmin')->with($user)->willReturn(false);
+ $this->groupManager->expects($this->any())->method('getSubAdmin')->willReturn($subadmin);
+
+ $this->navigationManager->clear();
+ $entries = $this->navigationManager->getAll();
+ $this->assertEquals($expected, $entries);
+ }
}
diff --git a/tests/lib/Net/HostnameClassifierTest.php b/tests/lib/Net/HostnameClassifierTest.php
index f363a08bb8a..766246ed8ad 100644
--- a/tests/lib/Net/HostnameClassifierTest.php
+++ b/tests/lib/Net/HostnameClassifierTest.php
@@ -2,25 +2,9 @@
declare(strict_types=1);
-/*
- * @copyright 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\Net;
diff --git a/tests/lib/Net/IpAddressClassifierTest.php b/tests/lib/Net/IpAddressClassifierTest.php
index 593abcd2b40..616a6872bdb 100644
--- a/tests/lib/Net/IpAddressClassifierTest.php
+++ b/tests/lib/Net/IpAddressClassifierTest.php
@@ -2,25 +2,9 @@
declare(strict_types=1);
-/*
- * @copyright 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\Net;
diff --git a/tests/lib/Notification/ActionTest.php b/tests/lib/Notification/ActionTest.php
index 6016760c24f..bfcfbbe75db 100644
--- a/tests/lib/Notification/ActionTest.php
+++ b/tests/lib/Notification/ActionTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Notification;
diff --git a/tests/lib/Notification/DummyApp.php b/tests/lib/Notification/DummyApp.php
index 564a1ff7d54..7cd99f13fd6 100644
--- a/tests/lib/Notification/DummyApp.php
+++ b/tests/lib/Notification/DummyApp.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Notification;
diff --git a/tests/lib/Notification/DummyNotifier.php b/tests/lib/Notification/DummyNotifier.php
index 2df97a9057d..c536c8483f2 100644
--- a/tests/lib/Notification/DummyNotifier.php
+++ b/tests/lib/Notification/DummyNotifier.php
@@ -2,23 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Notification;
diff --git a/tests/lib/Notification/ManagerTest.php b/tests/lib/Notification/ManagerTest.php
index a32eebcdb95..47740ed18b5 100644
--- a/tests/lib/Notification/ManagerTest.php
+++ b/tests/lib/Notification/ManagerTest.php
@@ -2,23 +2,9 @@
declare(strict_types=1);
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Notification;
diff --git a/tests/lib/Notification/NotificationTest.php b/tests/lib/Notification/NotificationTest.php
index 1479e8841a2..9afc74db495 100644
--- a/tests/lib/Notification/NotificationTest.php
+++ b/tests/lib/Notification/NotificationTest.php
@@ -2,23 +2,9 @@
declare(strict_types = 1);
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Notification;
diff --git a/tests/lib/OCS/DiscoveryServiceTest.php b/tests/lib/OCS/DiscoveryServiceTest.php
index da3897163cb..1c71ee4c7a5 100644
--- a/tests/lib/OCS/DiscoveryServiceTest.php
+++ b/tests/lib/OCS/DiscoveryServiceTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\OCS;
diff --git a/tests/lib/OCS/MapStatusCodeTest.php b/tests/lib/OCS/MapStatusCodeTest.php
index 3022323870a..c6d6d5edd06 100644
--- a/tests/lib/OCS/MapStatusCodeTest.php
+++ b/tests/lib/OCS/MapStatusCodeTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\OCS;
diff --git a/tests/lib/OCS/ProviderTest.php b/tests/lib/OCS/ProviderTest.php
index f66bd2eab01..c1efa7d873e 100644
--- a/tests/lib/OCS/ProviderTest.php
+++ b/tests/lib/OCS/ProviderTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\OCS;
diff --git a/tests/lib/Preview/BackgroundCleanupJobTest.php b/tests/lib/Preview/BackgroundCleanupJobTest.php
index aa15ea7f562..a221829b712 100644
--- a/tests/lib/Preview/BackgroundCleanupJobTest.php
+++ b/tests/lib/Preview/BackgroundCleanupJobTest.php
@@ -1,23 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2018, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Preview;
@@ -84,7 +68,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase {
$this->connection = \OC::$server->getDatabaseConnection();
$this->previewManager = \OC::$server->getPreviewManager();
- $this->rootFolder = \OC::$server->getRootFolder();
+ $this->rootFolder = \OC::$server->get(IRootFolder::class);
$this->mimeTypeLoader = \OC::$server->getMimeTypeLoader();
$this->timeFactory = \OCP\Server::get(ITimeFactory::class);
}
@@ -102,7 +86,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase {
private function getRoot(): Root {
return new Root(
- \OC::$server->getRootFolder(),
+ \OC::$server->get(IRootFolder::class),
\OC::$server->getSystemConfig()
);
}
diff --git a/tests/lib/Preview/BitmapTest.php b/tests/lib/Preview/BitmapTest.php
index 554e499ee84..c4f3f8d3cf5 100644
--- a/tests/lib/Preview/BitmapTest.php
+++ b/tests/lib/Preview/BitmapTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Olivier Paroz <owncloud@interfasys.ch>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Preview;
diff --git a/tests/lib/Preview/GeneratorTest.php b/tests/lib/Preview/GeneratorTest.php
index c7ffab27592..9116fee7e2f 100644
--- a/tests/lib/Preview/GeneratorTest.php
+++ b/tests/lib/Preview/GeneratorTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Preview;
diff --git a/tests/lib/Preview/HEICTest.php b/tests/lib/Preview/HEICTest.php
index 18571dc52ea..cfd2adac912 100644
--- a/tests/lib/Preview/HEICTest.php
+++ b/tests/lib/Preview/HEICTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2018, Sebastian Steinmetz (me@sebastiansteinmetz.ch)
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Preview;
diff --git a/tests/lib/Preview/ImageTest.php b/tests/lib/Preview/ImageTest.php
index d58e4ca91ba..f4b8e7e1dd4 100644
--- a/tests/lib/Preview/ImageTest.php
+++ b/tests/lib/Preview/ImageTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Olivier Paroz <owncloud@interfasys.ch>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Preview;
diff --git a/tests/lib/Preview/MP3Test.php b/tests/lib/Preview/MP3Test.php
index 6e841e29ec4..6f40b862b7b 100644
--- a/tests/lib/Preview/MP3Test.php
+++ b/tests/lib/Preview/MP3Test.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Olivier Paroz <owncloud@interfasys.ch>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Preview;
diff --git a/tests/lib/Preview/MovieTest.php b/tests/lib/Preview/MovieTest.php
index 767ce130ae4..d41b242945b 100644
--- a/tests/lib/Preview/MovieTest.php
+++ b/tests/lib/Preview/MovieTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Olivier Paroz <owncloud@interfasys.ch>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Preview;
diff --git a/tests/lib/Preview/OfficeTest.php b/tests/lib/Preview/OfficeTest.php
index c37e5b95a75..c9019d017a3 100644
--- a/tests/lib/Preview/OfficeTest.php
+++ b/tests/lib/Preview/OfficeTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Olivier Paroz <owncloud@interfasys.ch>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Preview;
diff --git a/tests/lib/Preview/Provider.php b/tests/lib/Preview/Provider.php
index a2e5170c82c..6cecd8a0762 100644
--- a/tests/lib/Preview/Provider.php
+++ b/tests/lib/Preview/Provider.php
@@ -1,27 +1,14 @@
<?php
/**
- * @author Olivier Paroz <owncloud@interfasys.ch>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Preview;
use OC\Files\Node\File;
+use OCP\Files\IRootFolder;
abstract class Provider extends \Test\TestCase {
/** @var string */
@@ -137,7 +124,7 @@ abstract class Provider extends \Test\TestCase {
* @return bool|\OCP\IImage
*/
private function getPreview($provider) {
- $file = new File(\OC::$server->getRootFolder(), $this->rootView, $this->imgPath);
+ $file = new File(\OC::$server->get(IRootFolder::class), $this->rootView, $this->imgPath);
$preview = $provider->getThumbnail($file, $this->maxWidth, $this->maxHeight, $this->scalingUp);
if (get_class($this) === BitmapTest::class && $preview === null) {
diff --git a/tests/lib/Preview/SVGTest.php b/tests/lib/Preview/SVGTest.php
index e48018a301b..6a0e93e5f79 100644
--- a/tests/lib/Preview/SVGTest.php
+++ b/tests/lib/Preview/SVGTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Olivier Paroz <owncloud@interfasys.ch>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Preview;
@@ -43,4 +29,33 @@ class SVGTest extends Provider {
$this->markTestSkipped('No SVG provider present');
}
}
+
+ public function dataGetThumbnailSVGHref(): array {
+ return [
+ ['href'],
+ [' href'],
+ ["\nhref"],
+ ['xlink:href'],
+ [' xlink:href'],
+ ["\nxlink:href"],
+ ];
+ }
+
+ /**
+ * @dataProvider dataGetThumbnailSVGHref
+ * @requires extension imagick
+ */
+ public function testGetThumbnailSVGHref(string $content): void {
+ $handle = fopen('php://temp', 'w+');
+ fwrite($handle, '<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
+ <image x="0" y="0"' . $content . '="fxlogo.png" height="100" width="100" />
+</svg>');
+ rewind($handle);
+
+ $file = $this->createMock(\OCP\Files\File::class);
+ $file->method('fopen')
+ ->willReturn($handle);
+
+ self::assertNull($this->provider->getThumbnail($file, 512, 512));
+ }
}
diff --git a/tests/lib/Preview/TXTTest.php b/tests/lib/Preview/TXTTest.php
index 785fe8c2526..7f5510eb60f 100644
--- a/tests/lib/Preview/TXTTest.php
+++ b/tests/lib/Preview/TXTTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Olivier Paroz <owncloud@interfasys.ch>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Preview;
diff --git a/tests/lib/PublicNamespace/UtilTest.php b/tests/lib/PublicNamespace/UtilTest.php
index 9699d7a0ed2..6931b191a4d 100644
--- a/tests/lib/PublicNamespace/UtilTest.php
+++ b/tests/lib/PublicNamespace/UtilTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Victor Dubiniuk
- * @copyright 2015 Victor Dubiniuk victor.dubiniuk@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\PublicNamespace;
diff --git a/tests/lib/Remote/Api/OCSTest.php b/tests/lib/Remote/Api/OCSTest.php
index 43e7c61a4cd..d47bb50cc35 100644
--- a/tests/lib/Remote/Api/OCSTest.php
+++ b/tests/lib/Remote/Api/OCSTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Remote\Api;
diff --git a/tests/lib/Remote/InstanceTest.php b/tests/lib/Remote/InstanceTest.php
index 3ec7451263d..3e4ffda15b7 100644
--- a/tests/lib/Remote/InstanceTest.php
+++ b/tests/lib/Remote/InstanceTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Remote;
diff --git a/tests/lib/Repair/CleanTagsTest.php b/tests/lib/Repair/CleanTagsTest.php
index 9fc3ef17150..586ae24a0aa 100644
--- a/tests/lib/Repair/CleanTagsTest.php
+++ b/tests/lib/Repair/CleanTagsTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Joas Schilling <nickvergessen@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Repair;
diff --git a/tests/lib/Repair/ClearFrontendCachesTest.php b/tests/lib/Repair/ClearFrontendCachesTest.php
index 0050f0e2340..640e272f3b7 100644
--- a/tests/lib/Repair/ClearFrontendCachesTest.php
+++ b/tests/lib/Repair/ClearFrontendCachesTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Repair;
diff --git a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php b/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php
index 0e3347cd5ac..1545085f977 100644
--- a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php
+++ b/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Repair;
diff --git a/tests/lib/Repair/NC11/FixMountStoragesTest.php b/tests/lib/Repair/NC11/FixMountStoragesTest.php
index 843cc31392c..6fdcc07d24e 100644
--- a/tests/lib/Repair/NC11/FixMountStoragesTest.php
+++ b/tests/lib/Repair/NC11/FixMountStoragesTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2016 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Repair\NC11;
diff --git a/tests/lib/Repair/OldGroupMembershipSharesTest.php b/tests/lib/Repair/OldGroupMembershipSharesTest.php
index 7ebc12732d6..4678bd174eb 100644
--- a/tests/lib/Repair/OldGroupMembershipSharesTest.php
+++ b/tests/lib/Repair/OldGroupMembershipSharesTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Repair;
diff --git a/tests/lib/Repair/RepairCollationTest.php b/tests/lib/Repair/RepairCollationTest.php
index 9e76a81080f..55bda8337c9 100644
--- a/tests/lib/Repair/RepairCollationTest.php
+++ b/tests/lib/Repair/RepairCollationTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Repair;
diff --git a/tests/lib/Repair/RepairDavSharesTest.php b/tests/lib/Repair/RepairDavSharesTest.php
index 394fc985469..9831365e974 100644
--- a/tests/lib/Repair/RepairDavSharesTest.php
+++ b/tests/lib/Repair/RepairDavSharesTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2021 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Repair;
@@ -32,9 +15,9 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroupManager;
+use OCP\Migration\IOutput;
use Psr\Log\LoggerInterface;
use Test\TestCase;
-use OCP\Migration\IOutput;
use function in_array;
class RepairDavSharesTest extends TestCase {
diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php
index 486e11230b8..eb0e46c61db 100644
--- a/tests/lib/Repair/RepairInvalidSharesTest.php
+++ b/tests/lib/Repair/RepairInvalidSharesTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Repair;
diff --git a/tests/lib/Repair/RepairMimeTypesTest.php b/tests/lib/Repair/RepairMimeTypesTest.php
index 61cf5858241..b7076b32e77 100644
--- a/tests/lib/Repair/RepairMimeTypesTest.php
+++ b/tests/lib/Repair/RepairMimeTypesTest.php
@@ -1,10 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
- * Copyright (c) 2014-2015 Olivier Paroz owncloud@oparoz.com
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Repair;
diff --git a/tests/lib/Repair/RepairSqliteAutoincrementTest.php b/tests/lib/Repair/RepairSqliteAutoincrementTest.php
deleted file mode 100644
index b4be47d0157..00000000000
--- a/tests/lib/Repair/RepairSqliteAutoincrementTest.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-/**
- * Copyright (c) 2015 Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-namespace Test\Repair;
-
-use OC\DB\Connection;
-use OCP\Migration\IOutput;
-
-/**
- * Tests for fixing the SQLite id recycling
- *
- * @group DB
- */
-class RepairSqliteAutoincrementTest extends \Test\TestCase {
- /**
- * @var \OC\Repair\SqliteAutoincrement
- */
- private $repair;
-
- /**
- * @var Connection
- */
- private $connection;
-
- /**
- * @var string
- */
- private $tableName;
-
- /**
- * @var \OCP\IConfig
- */
- private $config;
-
- protected function setUp(): void {
- parent::setUp();
-
- $this->connection = \OC::$server->get(\OC\DB\Connection::class);
- $this->config = \OC::$server->getConfig();
- if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
- $this->markTestSkipped("Test only relevant on Sqlite");
- }
-
- $dbPrefix = $this->config->getSystemValueString('dbtableprefix', 'oc_');
- $this->tableName = $this->getUniqueID($dbPrefix . 'autoinc_test');
- $this->connection->prepare('CREATE TABLE ' . $this->tableName . '("someid" INTEGER NOT NULL, "text" VARCHAR(16), PRIMARY KEY("someid"))')->execute();
-
- $this->repair = new \OC\Repair\SqliteAutoincrement($this->connection);
- }
-
- protected function tearDown(): void {
- $this->connection->getSchemaManager()->dropTable($this->tableName);
- parent::tearDown();
- }
-
- /**
- * Tests whether autoincrement works
- *
- * @return boolean true if autoincrement works, false otherwise
- */
- protected function checkAutoincrement() {
- $this->connection->executeUpdate('INSERT INTO ' . $this->tableName . ' ("text") VALUES ("test")');
- $insertId = $this->connection->lastInsertId();
- $this->connection->executeUpdate('DELETE FROM ' . $this->tableName . ' WHERE "someid" = ?', [$insertId]);
-
- // insert again
- $this->connection->executeUpdate('INSERT INTO ' . $this->tableName . ' ("text") VALUES ("test2")');
- $newInsertId = $this->connection->lastInsertId();
-
- return ($insertId !== $newInsertId);
- }
-
- public function testConvertIdColumn() {
- $this->assertFalse($this->checkAutoincrement());
-
- /** @var IOutput | \PHPUnit\Framework\MockObject\MockObject $outputMock */
- $outputMock = $this->getMockBuilder('\OCP\Migration\IOutput')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->repair->run($outputMock);
-
- $this->assertTrue($this->checkAutoincrement());
- }
-}
diff --git a/tests/lib/RepairTest.php b/tests/lib/RepairTest.php
index 1a2fd620e49..ab60b14d47e 100644
--- a/tests/lib/RepairTest.php
+++ b/tests/lib/RepairTest.php
@@ -1,20 +1,19 @@
<?php
/**
- * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
-use OCP\EventDispatcher\IEventDispatcher;
-use OCP\Migration\IRepairStep;
use OC\Repair;
+use OC\Repair\Events\RepairErrorEvent;
use OC\Repair\Events\RepairInfoEvent;
use OC\Repair\Events\RepairStepEvent;
use OC\Repair\Events\RepairWarningEvent;
-use OC\Repair\Events\RepairErrorEvent;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Migration\IRepairStep;
use Psr\Log\LoggerInterface;
class TestRepairStep implements IRepairStep {
@@ -46,7 +45,7 @@ class RepairTest extends TestCase {
protected function setUp(): void {
parent::setUp();
$dispatcher = \OC::$server->get(IEventDispatcher::class);
- $this->repair = new \OC\Repair([], $dispatcher, $this->createMock(LoggerInterface::class));
+ $this->repair = new Repair($dispatcher, $this->createMock(LoggerInterface::class));
$dispatcher->addListener(RepairWarningEvent::class, function (RepairWarningEvent $event) {
$this->outputArray[] = 'warning: ' . $event->getMessage();
diff --git a/tests/lib/RichObjectStrings/DefinitionsTest.php b/tests/lib/RichObjectStrings/DefinitionsTest.php
index a17585079f2..efe372a25e8 100644
--- a/tests/lib/RichObjectStrings/DefinitionsTest.php
+++ b/tests/lib/RichObjectStrings/DefinitionsTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\RichObjectStrings;
diff --git a/tests/lib/RichObjectStrings/ValidatorTest.php b/tests/lib/RichObjectStrings/ValidatorTest.php
index 45c6f745bdd..3604dcba4f7 100644
--- a/tests/lib/RichObjectStrings/ValidatorTest.php
+++ b/tests/lib/RichObjectStrings/ValidatorTest.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\RichObjectStrings;
diff --git a/tests/lib/Route/RouterTest.php b/tests/lib/Route/RouterTest.php
index 301058f74a6..87d4afbc7b5 100644
--- a/tests/lib/Route/RouterTest.php
+++ b/tests/lib/Route/RouterTest.php
@@ -2,28 +2,14 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019 Morris Jobke <hey@morrisjobke.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Route;
use OC\Route\Router;
+use OCP\App\IAppManager;
use OCP\Diagnostics\IEventLogger;
use OCP\IConfig;
use OCP\IRequest;
@@ -54,6 +40,7 @@ class RouterTest extends TestCase {
$this->createMock(IConfig::class),
$this->createMock(IEventLogger::class),
$this->createMock(ContainerInterface::class),
+ $this->createMock(IAppManager::class),
);
$this->assertEquals('/index.php/apps/files/', $router->generate('files.view.index'));
diff --git a/tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php b/tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php
index 648d8627421..82bffb74e01 100644
--- a/tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php
+++ b/tests/lib/Security/Bruteforce/Backend/MemoryCacheBackendTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2023 Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\Bruteforce\Backend;
diff --git a/tests/lib/Security/Bruteforce/CapabilitiesTest.php b/tests/lib/Security/Bruteforce/CapabilitiesTest.php
index 266acdcb285..438a24f2240 100644
--- a/tests/lib/Security/Bruteforce/CapabilitiesTest.php
+++ b/tests/lib/Security/Bruteforce/CapabilitiesTest.php
@@ -3,23 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2017 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\Bruteforce;
diff --git a/tests/lib/Security/Bruteforce/ThrottlerTest.php b/tests/lib/Security/Bruteforce/ThrottlerTest.php
index e368a0912b1..69d20cccd3a 100644
--- a/tests/lib/Security/Bruteforce/ThrottlerTest.php
+++ b/tests/lib/Security/Bruteforce/ThrottlerTest.php
@@ -3,23 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\Bruteforce;
@@ -160,9 +145,9 @@ class ThrottlerTest extends TestCase {
* @param bool $enabled
*/
private function isIpWhiteListedHelper($ip,
- $whitelists,
- $isWhiteListed,
- $enabled) {
+ $whitelists,
+ $isWhiteListed,
+ $enabled) {
$this->config->method('getAppKeys')
->with($this->equalTo('bruteForce'))
->willReturn(array_keys($whitelists));
@@ -197,8 +182,8 @@ class ThrottlerTest extends TestCase {
* @param bool $isWhiteListed
*/
public function testIsIpWhiteListedWithEnabledProtection($ip,
- $whitelists,
- $isWhiteListed) {
+ $whitelists,
+ $isWhiteListed) {
$this->isIpWhiteListedHelper(
$ip,
$whitelists,
@@ -215,8 +200,8 @@ class ThrottlerTest extends TestCase {
* @param bool $isWhiteListed
*/
public function testIsIpWhiteListedWithDisabledProtection($ip,
- $whitelists,
- $isWhiteListed) {
+ $whitelists,
+ $isWhiteListed) {
$this->isIpWhiteListedHelper(
$ip,
$whitelists,
diff --git a/tests/lib/Security/CSP/AddContentSecurityPolicyEventTest.php b/tests/lib/Security/CSP/AddContentSecurityPolicyEventTest.php
index 7de4665ec58..edc0c613655 100644
--- a/tests/lib/Security/CSP/AddContentSecurityPolicyEventTest.php
+++ b/tests/lib/Security/CSP/AddContentSecurityPolicyEventTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\CSP;
diff --git a/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php b/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php
index 24acd3cabc9..dc0fe7c8340 100644
--- a/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php
+++ b/tests/lib/Security/CSP/ContentSecurityPolicyManagerTest.php
@@ -3,23 +3,9 @@
declare(strict_types=1);
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Security\CSP;
diff --git a/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php b/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php
index 0e21f13e6f7..f4281bd2b22 100644
--- a/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php
+++ b/tests/lib/Security/CSP/ContentSecurityPolicyNonceManagerTest.php
@@ -3,23 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\CSP;
diff --git a/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php b/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php
index 256199eff15..8b92848341c 100644
--- a/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php
+++ b/tests/lib/Security/CSRF/CsrfTokenGeneratorTest.php
@@ -3,23 +3,9 @@
declare(strict_types=1);
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Security\CSRF;
diff --git a/tests/lib/Security/CSRF/CsrfTokenManagerTest.php b/tests/lib/Security/CSRF/CsrfTokenManagerTest.php
index 44a9a7a929d..c4fd480654d 100644
--- a/tests/lib/Security/CSRF/CsrfTokenManagerTest.php
+++ b/tests/lib/Security/CSRF/CsrfTokenManagerTest.php
@@ -3,23 +3,9 @@
declare(strict_types=1);
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Security\CSRF;
diff --git a/tests/lib/Security/CSRF/CsrfTokenTest.php b/tests/lib/Security/CSRF/CsrfTokenTest.php
index b694e797232..c6f9aaa5be7 100644
--- a/tests/lib/Security/CSRF/CsrfTokenTest.php
+++ b/tests/lib/Security/CSRF/CsrfTokenTest.php
@@ -3,23 +3,9 @@
declare(strict_types=1);
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Security\CSRF;
diff --git a/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php b/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php
index f55cf49f142..8e5c8b8e481 100644
--- a/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php
+++ b/tests/lib/Security/CSRF/TokenStorage/SessionStorageTest.php
@@ -3,23 +3,9 @@
declare(strict_types=1);
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Security\CSRF\TokenStorage;
diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php
index 6ad8231a61d..fc5ae1f03f2 100644
--- a/tests/lib/Security/CertificateManagerTest.php
+++ b/tests/lib/Security/CertificateManagerTest.php
@@ -3,10 +3,9 @@
declare(strict_types=1);
/**
- * Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security;
@@ -146,9 +145,9 @@ class CertificateManagerTest extends \Test\TestCase {
* @param bool $expected
*/
public function testNeedRebundling($CaBundleMtime,
- $targetBundleMtime,
- $targetBundleExists,
- $expected
+ $targetBundleMtime,
+ $targetBundleExists,
+ $expected
) {
$view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock();
diff --git a/tests/lib/Security/CertificateTest.php b/tests/lib/Security/CertificateTest.php
index 2c430fc1273..6f4e736263b 100644
--- a/tests/lib/Security/CertificateTest.php
+++ b/tests/lib/Security/CertificateTest.php
@@ -3,23 +3,9 @@
declare(strict_types=1);
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Security;
diff --git a/tests/lib/Security/CredentialsManagerTest.php b/tests/lib/Security/CredentialsManagerTest.php
index bb4feb8b6a9..d9272627e5b 100644
--- a/tests/lib/Security/CredentialsManagerTest.php
+++ b/tests/lib/Security/CredentialsManagerTest.php
@@ -3,23 +3,9 @@
declare(strict_types=1);
/**
- * @author Robin McCorkell <rmccorkell@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Security;
diff --git a/tests/lib/Security/CryptoTest.php b/tests/lib/Security/CryptoTest.php
index bdbad8b2610..b65a9a36985 100644
--- a/tests/lib/Security/CryptoTest.php
+++ b/tests/lib/Security/CryptoTest.php
@@ -3,10 +3,9 @@
declare(strict_types=1);
/**
- * Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security;
diff --git a/tests/lib/Security/FeaturePolicy/AddFeaturePolicyEventTest.php b/tests/lib/Security/FeaturePolicy/AddFeaturePolicyEventTest.php
index 6e6433adbeb..3c964972238 100644
--- a/tests/lib/Security/FeaturePolicy/AddFeaturePolicyEventTest.php
+++ b/tests/lib/Security/FeaturePolicy/AddFeaturePolicyEventTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\CSP;
diff --git a/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php b/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php
index 7202e45de73..7110effb261 100644
--- a/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php
+++ b/tests/lib/Security/FeaturePolicy/FeaturePolicyManagerTest.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\CSP;
diff --git a/tests/lib/Security/HasherTest.php b/tests/lib/Security/HasherTest.php
index 3848b216f2b..0eb233de485 100644
--- a/tests/lib/Security/HasherTest.php
+++ b/tests/lib/Security/HasherTest.php
@@ -3,10 +3,9 @@
declare(strict_types=1);
/**
- * Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security;
diff --git a/tests/lib/Security/IdentityProof/KeyTest.php b/tests/lib/Security/IdentityProof/KeyTest.php
index 4c852ff7020..19dc02e2ad1 100644
--- a/tests/lib/Security/IdentityProof/KeyTest.php
+++ b/tests/lib/Security/IdentityProof/KeyTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\IdentityProof;
diff --git a/tests/lib/Security/IdentityProof/ManagerTest.php b/tests/lib/Security/IdentityProof/ManagerTest.php
index 8733d5de8be..bb5b01d563c 100644
--- a/tests/lib/Security/IdentityProof/ManagerTest.php
+++ b/tests/lib/Security/IdentityProof/ManagerTest.php
@@ -3,23 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\IdentityProof;
diff --git a/tests/lib/Security/IdentityProof/SignerTest.php b/tests/lib/Security/IdentityProof/SignerTest.php
index 36b7ef97bb6..8b8d93e6b9a 100644
--- a/tests/lib/Security/IdentityProof/SignerTest.php
+++ b/tests/lib/Security/IdentityProof/SignerTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\IdentityProof;
diff --git a/tests/lib/Security/Normalizer/IpAddressTest.php b/tests/lib/Security/Normalizer/IpAddressTest.php
index bb487659ced..ae6b5cbc9ca 100644
--- a/tests/lib/Security/Normalizer/IpAddressTest.php
+++ b/tests/lib/Security/Normalizer/IpAddressTest.php
@@ -3,23 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\Normalizer;
diff --git a/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php b/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php
index a48b1211587..27799ce4af5 100644
--- a/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php
+++ b/tests/lib/Security/RateLimiting/Backend/MemoryCacheBackendTest.php
@@ -3,23 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\RateLimiting\Backend;
diff --git a/tests/lib/Security/RateLimiting/LimiterTest.php b/tests/lib/Security/RateLimiting/LimiterTest.php
index a5b187fb546..332f26b81d0 100644
--- a/tests/lib/Security/RateLimiting/LimiterTest.php
+++ b/tests/lib/Security/RateLimiting/LimiterTest.php
@@ -3,23 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\RateLimiting;
diff --git a/tests/lib/Security/RemoteHostValidatorIntegrationTest.php b/tests/lib/Security/RemoteHostValidatorIntegrationTest.php
index 3cf99161b77..6cddb8b4ce9 100644
--- a/tests/lib/Security/RemoteHostValidatorIntegrationTest.php
+++ b/tests/lib/Security/RemoteHostValidatorIntegrationTest.php
@@ -2,25 +2,9 @@
declare(strict_types=1);
-/*
- * @copyright 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\Security;
diff --git a/tests/lib/Security/RemoteHostValidatorTest.php b/tests/lib/Security/RemoteHostValidatorTest.php
index 030a75b1e79..c698ebbc3c6 100644
--- a/tests/lib/Security/RemoteHostValidatorTest.php
+++ b/tests/lib/Security/RemoteHostValidatorTest.php
@@ -2,25 +2,9 @@
declare(strict_types=1);
-/*
- * @copyright 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace lib\Security;
@@ -60,8 +44,17 @@ class RemoteHostValidatorTest extends TestCase {
);
}
- public function testValid(): void {
- $host = 'nextcloud.com';
+ public function dataValid(): array {
+ return [
+ ['nextcloud.com', true],
+ ['com.one-.nextcloud-one.com', false],
+ ];
+ }
+
+ /**
+ * @dataProvider dataValid
+ */
+ public function testValid(string $host, bool $expected): void {
$this->hostnameClassifier
->method('isLocalHostname')
->with($host)
@@ -73,7 +66,7 @@ class RemoteHostValidatorTest extends TestCase {
$valid = $this->validator->isValid($host);
- self::assertTrue($valid);
+ self::assertSame($expected, $valid);
}
public function testLocalHostname(): void {
diff --git a/tests/lib/Security/SecureRandomTest.php b/tests/lib/Security/SecureRandomTest.php
index c7ee76a96bb..6e5f3587630 100644
--- a/tests/lib/Security/SecureRandomTest.php
+++ b/tests/lib/Security/SecureRandomTest.php
@@ -3,10 +3,9 @@
declare(strict_types=1);
/**
- * Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security;
diff --git a/tests/lib/Security/TrustedDomainHelperTest.php b/tests/lib/Security/TrustedDomainHelperTest.php
index 3fedf8964c5..3dbaf376b52 100644
--- a/tests/lib/Security/TrustedDomainHelperTest.php
+++ b/tests/lib/Security/TrustedDomainHelperTest.php
@@ -3,10 +3,9 @@
declare(strict_types=1);
/**
- * Copyright (c) 2015 Lukas Reschke <lukas@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security;
diff --git a/tests/lib/Security/VerificationToken/VerificationTokenTest.php b/tests/lib/Security/VerificationToken/VerificationTokenTest.php
index a71d2b09f71..f8573478fa5 100644
--- a/tests/lib/Security/VerificationToken/VerificationTokenTest.php
+++ b/tests/lib/Security/VerificationToken/VerificationTokenTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2021 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Security\VerificationToken;
@@ -34,8 +17,8 @@ use OCP\IUser;
use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom;
use OCP\Security\VerificationToken\InvalidTokenException;
-use Test\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
+use Test\TestCase;
class VerificationTokenTest extends TestCase {
/** @var VerificationToken */
diff --git a/tests/lib/ServerTest.php b/tests/lib/ServerTest.php
index d9f95e9eab1..d9ff8ea41c2 100644
--- a/tests/lib/ServerTest.php
+++ b/tests/lib/ServerTest.php
@@ -1,31 +1,15 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- * @author Lukas Reschke <lukas@owncloud.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test;
use OC\App\AppStore\Fetcher\AppFetcher;
use OC\App\AppStore\Fetcher\CategoryFetcher;
+use OCP\Comments\ICommentsManager;
/**
* Class Server
@@ -185,7 +169,7 @@ class ServerTest extends \Test\TestCase {
$config->setSystemValue('comments.managerFactory', '\Test\Comments\FakeFactory');
- $manager = $this->server->getCommentsManager();
+ $manager = $this->server->get(ICommentsManager::class);
$this->assertInstanceOf('\OCP\Comments\ICommentsManager', $manager);
$config->setSystemValue('comments.managerFactory', $defaultManagerFactory);
diff --git a/tests/lib/Session/CryptoSessionDataTest.php b/tests/lib/Session/CryptoSessionDataTest.php
index 10bc62e099c..83768ef49aa 100644
--- a/tests/lib/Session/CryptoSessionDataTest.php
+++ b/tests/lib/Session/CryptoSessionDataTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Session;
diff --git a/tests/lib/Session/CryptoWrappingTest.php b/tests/lib/Session/CryptoWrappingTest.php
index b8635b99120..093f2214929 100644
--- a/tests/lib/Session/CryptoWrappingTest.php
+++ b/tests/lib/Session/CryptoWrappingTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Session;
diff --git a/tests/lib/Session/MemoryTest.php b/tests/lib/Session/MemoryTest.php
index fab7292ae00..ae4a1b64dc0 100644
--- a/tests/lib/Session/MemoryTest.php
+++ b/tests/lib/Session/MemoryTest.php
@@ -1,10 +1,9 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Session;
diff --git a/tests/lib/Session/Session.php b/tests/lib/Session/Session.php
index 0c947b8d302..63fa4554477 100644
--- a/tests/lib/Session/Session.php
+++ b/tests/lib/Session/Session.php
@@ -1,10 +1,9 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Session;
diff --git a/tests/lib/Settings/DeclarativeManagerTest.php b/tests/lib/Settings/DeclarativeManagerTest.php
new file mode 100644
index 00000000000..f0d97c7ea25
--- /dev/null
+++ b/tests/lib/Settings/DeclarativeManagerTest.php
@@ -0,0 +1,521 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace Test\Settings;
+
+use OC\AppFramework\Bootstrap\Coordinator;
+use OC\Settings\DeclarativeManager;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\IAppConfig;
+use OCP\IConfig;
+use OCP\IGroupManager;
+use OCP\IUser;
+use OCP\Settings\DeclarativeSettingsTypes;
+use OCP\Settings\Events\DeclarativeSettingsSetValueEvent;
+use OCP\Settings\IDeclarativeManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
+use Test\TestCase;
+
+class DeclarativeManagerTest extends TestCase {
+
+ /** @var IDeclarativeManager|MockObject */
+ private $declarativeManager;
+
+ /** @var IEventDispatcher|MockObject */
+ private $eventDispatcher;
+
+ /** @var IGroupManager|MockObject */
+ private $groupManager;
+
+ /** @var Coordinator|MockObject */
+ private $coordinator;
+
+ /** @var IConfig|MockObject */
+ private $config;
+
+ /** @var IAppConfig|MockObject */
+ private $appConfig;
+
+ /** @var LoggerInterface|MockObject */
+ private $logger;
+
+ /** @var IUser|MockObject */
+ private $user;
+
+ /** @var IUser|MockObject */
+ private $adminUser;
+
+ public const validSchemaAllFields = [
+ 'id' => 'test_form_1',
+ 'priority' => 10,
+ 'section_type' => DeclarativeSettingsTypes::SECTION_TYPE_ADMIN, // admin, personal
+ 'section_id' => 'additional',
+ 'storage_type' => DeclarativeSettingsTypes::STORAGE_TYPE_INTERNAL, // external, internal (handled by core to store in appconfig and preferences)
+ 'title' => 'Test declarative settings', // NcSettingsSection name
+ 'description' => 'These fields are rendered dynamically from declarative schema', // NcSettingsSection description
+ 'doc_url' => '', // NcSettingsSection doc_url for documentation or help page, empty string if not needed
+ 'fields' => [
+ [
+ 'id' => 'test_field_7', // configkey
+ 'title' => 'Multi-selection', // name or label
+ 'description' => 'Select some option setting', // hint
+ 'type' => DeclarativeSettingsTypes::MULTI_SELECT,
+ 'options' => ['foo', 'bar', 'baz'], // simple options for select, radio, multi-select
+ 'placeholder' => 'Select some multiple options', // input placeholder
+ 'default' => ['foo', 'bar'],
+ ],
+ [
+ 'id' => 'some_real_setting',
+ 'title' => 'Select single option',
+ 'description' => 'Single option radio buttons',
+ 'type' => DeclarativeSettingsTypes::RADIO, // radio (NcCheckboxRadioSwitch type radio)
+ 'placeholder' => 'Select single option, test interval',
+ 'default' => '40m',
+ 'options' => [
+ [
+ 'name' => 'Each 40 minutes', // NcCheckboxRadioSwitch display name
+ 'value' => '40m' // NcCheckboxRadioSwitch value
+ ],
+ [
+ 'name' => 'Each 60 minutes',
+ 'value' => '60m'
+ ],
+ [
+ 'name' => 'Each 120 minutes',
+ 'value' => '120m'
+ ],
+ [
+ 'name' => 'Each day',
+ 'value' => 60 * 24 . 'm'
+ ],
+ ],
+ ],
+ [
+ 'id' => 'test_field_1', // configkey
+ 'title' => 'Default text field', // label
+ 'description' => 'Set some simple text setting', // hint
+ 'type' => DeclarativeSettingsTypes::TEXT,
+ 'placeholder' => 'Enter text setting', // placeholder
+ 'default' => 'foo',
+ ],
+ [
+ 'id' => 'test_field_1_1',
+ 'title' => 'Email field',
+ 'description' => 'Set email config',
+ 'type' => DeclarativeSettingsTypes::EMAIL,
+ 'placeholder' => 'Enter email',
+ 'default' => '',
+ ],
+ [
+ 'id' => 'test_field_1_2',
+ 'title' => 'Tel field',
+ 'description' => 'Set tel config',
+ 'type' => DeclarativeSettingsTypes::TEL,
+ 'placeholder' => 'Enter your tel',
+ 'default' => '',
+ ],
+ [
+ 'id' => 'test_field_1_3',
+ 'title' => 'Url (website) field',
+ 'description' => 'Set url config',
+ 'type' => 'url',
+ 'placeholder' => 'Enter url',
+ 'default' => '',
+ ],
+ [
+ 'id' => 'test_field_1_4',
+ 'title' => 'Number field',
+ 'description' => 'Set number config',
+ 'type' => DeclarativeSettingsTypes::NUMBER,
+ 'placeholder' => 'Enter number value',
+ 'default' => 0,
+ ],
+ [
+ 'id' => 'test_field_2',
+ 'title' => 'Password',
+ 'description' => 'Set some secure value setting',
+ 'type' => 'password',
+ 'placeholder' => 'Set secure value',
+ 'default' => '',
+ ],
+ [
+ 'id' => 'test_field_3',
+ 'title' => 'Selection',
+ 'description' => 'Select some option setting',
+ 'type' => DeclarativeSettingsTypes::SELECT,
+ 'options' => ['foo', 'bar', 'baz'],
+ 'placeholder' => 'Select some option setting',
+ 'default' => 'foo',
+ ],
+ [
+ 'id' => 'test_field_4',
+ 'title' => 'Toggle something',
+ 'description' => 'Select checkbox option setting',
+ 'type' => DeclarativeSettingsTypes::CHECKBOX,
+ 'label' => 'Verify something if enabled',
+ 'default' => false,
+ ],
+ [
+ 'id' => 'test_field_5',
+ 'title' => 'Multiple checkbox toggles, describing one setting, checked options are saved as an JSON object {foo: true, bar: false}',
+ 'description' => 'Select checkbox option setting',
+ 'type' => DeclarativeSettingsTypes::MULTI_CHECKBOX,
+ 'default' => ['foo' => true, 'bar' => true],
+ 'options' => [
+ [
+ 'name' => 'Foo',
+ 'value' => 'foo', // multiple-checkbox configkey
+ ],
+ [
+ 'name' => 'Bar',
+ 'value' => 'bar',
+ ],
+ [
+ 'name' => 'Baz',
+ 'value' => 'baz',
+ ],
+ [
+ 'name' => 'Qux',
+ 'value' => 'qux',
+ ],
+ ],
+ ],
+ [
+ 'id' => 'test_field_6',
+ 'title' => 'Radio toggles, describing one setting like single select',
+ 'description' => 'Select radio option setting',
+ 'type' => DeclarativeSettingsTypes::RADIO, // radio (NcCheckboxRadioSwitch type radio)
+ 'label' => 'Select single toggle',
+ 'default' => 'foo',
+ 'options' => [
+ [
+ 'name' => 'First radio', // NcCheckboxRadioSwitch display name
+ 'value' => 'foo' // NcCheckboxRadioSwitch value
+ ],
+ [
+ 'name' => 'Second radio',
+ 'value' => 'bar'
+ ],
+ [
+ 'name' => 'Second radio',
+ 'value' => 'baz'
+ ],
+ ],
+ ],
+ ],
+ ];
+
+ public static bool $testSetInternalValueAfterChange = false;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
+ $this->groupManager = $this->createMock(IGroupManager::class);
+ $this->coordinator = $this->createMock(Coordinator::class);
+ $this->config = $this->createMock(IConfig::class);
+ $this->appConfig = $this->createMock(IAppConfig::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
+
+ $this->declarativeManager = new DeclarativeManager(
+ $this->eventDispatcher,
+ $this->groupManager,
+ $this->coordinator,
+ $this->config,
+ $this->appConfig,
+ $this->logger
+ );
+
+ $this->user = $this->createMock(IUser::class);
+ $this->user->expects($this->any())
+ ->method('getUID')
+ ->willReturn('test_user');
+
+ $this->adminUser = $this->createMock(IUser::class);
+ $this->adminUser->expects($this->any())
+ ->method('getUID')
+ ->willReturn('admin_test_user');
+
+ $this->groupManager->expects($this->any())
+ ->method('isAdmin')
+ ->willReturnCallback(function ($userId) {
+ return $userId === 'admin_test_user';
+ });
+ }
+
+ public function testRegisterSchema(): void {
+ $app = 'testing';
+ $schema = self::validSchemaAllFields;
+ $this->declarativeManager->registerSchema($app, $schema);
+ $formIds = $this->declarativeManager->getFormIDs($this->adminUser, $schema['section_type'], $schema['section_id']);
+ $this->assertTrue(isset($formIds[$app]) && in_array($schema['id'], $formIds[$app]));
+ }
+
+ /**
+ * Simple test to verify that exception is thrown when trying to register schema with duplicate id
+ */
+ public function testRegisterDuplicateSchema(): void {
+ $this->declarativeManager->registerSchema('testing', self::validSchemaAllFields);
+ $this->expectException(\Exception::class);
+ $this->declarativeManager->registerSchema('testing', self::validSchemaAllFields);
+ }
+
+ /**
+ * It's not allowed to register schema with duplicate fields ids for the same app
+ */
+ public function testRegisterSchemaWithDuplicateFields(): void {
+ // Register first valid schema
+ $this->declarativeManager->registerSchema('testing', self::validSchemaAllFields);
+ // Register second schema with duplicate fields, but different schema id
+ $this->expectException(\Exception::class);
+ $schema = self::validSchemaAllFields;
+ $schema['id'] = 'test_form_2';
+ $this->declarativeManager->registerSchema('testing', $schema);
+ }
+
+ public function testRegisterMultipleSchemasAndDuplicate(): void {
+ $app = 'testing';
+ $schema = self::validSchemaAllFields;
+ $this->declarativeManager->registerSchema($app, $schema);
+ $formIds = $this->declarativeManager->getFormIDs($this->adminUser, $schema['section_type'], $schema['section_id']);
+ // 1. Check that form is registered for the app
+ $this->assertTrue(isset($formIds[$app]) && in_array($schema['id'], $formIds[$app]));
+ $app = 'testing2';
+ $this->declarativeManager->registerSchema($app, $schema);
+ $formIds = $this->declarativeManager->getFormIDs($this->adminUser, $schema['section_type'], $schema['section_id']);
+ // 2. Check that form is registered for the second app
+ $this->assertTrue(isset($formIds[$app]) && in_array($schema['id'], $formIds[$app]));
+ $app = 'testing';
+ $this->expectException(\Exception::class); // expecting duplicate form id and duplicate fields ids exception
+ $this->declarativeManager->registerSchema($app, $schema);
+ $schemaDuplicateFields = self::validSchemaAllFields;
+ $schemaDuplicateFields['id'] = 'test_form_2'; // change form id to test duplicate fields
+ $this->declarativeManager->registerSchema($app, $schemaDuplicateFields);
+ // 3. Check that not valid form with duplicate fields is not registered
+ $formIds = $this->declarativeManager->getFormIDs($this->adminUser, $schemaDuplicateFields['section_type'], $schemaDuplicateFields['section_id']);
+ $this->assertFalse(isset($formIds[$app]) && in_array($schemaDuplicateFields['id'], $formIds[$app]));
+ }
+
+ /**
+ * @dataProvider dataValidateSchema
+ */
+ public function testValidateSchema(bool $expected, bool $expectException, string $app, array $schema): void {
+ if ($expectException) {
+ $this->expectException(\Exception::class);
+ }
+ $this->declarativeManager->registerSchema($app, $schema);
+ $formIds = $this->declarativeManager->getFormIDs($this->adminUser, $schema['section_type'], $schema['section_id']);
+ $this->assertEquals($expected, isset($formIds[$app]) && in_array($schema['id'], $formIds[$app]));
+ }
+
+ public static function dataValidateSchema(): array {
+ return [
+ 'valid schema with all supported fields' => [
+ true,
+ false,
+ 'testing',
+ self::validSchemaAllFields,
+ ],
+ 'invalid schema with missing id' => [
+ false,
+ true,
+ 'testing',
+ [
+ 'priority' => 10,
+ 'section_type' => DeclarativeSettingsTypes::SECTION_TYPE_ADMIN,
+ 'section_id' => 'additional',
+ 'storage_type' => DeclarativeSettingsTypes::STORAGE_TYPE_INTERNAL,
+ 'title' => 'Test declarative settings',
+ 'description' => 'These fields are rendered dynamically from declarative schema',
+ 'doc_url' => '',
+ 'fields' => [
+ [
+ 'id' => 'test_field_7',
+ 'title' => 'Multi-selection',
+ 'description' => 'Select some option setting',
+ 'type' => DeclarativeSettingsTypes::MULTI_SELECT,
+ 'options' => ['foo', 'bar', 'baz'],
+ 'placeholder' => 'Select some multiple options',
+ 'default' => ['foo', 'bar'],
+ ],
+ ],
+ ],
+ ],
+ 'invalid schema with invalid field' => [
+ false,
+ true,
+ 'testing',
+ [
+ 'id' => 'test_form_1',
+ 'priority' => 10,
+ 'section_type' => DeclarativeSettingsTypes::SECTION_TYPE_ADMIN,
+ 'section_id' => 'additional',
+ 'storage_type' => DeclarativeSettingsTypes::STORAGE_TYPE_INTERNAL,
+ 'title' => 'Test declarative settings',
+ 'description' => 'These fields are rendered dynamically from declarative schema',
+ 'doc_url' => '',
+ 'fields' => [
+ [
+ 'id' => 'test_invalid_field',
+ 'title' => 'Invalid field',
+ 'description' => 'Some invalid setting description',
+ 'type' => 'some_invalid_type',
+ 'placeholder' => 'Some invalid field placeholder',
+ 'default' => null,
+ ],
+ ],
+ ],
+ ],
+ ];
+ }
+
+ public function testGetFormIDs(): void {
+ $app = 'testing';
+ $schema = self::validSchemaAllFields;
+ $this->declarativeManager->registerSchema($app, $schema);
+ $formIds = $this->declarativeManager->getFormIDs($this->adminUser, $schema['section_type'], $schema['section_id']);
+ $this->assertTrue(isset($formIds[$app]) && in_array($schema['id'], $formIds[$app]));
+ $app = 'testing2';
+ $this->declarativeManager->registerSchema($app, $schema);
+ $formIds = $this->declarativeManager->getFormIDs($this->adminUser, $schema['section_type'], $schema['section_id']);
+ $this->assertTrue(isset($formIds[$app]) && in_array($schema['id'], $formIds[$app]));
+ }
+
+ /**
+ * Check that form with default values is returned with internal storage_type
+ */
+ public function testGetFormsWithDefaultValues(): void {
+ $app = 'testing';
+ $schema = self::validSchemaAllFields;
+ $this->declarativeManager->registerSchema($app, $schema);
+
+ $this->config->expects($this->any())
+ ->method('getAppValue')
+ ->willReturnCallback(fn ($app, $configkey, $default) => $default);
+
+ $forms = $this->declarativeManager->getFormsWithValues($this->adminUser, $schema['section_type'], $schema['section_id']);
+ $this->assertNotEmpty($forms);
+ $this->assertTrue(array_search($schema['id'], array_column($forms, 'id')) !== false);
+ // Check some_real_setting field default value
+ $someRealSettingField = array_values(array_filter(array_filter($forms, fn ($form) => $form['id'] === $schema['id'])[0]['fields'], fn ($field) => $field['id'] === 'some_real_setting'))[0];
+ $schemaSomeRealSettingField = array_values(array_filter($schema['fields'], fn ($field) => $field['id'] === 'some_real_setting'))[0];
+ $this->assertEquals($schemaSomeRealSettingField['default'], $someRealSettingField['default']);
+ }
+
+ /**
+ * Check values in json format to ensure that they are properly encoded
+ */
+ public function testGetFormsWithDefaultValuesJson(): void {
+ $app = 'testing';
+ $schema = [
+ 'id' => 'test_form_1',
+ 'priority' => 10,
+ 'section_type' => DeclarativeSettingsTypes::SECTION_TYPE_PERSONAL,
+ 'section_id' => 'additional',
+ 'storage_type' => DeclarativeSettingsTypes::STORAGE_TYPE_INTERNAL,
+ 'title' => 'Test declarative settings',
+ 'description' => 'These fields are rendered dynamically from declarative schema',
+ 'doc_url' => '',
+ 'fields' => [
+ [
+ 'id' => 'test_field_json',
+ 'title' => 'Multi-selection',
+ 'description' => 'Select some option setting',
+ 'type' => DeclarativeSettingsTypes::MULTI_SELECT,
+ 'options' => ['foo', 'bar', 'baz'],
+ 'placeholder' => 'Select some multiple options',
+ 'default' => ['foo', 'bar'],
+ ],
+ ],
+ ];
+ $this->declarativeManager->registerSchema($app, $schema);
+
+ // config->getUserValue() should be called with json encoded default value
+ $this->config->expects($this->once())
+ ->method('getUserValue')
+ ->with($this->adminUser->getUID(), $app, 'test_field_json', json_encode($schema['fields'][0]['default']))
+ ->willReturn(json_encode($schema['fields'][0]['default']));
+
+ $forms = $this->declarativeManager->getFormsWithValues($this->adminUser, $schema['section_type'], $schema['section_id']);
+ $this->assertNotEmpty($forms);
+ $this->assertTrue(array_search($schema['id'], array_column($forms, 'id')) !== false);
+ $testFieldJson = array_values(array_filter(array_filter($forms, fn ($form) => $form['id'] === $schema['id'])[0]['fields'], fn ($field) => $field['id'] === 'test_field_json'))[0];
+ $this->assertEquals(json_encode($schema['fields'][0]['default']), $testFieldJson['value']);
+ }
+
+ /**
+ * Check that saving value for field with internal storage_type is handled by core
+ */
+ public function testSetInternalValue(): void {
+ $app = 'testing';
+ $schema = self::validSchemaAllFields;
+ $this->declarativeManager->registerSchema($app, $schema);
+ self::$testSetInternalValueAfterChange = false;
+
+ $this->config->expects($this->any())
+ ->method('getAppValue')
+ ->willReturnCallback(function ($app, $configkey, $default) {
+ if ($configkey === 'some_real_setting' && self::$testSetInternalValueAfterChange) {
+ return '120m';
+ }
+ return $default;
+ });
+
+ $this->appConfig->expects($this->once())
+ ->method('setValueString')
+ ->with($app, 'some_real_setting', '120m');
+
+ $forms = $this->declarativeManager->getFormsWithValues($this->adminUser, $schema['section_type'], $schema['section_id']);
+ $someRealSettingField = array_values(array_filter(array_filter($forms, fn ($form) => $form['id'] === $schema['id'])[0]['fields'], fn ($field) => $field['id'] === 'some_real_setting'))[0];
+ $this->assertEquals('40m', $someRealSettingField['value']); // first check that default value (40m) is returned
+
+ // Set new value for some_real_setting field
+ $this->declarativeManager->setValue($this->adminUser, $app, $schema['id'], 'some_real_setting', '120m');
+ self::$testSetInternalValueAfterChange = true;
+
+ $forms = $this->declarativeManager->getFormsWithValues($this->adminUser, $schema['section_type'], $schema['section_id']);
+ $this->assertNotEmpty($forms);
+ $this->assertTrue(array_search($schema['id'], array_column($forms, 'id')) !== false);
+ // Check some_real_setting field default value
+ $someRealSettingField = array_values(array_filter(array_filter($forms, fn ($form) => $form['id'] === $schema['id'])[0]['fields'], fn ($field) => $field['id'] === 'some_real_setting'))[0];
+ $this->assertEquals('120m', $someRealSettingField['value']);
+ }
+
+ public function testSetExternalValue(): void {
+ $app = 'testing';
+ $schema = self::validSchemaAllFields;
+ // Change storage_type to external and section_type to personal
+ $schema['storage_type'] = DeclarativeSettingsTypes::STORAGE_TYPE_EXTERNAL;
+ $schema['section_type'] = DeclarativeSettingsTypes::SECTION_TYPE_PERSONAL;
+ $this->declarativeManager->registerSchema($app, $schema);
+
+ $setDeclarativeSettingsValueEvent = new DeclarativeSettingsSetValueEvent(
+ $this->adminUser,
+ $app,
+ $schema['id'],
+ 'some_real_setting',
+ '120m'
+ );
+
+ $this->eventDispatcher->expects($this->once())
+ ->method('dispatchTyped')
+ ->with($setDeclarativeSettingsValueEvent);
+ $this->declarativeManager->setValue($this->adminUser, $app, $schema['id'], 'some_real_setting', '120m');
+ }
+
+ public function testAdminFormUserUnauthorized(): void {
+ $app = 'testing';
+ $schema = self::validSchemaAllFields;
+ $this->declarativeManager->registerSchema($app, $schema);
+
+ $this->expectException(\Exception::class);
+ $this->declarativeManager->getFormsWithValues($this->user, $schema['section_type'], $schema['section_id']);
+ }
+}
diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php
index cc13479b1d0..6ed8ed74359 100644
--- a/tests/lib/Settings/ManagerTest.php
+++ b/tests/lib/Settings/ManagerTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @author Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Settings\Tests\AppInfo;
@@ -34,9 +17,9 @@ use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use OCP\Settings\ISettings;
use OCP\Settings\ISubAdminSettings;
+use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\TestCase;
-use PHPUnit\Framework\MockObject\MockObject;
class ManagerTest extends TestCase {
/** @var Manager|MockObject */
diff --git a/tests/lib/Settings/SectionTest.php b/tests/lib/Settings/SectionTest.php
index 70606135630..964256f303c 100644
--- a/tests/lib/Settings/SectionTest.php
+++ b/tests/lib/Settings/SectionTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @author Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Settings\Tests\AppInfo;
diff --git a/tests/lib/SetupTest.php b/tests/lib/SetupTest.php
index eacc165650c..5216d2a730a 100644
--- a/tests/lib/SetupTest.php
+++ b/tests/lib/SetupTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
@@ -14,27 +13,20 @@ use OC\Setup;
use OC\SystemConfig;
use OCP\Defaults;
use OCP\IL10N;
+use OCP\L10N\IFactory as IL10NFactory;
use OCP\Security\ISecureRandom;
-use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
class SetupTest extends \Test\TestCase {
- /** @var SystemConfig|MockObject */
- protected $config;
- /** @var \bantu\IniGetWrapper\IniGetWrapper|MockObject */
- private $iniWrapper;
- /** @var \OCP\IL10N|MockObject */
- private $l10n;
- /** @var Defaults|MockObject */
- private $defaults;
- /** @var \OC\Setup|MockObject */
- protected $setupClass;
- /** @var LoggerInterface|MockObject */
- protected $logger;
- /** @var \OCP\Security\ISecureRandom|MockObject */
- protected $random;
- /** @var Installer|MockObject */
- protected $installer;
+ protected SystemConfig $config;
+ private IniGetWrapper $iniWrapper;
+ private IL10N $l10n;
+ private IL10NFactory $l10nFactory;
+ private Defaults $defaults;
+ protected Setup $setupClass;
+ protected LoggerInterface $logger;
+ protected ISecureRandom $random;
+ protected Installer $installer;
protected function setUp(): void {
parent::setUp();
@@ -42,13 +34,16 @@ class SetupTest extends \Test\TestCase {
$this->config = $this->createMock(SystemConfig::class);
$this->iniWrapper = $this->createMock(IniGetWrapper::class);
$this->l10n = $this->createMock(IL10N::class);
+ $this->l10nFactory = $this->createMock(IL10NFactory::class);
+ $this->l10nFactory->method('get')
+ ->willReturn($this->l10n);
$this->defaults = $this->createMock(Defaults::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->random = $this->createMock(ISecureRandom::class);
$this->installer = $this->createMock(Installer::class);
$this->setupClass = $this->getMockBuilder(Setup::class)
->setMethods(['class_exists', 'is_callable', 'getAvailableDbDriversForPdo'])
- ->setConstructorArgs([$this->config, $this->iniWrapper, $this->l10n, $this->defaults, $this->logger, $this->random, $this->installer])
+ ->setConstructorArgs([$this->config, $this->iniWrapper, $this->l10nFactory, $this->defaults, $this->logger, $this->random, $this->installer])
->getMock();
}
diff --git a/tests/lib/Share/Backend.php b/tests/lib/Share/Backend.php
index 18443a4e247..91493d599dc 100644
--- a/tests/lib/Share/Backend.php
+++ b/tests/lib/Share/Backend.php
@@ -1,26 +1,16 @@
<?php
/**
- * ownCloud
- *
- * @author Michael Gapczynski
- * @copyright 2012 Michael Gapczynski mtgap@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Share;
+use OC\Share20\Manager;
+use OCP\Server;
+use OCP\Share\IShare;
+
class Backend implements \OCP\Share_Backend {
public const FORMAT_SOURCE = 0;
public const FORMAT_TARGET = 1;
@@ -46,7 +36,11 @@ class Backend implements \OCP\Share_Backend {
}
- $shares = \OC\Share\Share::getItemsSharedWithUser('test', $shareWith);
+ $shareManager = Server::get(Manager::class);
+ $shares = array_merge(
+ $shareManager->getSharedWith($shareWith, IShare::TYPE_USER),
+ $shareManager->getSharedWith($shareWith, IShare::TYPE_GROUP),
+ );
$knownTargets = [];
foreach ($shares as $share) {
diff --git a/tests/lib/Share/HelperTest.php b/tests/lib/Share/HelperTest.php
index 8d010400273..f92effebd5d 100644
--- a/tests/lib/Share/HelperTest.php
+++ b/tests/lib/Share/HelperTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Bjoern Schiessle
- * @copyright 2014 Bjoern Schiessle <schiessle@owncloud.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Share;
diff --git a/tests/lib/Share/ShareTest.php b/tests/lib/Share/ShareTest.php
index 35dc00739f6..d6ed54f06da 100644
--- a/tests/lib/Share/ShareTest.php
+++ b/tests/lib/Share/ShareTest.php
@@ -1,34 +1,18 @@
<?php
/**
- * ownCloud
- *
- * @author Michael Gapczynski
- * @copyright 2012 Michael Gapczynski mtgap@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Share;
use OC\Share\Share;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
-use OCP\Share\IShare;
/**
* Class Test_Share
@@ -127,110 +111,6 @@ class ShareTest extends \Test\TestCase {
parent::tearDown();
}
- public function testGetItemSharedWithUser() {
- \OC_User::setUserId($this->user1->getUID());
-
- // add dummy values to the share table
- $query = $this->connection->getQueryBuilder();
- $query->insert('share')
- ->values([
- 'item_type' => $query->createParameter('itemType'),
- 'item_source' => $query->createParameter('itemSource'),
- 'item_target' => $query->createParameter('itemTarget'),
- 'share_type' => $query->createParameter('shareType'),
- 'share_with' => $query->createParameter('shareWith'),
- 'uid_owner' => $query->createParameter('uidOwner')
- ]);
- $args = [
- ['test', 99, 'target1', IShare::TYPE_USER, $this->user2->getUID(), $this->user1->getUID()],
- ['test', 99, 'target2', IShare::TYPE_USER, $this->user4->getUID(), $this->user1->getUID()],
- ['test', 99, 'target3', IShare::TYPE_USER, $this->user3->getUID(), $this->user2->getUID()],
- ['test', 99, 'target4', IShare::TYPE_USER, $this->user3->getUID(), $this->user4->getUID()],
- ['test', 99, 'target4', IShare::TYPE_USER, $this->user6->getUID(), $this->user4->getUID()],
- ];
- foreach ($args as $row) {
- $query->setParameter('itemType', $row[0]);
- $query->setParameter('itemSource', $row[1], IQueryBuilder::PARAM_INT);
- $query->setParameter('itemTarget', $row[2]);
- $query->setParameter('shareType', $row[3], IQueryBuilder::PARAM_INT);
- $query->setParameter('shareWith', $row[4]);
- $query->setParameter('uidOwner', $row[5]);
- $query->executeStatement();
- }
-
- $result1 = Share::getItemSharedWithUser('test', 99, $this->user2->getUID(), $this->user1->getUID());
- $this->assertSame(1, count($result1));
- $this->verifyResult($result1, ['target1']);
-
- $result2 = Share::getItemSharedWithUser('test', 99, null, $this->user1->getUID());
- $this->assertSame(2, count($result2));
- $this->verifyResult($result2, ['target1', 'target2']);
-
- $result3 = Share::getItemSharedWithUser('test', 99, $this->user3->getUID());
- $this->assertSame(2, count($result3));
- $this->verifyResult($result3, ['target3', 'target4']);
-
- $result4 = Share::getItemSharedWithUser('test', 99, null, null);
- $this->assertSame(5, count($result4)); // 5 because target4 appears twice
- $this->verifyResult($result4, ['target1', 'target2', 'target3', 'target4']);
-
- $result6 = Share::getItemSharedWithUser('test', 99, $this->user6->getUID(), null);
- $this->assertSame(1, count($result6));
- $this->verifyResult($result6, ['target4']);
- }
-
- public function testGetItemSharedWithUserFromGroupShare() {
- \OC_User::setUserId($this->user1->getUID());
-
- // add dummy values to the share table
- $query = $this->connection->getQueryBuilder();
- $query->insert('share')
- ->values([
- 'item_type' => $query->createParameter('itemType'),
- 'item_source' => $query->createParameter('itemSource'),
- 'item_target' => $query->createParameter('itemTarget'),
- 'share_type' => $query->createParameter('shareType'),
- 'share_with' => $query->createParameter('shareWith'),
- 'uid_owner' => $query->createParameter('uidOwner')
- ]);
- $args = [
- ['test', 99, 'target1', IShare::TYPE_GROUP, $this->group1->getGID(), $this->user1->getUID()],
- ['test', 99, 'target2', IShare::TYPE_GROUP, $this->group2->getGID(), $this->user1->getUID()],
- ['test', 99, 'target3', IShare::TYPE_GROUP, $this->group1->getGID(), $this->user2->getUID()],
- ['test', 99, 'target4', IShare::TYPE_GROUP, $this->group1->getGID(), $this->user4->getUID()],
- ];
- foreach ($args as $row) {
- $query->setParameter('itemType', $row[0]);
- $query->setParameter('itemSource', $row[1], IQueryBuilder::PARAM_INT);
- $query->setParameter('itemTarget', $row[2]);
- $query->setParameter('shareType', $row[3], IQueryBuilder::PARAM_INT);
- $query->setParameter('shareWith', $row[4]);
- $query->setParameter('uidOwner', $row[5]);
- $query->executeStatement();
- }
-
- // user2 is in group1 and group2
- $result1 = Share::getItemSharedWithUser('test', 99, $this->user2->getUID(), $this->user1->getUID());
- $this->assertSame(2, count($result1));
- $this->verifyResult($result1, ['target1', 'target2']);
-
- $result2 = Share::getItemSharedWithUser('test', 99, null, $this->user1->getUID());
- $this->assertSame(2, count($result2));
- $this->verifyResult($result2, ['target1', 'target2']);
-
- // user3 is in group1 and group2
- $result3 = Share::getItemSharedWithUser('test', 99, $this->user3->getUID());
- $this->assertSame(3, count($result3));
- $this->verifyResult($result3, ['target1', 'target3', 'target4']);
-
- $result4 = Share::getItemSharedWithUser('test', 99, null, null);
- $this->assertSame(4, count($result4));
- $this->verifyResult($result4, ['target1', 'target2', 'target3', 'target4']);
-
- $result6 = Share::getItemSharedWithUser('test', 99, $this->user6->getUID(), null);
- $this->assertSame(0, count($result6));
- }
-
public function verifyResult($result, $expected) {
foreach ($result as $r) {
if (in_array($r['item_target'], $expected)) {
diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php
index 0a6f106a5db..72ef83331e9 100644
--- a/tests/lib/Share20/DefaultShareProviderTest.php
+++ b/tests/lib/Share20/DefaultShareProviderTest.php
@@ -1,35 +1,20 @@
<?php
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @copyright Copyright (c) 2016, Roeland Jago Douma <roeland@famdouma.nl>
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Share20;
use OC\Share20\DefaultShareProvider;
use OC\Share20\ShareAttributes;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Defaults;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
-use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroup;
use OCP\IGroupManager;
@@ -39,6 +24,7 @@ use OCP\IUser;
use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
+use OCP\Share\IManager as IShareManager;
use OCP\Share\IShare;
use PHPUnit\Framework\MockObject\MockObject;
@@ -79,8 +65,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
/** @var \PHPUnit\Framework\MockObject\MockObject|IURLGenerator */
protected $urlGenerator;
- /** @var IConfig|MockObject */
- protected $config;
+ /** @var ITimeFactory|MockObject */
+ protected $timeFactory;
protected function setUp(): void {
$this->dbConn = \OC::$server->getDatabaseConnection();
@@ -92,9 +78,10 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->l10n = $this->createMock(IL10N::class);
$this->defaults = $this->getMockBuilder(Defaults::class)->disableOriginalConstructor()->getMock();
$this->urlGenerator = $this->createMock(IURLGenerator::class);
- $this->config = $this->createMock(IConfig::class);
+ $this->timeFactory = $this->createMock(ITimeFactory::class);
$this->userManager->expects($this->any())->method('userExists')->willReturn(true);
+ $this->timeFactory->expects($this->any())->method('now')->willReturn(new \DateTimeImmutable("2023-05-04 00:00 Europe/Berlin"));
//Empty share table
$this->dbConn->getQueryBuilder()->delete('share')->execute();
@@ -108,7 +95,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->config
+ $this->timeFactory
);
}
@@ -132,8 +119,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
* @return int
*/
private function addShareToDB($shareType, $sharedWith, $sharedBy, $shareOwner,
- $itemType, $fileSource, $fileTarget, $permissions, $token, $expiration,
- $parent = null) {
+ $itemType, $fileSource, $fileTarget, $permissions, $token, $expiration,
+ $parent = null) {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share');
@@ -209,7 +196,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$ownerPath = $this->createMock(File::class);
$shareOwnerFolder = $this->createMock(Folder::class);
- $shareOwnerFolder->method('getById')->with(42)->willReturn([$ownerPath]);
+ $shareOwnerFolder->method('getFirstNodeById')->with(42)->willReturn($ownerPath);
$this->rootFolder
->method('getUserFolder')
@@ -287,7 +274,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$ownerPath = $this->createMock(File::class);
$shareOwnerFolder = $this->createMock(Folder::class);
- $shareOwnerFolder->method('getById')->with(42)->willReturn([$ownerPath]);
+ $shareOwnerFolder->method('getFirstNodeById')->with(42)->willReturn($ownerPath);
$this->rootFolder
->method('getUserFolder')
@@ -331,7 +318,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$ownerPath = $this->createMock(Folder::class);
$shareOwnerFolder = $this->createMock(Folder::class);
- $shareOwnerFolder->method('getById')->with(42)->willReturn([$ownerPath]);
+ $shareOwnerFolder->method('getFirstNodeById')->with(42)->willReturn($ownerPath);
$this->rootFolder
->method('getUserFolder')
@@ -370,7 +357,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$node->method('getId')->willReturn(42);
$this->rootFolder->method('getUserFolder')->with('user0')->willReturnSelf();
- $this->rootFolder->method('getById')->willReturn([$node]);
+ $this->rootFolder->method('getFirstNodeById')->willReturn($node);
$this->userManager->method('get')->willReturnMap([
['user0', $user0],
@@ -415,7 +402,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$ownerPath = $this->createMock(Folder::class);
$shareOwnerFolder = $this->createMock(Folder::class);
- $shareOwnerFolder->method('getById')->with(42)->willReturn([$ownerPath]);
+ $shareOwnerFolder->method('getFirstNodeById')->with(42)->willReturn($ownerPath);
$this->rootFolder
->method('getUserFolder')
@@ -469,7 +456,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->config
+ $this->timeFactory
])
->setMethods(['getShareById'])
->getMock();
@@ -564,7 +551,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->config
+ $this->timeFactory
])
->setMethods(['getShareById'])
->getMock();
@@ -632,7 +619,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$ownerPath = $this->createMock(Folder::class);
$ownerFolder = $this->createMock(Folder::class);
- $ownerFolder->method('getById')->willReturn([$ownerPath]);
+ $ownerFolder->method('getFirstNodeById')->willReturn($ownerPath);
$this->rootFolder
->method('getUserFolder')
@@ -689,12 +676,12 @@ class DefaultShareProviderTest extends \Test\TestCase {
['shareOwner', $ownerFolder],
]);
- $userFolder->method('getById')
+ $userFolder->method('getFirstNodeById')
->with(100)
- ->willReturn([$path]);
- $ownerFolder->method('getById')
+ ->willReturn($path);
+ $ownerFolder->method('getFirstNodeById')
->with(100)
- ->willReturn([$path]);
+ ->willReturn($path);
$share->setShareType(IShare::TYPE_USER);
$share->setSharedWith('sharedWith');
@@ -724,11 +711,11 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime());
$this->assertSame($path, $share2->getNode());
- // nothing from setSharedWithDisplayName/setSharedWithAvatar is saved in DB
+ // Data is kept after creation
$this->assertSame('Displayed Name', $share->getSharedWithDisplayName());
$this->assertSame('/path/to/image.svg', $share->getSharedWithAvatar());
- $this->assertSame(null, $share2->getSharedWithDisplayName());
- $this->assertSame(null, $share2->getSharedWithAvatar());
+ $this->assertSame('Displayed Name', $share2->getSharedWithDisplayName());
+ $this->assertSame('/path/to/image.svg', $share2->getSharedWithAvatar());
$this->assertSame(
[
@@ -761,12 +748,12 @@ class DefaultShareProviderTest extends \Test\TestCase {
['shareOwner', $ownerFolder],
]);
- $userFolder->method('getById')
+ $userFolder->method('getFirstNodeById')
->with(100)
- ->willReturn([$path]);
- $ownerFolder->method('getById')
+ ->willReturn($path);
+ $ownerFolder->method('getFirstNodeById')
->with(100)
- ->willReturn([$path]);
+ ->willReturn($path);
$share->setShareType(IShare::TYPE_GROUP);
$share->setSharedWith('sharedWith');
@@ -794,11 +781,11 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime());
$this->assertSame($path, $share2->getNode());
- // nothing from setSharedWithDisplayName/setSharedWithAvatar is saved in DB
+ // Data is kept after creation
$this->assertSame('Displayed Name', $share->getSharedWithDisplayName());
$this->assertSame('/path/to/image.svg', $share->getSharedWithAvatar());
- $this->assertSame(null, $share2->getSharedWithDisplayName());
- $this->assertSame(null, $share2->getSharedWithAvatar());
+ $this->assertSame('Displayed Name', $share2->getSharedWithDisplayName());
+ $this->assertSame('/path/to/image.svg', $share2->getSharedWithAvatar());
$this->assertSame(
[
@@ -831,12 +818,12 @@ class DefaultShareProviderTest extends \Test\TestCase {
['shareOwner', $ownerFolder],
]);
- $userFolder->method('getById')
+ $userFolder->method('getFirstNodeById')
->with(100)
- ->willReturn([$path]);
- $ownerFolder->method('getById')
+ ->willReturn($path);
+ $ownerFolder->method('getFirstNodeById')
->with(100)
- ->willReturn([$path]);
+ ->willReturn($path);
$share->setShareType(IShare::TYPE_LINK);
$share->setSharedBy('sharedBy');
@@ -889,7 +876,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
- $this->rootFolder->method('getById')->with(42)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with(42)->willReturn($file);
$share = $this->provider->getShareByToken('secrettoken');
$this->assertEquals($id, $share->getId());
@@ -980,7 +967,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
- $this->rootFolder->method('getById')->with($fileId)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with($fileId)->willReturn($file);
$share = $this->provider->getSharedWith('sharedWith', IShare::TYPE_USER, null, 1, 0);
$this->assertCount(1, $share);
@@ -1052,7 +1039,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
- $this->rootFolder->method('getById')->with($fileId)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with($fileId)->willReturn($file);
$share = $this->provider->getSharedWith('sharedWith', IShare::TYPE_GROUP, null, 20, 1);
$this->assertCount(1, $share);
@@ -1140,7 +1127,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
- $this->rootFolder->method('getById')->with($fileId)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with($fileId)->willReturn($file);
$share = $this->provider->getSharedWith('user', IShare::TYPE_GROUP, null, -1, 0);
$this->assertCount(1, $share);
@@ -1183,7 +1170,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file->method('getId')->willReturn($fileId2);
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
- $this->rootFolder->method('getById')->with($fileId2)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with($fileId2)->willReturn($file);
$share = $this->provider->getSharedWith('user0', IShare::TYPE_USER, $file, -1, 0);
$this->assertCount(1, $share);
@@ -1224,7 +1211,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$node = $this->createMock(Folder::class);
$node->method('getId')->willReturn($fileId2);
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
- $this->rootFolder->method('getById')->with($fileId2)->willReturn([$node]);
+ $this->rootFolder->method('getFirstNodeById')->with($fileId2)->willReturn($node);
$share = $this->provider->getSharedWith('user0', IShare::TYPE_GROUP, $node, -1, 0);
$this->assertCount(1, $share);
@@ -1275,7 +1262,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
- $this->rootFolder->method('getById')->with($deletedFileId)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with($deletedFileId)->willReturn($file);
$groups = [];
foreach (range(0, 100) as $i) {
@@ -1335,7 +1322,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
- $this->rootFolder->method('getById')->with(42)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with(42)->willReturn($file);
$share = $this->provider->getSharesBy('sharedBy', IShare::TYPE_USER, null, false, 1, 0);
$this->assertCount(1, $share);
@@ -1385,7 +1372,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file = $this->createMock(File::class);
$file->method('getId')->willReturn(42);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
- $this->rootFolder->method('getById')->with(42)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with(42)->willReturn($file);
$share = $this->provider->getSharesBy('sharedBy', IShare::TYPE_USER, $file, false, 1, 0);
$this->assertCount(1, $share);
@@ -1435,7 +1422,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file = $this->createMock(File::class);
$file->method('getId')->willReturn(42);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
- $this->rootFolder->method('getById')->with(42)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with(42)->willReturn($file);
$shares = $this->provider->getSharesBy('shareOwner', IShare::TYPE_USER, null, true, -1, 0);
$this->assertCount(2, $shares);
@@ -1495,7 +1482,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file->method('getId')->willReturn(1);
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
- $this->rootFolder->method('getById')->with(1)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with(1)->willReturn($file);
$share = $this->provider->getShareById($id);
@@ -1567,7 +1554,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file->method('getId')->willReturn(1);
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
- $this->rootFolder->method('getById')->with(1)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with(1)->willReturn($file);
$share = $this->provider->getShareById($id);
@@ -1625,7 +1612,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file->method('getId')->willReturn(1);
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
- $this->rootFolder->method('getById')->with(1)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with(1)->willReturn($file);
$share = $this->provider->getShareById($id);
@@ -1667,7 +1654,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file->method('getId')->willReturn(1);
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
- $this->rootFolder->method('getById')->with(1)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with(1)->willReturn($file);
$share = $this->provider->getShareById($id);
@@ -1705,7 +1692,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file->method('getId')->willReturn(1);
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
- $this->rootFolder->method('getById')->with(1)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with(1)->willReturn($file);
$share = $this->provider->getShareById($id);
@@ -1759,7 +1746,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file->method('getId')->willReturn(1);
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
- $this->rootFolder->method('getById')->with(1)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with(1)->willReturn($file);
$share = $this->provider->getShareById($id);
@@ -1796,7 +1783,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file->method('getId')->willReturn(1);
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
- $this->rootFolder->method('getById')->with(1)->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->with(1)->willReturn($file);
$share = $this->provider->getShareById($id);
@@ -1827,9 +1814,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file2->method('getId')->willReturn(43);
$folder1 = $this->createMock(Folder::class);
- $folder1->method('getById')->with(42)->willReturn([$file1]);
+ $folder1->method('getFirstNodeById')->with(42)->willReturn($file1);
$folder2 = $this->createMock(Folder::class);
- $folder2->method('getById')->with(43)->willReturn([$file2]);
+ $folder2->method('getFirstNodeById')->with(43)->willReturn($file2);
$this->rootFolder->method('getUserFolder')->willReturnMap([
['user2', $folder1],
@@ -1884,9 +1871,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file2->method('getId')->willReturn(43);
$folder1 = $this->createMock(Folder::class);
- $folder1->method('getById')->with(42)->willReturn([$file1]);
+ $folder1->method('getFirstNodeById')->with(42)->willReturn($file1);
$folder2 = $this->createMock(Folder::class);
- $folder2->method('getById')->with(43)->willReturn([$file2]);
+ $folder2->method('getFirstNodeById')->with(43)->willReturn($file2);
$this->rootFolder->method('getUserFolder')->willReturnMap([
['user2', $folder1],
@@ -1950,9 +1937,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file2->method('getId')->willReturn(43);
$folder1 = $this->createMock(Folder::class);
- $folder1->method('getById')->with(42)->willReturn([$file1]);
+ $folder1->method('getFirstNodeById')->with(42)->willReturn($file1);
$folder2 = $this->createMock(Folder::class);
- $folder2->method('getById')->with(43)->willReturn([$file2]);
+ $folder2->method('getFirstNodeById')->with(43)->willReturn($file2);
$this->rootFolder->method('getUserFolder')->willReturnMap([
['user2', $folder1],
@@ -2021,9 +2008,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file2->method('getId')->willReturn(43);
$folder1 = $this->createMock(Folder::class);
- $folder1->method('getById')->with(42)->willReturn([$file1]);
+ $folder1->method('getFirstNodeById')->with(42)->willReturn($file1);
$folder2 = $this->createMock(Folder::class);
- $folder2->method('getById')->with(43)->willReturn([$file2]);
+ $folder2->method('getFirstNodeById')->with(43)->willReturn($file2);
$this->rootFolder->method('getUserFolder')->willReturnMap([
['user2', $folder1],
@@ -2100,9 +2087,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file2->method('getId')->willReturn(43);
$folder1 = $this->createMock(Folder::class);
- $folder1->method('getById')->with(42)->willReturn([$file1]);
+ $folder1->method('getFirstNodeById')->with(42)->willReturn($file1);
$folder2 = $this->createMock(Folder::class);
- $folder2->method('getById')->with(43)->willReturn([$file2]);
+ $folder2->method('getFirstNodeById')->with(43)->willReturn($file2);
$this->rootFolder->method('getUserFolder')->willReturnMap([
['user2', $folder1],
@@ -2178,7 +2165,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file->method('getId')->willReturn(42);
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
- $this->rootFolder->method('getById')->willReturn([$file]);
+ $this->rootFolder->method('getFirstNodeById')->willReturn($file);
$share = $this->provider->getShareById($id, null);
@@ -2214,7 +2201,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$folder->method('getId')->willReturn(42);
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
- $this->rootFolder->method('getById')->willReturn([$folder]);
+ $this->rootFolder->method('getFirstNodeById')->willReturn($folder);
$share = $this->provider->getShareById($id, 'user0');
@@ -2513,7 +2500,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
public function testGetSharesInFolder() {
$userManager = \OC::$server->getUserManager();
$groupManager = \OC::$server->getGroupManager();
- $rootFolder = \OC::$server->getRootFolder();
+ $rootFolder = \OC::$server->get(IRootFolder::class);
$provider = new DefaultShareProvider(
$this->dbConn,
@@ -2524,7 +2511,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->config
+ $this->timeFactory
);
$password = md5(time());
@@ -2540,7 +2527,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$file1 = $folder1->newFile('bar');
$folder2 = $folder1->newFolder('baz');
- $shareManager = \OC::$server->getShareManager();
+ $shareManager = \OC::$server->get(IShareManager::class);
$share1 = $shareManager->newShare();
$share1->setNode($folder1)
->setSharedBy($u1->getUID())
@@ -2611,7 +2598,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
public function testGetAccessListNoCurrentAccessRequired() {
$userManager = \OC::$server->getUserManager();
$groupManager = \OC::$server->getGroupManager();
- $rootFolder = \OC::$server->getRootFolder();
+ $rootFolder = \OC::$server->get(IRootFolder::class);
$provider = new DefaultShareProvider(
$this->dbConn,
@@ -2622,7 +2609,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->config
+ $this->timeFactory
);
$u1 = $userManager->createUser('testShare1', 'test');
@@ -2644,7 +2631,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertCount(0, $result['users']);
$this->assertFalse($result['public']);
- $shareManager = \OC::$server->getShareManager();
+ $shareManager = \OC::$server->get(IShareManager::class);
$share1 = $shareManager->newShare();
$share1->setNode($folder1)
->setSharedBy($u1->getUID())
@@ -2707,7 +2694,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
public function testGetAccessListCurrentAccessRequired() {
$userManager = \OC::$server->getUserManager();
$groupManager = \OC::$server->getGroupManager();
- $rootFolder = \OC::$server->getRootFolder();
+ $rootFolder = \OC::$server->get(IRootFolder::class);
$provider = new DefaultShareProvider(
$this->dbConn,
@@ -2718,7 +2705,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->config
+ $this->timeFactory
);
$u1 = $userManager->createUser('testShare1', 'test');
@@ -2740,7 +2727,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertCount(0, $result['users']);
$this->assertFalse($result['public']);
- $shareManager = \OC::$server->getShareManager();
+ $shareManager = \OC::$server->get(IShareManager::class);
$share1 = $shareManager->newShare();
$share1->setNode($folder1)
->setSharedBy($u1->getUID())
@@ -2880,23 +2867,23 @@ class DefaultShareProviderTest extends \Test\TestCase {
$ownerPath1 = $this->createMock(File::class);
$shareOwner1Folder = $this->createMock(Folder::class);
- $shareOwner1Folder->method('getById')->willReturn([$ownerPath1]);
+ $shareOwner1Folder->method('getFirstNodeById')->willReturn($ownerPath1);
$ownerPath2 = $this->createMock(File::class);
$shareOwner2Folder = $this->createMock(Folder::class);
- $shareOwner2Folder->method('getById')->willReturn([$ownerPath2]);
+ $shareOwner2Folder->method('getFirstNodeById')->willReturn($ownerPath2);
$ownerPath3 = $this->createMock(File::class);
$shareOwner3Folder = $this->createMock(Folder::class);
- $shareOwner3Folder->method('getById')->willReturn([$ownerPath3]);
+ $shareOwner3Folder->method('getFirstNodeById')->willReturn($ownerPath3);
$ownerPath4 = $this->createMock(File::class);
$shareOwner4Folder = $this->createMock(Folder::class);
- $shareOwner4Folder->method('getById')->willReturn([$ownerPath4]);
+ $shareOwner4Folder->method('getFirstNodeById')->willReturn($ownerPath4);
$ownerPath5 = $this->createMock(File::class);
$shareOwner5Folder = $this->createMock(Folder::class);
- $shareOwner5Folder->method('getById')->willReturn([$ownerPath5]);
+ $shareOwner5Folder->method('getFirstNodeById')->willReturn($ownerPath5);
$this->rootFolder
->method('getUserFolder')
diff --git a/tests/lib/Share20/LegacyHooksTest.php b/tests/lib/Share20/LegacyHooksTest.php
index 728f320ea9e..87643614f74 100644
--- a/tests/lib/Share20/LegacyHooksTest.php
+++ b/tests/lib/Share20/LegacyHooksTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2017, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Share20;
@@ -35,6 +18,7 @@ use OCP\Share\Events\BeforeShareDeletedEvent;
use OCP\Share\Events\ShareCreatedEvent;
use OCP\Share\Events\ShareDeletedEvent;
use OCP\Share\Events\ShareDeletedFromSelfEvent;
+use OCP\Share\IManager as IShareManager;
use OCP\Share\IShare;
use Psr\Log\LoggerInterface;
use Test\TestCase;
@@ -56,7 +40,7 @@ class LegacyHooksTest extends TestCase {
$logger = $this->createMock(LoggerInterface::class);
$this->eventDispatcher = new \OC\EventDispatcher\EventDispatcher($symfonyDispatcher, \OC::$server->get(IServerContainer::class), $logger);
$this->hooks = new LegacyHooks($this->eventDispatcher);
- $this->manager = \OC::$server->getShareManager();
+ $this->manager = \OC::$server->get(IShareManager::class);
}
public function testPreUnshare() {
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 1f3bcd405a1..15ecc839451 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -1,32 +1,20 @@
<?php
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Share20;
+use DateTimeZone;
use OC\Files\Mount\MoveableMount;
use OC\KnownUser\KnownUserService;
use OC\Share20\DefaultShareProvider;
use OC\Share20\Exception;
use OC\Share20\Manager;
use OC\Share20\Share;
+use OC\Share20\ShareDisableChecker;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\File;
@@ -38,6 +26,7 @@ use OCP\Files\Node;
use OCP\Files\Storage;
use OCP\HintException;
use OCP\IConfig;
+use OCP\IDateTimeZone;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IL10N;
@@ -111,6 +100,11 @@ class ManagerTest extends \Test\TestCase {
protected $userSession;
/** @var KnownUserService|MockObject */
protected $knownUserService;
+ /** @var ShareDisableChecker|MockObject */
+ protected $shareDisabledChecker;
+ private DateTimeZone $timezone;
+ /** @var IDateTimeZone|MockObject */
+ protected $dateTimeZone;
protected function setUp(): void {
$this->logger = $this->createMock(LoggerInterface::class);
@@ -128,6 +122,11 @@ class ManagerTest extends \Test\TestCase {
$this->userSession = $this->createMock(IUserSession::class);
$this->knownUserService = $this->createMock(KnownUserService::class);
+ $this->shareDisabledChecker = new ShareDisableChecker($this->config, $this->userManager, $this->groupManager);
+ $this->dateTimeZone = $this->createMock(IDateTimeZone::class);
+ $this->timezone = new \DateTimeZone('Pacific/Auckland');
+ $this->dateTimeZone->method('getTimeZone')->willReturnCallback(fn () => $this->timezone);
+
$this->l10nFactory = $this->createMock(IFactory::class);
$this->l = $this->createMock(IL10N::class);
$this->l->method('t')
@@ -138,19 +137,27 @@ class ManagerTest extends \Test\TestCase {
->willReturnCallback(function ($singular, $plural, $count, $parameters = []) {
return vsprintf(str_replace('%n', $count, ($count === 1) ? $singular : $plural), $parameters);
});
+ $this->l10nFactory->method('get')->willReturn($this->l);
$this->factory = new DummyFactory(\OC::$server);
- $this->manager = new Manager(
+ $this->manager = $this->createManager($this->factory);
+
+ $this->defaultProvider = $this->createMock(DefaultShareProvider::class);
+ $this->defaultProvider->method('identifier')->willReturn('default');
+ $this->factory->setProvider($this->defaultProvider);
+ }
+
+ private function createManager(IProviderFactory $factory): Manager {
+ return new Manager(
$this->logger,
$this->config,
$this->secureRandom,
$this->hasher,
$this->mountManager,
$this->groupManager,
- $this->l,
$this->l10nFactory,
- $this->factory,
+ $factory,
$this->userManager,
$this->rootFolder,
$this->mailer,
@@ -158,12 +165,10 @@ class ManagerTest extends \Test\TestCase {
$this->defaults,
$this->dispatcher,
$this->userSession,
- $this->knownUserService
+ $this->knownUserService,
+ $this->shareDisabledChecker,
+ $this->dateTimeZone,
);
-
- $this->defaultProvider = $this->createMock(DefaultShareProvider::class);
- $this->defaultProvider->method('identifier')->willReturn('default');
- $this->factory->setProvider($this->defaultProvider);
}
/**
@@ -178,7 +183,6 @@ class ManagerTest extends \Test\TestCase {
$this->hasher,
$this->mountManager,
$this->groupManager,
- $this->l,
$this->l10nFactory,
$this->factory,
$this->userManager,
@@ -188,7 +192,9 @@ class ManagerTest extends \Test\TestCase {
$this->defaults,
$this->dispatcher,
$this->userSession,
- $this->knownUserService
+ $this->knownUserService,
+ $this->shareDisabledChecker,
+ $this->dateTimeZone,
]);
}
@@ -595,7 +601,7 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'verifyPassword', ['password']);
}
- public function createShare($id, $type, $path, $sharedWith, $sharedBy, $shareOwner,
+ public function createShare($id, $type, $node, $sharedWith, $sharedBy, $shareOwner,
$permissions, $expireDate = null, $password = null, $attributes = null) {
$share = $this->createMock(IShare::class);
@@ -603,7 +609,10 @@ class ManagerTest extends \Test\TestCase {
$share->method('getSharedWith')->willReturn($sharedWith);
$share->method('getSharedBy')->willReturn($sharedBy);
$share->method('getShareOwner')->willReturn($shareOwner);
- $share->method('getNode')->willReturn($path);
+ $share->method('getNode')->willReturn($node);
+ if ($node && $node->getId()) {
+ $share->method('getNodeId')->willReturn($node->getId());
+ }
$share->method('getPermissions')->willReturn($permissions);
$share->method('getAttributes')->willReturn($attributes);
$share->method('getExpirationDate')->willReturn($expireDate);
@@ -628,8 +637,10 @@ class ManagerTest extends \Test\TestCase {
->willReturn(false);
$file->method('getStorage')
->willReturn($storage);
+ $file->method('getId')->willReturn(108);
$node->method('getStorage')
->willReturn($storage);
+ $node->method('getId')->willReturn(108);
$data = [
[$this->createShare(null, IShare::TYPE_USER, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
@@ -659,6 +670,7 @@ class ManagerTest extends \Test\TestCase {
];
$nonShareAble = $this->createMock(Folder::class);
+ $nonShareAble->method('getId')->willReturn(108);
$nonShareAble->method('isShareable')->willReturn(false);
$nonShareAble->method('getPath')->willReturn('path');
$nonShareAble->method('getName')->willReturn('name');
@@ -694,16 +706,22 @@ class ManagerTest extends \Test\TestCase {
$data[] = [$this->createShare(null, IShare::TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, 17, null, null), 'Cannot increase permissions of path', true];
$data[] = [$this->createShare(null, IShare::TYPE_LINK, $limitedPermssions, null, $user0, $user0, 3, null, null), 'Cannot increase permissions of path', true];
+ $nonMovableStorage = $this->createMock(Storage\IStorage::class);
+ $nonMovableStorage->method('instanceOfStorage')
+ ->with('\OCA\Files_Sharing\External\Storage')
+ ->willReturn(false);
+ $nonMovableStorage->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_ALL);
$nonMoveableMountPermssions = $this->createMock(Folder::class);
$nonMoveableMountPermssions->method('isShareable')->willReturn(true);
$nonMoveableMountPermssions->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ);
$nonMoveableMountPermssions->method('getId')->willReturn(108);
$nonMoveableMountPermssions->method('getPath')->willReturn('path');
$nonMoveableMountPermssions->method('getName')->willReturn('name');
+ $nonMoveableMountPermssions->method('getInternalPath')->willReturn('');
$nonMoveableMountPermssions->method('getOwner')
->willReturn($owner);
$nonMoveableMountPermssions->method('getStorage')
- ->willReturn($storage);
+ ->willReturn($nonMovableStorage);
$data[] = [$this->createShare(null, IShare::TYPE_USER, $nonMoveableMountPermssions, $user2, $user0, $user0, 11, null, null), 'Cannot increase permissions of path', false];
$data[] = [$this->createShare(null, IShare::TYPE_GROUP, $nonMoveableMountPermssions, $group0, $user0, $user0, 11, null, null), 'Cannot increase permissions of path', false];
@@ -777,8 +795,7 @@ class ManagerTest extends \Test\TestCase {
->method('getId')
->willReturn(42);
// Id 108 is used in the data to refer to the node of the share.
- $userFolder->expects($this->any())
- ->method('getById')
+ $userFolder->method('getById')
->with(108)
->willReturn([$share->getNode()]);
$userFolder->expects($this->any())
@@ -926,7 +943,7 @@ class ManagerTest extends \Test\TestCase {
]);
}
- $expected = new \DateTime();
+ $expected = new \DateTime('now', $this->timezone);
$expected->setTime(0, 0, 0);
$expected->add(new \DateInterval('P3D'));
@@ -961,7 +978,7 @@ class ManagerTest extends \Test\TestCase {
]);
}
- $expected = new \DateTime();
+ $expected = new \DateTime('now', $this->timezone);
$expected->setTime(0, 0, 0);
$expected->add(new \DateInterval('P1D'));
@@ -1008,7 +1025,7 @@ class ManagerTest extends \Test\TestCase {
* @dataProvider validateExpirationDateInternalProvider
*/
public function testValidateExpirationDateInternalEnforceValid($shareType) {
- $future = new \DateTime();
+ $future = new \DateTime('now', $this->dateTimeZone->getTimeZone());
$future->add(new \DateInterval('P2D'));
$future->setTime(1, 2, 3);
@@ -1050,7 +1067,7 @@ class ManagerTest extends \Test\TestCase {
* @dataProvider validateExpirationDateInternalProvider
*/
public function testValidateExpirationDateInternalNoDefault($shareType) {
- $date = new \DateTime();
+ $date = new \DateTime('now', $this->dateTimeZone->getTimeZone());
$date->add(new \DateInterval('P5D'));
$date->setTime(1, 2, 3);
@@ -1098,9 +1115,10 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare();
$share->setShareType($shareType);
- $expected = new \DateTime();
+ $expected = new \DateTime('now', $this->timezone);
+ $expected->setTime(0, 0);
$expected->add(new \DateInterval('P3D'));
- $expected->setTime(0, 0, 0);
+ $expected->setTimezone(new \DateTimeZone(date_default_timezone_get()));
if ($shareType === IShare::TYPE_USER) {
$this->config->method('getAppValue')
@@ -1133,12 +1151,12 @@ class ManagerTest extends \Test\TestCase {
* @dataProvider validateExpirationDateInternalProvider
*/
public function testValidateExpirationDateInternalDefault($shareType) {
- $future = new \DateTime();
+ $future = new \DateTime('now', $this->timezone);
$future->add(new \DateInterval('P5D'));
$future->setTime(1, 2, 3);
$expected = clone $future;
- $expected->setTime(0, 0, 0);
+ $expected->setTime(0, 0);
$share = $this->manager->newShare();
$share->setShareType($shareType);
@@ -1175,7 +1193,7 @@ class ManagerTest extends \Test\TestCase {
* @dataProvider validateExpirationDateInternalProvider
*/
public function testValidateExpirationDateInternalHookModification($shareType) {
- $nextWeek = new \DateTime();
+ $nextWeek = new \DateTime('now', $this->timezone);
$nextWeek->add(new \DateInterval('P7D'));
$nextWeek->setTime(0, 0, 0);
@@ -1304,7 +1322,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'link_defaultExpDays', '3', '3'],
]);
- $expected = new \DateTime();
+ $expected = new \DateTime('now', $this->timezone);
$expected->setTime(0, 0, 0);
$expected->add(new \DateInterval('P3D'));
@@ -1325,7 +1343,7 @@ class ManagerTest extends \Test\TestCase {
['core', 'link_defaultExpDays', '3', '1'],
]);
- $expected = new \DateTime();
+ $expected = new \DateTime('now', $this->timezone);
$expected->setTime(0, 0, 0);
$expected->add(new \DateInterval('P1D'));
@@ -1356,7 +1374,7 @@ class ManagerTest extends \Test\TestCase {
}
public function testValidateExpirationDateEnforceValid() {
- $future = new \DateTime();
+ $future = new \DateTime('now', $this->timezone);
$future->add(new \DateInterval('P2D'));
$future->setTime(1, 2, 3);
@@ -1385,12 +1403,13 @@ class ManagerTest extends \Test\TestCase {
}
public function testValidateExpirationDateNoDefault() {
- $date = new \DateTime();
+ $date = new \DateTime('now', $this->timezone);
$date->add(new \DateInterval('P5D'));
$date->setTime(1, 2, 3);
$expected = clone $date;
- $expected->setTime(0, 0, 0);
+ $expected->setTime(0, 0);
+ $expected->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$share = $this->manager->newShare();
$share->setExpirationDate($date);
@@ -1424,9 +1443,10 @@ class ManagerTest extends \Test\TestCase {
public function testValidateExpirationDateNoDateDefault() {
$share = $this->manager->newShare();
- $expected = new \DateTime();
+ $expected = new \DateTime('now', $this->timezone);
$expected->add(new \DateInterval('P3D'));
- $expected->setTime(0, 0, 0);
+ $expected->setTime(0, 0);
+ $expected->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$this->config->method('getAppValue')
->willReturnMap([
@@ -1447,12 +1467,44 @@ class ManagerTest extends \Test\TestCase {
}
public function testValidateExpirationDateDefault() {
- $future = new \DateTime();
+ $future = new \DateTime('now', $this->timezone);
$future->add(new \DateInterval('P5D'));
$future->setTime(1, 2, 3);
$expected = clone $future;
- $expected->setTime(0, 0, 0);
+ $expected->setTime(0, 0);
+ $expected->setTimezone(new \DateTimeZone(date_default_timezone_get()));
+
+ $share = $this->manager->newShare();
+ $share->setExpirationDate($future);
+
+ $this->config->method('getAppValue')
+ ->willReturnMap([
+ ['core', 'shareapi_default_expire_date', 'no', 'yes'],
+ ['core', 'shareapi_expire_after_n_days', '7', '3'],
+ ['core', 'link_defaultExpDays', '3', '1'],
+ ]);
+
+ $hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
+ \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
+ $hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
+ return $data['expirationDate'] == $expected;
+ }));
+
+ self::invokePrivate($this->manager, 'validateExpirationDateLink', [$share]);
+
+ $this->assertEquals($expected, $share->getExpirationDate());
+ }
+
+ public function testValidateExpirationNegativeOffsetTimezone() {
+ $this->timezone = new \DateTimeZone('Pacific/Tahiti');
+ $future = new \DateTime();
+ $future->add(new \DateInterval('P5D'));
+
+ $expected = clone $future;
+ $expected->setTimezone($this->timezone);
+ $expected->setTime(0, 0);
+ $expected->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$share = $this->manager->newShare();
$share->setExpirationDate($future);
@@ -1476,11 +1528,13 @@ class ManagerTest extends \Test\TestCase {
}
public function testValidateExpirationDateHookModification() {
- $nextWeek = new \DateTime();
+ $nextWeek = new \DateTime('now', $this->timezone);
$nextWeek->add(new \DateInterval('P7D'));
- $nextWeek->setTime(0, 0, 0);
$save = clone $nextWeek;
+ $save->setTime(0, 0);
+ $save->sub(new \DateInterval('P2D'));
+ $save->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
@@ -1493,7 +1547,6 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'validateExpirationDateLink', [$share]);
- $save->sub(new \DateInterval('P2D'));
$this->assertEquals($save, $share->getExpirationDate());
}
@@ -1562,6 +1615,7 @@ class ManagerTest extends \Test\TestCase {
->method('getAppValue')
->willReturnMap([
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
+ ['core', 'shareapi_only_share_with_group_members_exclude_group_list', '', '[]'],
]);
self::invokePrivate($this->manager, 'userCreateChecks', [$share]);
@@ -1595,6 +1649,7 @@ class ManagerTest extends \Test\TestCase {
->method('getAppValue')
->willReturnMap([
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
+ ['core', 'shareapi_only_share_with_group_members_exclude_group_list', '', '[]'],
]);
$this->defaultProvider
@@ -1609,7 +1664,7 @@ class ManagerTest extends \Test\TestCase {
public function testUserCreateChecksIdenticalShareExists() {
$this->expectException(AlreadySharedException::class);
- $this->expectExceptionMessage('Sharing name.txt failed, because this item is already shared with user user');
+ $this->expectExceptionMessage('Sharing name.txt failed, because this item is already shared with the account user');
$share = $this->manager->newShare();
$share->setSharedWithDisplayName('user');
@@ -1638,7 +1693,7 @@ class ManagerTest extends \Test\TestCase {
public function testUserCreateChecksIdenticalPathSharedViaGroup() {
$this->expectException(AlreadySharedException::class);
- $this->expectExceptionMessage('Sharing name2.txt failed, because this item is already shared with user userName');
+ $this->expectExceptionMessage('Sharing name2.txt failed, because this item is already shared with the account userName');
$share = $this->manager->newShare();
@@ -1787,6 +1842,7 @@ class ManagerTest extends \Test\TestCase {
->willReturnMap([
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
['core', 'shareapi_allow_group_sharing', 'yes', 'yes'],
+ ['core', 'shareapi_only_share_with_group_members_exclude_group_list', '', '[]'],
]);
self::invokePrivate($this->manager, 'groupCreateChecks', [$share]);
@@ -1810,6 +1866,7 @@ class ManagerTest extends \Test\TestCase {
->willReturnMap([
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
['core', 'shareapi_allow_group_sharing', 'yes', 'yes'],
+ ['core', 'shareapi_only_share_with_group_members_exclude_group_list', '', '[]'],
]);
$this->assertNull($this->invokePrivate($this->manager, 'groupCreateChecks', [$share]));
@@ -1839,6 +1896,7 @@ class ManagerTest extends \Test\TestCase {
->willReturnMap([
['core', 'shareapi_only_share_with_group_members', 'no', 'yes'],
['core', 'shareapi_allow_group_sharing', 'yes', 'yes'],
+ ['core', 'shareapi_only_share_with_group_members_exclude_group_list', '', '[]'],
]);
self::invokePrivate($this->manager, 'groupCreateChecks', [$share]);
@@ -2038,26 +2096,33 @@ class ManagerTest extends \Test\TestCase {
// No exclude groups
$data[] = ['no', null, null, [], false];
- // empty exclude list, user no groups
+ // empty exclude / allow list, user no groups
$data[] = ['yes', '', json_encode(['']), [], false];
+ $data[] = ['allow', '', json_encode(['']), [], true];
- // empty exclude list, user groups
+ // empty exclude / allow list, user groups
$data[] = ['yes', '', json_encode(['']), ['group1', 'group2'], false];
+ $data[] = ['allow', '', json_encode(['']), ['group1', 'group2'], true];
// Convert old list to json
$data[] = ['yes', 'group1,group2', json_encode(['group1', 'group2']), [], false];
+ $data[] = ['allow', 'group1,group2', json_encode(['group1', 'group2']), [], true];
// Old list partly groups in common
$data[] = ['yes', 'group1,group2', json_encode(['group1', 'group2']), ['group1', 'group3'], false];
+ $data[] = ['allow', 'group1,group2', json_encode(['group1', 'group2']), ['group1', 'group3'], false];
// Old list only groups in common
$data[] = ['yes', 'group1,group2', json_encode(['group1', 'group2']), ['group1'], true];
+ $data[] = ['allow', 'group1,group2', json_encode(['group1', 'group2']), ['group1'], false];
// New list partly in common
$data[] = ['yes', json_encode(['group1', 'group2']), null, ['group1', 'group3'], false];
+ $data[] = ['allow', json_encode(['group1', 'group2']), null, ['group1', 'group3'], false];
// New list only groups in common
$data[] = ['yes', json_encode(['group1', 'group2']), null, ['group2'], true];
+ $data[] = ['allow', json_encode(['group1', 'group2']), null, ['group2'], false];
return $data;
}
@@ -2738,25 +2803,7 @@ class ManagerTest extends \Test\TestCase {
$factory = $this->createMock(IProviderFactory::class);
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService
- );
+ $manager = $this->createManager($factory);
$share = $this->createMock(IShare::class);
@@ -2785,25 +2832,7 @@ class ManagerTest extends \Test\TestCase {
$factory = $this->createMock(IProviderFactory::class);
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService
- );
+ $manager = $this->createManager($factory);
$share = $this->createMock(IShare::class);
@@ -2839,25 +2868,7 @@ class ManagerTest extends \Test\TestCase {
$factory = $this->createMock(IProviderFactory::class);
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService
- );
+ $manager = $this->createManager($factory);
$share = $this->createMock(IShare::class);
@@ -4238,25 +4249,7 @@ class ManagerTest extends \Test\TestCase {
throw new Exception\ProviderException();
});
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService
- );
+ $manager = $this->createManager($factory);
$this->assertSame($expected,
$manager->shareProviderExists($shareType)
);
@@ -4272,25 +4265,7 @@ class ManagerTest extends \Test\TestCase {
public function testGetSharesInFolder() {
$factory = new DummyFactory2($this->createMock(IServerContainer::class));
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService
- );
+ $manager = $this->createManager($factory);
$factory->setProvider($this->defaultProvider);
$extraProvider = $this->createMock(IShareProvider::class);
@@ -4337,25 +4312,7 @@ class ManagerTest extends \Test\TestCase {
public function testGetAccessList() {
$factory = new DummyFactory2($this->createMock(IServerContainer::class));
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService
- );
+ $manager = $this->createManager($factory);
$factory->setProvider($this->defaultProvider);
$extraProvider = $this->createMock(IShareProvider::class);
@@ -4394,9 +4351,9 @@ class ManagerTest extends \Test\TestCase {
->willReturn($userFolder);
$folder->method('getPath')
->willReturn('/owner/files/folder');
- $userFolder->method('getById')
+ $userFolder->method('getFirstNodeById')
->with($this->equalTo(42))
- ->willReturn([12 => $file]);
+ ->willReturn($file);
$userFolder->method('getPath')
->willReturn('/user1/files');
@@ -4454,25 +4411,7 @@ class ManagerTest extends \Test\TestCase {
public function testGetAccessListWithCurrentAccess() {
$factory = new DummyFactory2($this->createMock(IServerContainer::class));
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService
- );
+ $manager = $this->createManager($factory);
$factory->setProvider($this->defaultProvider);
$extraProvider = $this->createMock(IShareProvider::class);
@@ -4511,9 +4450,9 @@ class ManagerTest extends \Test\TestCase {
->willReturn($userFolder);
$folder->method('getPath')
->willReturn('/owner/files/folder');
- $userFolder->method('getById')
+ $userFolder->method('getFirstNodeById')
->with($this->equalTo(42))
- ->willReturn([42 => $file]);
+ ->willReturn($file);
$userFolder->method('getPath')
->willReturn('/user1/files');
@@ -4580,25 +4519,7 @@ class ManagerTest extends \Test\TestCase {
public function testGetAllShares() {
$factory = new DummyFactory2($this->createMock(IServerContainer::class));
- $manager = new Manager(
- $this->logger,
- $this->config,
- $this->secureRandom,
- $this->hasher,
- $this->mountManager,
- $this->groupManager,
- $this->l,
- $this->l10nFactory,
- $factory,
- $this->userManager,
- $this->rootFolder,
- $this->mailer,
- $this->urlGenerator,
- $this->defaults,
- $this->dispatcher,
- $this->userSession,
- $this->knownUserService
- );
+ $manager = $this->createManager($factory);
$factory->setProvider($this->defaultProvider);
$extraProvider = $this->createMock(IShareProvider::class);
diff --git a/tests/lib/Share20/ShareByMailProviderTest.php b/tests/lib/Share20/ShareByMailProviderTest.php
index 5116dfe9e58..c3fe0dab790 100644
--- a/tests/lib/Share20/ShareByMailProviderTest.php
+++ b/tests/lib/Share20/ShareByMailProviderTest.php
@@ -3,24 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2022 Richard Steinmetz <richard@steinmetz.cloud>
- *
- * @author Richard Steinmetz <richard@steinmetz.cloud>
- *
- * @license AGPL-3.0-or-later
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Share20;
@@ -35,7 +19,6 @@ use OCP\Files\IRootFolder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
-use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\Mail\IMailer;
@@ -43,6 +26,7 @@ use OCP\Security\IHasher;
use OCP\Security\ISecureRandom;
use OCP\Share\IShare;
use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
use Test\TestCase;
/**
@@ -79,7 +63,7 @@ class ShareByMailProviderTest extends TestCase {
/** @var IConfig|MockObject */
protected $config;
- /** @var ILogger|MockObject */
+ /** @var LoggerInterface|MockObject */
private $logger;
/** @var IHasher|MockObject */
@@ -108,7 +92,7 @@ class ShareByMailProviderTest extends TestCase {
$this->l10n = $this->createMock(IL10N::class);
$this->defaults = $this->getMockBuilder(Defaults::class)->disableOriginalConstructor()->getMock();
$this->urlGenerator = $this->createMock(IURLGenerator::class);
- $this->logger = $this->createMock(ILogger::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
$this->activityManager = $this->createMock(\OCP\Activity\IManager::class);
$this->settingsManager = $this->createMock(SettingsManager::class);
$this->hasher = $this->createMock(IHasher::class);
@@ -162,8 +146,8 @@ class ShareByMailProviderTest extends TestCase {
* @throws \OCP\DB\Exception
*/
private function addShareToDB($shareType, $sharedWith, $sharedBy, $shareOwner,
- $itemType, $fileSource, $fileTarget, $permissions, $token, $expiration,
- $parent) {
+ $itemType, $fileSource, $fileTarget, $permissions, $token, $expiration,
+ $parent) {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share');
diff --git a/tests/lib/Share20/ShareHelperTest.php b/tests/lib/Share20/ShareHelperTest.php
index 857810e7881..04a079db0e9 100644
--- a/tests/lib/Share20/ShareHelperTest.php
+++ b/tests/lib/Share20/ShareHelperTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2017, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Share20;
diff --git a/tests/lib/Share20/ShareTest.php b/tests/lib/Share20/ShareTest.php
index b2419e07683..6769683aafe 100644
--- a/tests/lib/Share20/ShareTest.php
+++ b/tests/lib/Share20/ShareTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Share20;
diff --git a/tests/lib/SubAdminTest.php b/tests/lib/SubAdminTest.php
index 647141a73f7..a4138fa922b 100644
--- a/tests/lib/SubAdminTest.php
+++ b/tests/lib/SubAdminTest.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test;
diff --git a/tests/lib/Support/CrashReport/RegistryTest.php b/tests/lib/Support/CrashReport/RegistryTest.php
index 9424738cd70..b65c21b759e 100644
--- a/tests/lib/Support/CrashReport/RegistryTest.php
+++ b/tests/lib/Support/CrashReport/RegistryTest.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Support\CrashReport;
diff --git a/tests/lib/Support/Subscription/DummySubscription.php b/tests/lib/Support/Subscription/DummySubscription.php
index dfbee2e9a5e..ca1644c91f5 100644
--- a/tests/lib/Support/Subscription/DummySubscription.php
+++ b/tests/lib/Support/Subscription/DummySubscription.php
@@ -3,23 +3,8 @@
declare(strict_types=1);
/**
- * @author Daniel Kesselberg <mail@danielkesselberg.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Support\Subscription;
diff --git a/tests/lib/Support/Subscription/RegistryTest.php b/tests/lib/Support/Subscription/RegistryTest.php
index 2a6d5e5569f..de7f7600496 100644
--- a/tests/lib/Support/Subscription/RegistryTest.php
+++ b/tests/lib/Support/Subscription/RegistryTest.php
@@ -1,23 +1,8 @@
<?php
/**
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Support\Subscription;
diff --git a/tests/lib/SystemTag/SystemTagManagerTest.php b/tests/lib/SystemTag/SystemTagManagerTest.php
index e4610ede9bf..5029eaa7df6 100644
--- a/tests/lib/SystemTag/SystemTagManagerTest.php
+++ b/tests/lib/SystemTag/SystemTagManagerTest.php
@@ -1,11 +1,9 @@
<?php
/**
- * Copyright (c) 2015 Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\SystemTag;
diff --git a/tests/lib/SystemTag/SystemTagObjectMapperTest.php b/tests/lib/SystemTag/SystemTagObjectMapperTest.php
index 2c838e0a6b3..c9aff9f5183 100644
--- a/tests/lib/SystemTag/SystemTagObjectMapperTest.php
+++ b/tests/lib/SystemTag/SystemTagObjectMapperTest.php
@@ -1,11 +1,9 @@
<?php
/**
- * Copyright (c) 2015 Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\SystemTag;
diff --git a/tests/lib/TagsTest.php b/tests/lib/TagsTest.php
index 28a8d4913f2..a3e0c8f750f 100644
--- a/tests/lib/TagsTest.php
+++ b/tests/lib/TagsTest.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Thomas Tanghus
- * @copyright 2012-13 Thomas Tanghus (thomas@tanghus.net)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/Talk/BrokerTest.php b/tests/lib/Talk/BrokerTest.php
index b2f3b0c4fdb..dc901047b92 100644
--- a/tests/lib/Talk/BrokerTest.php
+++ b/tests/lib/Talk/BrokerTest.php
@@ -2,25 +2,9 @@
declare(strict_types=1);
-/*
- * @copyright 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Talk;
diff --git a/tests/lib/Talk/ConversationOptionsTest.php b/tests/lib/Talk/ConversationOptionsTest.php
index 62fbb268d24..ca6befbd7c9 100644
--- a/tests/lib/Talk/ConversationOptionsTest.php
+++ b/tests/lib/Talk/ConversationOptionsTest.php
@@ -2,25 +2,9 @@
declare(strict_types=1);
-/*
- * @copyright 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Talk;
diff --git a/tests/lib/TaskProcessing/TaskProcessingTest.php b/tests/lib/TaskProcessing/TaskProcessingTest.php
new file mode 100644
index 00000000000..fe679ebbd2d
--- /dev/null
+++ b/tests/lib/TaskProcessing/TaskProcessingTest.php
@@ -0,0 +1,762 @@
+<?php
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace Test\TextProcessing;
+
+use OC\AppFramework\Bootstrap\Coordinator;
+use OC\AppFramework\Bootstrap\RegistrationContext;
+use OC\AppFramework\Bootstrap\ServiceRegistration;
+use OC\EventDispatcher\EventDispatcher;
+use OC\TaskProcessing\Db\TaskMapper;
+use OC\TaskProcessing\Manager;
+use OC\TaskProcessing\RemoveOldTasksBackgroundJob;
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\BackgroundJob\IJobList;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\AppData\IAppDataFactory;
+use OCP\Files\IAppData;
+use OCP\Files\IRootFolder;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\IServerContainer;
+use OCP\IUserManager;
+use OCP\SpeechToText\ISpeechToTextManager;
+use OCP\TaskProcessing\EShapeType;
+use OCP\TaskProcessing\Events\TaskFailedEvent;
+use OCP\TaskProcessing\Events\TaskSuccessfulEvent;
+use OCP\TaskProcessing\Exception\NotFoundException;
+use OCP\TaskProcessing\Exception\ProcessingException;
+use OCP\TaskProcessing\Exception\UnauthorizedException;
+use OCP\TaskProcessing\Exception\ValidationException;
+use OCP\TaskProcessing\IManager;
+use OCP\TaskProcessing\IProvider;
+use OCP\TaskProcessing\ISynchronousProvider;
+use OCP\TaskProcessing\ITaskType;
+use OCP\TaskProcessing\ShapeDescriptor;
+use OCP\TaskProcessing\Task;
+use OCP\TaskProcessing\TaskTypes\TextToImage;
+use OCP\TaskProcessing\TaskTypes\TextToText;
+use OCP\TaskProcessing\TaskTypes\TextToTextSummary;
+use OCP\TextProcessing\SummaryTaskType;
+use PHPUnit\Framework\Constraint\IsInstanceOf;
+use Psr\Log\LoggerInterface;
+use Test\BackgroundJob\DummyJobList;
+
+class AudioToImage implements ITaskType {
+ public const ID = 'test:audiotoimage';
+
+ public function getId(): string {
+ return self::ID;
+ }
+
+ public function getName(): string {
+ return self::class;
+ }
+
+ public function getDescription(): string {
+ return self::class;
+ }
+
+ public function getInputShape(): array {
+ return [
+ 'audio' => new ShapeDescriptor('Audio', 'The audio', EShapeType::Audio),
+ ];
+ }
+
+ public function getOutputShape(): array {
+ return [
+ 'spectrogram' => new ShapeDescriptor('Spectrogram', 'The audio spectrogram', EShapeType::Image),
+ ];
+ }
+}
+
+class AsyncProvider implements IProvider {
+ public function getId(): string {
+ return 'test:sync:success';
+ }
+
+ public function getName(): string {
+ return self::class;
+ }
+
+ public function getTaskTypeId(): string {
+ return AudioToImage::ID;
+ }
+
+ public function getExpectedRuntime(): int {
+ return 10;
+ }
+
+ public function getOptionalInputShape(): array {
+ return [
+ 'optionalKey' => new ShapeDescriptor('optional Key', 'AN optional key', EShapeType::Text),
+ ];
+ }
+
+ public function getOptionalOutputShape(): array {
+ return [
+ 'optionalKey' => new ShapeDescriptor('optional Key', 'AN optional key', EShapeType::Text),
+ ];
+ }
+}
+
+class SuccessfulSyncProvider implements IProvider, ISynchronousProvider {
+ public function getId(): string {
+ return 'test:sync:success';
+ }
+
+ public function getName(): string {
+ return self::class;
+ }
+
+ public function getTaskTypeId(): string {
+ return TextToText::ID;
+ }
+
+ public function getExpectedRuntime(): int {
+ return 10;
+ }
+
+ public function getOptionalInputShape(): array {
+ return [
+ 'optionalKey' => new ShapeDescriptor('optional Key', 'AN optional key', EShapeType::Text),
+ ];
+ }
+
+ public function getOptionalOutputShape(): array {
+ return [
+ 'optionalKey' => new ShapeDescriptor('optional Key', 'AN optional key', EShapeType::Text),
+ ];
+ }
+
+ public function process(?string $userId, array $input, callable $reportProgress): array {
+ return ['output' => $input['input']];
+ }
+}
+
+class FailingSyncProvider implements IProvider, ISynchronousProvider {
+ public const ERROR_MESSAGE = 'Failure';
+ public function getId(): string {
+ return 'test:sync:fail';
+ }
+
+ public function getName(): string {
+ return self::class;
+ }
+
+ public function getTaskTypeId(): string {
+ return TextToText::ID;
+ }
+
+ public function getExpectedRuntime(): int {
+ return 10;
+ }
+
+ public function getOptionalInputShape(): array {
+ return [
+ 'optionalKey' => new ShapeDescriptor('optional Key', 'AN optional key', EShapeType::Text),
+ ];
+ }
+
+ public function getOptionalOutputShape(): array {
+ return [
+ 'optionalKey' => new ShapeDescriptor('optional Key', 'AN optional key', EShapeType::Text),
+ ];
+ }
+
+ public function process(?string $userId, array $input, callable $reportProgress): array {
+ throw new ProcessingException(self::ERROR_MESSAGE);
+ }
+}
+
+class BrokenSyncProvider implements IProvider, ISynchronousProvider {
+ public function getId(): string {
+ return 'test:sync:broken-output';
+ }
+
+ public function getName(): string {
+ return self::class;
+ }
+
+ public function getTaskTypeId(): string {
+ return TextToText::ID;
+ }
+
+ public function getExpectedRuntime(): int {
+ return 10;
+ }
+
+ public function getOptionalInputShape(): array {
+ return [
+ 'optionalKey' => new ShapeDescriptor('optional Key', 'AN optional key', EShapeType::Text),
+ ];
+ }
+
+ public function getOptionalOutputShape(): array {
+ return [
+ 'optionalKey' => new ShapeDescriptor('optional Key', 'AN optional key', EShapeType::Text),
+ ];
+ }
+
+ public function process(?string $userId, array $input, callable $reportProgress): array {
+ return [];
+ }
+}
+
+class SuccessfulTextProcessingSummaryProvider implements \OCP\TextProcessing\IProvider {
+ public bool $ran = false;
+
+ public function getName(): string {
+ return 'TEST Vanilla LLM Provider';
+ }
+
+ public function process(string $prompt): string {
+ $this->ran = true;
+ return $prompt . ' Summarize';
+ }
+
+ public function getTaskType(): string {
+ return SummaryTaskType::class;
+ }
+}
+
+class FailingTextProcessingSummaryProvider implements \OCP\TextProcessing\IProvider {
+ public bool $ran = false;
+
+ public function getName(): string {
+ return 'TEST Vanilla LLM Provider';
+ }
+
+ public function process(string $prompt): string {
+ $this->ran = true;
+ throw new \Exception('ERROR');
+ }
+
+ public function getTaskType(): string {
+ return SummaryTaskType::class;
+ }
+}
+
+class SuccessfulTextToImageProvider implements \OCP\TextToImage\IProvider {
+ public bool $ran = false;
+
+ public function getId(): string {
+ return 'test:successful';
+ }
+
+ public function getName(): string {
+ return 'TEST Provider';
+ }
+
+ public function generate(string $prompt, array $resources): void {
+ $this->ran = true;
+ foreach($resources as $resource) {
+ fwrite($resource, 'test');
+ }
+ }
+
+ public function getExpectedRuntime(): int {
+ return 1;
+ }
+}
+
+class FailingTextToImageProvider implements \OCP\TextToImage\IProvider {
+ public bool $ran = false;
+
+ public function getId(): string {
+ return 'test:failing';
+ }
+
+ public function getName(): string {
+ return 'TEST Provider';
+ }
+
+ public function generate(string $prompt, array $resources): void {
+ $this->ran = true;
+ throw new \RuntimeException('ERROR');
+ }
+
+ public function getExpectedRuntime(): int {
+ return 1;
+ }
+}
+
+/**
+ * @group DB
+ */
+class TaskProcessingTest extends \Test\TestCase {
+ private IManager $manager;
+ private Coordinator $coordinator;
+ private array $providers;
+ private IServerContainer $serverContainer;
+ private IEventDispatcher $eventDispatcher;
+ private RegistrationContext $registrationContext;
+ private TaskMapper $taskMapper;
+ private IJobList $jobList;
+ private IAppData $appData;
+ private \OCP\Share\IManager $shareManager;
+ private IRootFolder $rootFolder;
+
+ public const TEST_USER = 'testuser';
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->providers = [
+ SuccessfulSyncProvider::class => new SuccessfulSyncProvider(),
+ FailingSyncProvider::class => new FailingSyncProvider(),
+ BrokenSyncProvider::class => new BrokenSyncProvider(),
+ AsyncProvider::class => new AsyncProvider(),
+ AudioToImage::class => new AudioToImage(),
+ SuccessfulTextProcessingSummaryProvider::class => new SuccessfulTextProcessingSummaryProvider(),
+ FailingTextProcessingSummaryProvider::class => new FailingTextProcessingSummaryProvider(),
+ SuccessfulTextToImageProvider::class => new SuccessfulTextToImageProvider(),
+ FailingTextToImageProvider::class => new FailingTextToImageProvider(),
+ ];
+
+ $userManager = \OCP\Server::get(IUserManager::class);
+ if (!$userManager->userExists(self::TEST_USER)) {
+ $userManager->createUser(self::TEST_USER, 'test');
+ }
+
+ $this->serverContainer = $this->createMock(IServerContainer::class);
+ $this->serverContainer->expects($this->any())->method('get')->willReturnCallback(function ($class) {
+ return $this->providers[$class];
+ });
+
+ $this->eventDispatcher = new EventDispatcher(
+ new \Symfony\Component\EventDispatcher\EventDispatcher(),
+ $this->serverContainer,
+ \OC::$server->get(LoggerInterface::class),
+ );
+
+ $this->registrationContext = $this->createMock(RegistrationContext::class);
+ $this->coordinator = $this->createMock(Coordinator::class);
+ $this->coordinator->expects($this->any())->method('getRegistrationContext')->willReturn($this->registrationContext);
+
+ $this->rootFolder = \OCP\Server::get(IRootFolder::class);
+
+ $this->taskMapper = \OCP\Server::get(TaskMapper::class);
+
+ $this->jobList = $this->createPartialMock(DummyJobList::class, ['add']);
+ $this->jobList->expects($this->any())->method('add')->willReturnCallback(function () {
+ });
+
+ $config = $this->createMock(IConfig::class);
+ $config->method('getAppValue')
+ ->with('core', 'ai.textprocessing_provider_preferences', '')
+ ->willReturn('');
+
+ $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
+
+ $textProcessingManager = new \OC\TextProcessing\Manager(
+ $this->serverContainer,
+ $this->coordinator,
+ \OC::$server->get(LoggerInterface::class),
+ $this->jobList,
+ \OC::$server->get(\OC\TextProcessing\Db\TaskMapper::class),
+ \OC::$server->get(IConfig::class),
+ );
+
+ $text2imageManager = new \OC\TextToImage\Manager(
+ $this->serverContainer,
+ $this->coordinator,
+ \OC::$server->get(LoggerInterface::class),
+ $this->jobList,
+ \OC::$server->get(\OC\TextToImage\Db\TaskMapper::class),
+ \OC::$server->get(IConfig::class),
+ \OC::$server->get(IAppDataFactory::class),
+ );
+
+ $this->shareManager = $this->createMock(\OCP\Share\IManager::class);
+
+ $this->manager = new Manager(
+ $this->coordinator,
+ $this->serverContainer,
+ \OC::$server->get(LoggerInterface::class),
+ $this->taskMapper,
+ $this->jobList,
+ $this->eventDispatcher,
+ \OC::$server->get(IAppDataFactory::class),
+ \OC::$server->get(IRootFolder::class),
+ $textProcessingManager,
+ $text2imageManager,
+ \OC::$server->get(ISpeechToTextManager::class),
+ $this->shareManager,
+ );
+ }
+
+ private function getFile(string $name, string $content): \OCP\Files\File {
+ $folder = $this->rootFolder->getUserFolder(self::TEST_USER);
+ $file = $folder->newFile($name, $content);
+ return $file;
+ }
+
+ public function testShouldNotHaveAnyProviders() {
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([]);
+ self::assertCount(0, $this->manager->getAvailableTaskTypes());
+ self::assertFalse($this->manager->hasProviders());
+ self::expectException(\OCP\TaskProcessing\Exception\PreConditionNotMetException::class);
+ $this->manager->scheduleTask(new Task(TextToText::ID, ['input' => 'Hello'], 'test', null));
+ }
+
+ public function testProviderShouldBeRegisteredAndTaskFailValidation() {
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
+ new ServiceRegistration('test', BrokenSyncProvider::class)
+ ]);
+ self::assertCount(1, $this->manager->getAvailableTaskTypes());
+ self::assertTrue($this->manager->hasProviders());
+ $task = new Task(TextToText::ID, ['wrongInputKey' => 'Hello'], 'test', null);
+ self::assertNull($task->getId());
+ self::expectException(ValidationException::class);
+ $this->manager->scheduleTask($task);
+ }
+
+ public function testProviderShouldBeRegisteredAndTaskWithFilesFailValidation() {
+ $this->shareManager->expects($this->any())->method('getAccessList')->willReturn(['users' => []]);
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingTaskTypes')->willReturn([
+ new ServiceRegistration('test', AudioToImage::class)
+ ]);
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
+ new ServiceRegistration('test', AsyncProvider::class)
+ ]);
+ $this->shareManager->expects($this->any())->method('getAccessList')->willReturn(['users' => [null]]);
+ self::assertCount(1, $this->manager->getAvailableTaskTypes());
+
+ self::assertTrue($this->manager->hasProviders());
+ $audioId = $this->getFile('audioInput', 'Hello')->getId();
+ $task = new Task(AudioToImage::ID, ['audio' => $audioId], 'test', null);
+ self::assertNull($task->getId());
+ self::assertEquals(Task::STATUS_UNKNOWN, $task->getStatus());
+ self::expectException(UnauthorizedException::class);
+ $this->manager->scheduleTask($task);
+ }
+
+ public function testProviderShouldBeRegisteredAndFail() {
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
+ new ServiceRegistration('test', FailingSyncProvider::class)
+ ]);
+ self::assertCount(1, $this->manager->getAvailableTaskTypes());
+ self::assertTrue($this->manager->hasProviders());
+ $task = new Task(TextToText::ID, ['input' => 'Hello'], 'test', null);
+ self::assertNull($task->getId());
+ self::assertEquals(Task::STATUS_UNKNOWN, $task->getStatus());
+ $this->manager->scheduleTask($task);
+ self::assertNotNull($task->getId());
+ self::assertEquals(Task::STATUS_SCHEDULED, $task->getStatus());
+
+ $this->eventDispatcher->expects($this->once())->method('dispatchTyped')->with(new IsInstanceOf(TaskFailedEvent::class));
+
+ $backgroundJob = new \OC\TaskProcessing\SynchronousBackgroundJob(
+ \OCP\Server::get(ITimeFactory::class),
+ $this->manager,
+ $this->jobList,
+ \OCP\Server::get(LoggerInterface::class),
+ );
+ $backgroundJob->start($this->jobList);
+
+ $task = $this->manager->getTask($task->getId());
+ self::assertEquals(Task::STATUS_FAILED, $task->getStatus());
+ self::assertEquals(FailingSyncProvider::ERROR_MESSAGE, $task->getErrorMessage());
+ }
+
+ public function testProviderShouldBeRegisteredAndFailOutputValidation() {
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
+ new ServiceRegistration('test', BrokenSyncProvider::class)
+ ]);
+ self::assertCount(1, $this->manager->getAvailableTaskTypes());
+ self::assertTrue($this->manager->hasProviders());
+ $task = new Task(TextToText::ID, ['input' => 'Hello'], 'test', null);
+ self::assertNull($task->getId());
+ self::assertEquals(Task::STATUS_UNKNOWN, $task->getStatus());
+ $this->manager->scheduleTask($task);
+ self::assertNotNull($task->getId());
+ self::assertEquals(Task::STATUS_SCHEDULED, $task->getStatus());
+
+ $this->eventDispatcher->expects($this->once())->method('dispatchTyped')->with(new IsInstanceOf(TaskFailedEvent::class));
+
+ $backgroundJob = new \OC\TaskProcessing\SynchronousBackgroundJob(
+ \OCP\Server::get(ITimeFactory::class),
+ $this->manager,
+ $this->jobList,
+ \OCP\Server::get(LoggerInterface::class),
+ );
+ $backgroundJob->start($this->jobList);
+
+ $task = $this->manager->getTask($task->getId());
+ self::assertEquals(Task::STATUS_FAILED, $task->getStatus());
+ self::assertEquals('The task was processed successfully but the provider\'s output doesn\'t pass validation against the task type\'s outputShape spec and/or the provider\'s own optionalOutputShape spec', $task->getErrorMessage());
+ }
+
+ public function testProviderShouldBeRegisteredAndRun() {
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
+ new ServiceRegistration('test', SuccessfulSyncProvider::class)
+ ]);
+ self::assertCount(1, $this->manager->getAvailableTaskTypes());
+ $taskTypeStruct = $this->manager->getAvailableTaskTypes()[array_keys($this->manager->getAvailableTaskTypes())[0]];
+ self::assertTrue(isset($taskTypeStruct['inputShape']['input']));
+ self::assertEquals(EShapeType::Text, $taskTypeStruct['inputShape']['input']->getShapeType());
+ self::assertTrue(isset($taskTypeStruct['optionalInputShape']['optionalKey']));
+ self::assertEquals(EShapeType::Text, $taskTypeStruct['optionalInputShape']['optionalKey']->getShapeType());
+ self::assertTrue(isset($taskTypeStruct['outputShape']['output']));
+ self::assertEquals(EShapeType::Text, $taskTypeStruct['outputShape']['output']->getShapeType());
+ self::assertTrue(isset($taskTypeStruct['optionalOutputShape']['optionalKey']));
+ self::assertEquals(EShapeType::Text, $taskTypeStruct['optionalOutputShape']['optionalKey']->getShapeType());
+
+ self::assertTrue($this->manager->hasProviders());
+ $task = new Task(TextToText::ID, ['input' => 'Hello'], 'test', null);
+ self::assertNull($task->getId());
+ self::assertEquals(Task::STATUS_UNKNOWN, $task->getStatus());
+ $this->manager->scheduleTask($task);
+ self::assertNotNull($task->getId());
+ self::assertEquals(Task::STATUS_SCHEDULED, $task->getStatus());
+
+ // Task object retrieved from db is up-to-date
+ $task2 = $this->manager->getTask($task->getId());
+ self::assertEquals($task->getId(), $task2->getId());
+ self::assertEquals(['input' => 'Hello'], $task2->getInput());
+ self::assertNull($task2->getOutput());
+ self::assertEquals(Task::STATUS_SCHEDULED, $task2->getStatus());
+
+ $this->eventDispatcher->expects($this->once())->method('dispatchTyped')->with(new IsInstanceOf(TaskSuccessfulEvent::class));
+
+ $backgroundJob = new \OC\TaskProcessing\SynchronousBackgroundJob(
+ \OCP\Server::get(ITimeFactory::class),
+ $this->manager,
+ $this->jobList,
+ \OCP\Server::get(LoggerInterface::class),
+ );
+ $backgroundJob->start($this->jobList);
+
+ $task = $this->manager->getTask($task->getId());
+ self::assertEquals(Task::STATUS_SUCCESSFUL, $task->getStatus(), 'Status is '. $task->getStatus() . ' with error message: ' . $task->getErrorMessage());
+ self::assertEquals(['output' => 'Hello'], $task->getOutput());
+ self::assertEquals(1, $task->getProgress());
+ }
+
+ public function testAsyncProviderWithFilesShouldBeRegisteredAndRun() {
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingTaskTypes')->willReturn([
+ new ServiceRegistration('test', AudioToImage::class)
+ ]);
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
+ new ServiceRegistration('test', AsyncProvider::class)
+ ]);
+ $this->shareManager->expects($this->any())->method('getAccessList')->willReturn(['users' => ['testuser' => 1]]);
+ self::assertCount(1, $this->manager->getAvailableTaskTypes());
+
+ self::assertTrue($this->manager->hasProviders());
+ $audioId = $this->getFile('audioInput', 'Hello')->getId();
+ $task = new Task(AudioToImage::ID, ['audio' => $audioId], 'test', 'testuser');
+ self::assertNull($task->getId());
+ self::assertEquals(Task::STATUS_UNKNOWN, $task->getStatus());
+ $this->manager->scheduleTask($task);
+ self::assertNotNull($task->getId());
+ self::assertEquals(Task::STATUS_SCHEDULED, $task->getStatus());
+
+ // Task object retrieved from db is up-to-date
+ $task2 = $this->manager->getTask($task->getId());
+ self::assertEquals($task->getId(), $task2->getId());
+ self::assertEquals(['audio' => $audioId], $task2->getInput());
+ self::assertNull($task2->getOutput());
+ self::assertEquals(Task::STATUS_SCHEDULED, $task2->getStatus());
+
+ $this->eventDispatcher->expects($this->once())->method('dispatchTyped')->with(new IsInstanceOf(TaskSuccessfulEvent::class));
+
+ $this->manager->setTaskProgress($task2->getId(), 0.1);
+ $input = $this->manager->prepareInputData($task2);
+ self::assertTrue(isset($input['audio']));
+ self::assertInstanceOf(\OCP\Files\File::class, $input['audio']);
+ self::assertEquals($audioId, $input['audio']->getId());
+
+ $this->manager->setTaskResult($task2->getId(), null, ['spectrogram' => 'World']);
+
+ $task = $this->manager->getTask($task->getId());
+ self::assertEquals(Task::STATUS_SUCCESSFUL, $task->getStatus());
+ self::assertEquals(1, $task->getProgress());
+ self::assertTrue(isset($task->getOutput()['spectrogram']));
+ $node = $this->rootFolder->getFirstNodeByIdInPath($task->getOutput()['spectrogram'], '/' . $this->rootFolder->getAppDataDirectoryName() . '/');
+ self::assertNotNull($node);
+ self::assertInstanceOf(\OCP\Files\File::class, $node);
+ self::assertEquals('World', $node->getContent());
+ }
+
+ public function testNonexistentTask() {
+ $this->expectException(\OCP\TaskProcessing\Exception\NotFoundException::class);
+ $this->manager->getTask(2147483646);
+ }
+
+ public function testOldTasksShouldBeCleanedUp() {
+ $currentTime = new \DateTime('now');
+ $timeFactory = $this->createMock(ITimeFactory::class);
+ $timeFactory->expects($this->any())->method('getDateTime')->willReturnCallback(fn () => $currentTime);
+ $timeFactory->expects($this->any())->method('getTime')->willReturnCallback(fn () => $currentTime->getTimestamp());
+
+ $this->taskMapper = new TaskMapper(
+ \OCP\Server::get(IDBConnection::class),
+ $timeFactory,
+ );
+
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
+ new ServiceRegistration('test', SuccessfulSyncProvider::class)
+ ]);
+ self::assertCount(1, $this->manager->getAvailableTaskTypes());
+ self::assertTrue($this->manager->hasProviders());
+ $task = new Task(TextToText::ID, ['input' => 'Hello'], 'test', null);
+ $this->manager->scheduleTask($task);
+
+ $this->eventDispatcher->expects($this->once())->method('dispatchTyped')->with(new IsInstanceOf(TaskSuccessfulEvent::class));
+
+ $backgroundJob = new \OC\TaskProcessing\SynchronousBackgroundJob(
+ \OCP\Server::get(ITimeFactory::class),
+ $this->manager,
+ $this->jobList,
+ \OCP\Server::get(LoggerInterface::class),
+ );
+ $backgroundJob->start($this->jobList);
+
+ $task = $this->manager->getTask($task->getId());
+
+ $currentTime = $currentTime->add(new \DateInterval('P1Y'));
+ // run background job
+ $bgJob = new RemoveOldTasksBackgroundJob(
+ $timeFactory,
+ $this->taskMapper,
+ \OC::$server->get(LoggerInterface::class),
+ \OCP\Server::get(IAppDataFactory::class),
+ );
+ $bgJob->setArgument([]);
+ $bgJob->start($this->jobList);
+
+ $this->expectException(NotFoundException::class);
+ $this->manager->getTask($task->getId());
+ }
+
+ public function testShouldTransparentlyHandleTextProcessingProviders() {
+ $this->registrationContext->expects($this->any())->method('getTextProcessingProviders')->willReturn([
+ new ServiceRegistration('test', SuccessfulTextProcessingSummaryProvider::class)
+ ]);
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
+ ]);
+ $taskTypes = $this->manager->getAvailableTaskTypes();
+ self::assertCount(1, $taskTypes);
+ self::assertTrue(isset($taskTypes[TextToTextSummary::ID]));
+ self::assertTrue($this->manager->hasProviders());
+ $task = new Task(TextToTextSummary::ID, ['input' => 'Hello'], 'test', null);
+ $this->manager->scheduleTask($task);
+
+ $this->eventDispatcher->expects($this->once())->method('dispatchTyped')->with(new IsInstanceOf(TaskSuccessfulEvent::class));
+
+ $backgroundJob = new \OC\TaskProcessing\SynchronousBackgroundJob(
+ \OCP\Server::get(ITimeFactory::class),
+ $this->manager,
+ $this->jobList,
+ \OCP\Server::get(LoggerInterface::class),
+ );
+ $backgroundJob->start($this->jobList);
+
+ $task = $this->manager->getTask($task->getId());
+ self::assertEquals(Task::STATUS_SUCCESSFUL, $task->getStatus());
+ self::assertIsArray($task->getOutput());
+ self::assertTrue(isset($task->getOutput()['output']));
+ self::assertEquals('Hello Summarize', $task->getOutput()['output']);
+ self::assertTrue($this->providers[SuccessfulTextProcessingSummaryProvider::class]->ran);
+ }
+
+ public function testShouldTransparentlyHandleFailingTextProcessingProviders() {
+ $this->registrationContext->expects($this->any())->method('getTextProcessingProviders')->willReturn([
+ new ServiceRegistration('test', FailingTextProcessingSummaryProvider::class)
+ ]);
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
+ ]);
+ $taskTypes = $this->manager->getAvailableTaskTypes();
+ self::assertCount(1, $taskTypes);
+ self::assertTrue(isset($taskTypes[TextToTextSummary::ID]));
+ self::assertTrue($this->manager->hasProviders());
+ $task = new Task(TextToTextSummary::ID, ['input' => 'Hello'], 'test', null);
+ $this->manager->scheduleTask($task);
+
+ $this->eventDispatcher->expects($this->once())->method('dispatchTyped')->with(new IsInstanceOf(TaskFailedEvent::class));
+
+ $backgroundJob = new \OC\TaskProcessing\SynchronousBackgroundJob(
+ \OCP\Server::get(ITimeFactory::class),
+ $this->manager,
+ $this->jobList,
+ \OCP\Server::get(LoggerInterface::class),
+ );
+ $backgroundJob->start($this->jobList);
+
+ $task = $this->manager->getTask($task->getId());
+ self::assertEquals(Task::STATUS_FAILED, $task->getStatus());
+ self::assertTrue($task->getOutput() === null);
+ self::assertEquals('ERROR', $task->getErrorMessage());
+ self::assertTrue($this->providers[FailingTextProcessingSummaryProvider::class]->ran);
+ }
+
+ public function testShouldTransparentlyHandleText2ImageProviders() {
+ $this->registrationContext->expects($this->any())->method('getTextToImageProviders')->willReturn([
+ new ServiceRegistration('test', SuccessfulTextToImageProvider::class)
+ ]);
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
+ ]);
+ $taskTypes = $this->manager->getAvailableTaskTypes();
+ self::assertCount(1, $taskTypes);
+ self::assertTrue(isset($taskTypes[TextToImage::ID]));
+ self::assertTrue($this->manager->hasProviders());
+ $task = new Task(TextToImage::ID, ['input' => 'Hello', 'numberOfImages' => 3], 'test', null);
+ $this->manager->scheduleTask($task);
+
+ $this->eventDispatcher->expects($this->once())->method('dispatchTyped')->with(new IsInstanceOf(TaskSuccessfulEvent::class));
+
+ $backgroundJob = new \OC\TaskProcessing\SynchronousBackgroundJob(
+ \OCP\Server::get(ITimeFactory::class),
+ $this->manager,
+ $this->jobList,
+ \OCP\Server::get(LoggerInterface::class),
+ );
+ $backgroundJob->start($this->jobList);
+
+ $task = $this->manager->getTask($task->getId());
+ self::assertEquals(Task::STATUS_SUCCESSFUL, $task->getStatus());
+ self::assertIsArray($task->getOutput());
+ self::assertTrue(isset($task->getOutput()['images']));
+ self::assertIsArray($task->getOutput()['images']);
+ self::assertCount(3, $task->getOutput()['images']);
+ self::assertTrue($this->providers[SuccessfulTextToImageProvider::class]->ran);
+ $node = $this->rootFolder->getFirstNodeByIdInPath($task->getOutput()['images'][0], '/' . $this->rootFolder->getAppDataDirectoryName() . '/');
+ self::assertNotNull($node);
+ self::assertInstanceOf(\OCP\Files\File::class, $node);
+ self::assertEquals('test', $node->getContent());
+ }
+
+ public function testShouldTransparentlyHandleFailingText2ImageProviders() {
+ $this->registrationContext->expects($this->any())->method('getTextToImageProviders')->willReturn([
+ new ServiceRegistration('test', FailingTextToImageProvider::class)
+ ]);
+ $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([
+ ]);
+ $taskTypes = $this->manager->getAvailableTaskTypes();
+ self::assertCount(1, $taskTypes);
+ self::assertTrue(isset($taskTypes[TextToImage::ID]));
+ self::assertTrue($this->manager->hasProviders());
+ $task = new Task(TextToImage::ID, ['input' => 'Hello', 'numberOfImages' => 3], 'test', null);
+ $this->manager->scheduleTask($task);
+
+ $this->eventDispatcher->expects($this->once())->method('dispatchTyped')->with(new IsInstanceOf(TaskFailedEvent::class));
+
+ $backgroundJob = new \OC\TaskProcessing\SynchronousBackgroundJob(
+ \OCP\Server::get(ITimeFactory::class),
+ $this->manager,
+ $this->jobList,
+ \OCP\Server::get(LoggerInterface::class),
+ );
+ $backgroundJob->start($this->jobList);
+
+ $task = $this->manager->getTask($task->getId());
+ self::assertEquals(Task::STATUS_FAILED, $task->getStatus());
+ self::assertTrue($task->getOutput() === null);
+ self::assertEquals('ERROR', $task->getErrorMessage());
+ self::assertTrue($this->providers[FailingTextToImageProvider::class]->ran);
+ }
+}
diff --git a/tests/lib/TempManagerTest.php b/tests/lib/TempManagerTest.php
index 4b342c365b5..89b66654570 100644
--- a/tests/lib/TempManagerTest.php
+++ b/tests/lib/TempManagerTest.php
@@ -1,10 +1,9 @@
<?php
/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/Template/CSSResourceLocatorTest.php b/tests/lib/Template/CSSResourceLocatorTest.php
index 3d337dceb9e..64c31d9c94c 100644
--- a/tests/lib/Template/CSSResourceLocatorTest.php
+++ b/tests/lib/Template/CSSResourceLocatorTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Kyle Fazzari <kyrofa@ubuntu.com>
- *
- * @author Kyle Fazzari <kyrofa@ubuntu.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Template;
diff --git a/tests/lib/Template/JSCombinerTest.php b/tests/lib/Template/JSCombinerTest.php
index 1f2342f2b4e..d9de4b088d1 100644
--- a/tests/lib/Template/JSCombinerTest.php
+++ b/tests/lib/Template/JSCombinerTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright 2017, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Template;
diff --git a/tests/lib/Template/JSResourceLocatorTest.php b/tests/lib/Template/JSResourceLocatorTest.php
index f5af138060a..354f23fac19 100644
--- a/tests/lib/Template/JSResourceLocatorTest.php
+++ b/tests/lib/Template/JSResourceLocatorTest.php
@@ -1,24 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Kyle Fazzari <kyrofa@ubuntu.com>
- *
- * @author Kyle Fazzari <kyrofa@ubuntu.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Template;
@@ -127,9 +110,9 @@ class JSResourceLocatorTest extends \Test\TestCase {
$webRoot = $resource[1];
$file = $resource[2];
- $expectedRoot = $new_apps_path . '/test-js-app';
- $expectedWebRoot = \OC::$WEBROOT . '/js-apps-test/test-js-app';
- $expectedFile = 'test-file.js';
+ $expectedRoot = $new_apps_path;
+ $expectedWebRoot = \OC::$WEBROOT . '/js-apps-test';
+ $expectedFile = $appName . '/test-file.js';
$this->assertEquals($expectedRoot, $root,
'Ensure the app path symlink is resolved into the real path');
@@ -145,7 +128,7 @@ class JSResourceLocatorTest extends \Test\TestCase {
->method('getAppPath')
->with('core')
->willThrowException(new AppPathNotFoundException());
- $this->appManager->expects($this->once())
+ $this->appManager->expects($this->atMost(1))
->method('getAppWebPath')
->with('core')
->willThrowException(new AppPathNotFoundException());
diff --git a/tests/lib/Template/ResourceLocatorTest.php b/tests/lib/Template/ResourceLocatorTest.php
index fa329ca6581..e74e72014c5 100644
--- a/tests/lib/Template/ResourceLocatorTest.php
+++ b/tests/lib/Template/ResourceLocatorTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Template;
diff --git a/tests/lib/Template/data/1.js.license b/tests/lib/Template/data/1.js.license
new file mode 100644
index 00000000000..dddb428772d
--- /dev/null
+++ b/tests/lib/Template/data/1.js.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/tests/lib/Template/data/2.js.license b/tests/lib/Template/data/2.js.license
new file mode 100644
index 00000000000..dddb428772d
--- /dev/null
+++ b/tests/lib/Template/data/2.js.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/tests/lib/Template/data/combine.json.license b/tests/lib/Template/data/combine.json.license
new file mode 100644
index 00000000000..dddb428772d
--- /dev/null
+++ b/tests/lib/Template/data/combine.json.license
@@ -0,0 +1,2 @@
+SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+SPDX-License-Identifier: AGPL-3.0-or-later
diff --git a/tests/lib/TemplateFunctionsTest.php b/tests/lib/TemplateFunctionsTest.php
index aa9ba32610d..754551a415b 100644
--- a/tests/lib/TemplateFunctionsTest.php
+++ b/tests/lib/TemplateFunctionsTest.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Bernhard Posselt
- * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php
index f5fc9a6e8f2..5732e981ec7 100644
--- a/tests/lib/TestCase.php
+++ b/tests/lib/TestCase.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Joas Schilling
- * @copyright 2014 Joas Schilling nickvergessen@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
@@ -38,9 +23,42 @@ use OCP\Defaults;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
+use OCP\Lock\ILockingProvider;
use OCP\Security\ISecureRandom;
use Psr\Log\LoggerInterface;
+if (version_compare(\PHPUnit\Runner\Version::id(), 10, '>=')) {
+ trait OnNotSuccessfulTestTrait {
+ protected function onNotSuccessfulTest(\Throwable $t): never {
+ $this->restoreAllServices();
+
+ // restore database connection
+ if (!$this->IsDatabaseAccessAllowed()) {
+ \OC::$server->registerService(IDBConnection::class, function () {
+ return self::$realDatabase;
+ });
+ }
+
+ parent::onNotSuccessfulTest($t);
+ }
+ }
+} else {
+ trait OnNotSuccessfulTestTrait {
+ protected function onNotSuccessfulTest(\Throwable $t): void {
+ $this->restoreAllServices();
+
+ // restore database connection
+ if (!$this->IsDatabaseAccessAllowed()) {
+ \OC::$server->registerService(IDBConnection::class, function () {
+ return self::$realDatabase;
+ });
+ }
+
+ parent::onNotSuccessfulTest($t);
+ }
+ }
+}
+
abstract class TestCase extends \PHPUnit\Framework\TestCase {
/** @var \OC\Command\QueueBus */
private $commandBus;
@@ -54,6 +72,8 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
/** @var array */
protected $services = [];
+ use OnNotSuccessfulTestTrait;
+
/**
* @param string $name
* @param mixed $newService
@@ -150,19 +170,6 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
}
}
- protected function onNotSuccessfulTest(\Throwable $t): void {
- $this->restoreAllServices();
-
- // restore database connection
- if (!$this->IsDatabaseAccessAllowed()) {
- \OC::$server->registerService(IDBConnection::class, function () {
- return self::$realDatabase;
- });
- }
-
- parent::onNotSuccessfulTest($t);
- }
-
protected function tearDown(): void {
$this->restoreAllServices();
@@ -176,7 +183,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
// further cleanup
$hookExceptions = \OC_Hook::$thrownExceptions;
\OC_Hook::$thrownExceptions = [];
- \OC::$server->getLockingProvider()->releaseAll();
+ \OC::$server->get(ILockingProvider::class)->releaseAll();
if (!empty($hookExceptions)) {
throw $hookExceptions[0];
}
@@ -242,6 +249,8 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
}
return $property->getValue();
+ } elseif ($reflection->hasConstant($methodName)) {
+ return $reflection->getConstant($methodName);
}
return false;
@@ -395,7 +404,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
* Clean up the list of locks
*/
protected static function tearDownAfterClassCleanStrayLocks() {
- \OC::$server->getLockingProvider()->releaseAll();
+ \OC::$server->get(ILockingProvider::class)->releaseAll();
}
/**
@@ -501,7 +510,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
protected function IsDatabaseAccessAllowed() {
// on travis-ci.org we allow database access in any case - otherwise
// this will break all apps right away
- if (true == getenv('TRAVIS')) {
+ if (getenv('TRAVIS') == true) {
return true;
}
$annotations = $this->getGroupAnnotations();
diff --git a/tests/lib/TestMoveableMountPoint.php b/tests/lib/TestMoveableMountPoint.php
index 80cc6255071..4f3feccdbe2 100644
--- a/tests/lib/TestMoveableMountPoint.php
+++ b/tests/lib/TestMoveableMountPoint.php
@@ -1,22 +1,8 @@
<?php
/**
- * @author Vincent Petry <pvince81@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test;
diff --git a/tests/lib/TextProcessing/TextProcessingTest.php b/tests/lib/TextProcessing/TextProcessingTest.php
index 15f36cb2452..db479a7a7b6 100644
--- a/tests/lib/TextProcessing/TextProcessingTest.php
+++ b/tests/lib/TextProcessing/TextProcessingTest.php
@@ -1,9 +1,7 @@
<?php
/**
- * Copyright (c) 2023 Marcel Klehr <mklehr@gmx.net>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\TextProcessing;
@@ -24,13 +22,13 @@ use OCP\Common\Exception\NotFoundException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IServerContainer;
+use OCP\PreConditionNotMetException;
use OCP\TextProcessing\Events\TaskFailedEvent;
use OCP\TextProcessing\Events\TaskSuccessfulEvent;
use OCP\TextProcessing\FreePromptTaskType;
use OCP\TextProcessing\IManager;
use OCP\TextProcessing\IProvider;
use OCP\TextProcessing\SummaryTaskType;
-use OCP\PreConditionNotMetException;
use OCP\TextProcessing\Task;
use OCP\TextProcessing\TopicsTaskType;
use PHPUnit\Framework\Constraint\IsInstanceOf;
diff --git a/tests/lib/Traits/ClientServiceTrait.php b/tests/lib/Traits/ClientServiceTrait.php
index c35a57268f7..3f0d71aeb28 100644
--- a/tests/lib/Traits/ClientServiceTrait.php
+++ b/tests/lib/Traits/ClientServiceTrait.php
@@ -1,22 +1,7 @@
<?php
/**
- * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Traits;
diff --git a/tests/lib/Traits/EncryptionTrait.php b/tests/lib/Traits/EncryptionTrait.php
index 23f188ccd66..e435a286685 100644
--- a/tests/lib/Traits/EncryptionTrait.php
+++ b/tests/lib/Traits/EncryptionTrait.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Traits;
diff --git a/tests/lib/Traits/MountProviderTrait.php b/tests/lib/Traits/MountProviderTrait.php
index 379d33ea71c..6d947d645dd 100644
--- a/tests/lib/Traits/MountProviderTrait.php
+++ b/tests/lib/Traits/MountProviderTrait.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Traits;
diff --git a/tests/lib/Traits/UserTrait.php b/tests/lib/Traits/UserTrait.php
index 3f7cfe419db..3374b6b5fdd 100644
--- a/tests/lib/Traits/UserTrait.php
+++ b/tests/lib/Traits/UserTrait.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Traits;
diff --git a/tests/lib/Updater/ChangesCheckTest.php b/tests/lib/Updater/ChangesCheckTest.php
index e96406622f4..26da6579d33 100644
--- a/tests/lib/Updater/ChangesCheckTest.php
+++ b/tests/lib/Updater/ChangesCheckTest.php
@@ -3,38 +3,21 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Updater;
+use OC\Updater\Changes;
use OC\Updater\ChangesCheck;
use OC\Updater\ChangesMapper;
-use OC\Updater\Changes;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
-use Test\TestCase;
use Psr\Log\LoggerInterface;
+use Test\TestCase;
class ChangesCheckTest extends TestCase {
/** @var IClientService|\PHPUnit\Framework\MockObject\MockObject */
diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php
index be847253035..7aa04ad2ab6 100644
--- a/tests/lib/Updater/VersionCheckTest.php
+++ b/tests/lib/Updater/VersionCheckTest.php
@@ -1,47 +1,41 @@
<?php
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- * @author Victor Dubiniuk <dubiniuk@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Updater;
use OC\Updater\VersionCheck;
use OCP\Http\Client\IClientService;
+use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IUserManager;
use OCP\Support\Subscription\IRegistry;
use OCP\Util;
+use Psr\Log\LoggerInterface;
class VersionCheckTest extends \Test\TestCase {
/** @var IConfig| \PHPUnit\Framework\MockObject\MockObject */
private $config;
+ /** @var IAppConfig| \PHPUnit\Framework\MockObject\MockObject */
+ private $appConfig;
/** @var VersionCheck | \PHPUnit\Framework\MockObject\MockObject*/
private $updater;
/** @var IRegistry | \PHPUnit\Framework\Mo2ckObject\MockObject*/
private $registry;
+ /** @var LoggerInterface | \PHPUnit\Framework\Mo2ckObject\MockObject*/
+ private $logger;
protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
+ $this->appConfig = $this->getMockBuilder(IAppConfig::class)
+ ->disableOriginalConstructor()
+ ->getMock();
$clientService = $this->getMockBuilder(IClientService::class)
->disableOriginalConstructor()
->getMock();
@@ -50,13 +44,16 @@ class VersionCheckTest extends \Test\TestCase {
$this->registry
->method('delegateHasValidSubscription')
->willReturn(false);
+ $this->logger = $this->createMock(LoggerInterface::class);
$this->updater = $this->getMockBuilder(VersionCheck::class)
->setMethods(['getUrlContent'])
->setConstructorArgs([
$clientService,
$this->config,
+ $this->appConfig,
$this->createMock(IUserManager::class),
$this->registry,
+ $this->logger,
])
->getMock();
}
@@ -66,7 +63,7 @@ class VersionCheckTest extends \Test\TestCase {
* @return string
*/
private function buildUpdateUrl($baseUrl) {
- return $baseUrl . '?version='.implode('x', Util::getVersion()).'xinstalledatxlastupdatedatx'.\OC_Util::getChannel().'xxx'.PHP_MAJOR_VERSION.'x'.PHP_MINOR_VERSION.'x'.PHP_RELEASE_VERSION.'x0x0';
+ return $baseUrl . '?version='.implode('x', Util::getVersion()).'xinstalledatx' . time() . 'x'.\OC_Util::getChannel().'xxx'.PHP_MAJOR_VERSION.'x'.PHP_MINOR_VERSION.'x'.PHP_RELEASE_VERSION.'x0x0';
}
public function testCheckInCache() {
@@ -83,17 +80,16 @@ class VersionCheckTest extends \Test\TestCase {
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
+ $this->appConfig
+ ->expects($this->once())
+ ->method('getValueInt')
+ ->with('core', 'lastupdatedat')
+ ->willReturn(time());
$this->config
- ->expects($this->exactly(2))
+ ->expects($this->once())
->method('getAppValue')
- ->withConsecutive(
- ['core', 'lastupdatedat'],
- ['core', 'lastupdateResult']
- )
- ->willReturnOnConsecutiveCalls(
- time(),
- json_encode($expectedResult)
- );
+ ->with('core', 'lastupdateResult')
+ ->willReturn(json_encode($expectedResult));
$this->assertSame($expectedResult, $this->updater->check());
}
@@ -114,33 +110,32 @@ class VersionCheckTest extends \Test\TestCase {
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
- $this->config
- ->expects($this->exactly(4))
- ->method('getAppValue')
- ->withConsecutive(
- ['core', 'lastupdatedat'],
- ['core', 'installedat'],
- ['core', 'installedat'],
- ['core', 'lastupdatedat'],
- )
+ $this->appConfig
+ ->expects($this->exactly(2))
+ ->method('getValueInt')
+ ->with('core', 'lastupdatedat')
->willReturnOnConsecutiveCalls(
- '0',
- 'installedat',
- 'installedat',
- 'lastupdatedat',
+ 0,
+ time(),
);
$this->config
+ ->expects($this->exactly(2))
+ ->method('getAppValue')
+ ->with('core', 'installedat')
+ ->willReturn('installedat');
+ $this->config
->expects($this->once())
->method('getSystemValueString')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
+ $this->appConfig
+ ->expects($this->once())
+ ->method('setValueInt')
+ ->with('core', 'lastupdatedat', time());
$this->config
- ->expects($this->exactly(2))
+ ->expects($this->once())
->method('setAppValue')
- ->withConsecutive(
- ['core', 'lastupdatedat', $this->isType('string')],
- ['core', 'lastupdateResult', json_encode($expectedResult)]
- );
+ ->with('core', 'lastupdateResult', json_encode($expectedResult));
$updateXml = '<?xml version="1.0"?>
<owncloud>
@@ -166,33 +161,32 @@ class VersionCheckTest extends \Test\TestCase {
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
- $this->config
- ->expects($this->exactly(4))
- ->method('getAppValue')
- ->withConsecutive(
- ['core', 'lastupdatedat'],
- ['core', 'installedat'],
- ['core', 'installedat'],
- ['core', 'lastupdatedat'],
- )
+ $this->appConfig
+ ->expects($this->exactly(2))
+ ->method('getValueInt')
+ ->with('core', 'lastupdatedat')
->willReturnOnConsecutiveCalls(
- '0',
- 'installedat',
- 'installedat',
- 'lastupdatedat',
+ 0,
+ time(),
);
$this->config
+ ->expects($this->exactly(2))
+ ->method('getAppValue')
+ ->with('core', 'installedat')
+ ->willReturn('installedat');
+ $this->config
->expects($this->once())
->method('getSystemValueString')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
+ $this->appConfig
+ ->expects($this->once())
+ ->method('setValueInt')
+ ->with('core', 'lastupdatedat', time());
$this->config
- ->expects($this->exactly(2))
+ ->expects($this->once())
->method('setAppValue')
- ->withConsecutive(
- ['core', 'lastupdatedat', $this->isType('string')],
- ['core', 'lastupdateResult', '[]']
- );
+ ->with('core', 'lastupdateResult', $this->isType('string'));
$updateXml = 'Invalid XML Response!';
$this->updater
@@ -220,33 +214,32 @@ class VersionCheckTest extends \Test\TestCase {
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
- $this->config
- ->expects($this->exactly(4))
- ->method('getAppValue')
- ->withConsecutive(
- ['core', 'lastupdatedat'],
- ['core', 'installedat'],
- ['core', 'installedat'],
- ['core', 'lastupdatedat'],
- )
+ $this->appConfig
+ ->expects($this->exactly(2))
+ ->method('getValueInt')
+ ->with('core', 'lastupdatedat')
->willReturnOnConsecutiveCalls(
- '0',
- 'installedat',
- 'installedat',
- 'lastupdatedat',
+ 0,
+ time(),
);
$this->config
+ ->expects($this->exactly(2))
+ ->method('getAppValue')
+ ->with('core', 'installedat')
+ ->willReturn('installedat');
+ $this->config
->expects($this->once())
->method('getSystemValueString')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
+ $this->appConfig
+ ->expects($this->once())
+ ->method('setValueInt')
+ ->with('core', 'lastupdatedat', time());
$this->config
- ->expects($this->exactly(2))
+ ->expects($this->once())
->method('setAppValue')
- ->withConsecutive(
- ['core', 'lastupdatedat', $this->isType('string')],
- ['core', 'lastupdateResult', $this->isType('string')]
- );
+ ->with('core', 'lastupdateResult', $this->isType('string'));
$updateXml = '<?xml version="1.0"?>
<owncloud>
@@ -273,33 +266,32 @@ class VersionCheckTest extends \Test\TestCase {
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
- $this->config
- ->expects($this->exactly(4))
- ->method('getAppValue')
- ->withConsecutive(
- ['core', 'lastupdatedat'],
- ['core', 'installedat'],
- ['core', 'installedat'],
- ['core', 'lastupdatedat'],
- )
+ $this->appConfig
+ ->expects($this->exactly(2))
+ ->method('getValueInt')
+ ->with('core', 'lastupdatedat')
->willReturnOnConsecutiveCalls(
- '0',
- 'installedat',
- 'installedat',
- 'lastupdatedat',
+ 0,
+ time(),
);
$this->config
+ ->expects($this->exactly(2))
+ ->method('getAppValue')
+ ->with('core', 'installedat')
+ ->willReturn('installedat');
+ $this->config
->expects($this->once())
->method('getSystemValueString')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
+ $this->appConfig
+ ->expects($this->once())
+ ->method('setValueInt')
+ ->with('core', 'lastupdatedat', time());
$this->config
- ->expects($this->exactly(2))
+ ->expects($this->once())
->method('setAppValue')
- ->withConsecutive(
- ['core', 'lastupdatedat', $this->isType('string')],
- ['core', 'lastupdateResult', json_encode($expectedResult)]
- );
+ ->with('core', 'lastupdateResult', $this->isType('string'));
$updateXml = '';
$this->updater
@@ -327,33 +319,32 @@ class VersionCheckTest extends \Test\TestCase {
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
- $this->config
- ->expects($this->exactly(4))
- ->method('getAppValue')
- ->withConsecutive(
- ['core', 'lastupdatedat'],
- ['core', 'installedat'],
- ['core', 'installedat'],
- ['core', 'lastupdatedat'],
- )
+ $this->appConfig
+ ->expects($this->exactly(2))
+ ->method('getValueInt')
+ ->with('core', 'lastupdatedat')
->willReturnOnConsecutiveCalls(
- '0',
- 'installedat',
- 'installedat',
- 'lastupdatedat',
+ 0,
+ time(),
);
$this->config
+ ->expects($this->exactly(2))
+ ->method('getAppValue')
+ ->with('core', 'installedat')
+ ->willReturn('installedat');
+ $this->config
->expects($this->once())
->method('getSystemValueString')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
+ $this->appConfig
+ ->expects($this->once())
+ ->method('setValueInt')
+ ->with('core', 'lastupdatedat', time());
$this->config
- ->expects($this->exactly(2))
+ ->expects($this->once())
->method('setAppValue')
- ->withConsecutive(
- ['core', 'lastupdatedat', $this->isType('string')],
- ['core', 'lastupdateResult', $this->isType('string')]
- );
+ ->with('core', 'lastupdateResult', $this->isType('string'));
// missing autoupdater element should still not fail
$updateXml = '<?xml version="1.0"?>
diff --git a/tests/lib/UpdaterTest.php b/tests/lib/UpdaterTest.php
index 579761208db..118cb1b6d41 100644
--- a/tests/lib/UpdaterTest.php
+++ b/tests/lib/UpdaterTest.php
@@ -1,37 +1,25 @@
<?php
/**
- * @author Lukas Reschke <lukas@owncloud.com>
- * @author Victor Dubiniuk <dubiniuk@owncloud.com>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test;
-use PHPUnit\Framework\MockObject\MockObject;
-use Psr\Log\LoggerInterface;
use OC\Installer;
use OC\IntegrityCheck\Checker;
use OC\Updater;
+use OCP\IAppConfig;
use OCP\IConfig;
+use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
class UpdaterTest extends TestCase {
/** @var IConfig|MockObject */
private $config;
+ /** @var IAppConfig|MockObject */
+ private $appConfig;
/** @var LoggerInterface|MockObject */
private $logger;
/** @var Updater */
@@ -46,6 +34,9 @@ class UpdaterTest extends TestCase {
$this->config = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
+ $this->appConfig = $this->getMockBuilder(IAppConfig::class)
+ ->disableOriginalConstructor()
+ ->getMock();
$this->logger = $this->getMockBuilder(LoggerInterface::class)
->disableOriginalConstructor()
->getMock();
@@ -58,6 +49,7 @@ class UpdaterTest extends TestCase {
$this->updater = new Updater(
$this->config,
+ $this->appConfig,
$this->checker,
$this->logger,
$this->installer
diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php
index dac15798a98..d54698b7a0a 100644
--- a/tests/lib/UrlGeneratorTest.php
+++ b/tests/lib/UrlGeneratorTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Bjoern Schiessle <schiessle@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
@@ -192,26 +191,34 @@ class UrlGeneratorTest extends \Test\TestCase {
/**
* @dataProvider provideOCSRoutes
*/
- public function testLinkToOCSRouteAbsolute(string $route, string $expected) {
+ public function testLinkToOCSRouteAbsolute(string $route, bool $ignoreFrontController, string $expected): void {
$this->mockBaseUrl();
\OC::$WEBROOT = '/nextcloud';
$this->router->expects($this->once())
->method('generate')
- ->willReturnCallback(function ($routeName, $parameters) {
+ ->willReturnCallback(function (string $routeName, array $parameters) use ($ignoreFrontController) {
if ($routeName === 'ocs.core.OCS.getCapabilities') {
- return '/index.php/ocsapp/cloud/capabilities';
+ if (!$ignoreFrontController) {
+ return '/nextcloud/index.php/ocsapp/cloud/capabilities';
+ }
+ return '/nextcloud/ocsapp/cloud/capabilities';
} elseif ($routeName === 'ocs.core.WhatsNew.dismiss') {
- return '/index.php/ocsapp/core/whatsnew';
+ if (!$ignoreFrontController) {
+ return '/nextcloud/index.php/ocsapp/core/whatsnew';
+ }
+ return '/nextcloud/ocsapp/core/whatsnew';
}
});
$result = $this->urlGenerator->linkToOCSRouteAbsolute($route);
$this->assertEquals($expected, $result);
}
- public function provideOCSRoutes() {
+ public function provideOCSRoutes(): array {
return [
- ['core.OCS.getCapabilities', 'http://localhost/nextcloud/ocs/v2.php/cloud/capabilities'],
- ['core.WhatsNew.dismiss', 'http://localhost/nextcloud/ocs/v2.php/core/whatsnew'],
+ ['core.OCS.getCapabilities', false, 'http://localhost/nextcloud/ocs/v2.php/cloud/capabilities'],
+ ['core.OCS.getCapabilities', true, 'http://localhost/nextcloud/ocs/v2.php/cloud/capabilities'],
+ ['core.WhatsNew.dismiss', false, 'http://localhost/nextcloud/ocs/v2.php/core/whatsnew'],
+ ['core.WhatsNew.dismiss', true, 'http://localhost/nextcloud/ocs/v2.php/core/whatsnew'],
];
}
diff --git a/tests/lib/User/AvailabilityCoordinatorTest.php b/tests/lib/User/AvailabilityCoordinatorTest.php
new file mode 100644
index 00000000000..1b880575448
--- /dev/null
+++ b/tests/lib/User/AvailabilityCoordinatorTest.php
@@ -0,0 +1,201 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace Test\User;
+
+use OC\User\AvailabilityCoordinator;
+use OC\User\OutOfOfficeData;
+use OCA\DAV\CalDAV\TimezoneService;
+use OCA\DAV\Db\Absence;
+use OCA\DAV\Service\AbsenceService;
+use OCP\ICache;
+use OCP\ICacheFactory;
+use OCP\IConfig;
+use OCP\IUser;
+use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
+use Test\TestCase;
+
+class AvailabilityCoordinatorTest extends TestCase {
+ private AvailabilityCoordinator $availabilityCoordinator;
+ private ICacheFactory $cacheFactory;
+ private ICache $cache;
+ private IConfig|MockObject $config;
+ private AbsenceService $absenceService;
+ private LoggerInterface $logger;
+ private MockObject|TimezoneService $timezoneService;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->cacheFactory = $this->createMock(ICacheFactory::class);
+ $this->cache = $this->createMock(ICache::class);
+ $this->absenceService = $this->createMock(AbsenceService::class);
+ $this->config = $this->createMock(IConfig::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
+ $this->timezoneService = $this->createMock(TimezoneService::class);
+
+ $this->cacheFactory->expects(self::once())
+ ->method('createLocal')
+ ->willReturn($this->cache);
+
+ $this->availabilityCoordinator = new AvailabilityCoordinator(
+ $this->cacheFactory,
+ $this->config,
+ $this->absenceService,
+ $this->logger,
+ $this->timezoneService,
+ );
+ }
+
+ public function testIsEnabled(): void {
+ $this->config->expects(self::once())
+ ->method('getAppValue')
+ ->with('dav', 'hide_absence_settings', 'no')
+ ->willReturn('no');
+
+ $isEnabled = $this->availabilityCoordinator->isEnabled();
+
+ self::assertTrue($isEnabled);
+ }
+
+ public function testGetOutOfOfficeDataInEffect(): void {
+ $absence = new Absence();
+ $absence->setId(420);
+ $absence->setUserId('user');
+ $absence->setFirstDay('2023-10-01');
+ $absence->setLastDay('2023-10-08');
+ $absence->setStatus('Vacation');
+ $absence->setMessage('On vacation');
+ $this->timezoneService->method('getUserTimezone')->with('user')->willReturn('Europe/Berlin');
+
+ $user = $this->createMock(IUser::class);
+ $user->method('getUID')
+ ->willReturn('user');
+
+ $this->cache->expects(self::exactly(2))
+ ->method('get')
+ ->willReturnOnConsecutiveCalls(null, null);
+ $this->absenceService->expects(self::once())
+ ->method('getAbsence')
+ ->with($user->getUID())
+ ->willReturn($absence);
+ $this->cache->expects(self::exactly(2))
+ ->method('set')
+ ->withConsecutive([$user->getUID() . '_timezone', 'Europe/Berlin', 3600],
+ [$user->getUID(), '{"id":"420","startDate":1696111200,"endDate":1696802340,"shortMessage":"Vacation","message":"On vacation"}', 300]);
+
+ $expected = new OutOfOfficeData(
+ '420',
+ $user,
+ 1696111200,
+ 1696802340,
+ 'Vacation',
+ 'On vacation',
+ );
+ $actual = $this->availabilityCoordinator->getCurrentOutOfOfficeData($user);
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testGetOutOfOfficeDataCachedAll(): void {
+ $absence = new Absence();
+ $absence->setId(420);
+ $absence->setUserId('user');
+ $absence->setFirstDay('2023-10-01');
+ $absence->setLastDay('2023-10-08');
+ $absence->setStatus('Vacation');
+ $absence->setMessage('On vacation');
+
+ $user = $this->createMock(IUser::class);
+ $user->method('getUID')
+ ->willReturn('user');
+
+ $this->cache->expects(self::exactly(2))
+ ->method('get')
+ ->willReturnOnConsecutiveCalls('UTC', '{"id":"420","startDate":1696118400,"endDate":1696809540,"shortMessage":"Vacation","message":"On vacation"}');
+ $this->absenceService->expects(self::never())
+ ->method('getAbsence');
+ $this->cache->expects(self::exactly(1))
+ ->method('set');
+
+ $expected = new OutOfOfficeData(
+ '420',
+ $user,
+ 1696118400,
+ 1696809540,
+ 'Vacation',
+ 'On vacation',
+ );
+ $actual = $this->availabilityCoordinator->getCurrentOutOfOfficeData($user);
+ self::assertEquals($expected, $actual);
+ }
+
+ public function testGetOutOfOfficeDataNoData(): void {
+ $absence = new Absence();
+ $absence->setId(420);
+ $absence->setUserId('user');
+ $absence->setFirstDay('2023-10-01');
+ $absence->setLastDay('2023-10-08');
+ $absence->setStatus('Vacation');
+ $absence->setMessage('On vacation');
+
+ $user = $this->createMock(IUser::class);
+ $user->method('getUID')
+ ->willReturn('user');
+
+ $this->cache->expects(self::exactly(2))
+ ->method('get')
+ ->willReturnOnConsecutiveCalls('UTC', null);
+ $this->absenceService->expects(self::once())
+ ->method('getAbsence')
+ ->willReturn(null);
+ $this->cache->expects(self::never())
+ ->method('set');
+
+ $actual = $this->availabilityCoordinator->getCurrentOutOfOfficeData($user);
+ self::assertNull($actual);
+ }
+
+ public function testGetOutOfOfficeDataWithInvalidCachedData(): void {
+ $absence = new Absence();
+ $absence->setId(420);
+ $absence->setUserId('user');
+ $absence->setFirstDay('2023-10-01');
+ $absence->setLastDay('2023-10-08');
+ $absence->setStatus('Vacation');
+ $absence->setMessage('On vacation');
+ $this->timezoneService->method('getUserTimezone')->with('user')->willReturn('Europe/Berlin');
+
+ $user = $this->createMock(IUser::class);
+ $user->method('getUID')
+ ->willReturn('user');
+
+ $this->cache->expects(self::exactly(2))
+ ->method('get')
+ ->willReturnOnConsecutiveCalls('UTC', '{"id":"420",}');
+ $this->absenceService->expects(self::once())
+ ->method('getAbsence')
+ ->with('user')
+ ->willReturn($absence);
+ $this->cache->expects(self::once())
+ ->method('set')
+ ->with('user', '{"id":"420","startDate":1696118400,"endDate":1696809540,"shortMessage":"Vacation","message":"On vacation"}', 300);
+
+ $expected = new OutOfOfficeData(
+ '420',
+ $user,
+ 1696118400,
+ 1696809540,
+ 'Vacation',
+ 'On vacation',
+ );
+ $actual = $this->availabilityCoordinator->getCurrentOutOfOfficeData($user);
+ self::assertEquals($expected, $actual);
+ }
+}
diff --git a/tests/lib/User/AvatarUserDummy.php b/tests/lib/User/AvatarUserDummy.php
index 87e1cfc5f83..d443a31e3f0 100644
--- a/tests/lib/User/AvatarUserDummy.php
+++ b/tests/lib/User/AvatarUserDummy.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Arthur Schiwon
- * @copyright 2013 Arthur Schiwon blizzz@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\User;
diff --git a/tests/lib/User/Backend.php b/tests/lib/User/Backend.php
index fd87da72364..7efba2eaeb6 100644
--- a/tests/lib/User/Backend.php
+++ b/tests/lib/User/Backend.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Robin Appelman
- * @copyright 2012 Robin Appelman icewind@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\User;
diff --git a/tests/lib/User/DatabaseTest.php b/tests/lib/User/DatabaseTest.php
index 1a375cdebae..16b223aaaba 100644
--- a/tests/lib/User/DatabaseTest.php
+++ b/tests/lib/User/DatabaseTest.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Robin Appelman
- * @copyright 2012 Robin Appelman icewind@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\User;
diff --git a/tests/lib/User/Dummy.php b/tests/lib/User/Dummy.php
index a9e4a2936a7..ffc5d343200 100644
--- a/tests/lib/User/Dummy.php
+++ b/tests/lib/User/Dummy.php
@@ -1,23 +1,8 @@
<?php
/**
- * ownCloud
- *
- * @author Robin Appelman
- * @copyright 2012 Robin Appelman icewind@owncloud.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\User;
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php
index aa597f758b0..c516b1de945 100644
--- a/tests/lib/User/ManagerTest.php
+++ b/tests/lib/User/ManagerTest.php
@@ -1,10 +1,9 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\User;
@@ -434,7 +433,7 @@ class ManagerTest extends TestCase {
public function testCreateUserFromBackendWithBackendError() {
$this->expectException(\InvalidArgumentException::class);
- $this->expectExceptionMessage('Could not create user');
+ $this->expectExceptionMessage('Could not create account');
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject $config */
$config = $this->createMock(IConfig::class);
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php
index b6ac7a69fed..236da2a1dcc 100644
--- a/tests/lib/User/SessionTest.php
+++ b/tests/lib/User/SessionTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\User;
@@ -11,9 +10,12 @@ namespace Test\User;
use OC\AppFramework\Http\Request;
use OC\Authentication\Events\LoginFailed;
use OC\Authentication\Exceptions\InvalidTokenException;
+use OC\Authentication\Exceptions\PasswordlessTokenException;
use OC\Authentication\Exceptions\PasswordLoginForbiddenException;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
+use OC\Authentication\Token\PublicKeyToken;
+use OC\Security\CSRF\CsrfTokenManager;
use OC\Session\Memory;
use OC\User\LoginException;
use OC\User\Manager;
@@ -34,7 +36,8 @@ use OCP\Security\ISecureRandom;
use OCP\User\Events\PostLoginEvent;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
-use OC\Security\CSRF\CsrfTokenManager;
+use function array_diff;
+use function get_class_methods;
/**
* @group DB
@@ -309,6 +312,80 @@ class SessionTest extends \Test\TestCase {
$userSession->login('foo', 'bar');
}
+ public function testPasswordlessLoginNoLastCheckUpdate(): void {
+ $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock();
+ $managerMethods = get_class_methods(Manager::class);
+ // 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)
+ ->setConstructorArgs([
+ $this->config,
+ $this->createMock(ICacheFactory::class),
+ $this->createMock(IEventDispatcher::class),
+ ])
+ ->getMock();
+ $userSession = new Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher);
+
+ $session->expects($this->never())
+ ->method('set');
+ $session->expects($this->once())
+ ->method('regenerateId');
+ $token = new PublicKeyToken();
+ $token->setLoginName('foo');
+ $token->setLastCheck(0); // Never
+ $token->setUid('foo');
+ $this->tokenProvider
+ ->method('getPassword')
+ ->with($token)
+ ->willThrowException(new PasswordlessTokenException());
+ $this->tokenProvider
+ ->method('getToken')
+ ->with('app-password')
+ ->willReturn($token);
+ $this->tokenProvider->expects(self::never())
+ ->method('updateToken');
+
+ $userSession->login('foo', 'app-password');
+ }
+
+ public function testLoginLastCheckUpdate(): void {
+ $session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock();
+ $managerMethods = get_class_methods(Manager::class);
+ // 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)
+ ->setConstructorArgs([
+ $this->config,
+ $this->createMock(ICacheFactory::class),
+ $this->createMock(IEventDispatcher::class),
+ ])
+ ->getMock();
+ $userSession = new Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher);
+
+ $session->expects($this->never())
+ ->method('set');
+ $session->expects($this->once())
+ ->method('regenerateId');
+ $token = new PublicKeyToken();
+ $token->setLoginName('foo');
+ $token->setLastCheck(0); // Never
+ $token->setUid('foo');
+ $this->tokenProvider
+ ->method('getPassword')
+ ->with($token)
+ ->willReturn('secret');
+ $this->tokenProvider
+ ->method('getToken')
+ ->with('app-password')
+ ->willReturn($token);
+ $this->tokenProvider->expects(self::once())
+ ->method('updateToken');
+
+ $userSession->login('foo', 'app-password');
+ }
+
public function testLoginNonExisting() {
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock();
$manager = $this->createMock(Manager::class);
@@ -479,6 +556,56 @@ class SessionTest extends \Test\TestCase {
$userSession->logClientIn('john', 'doe', $request, $this->throttler);
}
+ public function testTryTokenLoginNoHeaderNoSessionCookie(): void {
+ $request = $this->createMock(IRequest::class);
+ $this->config->expects(self::once())
+ ->method('getSystemValueString')
+ ->with('instanceid')
+ ->willReturn('abc123');
+ $request->method('getHeader')->with('Authorization')->willReturn('');
+ $request->method('getCookie')->with('abc123')->willReturn(null);
+ $this->tokenProvider->expects(self::never())
+ ->method('getToken');
+
+ $loginResult = $this->userSession->tryTokenLogin($request);
+
+ self::assertFalse($loginResult);
+ }
+
+ public function testTryTokenLoginAuthorizationHeaderTokenNotFound(): void {
+ $request = $this->createMock(IRequest::class);
+ $request->method('getHeader')->with('Authorization')->willReturn('Bearer abcde-12345');
+ $this->tokenProvider->expects(self::once())
+ ->method('getToken')
+ ->with('abcde-12345')
+ ->willThrowException(new InvalidTokenException());
+
+ $loginResult = $this->userSession->tryTokenLogin($request);
+
+ self::assertFalse($loginResult);
+ }
+
+ public function testTryTokenLoginSessionIdTokenNotFound(): void {
+ $request = $this->createMock(IRequest::class);
+ $this->config->expects(self::once())
+ ->method('getSystemValueString')
+ ->with('instanceid')
+ ->willReturn('abc123');
+ $request->method('getHeader')->with('Authorization')->willReturn('');
+ $request->method('getCookie')->with('abc123')->willReturn('abcde12345');
+ $this->session->expects(self::once())
+ ->method('getId')
+ ->willReturn('abcde12345');
+ $this->tokenProvider->expects(self::once())
+ ->method('getToken')
+ ->with('abcde12345')
+ ->willThrowException(new InvalidTokenException());
+
+ $loginResult = $this->userSession->tryTokenLogin($request);
+
+ self::assertFalse($loginResult);
+ }
+
public function testRememberLoginValidToken() {
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock();
$managerMethods = get_class_methods(Manager::class);
@@ -1110,7 +1237,7 @@ class SessionTest extends \Test\TestCase {
$userSession->expects($this->once())
->method('isTokenPassword')
- ->willReturn(true);
+ ->willReturn(false);
$userSession->expects($this->once())
->method('login')
->with('john@foo.bar', 'I-AM-AN-PASSWORD')
diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php
index 806cb094066..8e62c06e1ba 100644
--- a/tests/lib/User/UserTest.php
+++ b/tests/lib/User/UserTest.php
@@ -1,10 +1,9 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\User;
diff --git a/tests/lib/Util/Group/Dummy.php b/tests/lib/Util/Group/Dummy.php
index a864c8ce9d9..50edc15c845 100644
--- a/tests/lib/Util/Group/Dummy.php
+++ b/tests/lib/Util/Group/Dummy.php
@@ -1,41 +1,19 @@
<?php
/**
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Felix Moeller <mail@felixmoeller.de>
- * @author Lukas Reschke <lukas@owncloud.com>
- * @author Michael Gapczynski <GapczynskiM@gmail.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <icewind@owncloud.com>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <rullzer@owncloud.com>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Util\Group;
-use Test\Util\User\Dummy as DummyUser;
use OCP\Group\Backend\ABackend;
-use OCP\Group\Backend\IDeleteGroupBackend;
use OCP\Group\Backend\IAddToGroupBackend;
-use OCP\Group\Backend\IRemoveFromGroupBackend;
-use OCP\Group\Backend\ICreateGroupBackend;
use OCP\Group\Backend\ICountUsersBackend;
+use OCP\Group\Backend\ICreateGroupBackend;
+use OCP\Group\Backend\IDeleteGroupBackend;
+use OCP\Group\Backend\IRemoveFromGroupBackend;
+use Test\Util\User\Dummy as DummyUser;
/**
* Dummy group backend, does not keep state, only for testing use
diff --git a/tests/lib/Util/User/Dummy.php b/tests/lib/Util/User/Dummy.php
index 478b7599701..d44b9d85d72 100644
--- a/tests/lib/Util/User/Dummy.php
+++ b/tests/lib/Util/User/Dummy.php
@@ -1,28 +1,8 @@
<?php
/**
- * @author Andreas Fischer <bantu@owncloud.com>
- * @author Arthur Schiwon <blizzz@owncloud.com>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <icewind@owncloud.com>
- * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace Test\Util\User;
@@ -168,7 +148,7 @@ class Dummy extends Backend implements \OCP\IUserBackend {
}
public function getDisplayName($uid) {
- return isset($this->displayNames[$uid])? $this->displayNames[$uid]: $uid;
+ return $this->displayNames[$uid] ?? $uid;
}
/**
diff --git a/tests/lib/UtilCheckServerTest.php b/tests/lib/UtilCheckServerTest.php
index 9ddb1f8e45f..f0cc8a57e6f 100644
--- a/tests/lib/UtilCheckServerTest.php
+++ b/tests/lib/UtilCheckServerTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
@@ -30,7 +29,7 @@ class UtilCheckServerTest extends \Test\TestCase {
$config->expects($this->any())
->method('getValue')
->willReturnCallback(function ($key, $default) use ($systemOptions) {
- return isset($systemOptions[$key]) ? $systemOptions[$key] : $default;
+ return $systemOptions[$key] ?? $default;
});
return $config;
}
diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php
index 568f535e557..4c346b072f1 100644
--- a/tests/lib/UtilTest.php
+++ b/tests/lib/UtilTest.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2012 Lukas Reschke <lukas@statuscode.ch>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
diff --git a/tests/objectstore/start-swift-ceph.sh b/tests/objectstore/start-swift-ceph.sh
index 98c0e8b78b2..125d215c542 100755
--- a/tests/objectstore/start-swift-ceph.sh
+++ b/tests/objectstore/start-swift-ceph.sh
@@ -1,6 +1,7 @@
#!/bin/bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# This script start a docker container to test the files_external tests
# against. It will also change the files_external config to use the docker
@@ -10,7 +11,6 @@
#
# @author Morris Jobke
# @author Robin McCorkell
-# @copyright 2015 ownCloud
if ! command -v docker >/dev/null 2>&1; then
echo "No docker executable found - skipped docker setup"
diff --git a/tests/objectstore/stop-swift-ceph.sh b/tests/objectstore/stop-swift-ceph.sh
index afc5f712ab4..9673270f6d8 100755
--- a/tests/objectstore/stop-swift-ceph.sh
+++ b/tests/objectstore/stop-swift-ceph.sh
@@ -1,6 +1,7 @@
#!/bin/bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# This script stops the docker container the files_external tests were run
# against. It will also revert the config changes done in start step.
diff --git a/tests/objectstore/wait-for-connection b/tests/objectstore/wait-for-connection
index 2c480fb733e..c6a3ed270f1 100755
--- a/tests/objectstore/wait-for-connection
+++ b/tests/objectstore/wait-for-connection
@@ -1,6 +1,9 @@
#!/usr/bin/php
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
$timeout = 60;
switch ($argc) {
diff --git a/tests/phpunit-autotest-external.xml b/tests/phpunit-autotest-external.xml
index e70391e346a..fc3848d8cdb 100644
--- a/tests/phpunit-autotest-external.xml
+++ b/tests/phpunit-autotest-external.xml
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ - SPDX-FileCopyrightText: 2014-2016 ownCloud, Inc.
+ - SPDX-License-Identifier: AGPL-3.0-only
+-->
<phpunit bootstrap="bootstrap.php"
verbose="true"
timeoutForSmallTests="900"
diff --git a/tests/phpunit-autotest.xml b/tests/phpunit-autotest.xml
index d2d45b50db7..46de05abd7b 100644
--- a/tests/phpunit-autotest.xml
+++ b/tests/phpunit-autotest.xml
@@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ - SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ - SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ - SPDX-License-Identifier: AGPL-3.0-only
+-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="bootstrap.php"
verbose="true"
@@ -7,8 +12,8 @@
timeoutForMediumTests="900"
timeoutForLargeTests="900"
convertDeprecationsToExceptions="true"
- xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
- <testsuite name="ownCloud">
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd">
+ <testsuite name="Nextcloud Server">
<directory suffix=".php">lib/</directory>
<directory suffix=".php">Core/</directory>
<directory suffix=".php">Test/</directory>
diff --git a/tests/preseed-config.php b/tests/preseed-config.php
index 16aea87c8a7..3739335676a 100644
--- a/tests/preseed-config.php
+++ b/tests/preseed-config.php
@@ -1,5 +1,9 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2012-2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
$CONFIG = [
'appstoreenabled' => false,
'apps_paths' => [
@@ -25,71 +29,52 @@ if (getenv('OBJECT_STORE') === 's3') {
'arguments' => [
'bucket' => 'nextcloud',
'autocreate' => true,
- 'key' => 'nextcloud',
- 'secret' => 'nextcloud',
- 'hostname' => getenv('DRONE') === 'true' ? 'minio' : 'localhost',
+ 'key' => getenv('OBJECT_STORE_KEY') ?: 'nextcloud',
+ 'secret' => getenv('OBJECT_STORE_SECRET') ?: 'nextcloud',
+ 'hostname' => getenv('OBJECT_STORE_HOST') ?: 'localhost',
'port' => 9000,
'use_ssl' => false,
// required for some non amazon s3 implementations
'use_path_style' => true
]
];
-}
-if (getenv('OBJECT_STORE') === 'swift') {
- $swiftHost = getenv('DRONE') === 'true' ? 'dockswift' : 'localhost';
-
- if (getenv('SWIFT-AUTH') === 'v2.0') {
- $CONFIG['objectstore'] = [
- 'class' => 'OC\\Files\\ObjectStore\\Swift',
- 'arguments' => [
- 'autocreate' => true,
- 'username' => 'swift',
- 'tenantName' => 'service',
- 'password' => 'swift',
- 'serviceName' => 'swift',
- 'region' => 'regionOne',
- 'url' => "http://$swiftHost:5000/v2.0",
- 'bucket' => 'nextcloud'
- ]
- ];
- } else {
- $CONFIG['objectstore'] = [
- 'class' => 'OC\\Files\\ObjectStore\\Swift',
- 'arguments' => [
- 'autocreate' => true,
- 'user' => [
- 'name' => 'swift',
- 'password' => 'swift',
- 'domain' => [
- 'name' => 'default',
- ]
- ],
- 'scope' => [
- 'project' => [
- 'name' => 'service',
- 'domain' => [
- 'name' => 'default',
- ],
- ],
- ],
- 'tenantName' => 'service',
- 'serviceName' => 'swift',
- 'region' => 'regionOne',
- 'url' => "http://$swiftHost:5000/v3",
- 'bucket' => 'nextcloud'
- ]
- ];
- }
-}
-if (getenv('OBJECT_STORE') === 'azure') {
+} elseif (getenv('OBJECT_STORE') === 'azure') {
$CONFIG['objectstore'] = [
'class' => 'OC\\Files\\ObjectStore\\Azure',
'arguments' => [
'container' => 'test',
- 'account_name' => 'devstoreaccount1',
- 'account_key' => 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==',
- 'endpoint' => 'http://' . (getenv('DRONE') === 'true' ? 'azurite' : 'localhost') . ':10000/devstoreaccount1',
+ 'account_name' => getenv('OBJECT_STORE_KEY') ?: 'devstoreaccount1',
+ 'account_key' => getenv('OBJECT_STORE_SECRET') ?: 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==',
+ 'endpoint' => 'http://' . (getenv('OBJECT_STORE_HOST') ?: 'localhost') . ':10000/' . (getenv('OBJECT_STORE_KEY') ?: 'devstoreaccount1'),
'autocreate' => true
]
];
+} elseif (getenv('OBJECT_STORE') === 'swift') {
+ $swiftHost = getenv('OBJECT_STORE_HOST') ?: 'localhost:5000';
+
+ $CONFIG['objectstore'] = [
+ 'class' => 'OC\\Files\\ObjectStore\\Swift',
+ 'arguments' => [
+ 'autocreate' => true,
+ 'user' => [
+ 'name' => getenv('OBJECT_STORE_KEY') ?: 'swift',
+ 'password' => getenv('OBJECT_STORE_SECRET') ?: 'swift',
+ 'domain' => [
+ 'name' => 'Default',
+ ],
+ ],
+ 'scope' => [
+ 'project' => [
+ 'name' => 'service',
+ 'domain' => [
+ 'name' => 'Default',
+ ],
+ ],
+ ],
+ 'serviceName' => 'service',
+ 'region' => 'RegionOne',
+ 'url' => "http://$swiftHost/v3",
+ 'bucket' => 'nextcloud',
+ ]
+ ];
}
diff --git a/tests/redis-cluster.config.php b/tests/redis-cluster.config.php
index e255d123f60..d9951218384 100644
--- a/tests/redis-cluster.config.php
+++ b/tests/redis-cluster.config.php
@@ -1,5 +1,8 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
$CONFIG = [
'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
diff --git a/tests/redis.config.php b/tests/redis.config.php
index 9d3f1eca63e..9068d1ad3d5 100644
--- a/tests/redis.config.php
+++ b/tests/redis.config.php
@@ -1,11 +1,14 @@
<?php
-
+/**
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
$CONFIG = [
'memcache.local' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' => [
- 'host' => 'cache',
+ 'host' => 'localhost',
'port' => 6379,
'timeout' => 0,
],
diff --git a/tests/startsessionlistener.php b/tests/startsessionlistener.php
index b85feac8f78..c0ea9a1cb45 100644
--- a/tests/startsessionlistener.php
+++ b/tests/startsessionlistener.php
@@ -1,9 +1,8 @@
<?php
/**
- * Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
use OC\Session\Memory;
diff --git a/tests/travis/before_install.sh b/tests/travis/before_install.sh
index ee8c3a9862a..b05e93e856f 100644
--- a/tests/travis/before_install.sh
+++ b/tests/travis/before_install.sh
@@ -1,6 +1,7 @@
#!/bin/bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# @author Thomas Müller
# @copyright 2014 Thomas Müller thomas.mueller@tmit.eu
diff --git a/tests/travis/changed_app.sh b/tests/travis/changed_app.sh
index a4be0476573..59410788bd9 100755
--- a/tests/travis/changed_app.sh
+++ b/tests/travis/changed_app.sh
@@ -1,6 +1,7 @@
#!/bin/bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# @author Joas Schilling
# @author Thomas Müller
diff --git a/tests/travis/custom.ini b/tests/travis/custom.ini
index 7a2c0aab426..6eea6fb5cec 100644
--- a/tests/travis/custom.ini
+++ b/tests/travis/custom.ini
@@ -1,3 +1,5 @@
+# SPDX-FileCopyrightText: 2015 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
always_populate_raw_post_data = -1
mbstring.func_overload = 0
default_charset = 'UTF-8'
diff --git a/tests/travis/install.sh b/tests/travis/install.sh
index 180e0c634da..bfedb45caa3 100755
--- a/tests/travis/install.sh
+++ b/tests/travis/install.sh
@@ -1,6 +1,8 @@
#!/bin/bash
#
-# ownCloud
+# SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+# SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+# SPDX-License-Identifier: AGPL-3.0-only
#
# @author Thomas Müller
# @copyright 2014 Thomas Müller thomas.mueller@tmit.eu