1<?php 2 3namespace Sabre\VObject\Recur; 4 5use DateTime; 6use Sabre\VObject\Reader; 7 8class BySetPosHangTest extends \PHPUnit_Framework_TestCase { 9 10 /** 11 * Using this iCalendar object, including BYSETPOS=-2 causes the iterator 12 * to hang, as reported in ticket #212. 13 * 14 * See: https://github.com/fruux/sabre-vobject/issues/212 15 */ 16 function testExpand() { 17 18 $ics = <<<ICS 19BEGIN:VCALENDAR 20VERSION:2.0 21PRODID:-//Sabre//Sabre VObject 3.4.2//EN 22CALSCALE:GREGORIAN 23BEGIN:VEVENT 24SUMMARY:Test event 1 25DTSTART;TZID=Europe/Copenhagen:20150101T170000 26RRULE:FREQ=MONTHLY;BYDAY=TH;BYSETPOS=-2 27UID:b4071499-6fe4-418a-83b8-2b8d5ebb38e4 28END:VEVENT 29END:VCALENDAR 30ICS; 31 32 $vcal = Reader::read($ics); 33 $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); 34 35 $vcal = $vcal->expand(new DateTime('2015-01-01'), new DateTime('2016-01-01')); 36 37 foreach ($vcal->VEVENT as $event) { 38 $dates[] = $event->DTSTART->getValue(); 39 } 40 41 $expectedDates = [ 42 "20150101T160000Z", 43 "20150122T160000Z", 44 "20150219T160000Z", 45 "20150319T160000Z", 46 "20150423T150000Z", 47 "20150521T150000Z", 48 "20150618T150000Z", 49 "20150723T150000Z", 50 "20150820T150000Z", 51 "20150917T150000Z", 52 "20151022T150000Z", 53 "20151119T160000Z", 54 "20151224T160000Z", 55 ]; 56 57 $this->assertEquals($expectedDates, $dates); 58 } 59 60} 61