ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
HandleRDateExpandTest.php
Go to the documentation of this file.
1<?php
2
4
5use DateTime;
6use DateTimeImmutable;
7use DateTimeZone;
8use PHPUnit\Framework\TestCase;
10
14class HandleRDateExpandTest extends TestCase {
15
16 function testExpand() {
17
18 $input = <<<ICS
19BEGIN:VCALENDAR
20VERSION:2.0
21BEGIN:VEVENT
22UID:2CD5887F7CF4600F7A3B1F8065099E40-240BDA7121B61224
23DTSTAMP;VALUE=DATE-TIME:20151014T110604Z
24CREATED;VALUE=DATE-TIME:20151014T110245Z
25LAST-MODIFIED;VALUE=DATE-TIME:20151014T110541Z
26DTSTART;VALUE=DATE-TIME;TZID=Europe/Berlin:20151012T020000
27DTEND;VALUE=DATE-TIME;TZID=Europe/Berlin:20151012T013000
28SUMMARY:Test
29SEQUENCE:2
30RDATE;VALUE=DATE-TIME;TZID=Europe/Berlin:20151015T020000,20151017T020000,20
31 151018T020000,20151020T020000
32TRANSP:OPAQUE
33CLASS:PUBLIC
34END:VEVENT
35END:VCALENDAR
36ICS;
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
An exception for terminatinating execution or to throw for unit testing.
iCalendar/vCard/jCal/jCard/xCal/xCard reader object.
Definition: Reader.php:15
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
foreach($paths as $path) if($argc< 3) $input