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