Mercurial > hg > rc1
comparison vendor/sabre/vobject/tests/VObject/Recur/RDateIteratorTest.php @ 7:430dbd5346f7
vendor sabre as distributed
| author | Charlie Root |
|---|---|
| date | Sat, 13 Jan 2018 09:06:10 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 6:cec75ba50afc | 7:430dbd5346f7 |
|---|---|
| 1 <?php | |
| 2 | |
| 3 namespace Sabre\VObject\Recur; | |
| 4 | |
| 5 use DateTime; | |
| 6 use DateTimeZone; | |
| 7 | |
| 8 class 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 } |
