xref: /PHP-5.6/ext/date/tests/bug52808.phpt (revision 0f9cf353)
1--TEST--
2Bug #52808 (Segfault when specifying interval as two dates)
3--FILE--
4<?php
5date_default_timezone_set('Europe/Oslo');
6$intervals = array(
7	"2008-05-11T15:30:00Z/2007-03-01T13:00:00Z",
8	"2007-05-11T15:30:00Z/2008-03-01T13:00:00Z",
9	"2007-05-11T15:30:00Z 2008-03-01T13:00:00Z",
10	"2007-05-11T15:30:00Z/",
11	"2007-05-11T15:30:00Z",
12	"2007-05-11T15:30:00Z/:00Z",
13);
14foreach($intervals as $iv) {
15    try
16    {
17    	$di = new DateInterval($iv);
18    	var_dump($di);
19    }
20    catch ( Exception $e )
21    {
22    	echo $e->getMessage(), "\n";
23    }
24}
25echo "==DONE==\n";
26?>
27--EXPECTF--
28object(DateInterval)#%d (15) {
29  ["y"]=>
30  int(1)
31  ["m"]=>
32  int(2)
33  ["d"]=>
34  int(10)
35  ["h"]=>
36  int(2)
37  ["i"]=>
38  int(30)
39  ["s"]=>
40  int(0)
41  ["weekday"]=>
42  int(0)
43  ["weekday_behavior"]=>
44  int(0)
45  ["first_last_day_of"]=>
46  int(0)
47  ["invert"]=>
48  int(1)
49  ["days"]=>
50  int(437)
51  ["special_type"]=>
52  int(0)
53  ["special_amount"]=>
54  int(0)
55  ["have_weekday_relative"]=>
56  int(0)
57  ["have_special_relative"]=>
58  int(0)
59}
60object(DateInterval)#%d (15) {
61  ["y"]=>
62  int(0)
63  ["m"]=>
64  int(9)
65  ["d"]=>
66  int(18)
67  ["h"]=>
68  int(21)
69  ["i"]=>
70  int(30)
71  ["s"]=>
72  int(0)
73  ["weekday"]=>
74  int(0)
75  ["weekday_behavior"]=>
76  int(0)
77  ["first_last_day_of"]=>
78  int(0)
79  ["invert"]=>
80  int(0)
81  ["days"]=>
82  int(294)
83  ["special_type"]=>
84  int(0)
85  ["special_amount"]=>
86  int(0)
87  ["have_weekday_relative"]=>
88  int(0)
89  ["have_special_relative"]=>
90  int(0)
91}
92object(DateInterval)#%d (15) {
93  ["y"]=>
94  int(0)
95  ["m"]=>
96  int(9)
97  ["d"]=>
98  int(18)
99  ["h"]=>
100  int(21)
101  ["i"]=>
102  int(30)
103  ["s"]=>
104  int(0)
105  ["weekday"]=>
106  int(0)
107  ["weekday_behavior"]=>
108  int(0)
109  ["first_last_day_of"]=>
110  int(0)
111  ["invert"]=>
112  int(0)
113  ["days"]=>
114  int(294)
115  ["special_type"]=>
116  int(0)
117  ["special_amount"]=>
118  int(0)
119  ["have_weekday_relative"]=>
120  int(0)
121  ["have_special_relative"]=>
122  int(0)
123}
124DateInterval::__construct(): Failed to parse interval (2007-05-11T15:30:00Z/)
125DateInterval::__construct(): Failed to parse interval (2007-05-11T15:30:00Z)
126DateInterval::__construct(): Unknown or bad format (2007-05-11T15:30:00Z/:00Z)
127==DONE==
128