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/lib/App | |
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/lib/App')
-rw-r--r-- | tests/lib/App/AppManagerTest.php | 48 |
1 files changed, 48 insertions, 0 deletions
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)); + } } |