xref: /PHP-8.4/ext/date/tests/gh14709.phpt (revision 16c0e575)
1--TEST--
2Bug GH-14709 overflow on reccurences parameter
3--FILE--
4<?php
5$start = new DateTime('2018-12-31 00:00:00');
6$interval = new DateInterval('P1M');
7
8try {
9	new DatePeriod($start, $interval, 2147483640);
10} catch (Exception $e) {
11	echo $e::class, ': ', $e->getMessage(), PHP_EOL;
12}
13
14try {
15	new DatePeriod($start, $interval, 2147483639, DatePeriod::EXCLUDE_START_DATE | DatePeriod::INCLUDE_END_DATE);
16} catch (Exception $e) {
17	echo $e::class, ': ', $e->getMessage(), PHP_EOL;
18}
19?>
20--EXPECTF--
21DateMalformedPeriodStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
22DateMalformedStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d (including options)
23