1<?php
2
3namespace Sabre\VObject\Recur;
4
5use DateTime;
6use Sabre\VObject\Reader;
7
8class ByMonthInDailyTest extends \PHPUnit_Framework_TestCase {
9
10    /**
11     * This tests the expansion of dates with DAILY frequency in RRULE with BYMONTH restrictions
12     */
13    function testExpand() {
14
15        $ics = <<<ICS
16BEGIN:VCALENDAR
17VERSION:2.0
18PRODID:-//Apple Inc.//iCal 4.0.4//EN
19CALSCALE:GREGORIAN
20BEGIN:VEVENT
21TRANSP:OPAQUE
22DTEND:20070925T183000Z
23UID:uuid
24DTSTAMP:19700101T000000Z
25LOCATION:
26DESCRIPTION:
27STATUS:CONFIRMED
28SEQUENCE:18
29SUMMARY:Stuff
30DTSTART:20070925T160000Z
31CREATED:20071004T144642Z
32RRULE:FREQ=DAILY;BYMONTH=9,10;BYDAY=SU
33END:VEVENT
34END:VCALENDAR
35ICS;
36
37        $vcal = Reader::read($ics);
38        $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal);
39
40        $vcal = $vcal->expand(new DateTime('2013-09-28'), new DateTime('2014-09-11'));
41
42        foreach ($vcal->VEVENT as $event) {
43            $dates[] = $event->DTSTART->getValue();
44        }
45
46        $expectedDates = [
47            "20130929T160000Z",
48            "20131006T160000Z",
49            "20131013T160000Z",
50            "20131020T160000Z",
51            "20131027T160000Z",
52            "20140907T160000Z"
53        ];
54
55        $this->assertEquals($expectedDates, $dates, 'Recursed dates are restricted by month');
56    }
57
58}
59