ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ExpandFloatingTimesTest.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use DateTime;
6 use DateTimeZone;
9 
10 class ExpandFloatingTimesTest extends TestCase {
11 
12  use \Sabre\VObject\PHPUnitAssertions;
13 
14  function testExpand() {
15 
16  $input = <<<ICS
17 BEGIN:VCALENDAR
18 VERSION:2.0
19 BEGIN:VEVENT
20 UID:foo
21 DTSTART:20150109T090000
22 DTEND:20150109T100000
23 RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20191002T070000Z;BYDAY=FR
24 END:VEVENT
25 END:VCALENDAR
26 ICS;
27 
29  $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal);
30 
31  $vcal = $vcal->expand(new DateTime('2015-01-01'), new DateTime('2015-01-31'));
32  $output = <<<ICS
33 BEGIN:VCALENDAR
34 VERSION:2.0
35 BEGIN:VEVENT
36 UID:foo
37 DTSTART:20150109T090000Z
38 DTEND:20150109T100000Z
39 RECURRENCE-ID:20150109T090000Z
40 END:VEVENT
41 BEGIN:VEVENT
42 UID:foo
43 DTSTART:20150116T090000Z
44 DTEND:20150116T100000Z
45 RECURRENCE-ID:20150116T090000Z
46 END:VEVENT
47 BEGIN:VEVENT
48 UID:foo
49 DTSTART:20150123T090000Z
50 DTEND:20150123T100000Z
51 RECURRENCE-ID:20150123T090000Z
52 END:VEVENT
53 BEGIN:VEVENT
54 UID:foo
55 DTSTART:20150130T090000Z
56 DTEND:20150130T100000Z
57 RECURRENCE-ID:20150130T090000Z
58 END:VEVENT
59 END:VCALENDAR
60 
61 ICS;
62  $this->assertVObjectEqualsVObject($output, $vcal);
63 
64  }
65 
67 
68  $input = <<<ICS
69 BEGIN:VCALENDAR
70 VERSION:2.0
71 BEGIN:VEVENT
72 UID:foo
73 DTSTART:20150109T090000
74 DTEND:20150109T100000
75 RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20191002T070000Z;BYDAY=FR
76 END:VEVENT
77 END:VCALENDAR
78 ICS;
79 
81  $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal);
82 
83  $vcal = $vcal->expand(
84  new DateTime('2015-01-01'),
85  new DateTime('2015-01-31'),
86  new DateTimeZone('Europe/Berlin')
87  );
88 
89  $output = <<<ICS
90 BEGIN:VCALENDAR
91 VERSION:2.0
92 BEGIN:VEVENT
93 UID:foo
94 DTSTART:20150109T080000Z
95 DTEND:20150109T090000Z
96 RECURRENCE-ID:20150109T080000Z
97 END:VEVENT
98 BEGIN:VEVENT
99 UID:foo
100 DTSTART:20150116T080000Z
101 DTEND:20150116T090000Z
102 RECURRENCE-ID:20150116T080000Z
103 END:VEVENT
104 BEGIN:VEVENT
105 UID:foo
106 DTSTART:20150123T080000Z
107 DTEND:20150123T090000Z
108 RECURRENCE-ID:20150123T080000Z
109 END:VEVENT
110 BEGIN:VEVENT
111 UID:foo
112 DTSTART:20150130T080000Z
113 DTEND:20150130T090000Z
114 RECURRENCE-ID:20150130T080000Z
115 END:VEVENT
116 END:VCALENDAR
117 
118 ICS;
119  $this->assertVObjectEqualsVObject($output, $vcal);
120 
121  }
122 
123 }
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