From 8d54335802e3c3de225bc9d0a661641ed94c82ce Mon Sep 17 00:00:00 2001 From: rlanvin Date: Fri, 6 Jan 2017 16:42:00 +0200 Subject: [PATCH] Add tests --- CHANGELOG.md | 2 +- tests/RRuleTest.php | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f9fee5..86c3c8f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,7 +63,7 @@ ### Fixed - Fix bug preventing the iteration of multiple instances of RRule at the same time -- Fix occursAt failing when the date passed was a different timezone [#8](https://github.com/rlanvin/php-rrule/pull/8) +- Fix `occursAt` failing when the date passed was a different timezone [#8](https://github.com/rlanvin/php-rrule/pull/8) - Fix bug at WEEKLY frequency with a partially filled cache in some circumstances - Fix various reference bugs causing corruption of the cache in some circumstances (related to DateTime object being mutable) diff --git a/tests/RRuleTest.php b/tests/RRuleTest.php index 7529615..f76f15f 100755 --- a/tests/RRuleTest.php +++ b/tests/RRuleTest.php @@ -2164,10 +2164,24 @@ class RRuleTest extends PHPUnit_Framework_TestCase public function testGetRule() { $array = array( - 'FREQ' => 'YEARLY' + 'FREQ' => 'YEARLY', + 'DTSTART' => '2016-01-01' ); $rrule = new RRule($array); $this->assertInternalType('array', $rrule->getRule()); + $rule = $rrule->getRule(); + $this->assertEquals('YEARLY', $rule['FREQ']); + $this->assertInternalType('string', $rule['DTSTART']); + + $rrule = new RRule("DTSTART;TZID=America/New_York:19970901T090000\nRRULE:FREQ=HOURLY;UNTIL=19971224T000000Z;WKST=SU;BYDAY=MO,WE,FR;BYMONTH=1;BYHOUR=1"); + $rule = $rrule->getRule(); + $this->assertEquals('HOURLY', $rule['FREQ']); + $this->assertTrue($rule['DTSTART'] instanceof \DateTime); + + $rrule = new RRule("DTSTART:19970901\nRRULE:FREQ=DAILY;UNTIL=19971224;WKST=SU;BYDAY=MO,WE,FR;BYMONTH=1"); + $rule = $rrule->getRule(); + $this->assertEquals('DAILY', $rule['FREQ']); + $this->assertTrue($rule['DTSTART'] instanceof \DateTime); } ///////////////////////////////////////////////////////////////////////////////