Add more unit tests for weekly interval

This commit is contained in:
Shaun Simmons 2014-01-06 19:59:50 -05:00
parent 70855859d4
commit fca792acd3

View File

@ -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';