1<?php 2 3namespace Sabre\VObject\Recur; 4 5use DateTime; 6use DateTimeZone; 7 8class RDateIteratorTest extends \PHPUnit_Framework_TestCase { 9 10 function testSimple() { 11 12 $utc = new DateTimeZone('UTC'); 13 $it = new RDateIterator('20140901T000000Z,20141001T000000Z', new DateTime('2014-08-01 00:00:00', $utc)); 14 15 $expected = array( 16 new DateTime('2014-08-01 00:00:00', $utc), 17 new DateTime('2014-09-01 00:00:00', $utc), 18 new DateTime('2014-10-01 00:00:00', $utc), 19 ); 20 21 $this->assertEquals( 22 $expected, 23 iterator_to_array($it) 24 ); 25 26 $this->assertFalse($it->isInfinite()); 27 28 } 29 30 function testFastForward() { 31 32 $utc = new DateTimeZone('UTC'); 33 $it = new RDateIterator('20140901T000000Z,20141001T000000Z', new DateTime('2014-08-01 00:00:00', $utc)); 34 35 $it->fastForward(new DateTime('2014-08-15 00:00:00')); 36 37 $result = array(); 38 while($it->valid()) { 39 $result[] = $it->current(); 40 $it->next(); 41 } 42 43 $expected = array( 44 new DateTime('2014-09-01 00:00:00', $utc), 45 new DateTime('2014-10-01 00:00:00', $utc), 46 ); 47 48 $this->assertEquals( 49 $expected, 50 $result 51 ); 52 53 $this->assertFalse($it->isInfinite()); 54 55 } 56} 57