summaryrefslogtreecommitdiff
path: root/tests/ServerImplementationTest.php
blob: 88be7c4c818ef31012118ea7e39a274352924a4e (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;

use Symfony\Component\HttpFoundation\Response;
use Tests\PHPUnit\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);
  }
}