comparison vendor/sabre/vobject/tests/VObject/Recur/EventIterator/OverrideFirstEventTest.php @ 7:430dbd5346f7

vendor sabre as distributed
author Charlie Root
date Sat, 13 Jan 2018 09:06:10 -0500
parents
children
comparison
equal deleted inserted replaced
6:cec75ba50afc 7:430dbd5346f7
1 <?php
2
3 namespace Sabre\VObject\RecurrenceIterator;
4
5 use Sabre\VObject\Reader;
6 use DateTime;
7
8 class OverrideFirstEventTest extends \PHPUnit_Framework_TestCase {
9
10 function testOverrideFirstEvent() {
11
12 $input = <<<ICS
13 BEGIN:VCALENDAR
14 BEGIN:VEVENT
15 UID:foobar
16 DTSTART:20140803T120000Z
17 RRULE:FREQ=WEEKLY
18 SUMMARY:Original
19 END:VEVENT
20 BEGIN:VEVENT
21 UID:foobar
22 RECURRENCE-ID:20140803T120000Z
23 DTSTART:20140803T120000Z
24 SUMMARY:Overridden
25 END:VEVENT
26 END:VCALENDAR
27 ICS;
28
29 $vcal = Reader::read($input);
30 $vcal->expand(new DateTime('2014-08-01'), new DateTime('2014-09-01'));
31
32 $expected = <<<ICS
33 BEGIN:VCALENDAR
34 BEGIN:VEVENT
35 UID:foobar
36 RECURRENCE-ID:20140803T120000Z
37 DTSTART:20140803T120000Z
38 SUMMARY:Overridden
39 END:VEVENT
40 BEGIN:VEVENT
41 UID:foobar
42 DTSTART:20140810T120000Z
43 SUMMARY:Original
44 RECURRENCE-ID:20140810T120000Z
45 END:VEVENT
46 BEGIN:VEVENT
47 UID:foobar
48 DTSTART:20140817T120000Z
49 SUMMARY:Original
50 RECURRENCE-ID:20140817T120000Z
51 END:VEVENT
52 BEGIN:VEVENT
53 UID:foobar
54 DTSTART:20140824T120000Z
55 SUMMARY:Original
56 RECURRENCE-ID:20140824T120000Z
57 END:VEVENT
58 BEGIN:VEVENT
59 UID:foobar
60 DTSTART:20140831T120000Z
61 SUMMARY:Original
62 RECURRENCE-ID:20140831T120000Z
63 END:VEVENT
64 END:VCALENDAR
65
66 ICS;
67
68 $newIcs = $vcal->serialize();
69 $newIcs = str_replace("\r\n","\n", $newIcs);
70 $this->assertEquals(
71 $expected,
72 $newIcs
73 );
74
75
76 }
77
78 function testRemoveFirstEvent() {
79
80 $input = <<<ICS
81 BEGIN:VCALENDAR
82 BEGIN:VEVENT
83 UID:foobar
84 DTSTART:20140803T120000Z
85 RRULE:FREQ=WEEKLY
86 EXDATE:20140803T120000Z
87 SUMMARY:Original
88 END:VEVENT
89 END:VCALENDAR
90 ICS;
91
92 $vcal = Reader::read($input);
93 $vcal->expand(new DateTime('2014-08-01'), new DateTime('2014-08-19'));
94
95 $expected = <<<ICS
96 BEGIN:VCALENDAR
97 BEGIN:VEVENT
98 UID:foobar
99 DTSTART:20140810T120000Z
100 SUMMARY:Original
101 RECURRENCE-ID:20140810T120000Z
102 END:VEVENT
103 BEGIN:VEVENT
104 UID:foobar
105 DTSTART:20140817T120000Z
106 SUMMARY:Original
107 RECURRENCE-ID:20140817T120000Z
108 END:VEVENT
109 END:VCALENDAR
110
111 ICS;
112
113 $newIcs = $vcal->serialize();
114 $newIcs = str_replace("\r\n","\n", $newIcs);
115 $this->assertEquals(
116 $expected,
117 $newIcs
118 );
119
120
121 }
122 }