blob: d2c953cee7f0a628f9e2c4baeb2a839bd9cdbb37 (
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
48
49
|
<?php
use JsonApi\Routes\Courses\CoursesShow;
class CourseShowTest extends \Codeception\Test\Unit
{
/**
* @var \UnitTester
*/
protected $tester;
protected function _before()
{
\DBManager::getInstance()->setConnection('studip', $this->getModule('\\Helper\\StudipDb')->dbh);
//Initialize $SEM_TYPE and $SEM_CLASS arrays
$GLOBALS['SEM_CLASS'] = SemClass::getClasses();
$GLOBALS['SEM_TYPE'] = SemType::getTypes();
}
protected function _after()
{
}
// tests
public function testShouldShowCourse()
{
$courseId = 'a07535cf2f8a72df33c12ddfa4b53dde';
$credentials = $this->tester->getCredentialsForTestAutor();
$response = $this->getCourse($credentials, $courseId);
$this->tester->assertSame($courseId, $response->document()->primaryResource()->id());
}
// **** helper functions ****
private function getCourse($credentials, $courseId)
{
$app = $this->tester->createApp($credentials, 'get', '/courses/{id}', CoursesShow::class);
return $this->tester->sendMockRequest(
$app,
$this->tester->createRequestBuilder($credentials)
->setUri('/courses/'.$courseId)
->fetch()
->getRequest()
);
}
}
|