1<?php
2
3namespace Sabre\VObject;
4
5use
6    DateTime,
7    DateTimeZone;
8
9/**
10 * This is a unittest for Issue #53.
11 */
12class RecurrenceIteratorIncorrectExpandTest extends \PHPUnit_Framework_TestCase {
13
14    function testExpand() {
15
16        $input = <<<ICS
17BEGIN:VCALENDAR
18VERSION:2.0
19BEGIN:VEVENT
20UID:foo
21DTSTART:20130711T050000Z
22DTEND:20130711T053000Z
23RRULE:FREQ=DAILY;INTERVAL=1;COUNT=2
24END:VEVENT
25BEGIN:VEVENT
26UID:foo
27DTSTART:20130719T050000Z
28DTEND:20130719T053000Z
29RECURRENCE-ID:20130712T050000Z
30END:VEVENT
31END:VCALENDAR
32ICS;
33
34        $vcal = Reader::read($input);
35        $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal);
36
37        $vcal->expand(new DateTime('2011-01-01'), new DateTime('2014-01-01'));
38
39        $result = $vcal->serialize();
40
41        $output = <<<ICS
42BEGIN:VCALENDAR
43VERSION:2.0
44BEGIN:VEVENT
45UID:foo
46DTSTART:20130711T050000Z
47DTEND:20130711T053000Z
48END:VEVENT
49BEGIN:VEVENT
50UID:foo
51DTSTART:20130719T050000Z
52DTEND:20130719T053000Z
53RECURRENCE-ID:20130712T050000Z
54END:VEVENT
55END:VCALENDAR
56
57ICS;
58        $this->assertEquals($output, str_replace("\r", "", $result));
59
60    }
61
62}
63