| 1 | <?php |
||
| 10 | class CloneTest extends TestCase |
||
| 11 | { |
||
| 12 | public function testClone() |
||
| 13 | { |
||
| 14 | $xml = new Person('Alex', 'Letnikow', [ |
||
| 15 | new Head('big', 'strong', [ |
||
| 16 | new XmlConvertibleObject('Test', [ |
||
| 17 | new XmlConvertibleObject('undefined'), |
||
| 18 | ]) |
||
| 19 | ]) |
||
| 20 | ]); |
||
| 21 | |||
| 22 | $cloned = clone $xml; |
||
| 23 | $xml->name = 'Roman'; |
||
| 24 | $this->assertNotEquals($xml->name, $cloned->name); |
||
| 25 | $xml->getXmlChildren()[0]->xmlChildren[0]->xmlChildren[0]->{'a'} = 1; |
||
| 26 | $cloned->xmlChildren[0]->xmlChildren[0]->xmlChildren[0]->{'a'} = 2; |
||
| 27 | $this->assertNotEquals( |
||
| 28 | $xml->getXmlChildren()[0]->xmlChildren[0]->xmlChildren[0]->{'a'}, |
||
| 29 | $cloned->xmlChildren[0]->xmlChildren[0]->xmlChildren[0]->{'a'} |
||
| 30 | ); |
||
| 31 | } |
||
| 32 | |||
| 33 | public function testCloneEmptyXmlChildren() |
||
| 34 | { |
||
| 35 | $xml = new Person(); |
||
| 36 | |||
| 37 | $cloned = clone $xml; |
||
| 38 | |||
| 39 | $this->assertNull($cloned->xmlChildren); |
||
| 40 | } |
||
| 41 | } |
||
| 42 |