ByMonthInDailyTest.php 1.3 KB

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