aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRichard Steinmetz <richard@steinmetz.cloud>2024-07-17 18:57:08 +0200
committerGitHub <noreply@github.com>2024-07-17 18:57:08 +0200
commit718ef5dea5288a13e9536fd9a611ff777ee7168d (patch)
tree952cef73e40bb468dd92d5d157f8a18fe603d447 /tests
parent7cb67c67c746d35f4762fb8e7a8ae40367a78fa5 (diff)
parente42bceac9fc5845ad3614d3254bbb270e0d9d847 (diff)
downloadnextcloud-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.json5
-rw-r--r--tests/data/app/navigation-one-item.json5
-rw-r--r--tests/data/app/navigation-two-items.json5
-rw-r--r--tests/data/app/valid-info.xml1
-rw-r--r--tests/lib/App/AppManagerTest.php48
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));
+ }
}