diff --git a/tests/LocalDateRangeTest.php b/tests/LocalDateRangeTest.php index 20ac064..541f1d6 100644 --- a/tests/LocalDateRangeTest.php +++ b/tests/LocalDateRangeTest.php @@ -151,17 +151,28 @@ public function providerContains() : array public function testIterator() { - $start = LocalDate::of(2013, 12, 30); - $end = LocalDate::of(2014, 1, 2); + $start = LocalDate::of(2013, 12, 29); + $end = LocalDate::of(2014, 1, 3); $range = LocalDateRange::of($start, $end); + $expected = [ + '2013-12-29', + '2013-12-30', + '2013-12-31', + '2014-01-01', + '2014-01-02', + '2014-01-03' + ]; + for ($i = 0; $i < 2; $i++) { // Test twice to test iterator rewind - $expected = $start; + $actual = []; + foreach ($range as $date) { - $this->assertTrue($date->isEqualTo($expected)); - $expected = $expected->plusDays(1); + $actual[] = (string) $date; } + + $this->assertSame($expected, $actual); } } diff --git a/tests/YearMonthRangeTest.php b/tests/YearMonthRangeTest.php index 1b57d7d..f546f33 100644 --- a/tests/YearMonthRangeTest.php +++ b/tests/YearMonthRangeTest.php @@ -149,12 +149,23 @@ public function testIterator() $range = YearMonthRange::of($start, $end); + $expected = [ + '2013-10', + '2013-11', + '2013-12', + '2014-01', + '2014-02', + '2014-03' + ]; + for ($i = 0; $i < 2; $i++) { // Test twice to test iterator rewind - $expected = $start; + $actual = []; + foreach ($range as $yearMonth) { - $this->assertTrue($yearMonth->isEqualTo($expected)); - $expected = $expected->plusMonths(1); + $actual[] = (string) $yearMonth; } + + $this->assertSame($expected, $actual); } }