ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Issue203Test.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\CalDAV;
4 
5 use Sabre\HTTP;
6 use Sabre\VObject;
7 
16 
17  protected $setupCalDAV = true;
18 
19  protected $caldavCalendars = [
20  [
21  'id' => 1,
22  'name' => 'Calendar',
23  'principaluri' => 'principals/user1',
24  'uri' => 'calendar1',
25  ]
26  ];
27 
28  protected $caldavCalendarObjects = [
29  1 => [
30  'event.ics' => [
31  'calendardata' => 'BEGIN:VCALENDAR
32 VERSION:2.0
33 BEGIN:VEVENT
34 UID:20120330T155305CEST-6585fBUVgV
35 DTSTAMP:20120330T135305Z
36 DTSTART;TZID=Europe/Berlin:20120326T155200
37 DTEND;TZID=Europe/Berlin:20120326T165200
38 RRULE:FREQ=DAILY;COUNT=2;INTERVAL=1
39 SUMMARY:original summary
40 TRANSP:OPAQUE
41 END:VEVENT
42 BEGIN:VEVENT
43 UID:20120330T155305CEST-6585fBUVgV
44 DTSTAMP:20120330T135352Z
45 DESCRIPTION:
46 DTSTART;TZID=Europe/Berlin:20120328T155200
47 DTEND;TZID=Europe/Berlin:20120328T165200
48 RECURRENCE-ID;TZID=Europe/Berlin:20120327T155200
49 SEQUENCE:1
50 SUMMARY:overwritten summary
51 TRANSP:OPAQUE
52 END:VEVENT
53 END:VCALENDAR
54 ',
55  ],
56  ],
57  ];
58 
59  function testIssue203() {
60 
62  'REQUEST_METHOD' => 'REPORT',
63  'HTTP_CONTENT_TYPE' => 'application/xml',
64  'REQUEST_URI' => '/calendars/user1/calendar1',
65  'HTTP_DEPTH' => '1',
66  ]);
67 
68  $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
69 <C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
70  <D:prop>
71  <C:calendar-data>
72  <C:expand start="20120325T220000Z" end="20120401T215959Z"/>
73  </C:calendar-data>
74  <D:getetag/>
75  </D:prop>
76  <C:filter>
77  <C:comp-filter name="VCALENDAR">
78  <C:comp-filter name="VEVENT">
79  <C:time-range start="20120325T220000Z" end="20120401T215959Z"/>
80  </C:comp-filter>
81  </C:comp-filter>
82  </C:filter>
83 </C:calendar-query>');
84 
85  $response = $this->request($request);
86 
87  // Everts super awesome xml parser.
88  $body = substr(
89  $response->body,
90  $start = strpos($response->body, 'BEGIN:VCALENDAR'),
91  strpos($response->body, 'END:VCALENDAR') - $start + 13
92  );
93  $body = str_replace('&#13;', '', $body);
94 
95  $vObject = VObject\Reader::read($body);
96 
97  $this->assertEquals(2, count($vObject->VEVENT));
98 
99 
100  $expectedEvents = [
101  [
102  'DTSTART' => '20120326T135200Z',
103  'DTEND' => '20120326T145200Z',
104  'SUMMARY' => 'original summary',
105  ],
106  [
107  'DTSTART' => '20120328T135200Z',
108  'DTEND' => '20120328T145200Z',
109  'SUMMARY' => 'overwritten summary',
110  'RECURRENCE-ID' => '20120327T135200Z',
111  ]
112  ];
113 
114  // try to match agains $expectedEvents array
115  foreach ($expectedEvents as $expectedEvent) {
116 
117  $matching = false;
118 
119  foreach ($vObject->VEVENT as $vevent) {
121  foreach ($vevent->children() as $child) {
123  if (isset($expectedEvent[$child->name])) {
124  if ($expectedEvent[$child->name] != $child->getValue()) {
125  continue 2;
126  }
127  }
128  }
129 
130  $matching = true;
131  break;
132  }
133 
134  $this->assertTrue($matching, 'Did not find the following event in the response: ' . var_export($expectedEvent, true));
135  }
136  }
137 }
foreach($paths as $path) $request
Definition: asyncclient.php:32
This unittest is created to find out why an overwritten DAILY event has wrong DTSTART, DTEND, SUMMARY and RECURRENCEID.
$start
Definition: bench.php:8
This class may be used as a basis for other webdav-related unittests.
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
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
$response