summaryrefslogtreecommitdiff
path: root/tests/Integration/ServerImplementationTest.php
blob: c1c18233687370a1bf8c6d428e3818ff82c780e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

namespace Tests\Integration;

use Symfony\Component\HttpFoundation\Response;
use Tests\Integration\TestCases\HttpResponseTestCase;

class ServerImplementationTest extends HttpResponseTestCase
{
  public function testVersion(): void
  {
    $response = $this->request("GET", "/_matrix/federation/v1/version");

    $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
    $this->assertTrue($this->hasJsonBody($response));

    $body = json_decode((string)$response->getBody(), true);

    $this->assertArrayHasKey("server", $body);
    $this->assertArrayHasKey("name", $body["server"]);
    $this->assertArrayHasKey("version", $body["server"]);
  }

  public function testVersions(): void
  {
    $response = $this->request("GET", "/_matrix/client/versions");

    $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
    $this->assertTrue($this->hasJsonBody($response));

    $body = json_decode((string)$response->getBody(), true);

    $this->assertIsArray($body["versions"]);
    $this->assertTrue(count($body["versions"]) > 0);
  }
}