Created
March 4, 2014 10:58
-
-
Save fatgy/9344330 to your computer and use it in GitHub Desktop.
Test three month for php recurrent rule https://github.com/simshaun/recurr/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function testThreeMonths() | |
{ | |
$timezone = 'Asia/Bangkok'; | |
$timezoneObj = new \DateTimeZone($timezone); | |
/* *\/ | |
$rule = new RecurrenceRule( | |
'FREQ=MONTHLY;COUNT=5;INTERVAL=3', | |
new \DateTime('2013-06-13 00:00:00', $timezoneObj), | |
$timezone | |
); | |
/* */ | |
/* *\/ | |
$rule = new RecurrenceRule( | |
'FREQ=MONTHLY;INTERVAL=3', | |
new \DateTime('2013-06-13 00:00:00', $timezoneObj), | |
$timezone | |
); | |
$rule->setUntil(new \DateTime('2014-06-13 00:00:00', $timezoneObj)); | |
/* */ | |
$rule = new RecurrenceRule( | |
'FREQ=MONTHLY;UNTIL=20140613;INTERVAL=3', | |
new \DateTime('2013-06-13', $timezoneObj), | |
$timezone | |
); | |
$this->transformer->setRule($rule); | |
$computed = $this->transformer->getComputedArray(); | |
$this->assertEquals(5, count($computed)); | |
$this->assertEquals(new \DateTime('2013-06-13 00:00:00', $timezoneObj), $computed[0]); | |
$this->assertEquals(new \DateTime('2013-09-13 00:00:00', $timezoneObj), $computed[1]); | |
$this->assertEquals(new \DateTime('2013-12-13 00:00:00', $timezoneObj), $computed[2]); | |
$this->assertEquals(new \DateTime('2014-03-13 00:00:00', $timezoneObj), $computed[3]); | |
$this->assertEquals(new \DateTime('2014-06-13 00:00:00', $timezoneObj), $computed[4]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment