aboutsummaryrefslogtreecommitdiffstats
path: root/apps/federation/tests/TrustedServersTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/federation/tests/TrustedServersTest.php')
-rw-r--r--apps/federation/tests/TrustedServersTest.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/apps/federation/tests/TrustedServersTest.php b/apps/federation/tests/TrustedServersTest.php
index c8477f637cb..0c900f6edf7 100644
--- a/apps/federation/tests/TrustedServersTest.php
+++ b/apps/federation/tests/TrustedServersTest.php
@@ -144,6 +144,64 @@ class TrustedServersTest extends TestCase {
);
}
+ public static function dataTestGetServer() {
+ return [
+ [
+ 15,
+ [
+ 'id' => 15,
+ 'otherData' => 'first server',
+ ]
+ ],
+ [
+ 16,
+ [
+ 'id' => 16,
+ 'otherData' => 'second server',
+ ]
+ ],
+ [
+ 42,
+ [
+ 'id' => 42,
+ 'otherData' => 'last server',
+ ]
+ ],
+ [
+ 108,
+ null
+ ],
+ ];
+ }
+
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetServer')]
+ public function testGetServer(int $id, ?array $expectedServer): void {
+ $servers = [
+ [
+ 'id' => 15,
+ 'otherData' => 'first server',
+ ],
+ [
+ 'id' => 16,
+ 'otherData' => 'second server',
+ ],
+ [
+ 'id' => 42,
+ 'otherData' => 'last server',
+ ],
+ ];
+ $this->dbHandler->expects($this->once())->method('getAllServer')->willReturn($servers);
+
+ if ($expectedServer === null) {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No server found with ID: ' . $id);
+ }
+
+ $this->assertEquals(
+ $expectedServer,
+ $this->trustedServers->getServer($id)
+ );
+ }
public function testIsTrustedServer(): void {
$this->dbHandler->expects($this->once())