File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed
Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -85,4 +85,56 @@ public function testUnsetUnknownValue()
8585 $ struct = new TestDataObject ();
8686 unset($ struct ->unknown );
8787 }
88+
89+ public function testBasicClone ()
90+ {
91+ $ struct = new TestDataObject ();
92+ $ struct ->property = 42 ;
93+
94+ $ clone = clone $ struct ;
95+
96+ $ this ->assertSame (
97+ $ struct ->property ,
98+ $ clone ->property
99+ );
100+ }
101+
102+ public function testCloneAggregate ()
103+ {
104+ $ struct = new TestDataObject ();
105+ $ struct ->property = new TestDataObject ();
106+
107+ $ clone = clone $ struct ;
108+
109+ $ this ->assertNotSame (
110+ $ struct ->property ,
111+ $ clone ->property
112+ );
113+ }
114+
115+ public function testCloneAggregateInArray ()
116+ {
117+ $ struct = new TestDataObject ();
118+ $ struct ->property = array (new TestDataObject ());
119+
120+ $ clone = clone $ struct ;
121+
122+ $ this ->assertNotSame (
123+ $ struct ->property [0 ],
124+ $ clone ->property [0 ]
125+ );
126+ }
127+
128+ public function testCloneAggregateInDeepArray ()
129+ {
130+ $ struct = new TestDataObject ();
131+ $ struct ->property = array (array (new TestDataObject ()));
132+
133+ $ clone = clone $ struct ;
134+
135+ $ this ->assertNotSame (
136+ $ struct ->property [0 ][0 ],
137+ $ clone ->property [0 ][0 ]
138+ );
139+ }
88140}
You can’t perform that action at this time.
0 commit comments