Skip to content

Commit 011b7f9

Browse files
committed
Test for bug #78055 (DatePeriod's getRecurrences and ->recurrences don't match)
1 parent 41a6a29 commit 011b7f9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

ext/date/tests/bug78055.phpt

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Bug #78055 (DatePeriod's getRecurrences and ->recurrences don't match)
3+
--FILE--
4+
<?php
5+
$start = new DateTime('2018-12-31 00:00:00');
6+
$end = new DateTime('2021-12-31 00:00:00');
7+
$interval = new DateInterval('P1M');
8+
$recurrences = 5;
9+
10+
$period = new DatePeriod($start, $interval, $recurrences, DatePeriod::EXCLUDE_START_DATE);
11+
echo $period->getRecurrences(), " ", $period->recurrences, "\n";
12+
13+
$period = new DatePeriod($start, $interval, $recurrences);
14+
echo $period->getRecurrences(), " ", $period->recurrences, "\n";
15+
16+
$period = new DatePeriod($start, $interval, $recurrences, DatePeriod::INCLUDE_END_DATE);
17+
echo $period->getRecurrences(), " ", $period->recurrences, "\n";
18+
19+
$period = new DatePeriod($start, $interval, $end);
20+
echo $period->getRecurrences(), " ", $period->recurrences, "\n";
21+
22+
$period = new DatePeriod($start, $interval, $end, DatePeriod::EXCLUDE_START_DATE);
23+
echo $period->getRecurrences(), " ", $period->recurrences, "\n";
24+
?>
25+
--EXPECT--
26+
5 5
27+
5 6
28+
5 7
29+
1
30+
0

0 commit comments

Comments
 (0)