some tests for cache

master
Tanguy Pruvot 2010-10-31 00:23:00 +02:00
rodzic 1a63569868
commit d1561547d8
1 zmienionych plików z 13 dodań i 6 usunięć

Wyświetl plik

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