From 8a72cd4622aa0f66082f4240eaff1cfec2611fa6 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Mon, 7 Jun 2010 10:17:41 -0400 Subject: [PATCH] Add test for Bug: 8799 --- framework/Date/test/Horde/Date/RecurrenceTest.php | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/framework/Date/test/Horde/Date/RecurrenceTest.php b/framework/Date/test/Horde/Date/RecurrenceTest.php index 4457e807b..e9eaefdd8 100644 --- a/framework/Date/test/Horde/Date/RecurrenceTest.php +++ b/framework/Date/test/Horde/Date/RecurrenceTest.php @@ -275,6 +275,46 @@ class Horde_Date_RecurrenceTest extends PHPUnit_Framework_TestCase $this->_getRecurrences($r)); } + public function testBug8799WeeklyISOWeek52() + { + // Friday, 2010-12-31 is in week 52, but the next recurrence is in + // the NEW year (2011). + $r = new Horde_Date_Recurrence('2010-06-04 10:00:00'); + $r->setRecurType(Horde_Date_Recurrence::RECUR_WEEKLY); + $r->setRecurOnDay(Horde_Date::MASK_FRIDAY); + $r->setRecurInterval(1); + + $after = new Horde_Date('12/21/2010'); + for ($i = 0; $i <= 5; $i++) { + $after = $r->nextRecurrence($after); + $recurrences[] = (string)$after; + $after->mday++; + } + $this->assertEquals(array('2010-12-24 10:00:00', + '2010-12-31 10:00:00', + '2011-01-07 10:00:00', + '2011-01-14 10:00:00', + '2011-01-21 10:00:00', + '2011-01-28 10:00:00'), + $recurrences); + + // The entire first week of Jan, 2012 is ISO Week 52 + $after = new Horde_Date('01/01/2012'); + $recurrences = array(); + for ($i = 0; $i <= 5; $i++) { + $after = $r->nextRecurrence($after); + $recurrences[] = (string)$after; + $after->mday++; + } + $this->assertEquals(array('2012-01-06 10:00:00', + '2012-01-13 10:00:00', + '2012-01-20 10:00:00', + '2012-01-27 10:00:00', + '2012-02-03 10:00:00', + '2012-02-10 10:00:00'), + $recurrences); + } + public function testMonthlyEnd() { $r = new Horde_Date_Recurrence('2007-03-01 10:00:00'); -- 2.11.0