Page MenuHomePhabricator

RDateIteratorTest.php
No OneTemporary

RDateIteratorTest.php

<?php
namespace Sabre\VObject\Recur;
use DateTime;
use DateTimeZone;
class RDateIteratorTest extends \PHPUnit_Framework_TestCase {
function testSimple() {
$utc = new DateTimeZone('UTC');
$it = new RDateIterator('20140901T000000Z,20141001T000000Z', new DateTime('2014-08-01 00:00:00', $utc));
$expected = array(
new DateTime('2014-08-01 00:00:00', $utc),
new DateTime('2014-09-01 00:00:00', $utc),
new DateTime('2014-10-01 00:00:00', $utc),
);
$this->assertEquals(
$expected,
iterator_to_array($it)
);
$this->assertFalse($it->isInfinite());
}
function testFastForward() {
$utc = new DateTimeZone('UTC');
$it = new RDateIterator('20140901T000000Z,20141001T000000Z', new DateTime('2014-08-01 00:00:00', $utc));
$it->fastForward(new DateTime('2014-08-15 00:00:00'));
$result = array();
while($it->valid()) {
$result[] = $it->current();
$it->next();
}
$expected = array(
new DateTime('2014-09-01 00:00:00', $utc),
new DateTime('2014-10-01 00:00:00', $utc),
);
$this->assertEquals(
$expected,
$result
);
$this->assertFalse($it->isInfinite());
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, Dec 23, 12:48 AM (1 d, 18 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
916613
Default Alt Text
RDateIteratorTest.php (1 KB)

Event Timeline