From d1561547d89fda59e7f35c22696a62e36a7cf4e7 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 31 Oct 2010 00:23:00 +0200 Subject: [PATCH] some tests for cache --- tests/helpers/FreqTest.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/helpers/FreqTest.php b/tests/helpers/FreqTest.php index 9cea3b9..7d82505 100755 --- a/tests/helpers/FreqTest.php +++ b/tests/helpers/FreqTest.php @@ -605,16 +605,14 @@ class FreqTest extends PHPUnit_Framework_TestCase { } } - - //weird : in this test $start is not an occurrence ! - /* - public function testFirstOccurrenceByYearDay() { + //weird : in this test $start is not a matched occurrence but... + public function testFirstOccurrencesByYearDay() { $rule = 'FREQ=YEARLY;INTERVAL=2;BYYEARDAY=1;COUNT=5'; $start = strtotime('2009-10-27T090000'); $freq = new SG_iCal_Freq($rule, $start); - $this->assertEquals(strtotime('2011-01-01T09:00:00'), $freq->firstOccurrence()); + $this->assertEquals(strtotime('2009-10-27T09:00:00'), $freq->firstOccurrence()); + $this->assertEquals(strtotime('2011-01-01T09:00:00'), $freq->nextOccurrence($start)); } - */ public function testLastOccurrenceByYearDay() { $rule = 'FREQ=YEARLY;INTERVAL=2;BYYEARDAY=1;COUNT=5'; @@ -623,6 +621,15 @@ class FreqTest extends PHPUnit_Framework_TestCase { $this->assertEquals(strtotime('2019-01-01T09:00:00'), $freq->lastOccurrence()); } + public function testCacheCount() { + $rule = 'FREQ=YEARLY;INTERVAL=2;BYYEARDAY=1;COUNT=5'; + $start = strtotime('2011-01-01T090000'); + $freq = new SG_iCal_Freq($rule, $start); + $this->assertEquals(5, count($freq->getAllOccurrences())); + $this->assertEquals(5, count($freq->getAllOccurrences())); + $this->assertEquals(strtotime('2019-01-01T09:00:00'), $freq->lastOccurrence()); + } + // TODO: WKST rule