aboutsummaryrefslogtreecommitdiff
path: root/tests/jsonapi/UserEventsIcalTest.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/UserEventsIcalTest.php
current code from svn, revision 62608
Diffstat (limited to 'tests/jsonapi/UserEventsIcalTest.php')
-rw-r--r--tests/jsonapi/UserEventsIcalTest.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/jsonapi/UserEventsIcalTest.php b/tests/jsonapi/UserEventsIcalTest.php
new file mode 100644
index 0000000..359763f
--- /dev/null
+++ b/tests/jsonapi/UserEventsIcalTest.php
@@ -0,0 +1,48 @@
+<?php
+
+use JsonApi\Routes\Events\UserEventsIcal;
+
+class UserEventsIcalTest 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 testIcalUserEvents()
+ {
+ $credentials = $this->tester->getCredentialsForTestAutor();
+
+ $calendar = new \SingleCalendar($credentials['id']);
+ $event = $calendar->getNewEvent();
+ $event->setTitle('blypyp');
+
+ $oldUser = $GLOBALS['user'];
+ $GLOBALS['user'] = \User::find($credentials['id']);
+
+ $calendar->storeEvent($event, [$credentials['id']]);
+
+ $GLOBALS['user'] = $oldUser;
+
+ $app = $this->tester->createApp($credentials, 'get', '/users/{id}/events.ics', UserEventsIcal::class);
+
+ $requestBuilder = $this->tester->createRequestBuilder($credentials);
+ $requestBuilder->setUri('/users/'.$credentials['id'].'/events.ics')->fetch();
+
+ $response = $app($requestBuilder->getRequest(), new \Slim\Http\Response());
+
+ $this->tester->assertEquals(200, $response->getStatusCode());
+ $this->tester->assertContains('BEGIN:VEVENT', (string) $response->getBody());
+ $this->tester->assertContains('SUMMARY:blypyp', (string) $response->getBody());
+ }
+}