diff options
author | Richard Steinmetz <richard@steinmetz.cloud> | 2024-07-17 18:57:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-17 18:57:08 +0200 |
commit | 718ef5dea5288a13e9536fd9a611ff777ee7168d (patch) | |
tree | 952cef73e40bb468dd92d5d157f8a18fe603d447 /tests | |
parent | 7cb67c67c746d35f4762fb8e7a8ae40367a78fa5 (diff) | |
parent | e42bceac9fc5845ad3614d3254bbb270e0d9d847 (diff) | |
download | nextcloud-server-718ef5dea5288a13e9536fd9a611ff777ee7168d.tar.gz nextcloud-server-718ef5dea5288a13e9536fd9a611ff777ee7168d.zip |
Merge pull request #46510 from nextcloud/feat/info-xml-backends
feat: hide caldav server settings if no app uses the caldav backend
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)); + } } |