blob: efca6584c445dc9839a838c5b7c8d40a1637bb07 (
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
|
<?php
use JsonApi\Routes\Institutes\InstitutesShow;
class InstitutesShowTest 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 testGetInstitutesShow()
{
$allInstitutes = \Institute::getInstitutes();
$this->tester->assertTrue(0 < count($allInstitutes));
$institute = current($allInstitutes);
$app = $this->tester->createApp(null, 'get', '/institutes/{id}', InstitutesShow::class);
$requestBuilder = $this->tester->createRequestBuilder(null);
$requestBuilder->setUri('/institutes/'.$institute['Institut_id'])->fetch();
$response = $this->tester->sendMockRequest($app, $requestBuilder->getRequest());
$this->tester->assertTrue($response->isSuccessfulDocument());
$document = $response->document();
$this->tester->assertTrue($document->isSingleResourceDocument());
$this->tester->assertSame($institute['Institut_id'], $document->primaryResource()->id());
}
}
|