ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ExpandEventsDTSTARTandDTENDTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\CalDAV;
4
5use Sabre\HTTP;
7
17
18 protected $setupCalDAV = true;
19
20 protected $caldavCalendars = [
21 [
22 'id' => 1,
23 'name' => 'Calendar',
24 'principaluri' => 'principals/user1',
25 'uri' => 'calendar1',
26 ]
27 ];
28
29 protected $caldavCalendarObjects = [
30 1 => [
31 'event.ics' => [
32 'calendardata' => 'BEGIN:VCALENDAR
33VERSION:2.0
34BEGIN:VEVENT
35UID:foobar
36DTEND;TZID=Europe/Berlin:20120207T191500
37RRULE:FREQ=DAILY;INTERVAL=1;COUNT=3
38SUMMARY:RecurringEvents 3 times
39DTSTART;TZID=Europe/Berlin:20120207T181500
40END:VEVENT
41BEGIN:VEVENT
42CREATED:20120207T111900Z
43UID:foobar
44DTEND;TZID=Europe/Berlin:20120208T191500
45SUMMARY:RecurringEvents 3 times OVERWRITTEN
46DTSTART;TZID=Europe/Berlin:20120208T181500
47RECURRENCE-ID;TZID=Europe/Berlin:20120208T181500
48END:VEVENT
49END:VCALENDAR
50',
51 ],
52 ],
53 ];
54
55 function testExpand() {
56
58 'REQUEST_METHOD' => 'REPORT',
59 'HTTP_CONTENT_TYPE' => 'application/xml',
60 'REQUEST_URI' => '/calendars/user1/calendar1',
61 'HTTP_DEPTH' => '1',
62 ]);
63
64 $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
65<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
66 <D:prop>
67 <C:calendar-data>
68 <C:expand start="20120205T230000Z" end="20120212T225959Z"/>
69 </C:calendar-data>
70 <D:getetag/>
71 </D:prop>
72 <C:filter>
73 <C:comp-filter name="VCALENDAR">
74 <C:comp-filter name="VEVENT">
75 <C:time-range start="20120205T230000Z" end="20120212T225959Z"/>
76 </C:comp-filter>
77 </C:comp-filter>
78 </C:filter>
79</C:calendar-query>');
80
81 $response = $this->request($request);
82
83 // Everts super awesome xml parser.
84 $body = substr(
85 $response->body,
86 $start = strpos($response->body, 'BEGIN:VCALENDAR'),
87 strpos($response->body, 'END:VCALENDAR') - $start + 13
88 );
89 $body = str_replace('&#13;', '', $body);
90
91 try {
92 $vObject = VObject\Reader::read($body);
93 } catch (VObject\ParseException $e) {
94 $this->fail('Could not parse object. Error:' . $e->getMessage() . ' full object: ' . $response->getBodyAsString());
95 }
96
97 // check if DTSTARTs and DTENDs are correct
98 foreach ($vObject->VEVENT as $vevent) {
100 foreach ($vevent->children() as $child) {
102 if ($child->name == 'DTSTART') {
103 // DTSTART has to be one of three valid values
104 $this->assertContains($child->getValue(), ['20120207T171500Z', '20120208T171500Z', '20120209T171500Z'], 'DTSTART is not a valid value: ' . $child->getValue());
105 } elseif ($child->name == 'DTEND') {
106 // DTEND has to be one of three valid values
107 $this->assertContains($child->getValue(), ['20120207T181500Z', '20120208T181500Z', '20120209T181500Z'], 'DTEND is not a valid value: ' . $child->getValue());
108 }
109 }
110 }
111 }
112
113}
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
This unittests is created to find out why recurring events have wrong DTSTART value.
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.
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
Exception thrown by Reader if an invalid object was attempted to be parsed.
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
$response
$start
Definition: bench.php:8