ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ExpandEventsDTSTARTandDTENDTest.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 
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
33 VERSION:2.0
34 BEGIN:VEVENT
35 UID:foobar
36 DTEND;TZID=Europe/Berlin:20120207T191500
37 RRULE:FREQ=DAILY;INTERVAL=1;COUNT=3
38 SUMMARY:RecurringEvents 3 times
39 DTSTART;TZID=Europe/Berlin:20120207T181500
40 END:VEVENT
41 BEGIN:VEVENT
42 CREATED:20120207T111900Z
43 UID:foobar
44 DTEND;TZID=Europe/Berlin:20120208T191500
45 SUMMARY:RecurringEvents 3 times OVERWRITTEN
46 DTSTART;TZID=Europe/Berlin:20120208T181500
47 RECURRENCE-ID;TZID=Europe/Berlin:20120208T181500
48 END:VEVENT
49 END: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
$start
Definition: bench.php:8
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.
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
Exception thrown by Reader if an invalid object was attempted to be parsed.
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