BySetPosHangTest.php 1.5 KB

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