ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
HandleRDateExpandTest.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use DateTime;
7 use DateTimeZone;
10 
14 class HandleRDateExpandTest extends TestCase {
15 
16  function testExpand() {
17 
18  $input = <<<ICS
19 BEGIN:VCALENDAR
20 VERSION:2.0
21 BEGIN:VEVENT
22 UID:2CD5887F7CF4600F7A3B1F8065099E40-240BDA7121B61224
23 DTSTAMP;VALUE=DATE-TIME:20151014T110604Z
24 CREATED;VALUE=DATE-TIME:20151014T110245Z
25 LAST-MODIFIED;VALUE=DATE-TIME:20151014T110541Z
26 DTSTART;VALUE=DATE-TIME;TZID=Europe/Berlin:20151012T020000
27 DTEND;VALUE=DATE-TIME;TZID=Europe/Berlin:20151012T013000
28 SUMMARY:Test
29 SEQUENCE:2
30 RDATE;VALUE=DATE-TIME;TZID=Europe/Berlin:20151015T020000,20151017T020000,20
31  151018T020000,20151020T020000
32 TRANSP:OPAQUE
33 CLASS:PUBLIC
34 END:VEVENT
35 END:VCALENDAR
36 ICS;
37 
39  $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal);
40 
41  $vcal = $vcal->expand(new DateTime('2015-01-01'), new DateTime('2015-12-01'));
42 
43  $result = iterator_to_array($vcal->VEVENT);
44 
45  $this->assertEquals(5, count($result));
46 
47  $utc = new DateTimeZone('UTC');
48  $expected = [
49  new DateTimeImmutable("2015-10-12", $utc),
50  new DateTimeImmutable("2015-10-15", $utc),
51  new DateTimeImmutable("2015-10-17", $utc),
52  new DateTimeImmutable("2015-10-18", $utc),
53  new DateTimeImmutable("2015-10-20", $utc),
54  ];
55 
56  $result = array_map(function($ev) {return $ev->DTSTART->getDateTime();}, $result);
57  $this->assertEquals($expected, $result);
58 
59  }
60 
61 }
$result
if($argc< 3) $input
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42