20 $this->server->addPlugin(
21 $this->icsExportPlugin
24 $id = $this->caldavBackend->createCalendar(
28 '{DAV:}displayname' =>
'Hello!',
29 '{http://apple.com/ns/ical/}calendar-color' =>
'#AA0000FF',
33 $this->caldavBackend->createCalendarObject(
43DTSTART;TZID=Europe/Amsterdam:20151020T000000
48 $this->caldavBackend->createCalendarObject(
66 $this->icsExportPlugin,
67 $this->server->getPlugin(
'ics-export')
69 $this->assertEquals($this->icsExportPlugin, $this->server->getPlugin(
'ics-export'));
70 $this->assertEquals(
'ics-export', $this->icsExportPlugin->getPluginInfo()[
'name']);
78 '/calendars/admin/UUID-123467?export'
83 $this->assertEquals(200,
$response->getStatus());
84 $this->assertEquals(
'text/calendar',
$response->getHeader(
'Content-Type'));
88 $this->assertEquals(8, count($obj->children()));
89 $this->assertEquals(1, count($obj->VERSION));
90 $this->assertEquals(1, count($obj->CALSCALE));
91 $this->assertEquals(1, count($obj->PRODID));
92 $this->assertTrue(strpos((
string)$obj->PRODID, DAV\
Version::VERSION) !==
false);
93 $this->assertEquals(1, count($obj->VTIMEZONE));
94 $this->assertEquals(1, count($obj->VEVENT));
95 $this->assertEquals(
"Hello!", $obj->{
"X-WR-CALNAME"});
96 $this->assertEquals(
"#AA0000FF", $obj->{
"X-APPLE-CALENDAR-COLOR"});
103 '/calendars/admin/UUID-123467?export'
105 DAV\Server::$exposeVersion =
false;
107 DAV\Server::$exposeVersion =
true;
109 $this->assertEquals(200,
$response->getStatus());
110 $this->assertEquals(
'text/calendar',
$response->getHeader(
'Content-Type'));
112 $obj = VObject\Reader::read(
$response->body);
114 $this->assertEquals(8, count($obj->children()));
115 $this->assertEquals(1, count($obj->VERSION));
116 $this->assertEquals(1, count($obj->CALSCALE));
117 $this->assertEquals(1, count($obj->PRODID));
118 $this->assertFalse(strpos((
string)$obj->PRODID, DAV\Version::VERSION) !==
false);
119 $this->assertEquals(1, count($obj->VTIMEZONE));
120 $this->assertEquals(1, count($obj->VEVENT));
128 '/calendars/admin/UUID-123467'
138 $aclPlugin->allowUnauthenticatedAccess =
false;
139 $this->server->addPlugin(
145 '/calendars/admin/UUID-123467?export'
155 $aclPlugin->allowUnauthenticatedAccess =
false;
156 $this->server->addPlugin(
159 $this->server->addPlugin(
163 $this->autoLogin(
'admin');
167 '/calendars/admin/UUID-123467?export'
171 $this->assertEquals(
'text/calendar',
$response->getHeader(
'Content-Type'));
173 $obj = VObject\Reader::read(
$response->body);
175 $this->assertEquals(8, count($obj->children()));
176 $this->assertEquals(1, count($obj->VERSION));
177 $this->assertEquals(1, count($obj->CALSCALE));
178 $this->assertEquals(1, count($obj->PRODID));
179 $this->assertTrue(strpos((
string)$obj->PRODID, DAV\Version::VERSION) !==
false);
180 $this->assertEquals(1, count($obj->VTIMEZONE));
181 $this->assertEquals(1, count($obj->VEVENT));
189 '/calendars/admin/UUID-123467?export&start=foo'
199 '/calendars/admin/UUID-123467?export&end=foo'
209 '/calendars/admin/UUID-123467?export&start=1&end=2'
213 $obj = VObject\Reader::read(
$response->getBody());
215 $this->assertEquals(0, count($obj->VTIMEZONE));
216 $this->assertEquals(0, count($obj->VEVENT));
224 '/calendars/admin/UUID-123467?export&expand=1&end=2'
234 '/calendars/admin/UUID-123467?export&start=1&end=2000000000&expand=1'
238 $obj = VObject\Reader::read(
$response->getBody());
240 $this->assertEquals(0, count($obj->VTIMEZONE));
241 $this->assertEquals(1, count($obj->VEVENT));
249 '/calendars/admin/UUID-123467?export',
250 [
'Accept' =>
'application/calendar+json']
254 $this->assertEquals(
'application/calendar+json',
$response->getHeader(
'Content-Type'));
262 '/calendars/admin/UUID-123467?export&accept=jcal'
266 $this->assertEquals(
'application/calendar+json',
$response->getHeader(
'Content-Type'));
274 '/calendars/admin/UUID-123467?export',
275 [
'Accept' =>
'text/plain']
279 $this->assertEquals(
'text/calendar',
$response->getHeader(
'Content-Type'));
287 '/calendars/admin/UUID-123467?export&componentType=VEVENT'
292 $obj = VObject\Reader::read(
$response->body);
293 $this->assertEquals(1, count($obj->VTIMEZONE));
294 $this->assertEquals(1, count($obj->VEVENT));
295 $this->assertEquals(0, count($obj->VTODO));
303 '/calendars/admin/UUID-123467?export&componentType=VTODO'
308 $obj = VObject\Reader::read(
$response->body);
310 $this->assertEquals(0, count($obj->VTIMEZONE));
311 $this->assertEquals(0, count($obj->VEVENT));
312 $this->assertEquals(1, count($obj->VTODO));
320 '/calendars/admin/UUID-123467?export&componentType=VVOODOO'
331 '/calendars/admin/UUID-123467?export'
335 $this->assertEquals(
'text/calendar',
$response->getHeader(
'Content-Type'));
337 'attachment; filename="UUID-123467-' . date(
'Y-m-d') .
'.ics"',
338 $response->getHeader(
'Content-Disposition')
347 '/calendars/admin/UUID-123467?export',
348 [
'Accept' =>
'application/calendar+json']
352 $this->assertEquals(
'application/calendar+json',
$response->getHeader(
'Content-Type'));
354 'attachment; filename="UUID-123467-' . date(
'Y-m-d') .
'.json"',
355 $response->getHeader(
'Content-Disposition')
362 $this->caldavBackend->createCalendar(
366 '{DAV:}displayname' =>
'Test bad characters',
367 '{http://apple.com/ns/ical/}calendar-color' =>
'#AA0000FF',
373 '/calendars/admin/UUID-b_ad"(ch)ars?export',
374 [
'Accept' =>
'application/calendar+json']
378 $this->assertEquals(
'application/calendar+json',
$response->getHeader(
'Content-Type'));
380 'attachment; filename="UUID-b_adchars-' . date(
'Y-m-d') .
'.json"',
381 $response->getHeader(
'Content-Disposition')
foreach($paths as $path) $request
An exception for terminatinating execution or to throw for unit testing.
testBeforeMethodNoVersion()
testACLIntegrationNotBlocked()
testBeforeMethodNoExport()
testACLIntegrationBlocked()
testFilterComponentVTODO()
testFilterComponentBadComponent()
testFilterComponentVEVENT()
testContentDispositionBadChars()
testContentDispositionJson()
This class may be used as a basis for other webdav-related unittests.
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
const VERSION
Full version number.
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
if(!array_key_exists('StateId', $_REQUEST)) $id