@@ 171-184 (lines=14) @@ | ||
168 | $this->assertEquals('c', $cont->get('baz')); |
|
169 | } |
|
170 | ||
171 | public function testExtractedChildDoesNotModifyParent() |
|
172 | { |
|
173 | $cont = new ImmutableContainer(['a' => 'b', 'c' => new Container(['d' => 'e'])]); |
|
174 | ||
175 | $child = $cont->get('c'); |
|
176 | ||
177 | $child->set('d', 'f'); |
|
178 | ||
179 | $this->assertEquals( |
|
180 | ['a' => 'b', 'c' => new Container(['d' => 'e'])], |
|
181 | $cont->getAll(), |
|
182 | 'modifying a child object should not modify the parent container' |
|
183 | ); |
|
184 | } |
|
185 | } |
|
186 |
@@ 189-200 (lines=12) @@ | ||
186 | ); |
|
187 | } |
|
188 | ||
189 | public function testImmutableChildReferences() |
|
190 | { |
|
191 | $child = new Container(['a' => 'b', 'c' => 'd']); |
|
192 | $container = new ImmutableFlatContainer(['child' => $child]); |
|
193 | ||
194 | $child->set('c', 'e'); |
|
195 | ||
196 | $this->assertEquals( |
|
197 | ['child' => new Container(['a' => 'b', 'c' => 'd'])], |
|
198 | $container->getAll() |
|
199 | ); |
|
200 | } |
|
201 | ||
202 | public function testExtractedChildDoesNotModifyParent() |
|
203 | { |
|
@@ 202-215 (lines=14) @@ | ||
199 | ); |
|
200 | } |
|
201 | ||
202 | public function testExtractedChildDoesNotModifyParent() |
|
203 | { |
|
204 | $cont = new ImmutableFlatContainer(['a' => 'b', 'c' => new Container(['d' => 'e'])]); |
|
205 | ||
206 | $child = $cont->get('c'); |
|
207 | ||
208 | $child->set('d', 'f'); |
|
209 | ||
210 | $this->assertEquals( |
|
211 | ['a' => 'b', 'c' => new Container(['d' => 'e'])], |
|
212 | $cont->getAll(), |
|
213 | 'modifying a child object should not modify the parent container' |
|
214 | ); |
|
215 | } |
|
216 | } |
|
217 |