aboutsummaryrefslogtreecommitdiff
path: root/tests/jsonapi/CourseEventsIndexTest.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/CourseEventsIndexTest.php
current code from svn, revision 62608
Diffstat (limited to 'tests/jsonapi/CourseEventsIndexTest.php')
-rw-r--r--tests/jsonapi/CourseEventsIndexTest.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/jsonapi/CourseEventsIndexTest.php b/tests/jsonapi/CourseEventsIndexTest.php
new file mode 100644
index 0000000..5e962de
--- /dev/null
+++ b/tests/jsonapi/CourseEventsIndexTest.php
@@ -0,0 +1,42 @@
+<?php
+
+use JsonApi\Routes\Events\CourseEventsIndex;
+
+class CourseEventsIndexTest 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 testIndexCourseEvents()
+ {
+ $credentials = $this->tester->getCredentialsForTestAutor();
+ $courseId = 'a07535cf2f8a72df33c12ddfa4b53dde';
+ $course = \Course::find($courseId);
+ $countEvents = count($course->dates) + count($course->ex_dates);
+
+ $app = $this->tester->createApp($credentials, 'get', '/courses/{id}/events', CourseEventsIndex::class);
+
+ $requestBuilder = $this->tester->createRequestBuilder($credentials);
+ $requestBuilder->setUri('/courses/'.$courseId.'/events')->fetch();
+
+ $response = $this->tester->sendMockRequest($app, $requestBuilder->getRequest());
+
+ $this->tester->assertTrue($response->isSuccessfulDocument([200]));
+ $document = $response->document();
+ $this->tester->assertTrue($document->isResourceCollectionDocument());
+ $resources = $document->primaryResources();
+ $this->tester->assertCount($countEvents, $resources);
+ }
+}