blob: b2dbdbaa6568ec42a9afc9396bf603b50556e9ac (
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\News\ByCourseIndex;
class CourseNewsShowTest 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 testCourseShowNews()
{
$courseId = 'a07535cf2f8a72df33c12ddfa4b53dde';
$credentials = $this->tester->getCredentialsForTestAutor();
$response = $this->getCourseNews($credentials, $courseId);
$this->tester->assertTrue($response->isSuccessfulDocument([200]));
}
//helpers:
private function getCourseNews($credentials, $courseId)
{
$app = $this->tester->createApp($credentials, 'get', '/courses/{id}/news', ByCourseIndex::class);
return $this->tester->sendMockRequest(
$app,
$this->tester->createRequestBuilder($credentials)
->setUri('/courses/'.$courseId.'/news')
->fetch()
->getRequest()
);
}
}
|