diff options
author | Richard Steinmetz <richard@steinmetz.cloud> | 2024-07-13 16:51:16 +0200 |
---|---|---|
committer | Richard Steinmetz <richard@steinmetz.cloud> | 2024-07-16 09:18:33 +0200 |
commit | e42bceac9fc5845ad3614d3254bbb270e0d9d847 (patch) | |
tree | 53062f9f3ee11966417266a241c0f2800514c7ad /tests | |
parent | 70dd8d513bf73c8d56fea2aae4a02718a328f6e3 (diff) | |
download | nextcloud-server-e42bceac9fc5845ad3614d3254bbb270e0d9d847.tar.gz nextcloud-server-e42bceac9fc5845ad3614d3254bbb270e0d9d847.zip |
feat: hide caldav server settings if no app uses the caldav backend
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/app/expected-info.json | 5 | ||||
-rw-r--r-- | tests/data/app/navigation-one-item.json | 5 | ||||
-rw-r--r-- | tests/data/app/navigation-two-items.json | 5 | ||||
-rw-r--r-- | tests/data/app/valid-info.xml | 1 | ||||
-rw-r--r-- | tests/lib/App/AppManagerTest.php | 48 |
5 files changed, 59 insertions, 5 deletions
diff --git a/tests/data/app/expected-info.json b/tests/data/app/expected-info.json index 8527f18a2c0..c3ea27af7d3 100644 --- a/tests/data/app/expected-info.json +++ b/tests/data/app/expected-info.json @@ -65,7 +65,10 @@ "min-version": "7.0.1", "max-version": "8" } - } + }, + "backend": [ + "caldav" + ] }, "repair-steps": { "install": [], diff --git a/tests/data/app/navigation-one-item.json b/tests/data/app/navigation-one-item.json index c9002da6b0d..2bd81461586 100644 --- a/tests/data/app/navigation-one-item.json +++ b/tests/data/app/navigation-one-item.json @@ -29,7 +29,8 @@ "min-version": "16", "max-version": "16" } - } + }, + "backend": [] }, "background-jobs": [ "OCA\\Activity\\BackgroundJob\\EmailNotification", @@ -82,4 +83,4 @@ "uninstall": [] }, "two-factor-providers": [] -}
\ No newline at end of file +} diff --git a/tests/data/app/navigation-two-items.json b/tests/data/app/navigation-two-items.json index a7579217238..4b081d3bbd9 100644 --- a/tests/data/app/navigation-two-items.json +++ b/tests/data/app/navigation-two-items.json @@ -29,7 +29,8 @@ "min-version": "16", "max-version": "16" } - } + }, + "backend": [] }, "background-jobs": [ "OCA\\Activity\\BackgroundJob\\EmailNotification", @@ -88,4 +89,4 @@ "uninstall": [] }, "two-factor-providers": [] -}
\ No newline at end of file +} diff --git a/tests/data/app/valid-info.xml b/tests/data/app/valid-info.xml index 9044c00f353..d2569788399 100644 --- a/tests/data/app/valid-info.xml +++ b/tests/data/app/valid-info.xml @@ -34,5 +34,6 @@ <lib>curl</lib> <os>Linux</os> <owncloud min-version="7.0.1" max-version="8" /> + <backend>caldav</backend> </dependencies> </info> diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php index c38cadf8e38..03c9d474c55 100644 --- a/tests/lib/App/AppManagerTest.php +++ b/tests/lib/App/AppManagerTest.php @@ -885,4 +885,52 @@ class AppManagerTest extends TestCase { $this->assertEquals($expectedApp, $this->manager->getDefaultAppForUser(null, $withFallbacks)); } + + public static function isBackendRequiredDataProvider(): array { + return [ + // backend available + [ + 'caldav', + ['app1' => ['caldav']], + true, + ], + [ + 'caldav', + ['app1' => [], 'app2' => ['foo'], 'app3' => ['caldav']], + true, + ], + // backend not available + [ + 'caldav', + ['app3' => [], 'app1' => ['foo'], 'app2' => ['bar', 'baz']], + false, + ], + // no app available + [ + 'caldav', + [], + false, + ], + ]; + } + + /** + * @dataProvider isBackendRequiredDataProvider + */ + public function testIsBackendRequired( + string $backend, + array $appBackends, + bool $expected, + ): void { + $appInfoData = array_map( + static fn (array $backends) => ['dependencies' => ['backend' => $backends]], + $appBackends, + ); + + $reflection = new \ReflectionClass($this->manager); + $property = $reflection->getProperty('appInfos'); + $property->setValue($this->manager, $appInfoData); + + $this->assertEquals($expected, $this->manager->isBackendRequired($backend)); + } } |