diff --git a/tests/Recurr/Test/RecurrenceRuleTransformerTest.php b/tests/Recurr/Test/RecurrenceRuleTransformerTest.php index 579e6ee..5fb7f73 100644 --- a/tests/Recurr/Test/RecurrenceRuleTransformerTest.php +++ b/tests/Recurr/Test/RecurrenceRuleTransformerTest.php @@ -205,6 +205,50 @@ class RecurrenceRuleTransformerTest extends \PHPUnit_Framework_TestCase $this->assertEquals(new \DateTime('2014-02-13 00:00:00', $timezoneObj), $computed[4]); } + public function testWeeklyIntervalLeapYear() + { + $timezone = 'America/New_York'; + $timezoneObj = new \DateTimeZone($timezone); + + $rule = new RecurrenceRule( + 'FREQ=WEEKLY;COUNT=7;INTERVAL=2', + new \DateTime('2015-12-21 00:00:00', $timezoneObj), + $timezone + ); + + $this->transformer->setRule($rule); + $computed = $this->transformer->getComputedArray(); + + $this->assertEquals(7, count($computed)); + $this->assertEquals(new \DateTime('2015-12-21 00:00:00', $timezoneObj), $computed[0]); + $this->assertEquals(new \DateTime('2016-01-04 00:00:00', $timezoneObj), $computed[1]); + $this->assertEquals(new \DateTime('2016-01-18 00:00:00', $timezoneObj), $computed[2]); + $this->assertEquals(new \DateTime('2016-02-01 00:00:00', $timezoneObj), $computed[3]); + $this->assertEquals(new \DateTime('2016-02-15 00:00:00', $timezoneObj), $computed[4]); + $this->assertEquals(new \DateTime('2016-02-29 00:00:00', $timezoneObj), $computed[5]); + $this->assertEquals(new \DateTime('2016-03-14 00:00:00', $timezoneObj), $computed[6]); + } + + public function testWeeklyIntervalHittingJan1() + { + $timezone = 'America/New_York'; + $timezoneObj = new \DateTimeZone($timezone); + + $rule = new RecurrenceRule( + 'FREQ=WEEKLY;COUNT=3;INTERVAL=2', + new \DateTime('2013-12-18 00:00:00', $timezoneObj), + $timezone + ); + + $this->transformer->setRule($rule); + $computed = $this->transformer->getComputedArray(); + + $this->assertEquals(3, count($computed)); + $this->assertEquals(new \DateTime('2013-12-18 00:00:00', $timezoneObj), $computed[0]); + $this->assertEquals(new \DateTime('2014-01-01 00:00:00', $timezoneObj), $computed[1]); + $this->assertEquals(new \DateTime('2014-01-15 00:00:00', $timezoneObj), $computed[2]); + } + public function testMonthly() { $timezone = 'America/New_York';