Passed
Push — master ( 4f9e3a...139be2 )
by Alexander
23:24
created

CloneTest::testCloneEmptyXmlChildren()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Horat1us\Tests;
4
5
use Horat1us\Examples\Head;
6
use Horat1us\Examples\Person;
7
use Horat1us\XmlConvertibleObject;
8
use PHPUnit\Framework\TestCase;
9
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