blob: e0b154ee15edc30a718f5e3f1a4b07edaad56b4d (
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
43
44
45
46
47
|
<?php
use JsonApi\Routes\Users\UsersShow;
class UsersShowTest 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 testShouldShowUser()
{
$credentials = $this->tester->getCredentialsForTestAutor();
$dozent = $this->tester->getCredentialsForTestDozent();
$response = $this->getUser($credentials, $dozent['id']);
$this->tester->assertTrue($response->isSuccessfulDocument([200]));
$this->tester->assertSame($dozent['id'], $response->document()->primaryResource()->id());
$this->tester->storeJsonMd('get_own_user', $response);
}
// **** helper functions ****
private function getUser($credentials, $userId)
{
$app = $this->tester->createApp($credentials, 'get', '/users/{id}', UsersShow::class);
return $this->tester->sendMockRequest(
$app,
$this->tester->createRequestBuilder($credentials)
->setUri('/users/'.$userId)
->fetch()
->getRequest()
);
}
}
|