1--TEST--
2Test clone of DateTime objects
3--FILE--
4<?php
5//Set the default time zone
6date_default_timezone_set("Europe/London");
7
8echo "*** Testing clone on DateTime objects ***\n";
9
10echo "\n-- Create a DateTime object --\n";
11$d1 = new DateTime("2009-02-03 12:34:41 GMT");
12var_dump($d1);
13echo "\n-- Add some properties --\n";
14$d1->property1 = 99;
15$d1->property2 = "Hello";
16var_dump($d1);
17echo "\n-- clone it --\n";
18$d1_clone = clone $d1;
19var_dump($d1_clone);
20echo "\n-- Add some more properties --\n";
21$d1_clone->property3 = true;
22$d1_clone->property4 = 10.5;
23var_dump($d1_clone);
24echo "\n-- clone it --\n";
25$d2_clone = clone $d1_clone;
26var_dump($d2_clone);
27?>
28--EXPECTF--
29*** Testing clone on DateTime objects ***
30
31-- Create a DateTime object --
32object(DateTime)#%d (3) {
33  ["date"]=>
34  string(26) "2009-02-03 12:34:41.000000"
35  ["timezone_type"]=>
36  int(2)
37  ["timezone"]=>
38  string(3) "GMT"
39}
40
41-- Add some properties --
42object(DateTime)#%d (5) {
43  ["property1"]=>
44  int(99)
45  ["property2"]=>
46  string(5) "Hello"
47  ["date"]=>
48  string(26) "2009-02-03 12:34:41.000000"
49  ["timezone_type"]=>
50  int(2)
51  ["timezone"]=>
52  string(3) "GMT"
53}
54
55-- clone it --
56object(DateTime)#%d (5) {
57  ["property1"]=>
58  int(99)
59  ["property2"]=>
60  string(5) "Hello"
61  ["date"]=>
62  string(26) "2009-02-03 12:34:41.000000"
63  ["timezone_type"]=>
64  int(2)
65  ["timezone"]=>
66  string(3) "GMT"
67}
68
69-- Add some more properties --
70object(DateTime)#%d (7) {
71  ["property1"]=>
72  int(99)
73  ["property2"]=>
74  string(5) "Hello"
75  ["property3"]=>
76  bool(true)
77  ["property4"]=>
78  float(10.5)
79  ["date"]=>
80  string(26) "2009-02-03 12:34:41.000000"
81  ["timezone_type"]=>
82  int(2)
83  ["timezone"]=>
84  string(3) "GMT"
85}
86
87-- clone it --
88object(DateTime)#%d (7) {
89  ["property1"]=>
90  int(99)
91  ["property2"]=>
92  string(5) "Hello"
93  ["property3"]=>
94  bool(true)
95  ["property4"]=>
96  float(10.5)
97  ["date"]=>
98  string(26) "2009-02-03 12:34:41.000000"
99  ["timezone_type"]=>
100  int(2)
101  ["timezone"]=>
102  string(3) "GMT"
103}
104