aboutsummaryrefslogtreecommitdiff
path: root/tests/jsonapi/InstitutesIndexTest.php
blob: 4c421b5fdb404d99cf478e79400a7da3f585b578 (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
37
38
<?php

use JsonApi\Routes\Institutes\InstitutesIndex;

class InstitutesIndexTest extends \Codeception\Test\Unit
{
    /**
     * @var \UnitTester
     */
    protected $tester;

    protected function _before()
    {
        \DBManager::getInstance()->setConnection('studip', $this->getModule('\\Helper\\StudipDb')->dbh);
    }

    protected function _after()
    {
    }

    // tests

    public function testGetInstitutesIndex()
    {
        $app = $this->tester->createApp(null, 'get', '/institutes', InstitutesIndex::class);

        $requestBuilder = $this->tester->createRequestBuilder(null);
        $requestBuilder->setUri('/institutes')->fetch();

        $response = $this->tester->sendMockRequest($app, $requestBuilder->getRequest());
        $this->tester->assertTrue($response->isSuccessfulDocument());

        $document = $response->document();
        $this->tester->assertTrue($document->isResourceCollectionDocument());

        $this->tester->assertSame(\Institute::countAll(), count($document->primaryResources()));
    }
}