FifthTuesdayProblemTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Sabre\VObject\Recur\EventIterator;
  3. use Sabre\VObject\Recur;
  4. use Sabre\VObject\Reader;
  5. class FifthTuesdayProblemTest extends \PHPUnit_Framework_TestCase {
  6. /**
  7. * A pretty slow test. Had to be marked as 'medium' for phpunit to not die
  8. * after 1 second. Would be good to optimize later.
  9. *
  10. * @medium
  11. */
  12. function testGetDTEnd() {
  13. $ics = <<<ICS
  14. BEGIN:VCALENDAR
  15. VERSION:2.0
  16. PRODID:-//Apple Inc.//iCal 4.0.4//EN
  17. CALSCALE:GREGORIAN
  18. BEGIN:VEVENT
  19. TRANSP:OPAQUE
  20. DTEND;TZID=America/New_York:20070925T170000
  21. UID:uuid
  22. DTSTAMP:19700101T000000Z
  23. LOCATION:
  24. DESCRIPTION:
  25. STATUS:CONFIRMED
  26. SEQUENCE:18
  27. SUMMARY:Stuff
  28. DTSTART;TZID=America/New_York:20070925T160000
  29. CREATED:20071004T144642Z
  30. RRULE:FREQ=MONTHLY;INTERVAL=1;UNTIL=20071030T035959Z;BYDAY=5TU
  31. END:VEVENT
  32. END:VCALENDAR
  33. ICS;
  34. $vObject = Reader::read($ics);
  35. $it = new Recur\EventIterator($vObject, (string)$vObject->VEVENT->UID);
  36. while($it->valid()) {
  37. $it->next();
  38. }
  39. // If we got here, it means we were successful. The bug that was in the
  40. // system before would fail on the 5th tuesday of the month, if the 5th
  41. // tuesday did not exist.
  42. $this->assertTrue(true);
  43. }
  44. }