diff --git a/generator/tests/DateTimeImmutableTest.php b/generator/tests/DateTimeImmutableTest.php index 3c89a691..ea1ffc6a 100644 --- a/generator/tests/DateTimeImmutableTest.php +++ b/generator/tests/DateTimeImmutableTest.php @@ -165,4 +165,23 @@ public function testEquals(): void $this->assertEquals($phpDateTime, $safeDateTime2); $this->assertEquals($safeDateTime1, $safeDateTime2); } + + public function testDatePeriod(): void + { + $datePeriod = new \DatePeriod(new \Safe\DateTimeImmutable('2020-01-01'), new \DateInterval('P1D'), (new \Safe\DateTimeImmutable('2020-01-03'))->modify('+1 day')); + $this->assertCount(3, $datePeriod); + + $strings = []; + foreach ($datePeriod as $date) { + $strings[] = $date->format('Y-m-d H:i:s'); + } + + $expected = [ + '2020-01-01 00:00:00', + '2020-01-02 00:00:00', + '2020-01-03 00:00:00', + ]; + + $this->assertSame($expected, $strings); + } }