aboutsummaryrefslogtreecommitdiff
path: root/tests/jsonapi/CourseShowTest.php
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+github@gmail.com>2021-07-22 16:07:19 +0200
committerJan-Hendrik Willms <tleilax+github@gmail.com>2021-07-22 16:19:12 +0200
commita3da1483a9e689846179159355badfec8073dbec (patch)
tree770dcca6bdf5f6f2a11b0e7fcbbeda6919a3fc52 /tests/jsonapi/CourseShowTest.php
current code from svn, revision 62608
Diffstat (limited to 'tests/jsonapi/CourseShowTest.php')
-rw-r--r--tests/jsonapi/CourseShowTest.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/jsonapi/CourseShowTest.php b/tests/jsonapi/CourseShowTest.php
new file mode 100644
index 0000000..e1acf92
--- /dev/null
+++ b/tests/jsonapi/CourseShowTest.php
@@ -0,0 +1,46 @@
+<?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);
+ }
+
+ 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()
+ );
+ }
+}