ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
RDateIteratorTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\VObject\Recur;
4 
6 use DateTimeZone;
8 
9 class RDateIteratorTest extends TestCase {
10 
11  function testSimple() {
12 
13  $utc = new DateTimeZone('UTC');
14  $it = new RDateIterator('20140901T000000Z,20141001T000000Z', new DateTimeImmutable('2014-08-01 00:00:00', $utc));
15 
16  $expected = [
17  new DateTimeImmutable('2014-08-01 00:00:00', $utc),
18  new DateTimeImmutable('2014-09-01 00:00:00', $utc),
19  new DateTimeImmutable('2014-10-01 00:00:00', $utc),
20  ];
21 
22  $this->assertEquals(
23  $expected,
24  iterator_to_array($it)
25  );
26 
27  $this->assertFalse($it->isInfinite());
28 
29  }
30 
31  function testTimezone() {
32 
33  $tz = new DateTimeZone('Europe/Berlin');
34  $it = new RDateIterator('20140901T000000,20141001T000000', new DateTimeImmutable('2014-08-01 00:00:00', $tz));
35 
36  $expected = [
37  new DateTimeImmutable('2014-08-01 00:00:00', $tz),
38  new DateTimeImmutable('2014-09-01 00:00:00', $tz),
39  new DateTimeImmutable('2014-10-01 00:00:00', $tz),
40  ];
41 
42  $this->assertEquals(
43  $expected,
44  iterator_to_array($it)
45  );
46 
47 
48  $this->assertFalse($it->isInfinite());
49 
50  }
51 
52 
53  function testFastForward() {
54 
55  $utc = new DateTimeZone('UTC');
56  $it = new RDateIterator('20140901T000000Z,20141001T000000Z', new DateTimeImmutable('2014-08-01 00:00:00', $utc));
57 
58  $it->fastForward(new DateTimeImmutable('2014-08-15 00:00:00'));
59 
60  $result = [];
61  while ($it->valid()) {
62  $result[] = $it->current();
63  $it->next();
64  }
65 
66  $expected = [
67  new DateTimeImmutable('2014-09-01 00:00:00', $utc),
68  new DateTimeImmutable('2014-10-01 00:00:00', $utc),
69  ];
70 
71  $this->assertEquals(
72  $expected,
73  $result
74  );
75 
76  $this->assertFalse($it->isInfinite());
77 
78  }
79 }
$result