aboutsummaryrefslogtreecommitdiff
path: root/tests/jsonapi/UsersShowNewsTest.php
blob: 78322b6bc5045916dc8d3e030de5fc28b81f9c29 (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
39
40
41
42
<?php

use JsonApi\Routes\News\ByUserIndex;

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

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

    protected function _after()
    {
    }

    //testszenario:
    public function testUsersShowNews()
    {
        $credentials = $this->tester->getCredentialsForTestAutor();
        $userId = $credentials['id'];
        $response = $this->getUserNews($credentials, $userId);
    }

    //helpers:
    private function getUserNews($credentials, $userId)
    {
        $app = $this->tester->createApp($credentials, 'get', '/users/{id}/news', ByUserIndex::class);

        return $this->tester->sendMockRequest(
                $app,
                $this->tester->createRequestBuilder($credentials)
                ->setUri('/users/'.$userId.'/news')
                ->fetch()
                ->getRequest()
        );
    }
}