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

CloneTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 32
rs 10
c 0
b 0
f 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