ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ExpandEventsDTSTARTandDTENDbyDayTest.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:foobar
35 DTEND;TZID=Europe/Berlin:20120207T191500
36 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,TH
37 SUMMARY:RecurringEvents on tuesday and thursday
38 DTSTART;TZID=Europe/Berlin:20120207T181500
39 END:VEVENT
40 END:VCALENDAR
41 ',
42  ],
43  ],
44  ];
45 
46  function testExpandRecurringByDayEvent() {
47 
49  'REQUEST_METHOD' => 'REPORT',
50  'HTTP_CONTENT_TYPE' => 'application/xml',
51  'REQUEST_URI' => '/calendars/user1/calendar1',
52  'HTTP_DEPTH' => '1',
53  ]);
54 
55  $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
56 <C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
57  <D:prop>
58  <C:calendar-data>
59  <C:expand start="20120210T230000Z" end="20120217T225959Z"/>
60  </C:calendar-data>
61  <D:getetag/>
62  </D:prop>
63  <C:filter>
64  <C:comp-filter name="VCALENDAR">
65  <C:comp-filter name="VEVENT">
66  <C:time-range start="20120210T230000Z" end="20120217T225959Z"/>
67  </C:comp-filter>
68  </C:comp-filter>
69  </C:filter>
70 </C:calendar-query>');
71 
72  $response = $this->request($request);
73 
74  // Everts super awesome xml parser.
75  $body = substr(
76  $response->body,
77  $start = strpos($response->body, 'BEGIN:VCALENDAR'),
78  strpos($response->body, 'END:VCALENDAR') - $start + 13
79  );
80  $body = str_replace('&#13;', '', $body);
81 
82  $vObject = VObject\Reader::read($body);
83 
84  $this->assertEquals(2, count($vObject->VEVENT));
85 
86  // check if DTSTARTs and DTENDs are correct
87  foreach ($vObject->VEVENT as $vevent) {
89  foreach ($vevent->children() as $child) {
91  if ($child->name == 'DTSTART') {
92  // DTSTART has to be one of two valid values
93  $this->assertContains($child->getValue(), ['20120214T171500Z', '20120216T171500Z'], 'DTSTART is not a valid value: ' . $child->getValue());
94  } elseif ($child->name == 'DTEND') {
95  // DTEND has to be one of two valid values
96  $this->assertContains($child->getValue(), ['20120214T181500Z', '20120216T181500Z'], 'DTEND is not a valid value: ' . $child->getValue());
97  }
98  }
99  }
100  }
101 
102 }
foreach($paths as $path) $request
Definition: asyncclient.php:32
This unittests is created to find out why recurring events have wrong DTSTART value.
$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