diff options
| author | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-07-22 16:07:19 +0200 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-07-22 16:19:12 +0200 |
| commit | a3da1483a9e689846179159355badfec8073dbec (patch) | |
| tree | 770dcca6bdf5f6f2a11b0e7fcbbeda6919a3fc52 /tests/jsonapi/CourseNewsCreateTest.php | |
current code from svn, revision 62608
Diffstat (limited to 'tests/jsonapi/CourseNewsCreateTest.php')
| -rw-r--r-- | tests/jsonapi/CourseNewsCreateTest.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/jsonapi/CourseNewsCreateTest.php b/tests/jsonapi/CourseNewsCreateTest.php new file mode 100644 index 0000000..83170be --- /dev/null +++ b/tests/jsonapi/CourseNewsCreateTest.php @@ -0,0 +1,45 @@ +<?php + + +class CourseNewsCreateTest 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 testCourseCreateNews() + { + $courseId = 'a07535cf2f8a72df33c12ddfa4b53dde'; + $title = 'Fakenews'; + $content = 'This is just fake news.'; + $date = time(); + $expire = $date + 1 * 7 * 24 * 60 * 60; + $credentials = $this->tester->getCredentialsForRoot(); + $response = $this->createCourseNews($credentials, $courseId, $title, $content, $date, $expire); + } + + //helpers: + private function createCourseNews($credentials, $courseId, $title, $content, $date, $expire) + { + $app = $this->tester->createApp($credentials, 'post', '/courses/{id}/news', CourseNewsCreate::class); + + return $this->tester->sendMockRequest( + $app, + $this->tester->createRequestBuilder($credentials) + ->setUri('/courses/'.$courseId.'/news') + ->fetch() + ->getRequest() + ); + } +} |
