Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Date Period Iteration #227

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions generator/tests/DateTimeImmutableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}