Newer
Older
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
44
<?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->assertStringContainsString('BEGIN:VEVENT', (string) $response->getBody());
$this->tester->assertStringContainsString('SUMMARY:blypyp', (string) $response->getBody());