xref: /PHP-7.1/ext/date/tests/bug44562.phpt (revision 7af945e2)
1--TEST--
2Bug #44562 (Creating instance of DatePeriod crashes)
3--FILE--
4<?php
5date_default_timezone_set('Europe/Oslo');
6
7try
8{
9	$dp = new DatePeriod('2D');
10}
11catch ( Exception $e )
12{
13	echo $e->getMessage(), "\n";
14}
15
16$begin = new DateTime( "2008-07-20T22:44:53+0200" );
17$interval = DateInterval::createFromDateString( "1 day" );
18
19$dp = new DatePeriod( $begin, $interval, 10 );
20foreach ( $dp as $d )
21{
22	var_dump ($d->format( DATE_ISO8601 ) );
23}
24
25?>
26--EXPECT--
27DatePeriod::__construct(): Unknown or bad format (2D)
28string(24) "2008-07-20T22:44:53+0200"
29string(24) "2008-07-21T22:44:53+0200"
30string(24) "2008-07-22T22:44:53+0200"
31string(24) "2008-07-23T22:44:53+0200"
32string(24) "2008-07-24T22:44:53+0200"
33string(24) "2008-07-25T22:44:53+0200"
34string(24) "2008-07-26T22:44:53+0200"
35string(24) "2008-07-27T22:44:53+0200"
36string(24) "2008-07-28T22:44:53+0200"
37string(24) "2008-07-29T22:44:53+0200"
38string(24) "2008-07-30T22:44:53+0200"
39