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

ElementChildrenTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Horat1us\Tests;
4
5
use Horat1us\Tests\helpers\SampleXml;
6
use Horat1us\XmlConvertible;
7
use Horat1us\XmlConvertibleInterface;
8
use PHPUnit\Framework\TestCase;
9
10
class ElementChildrenTest extends TestCase implements XmlConvertibleInterface
11
{
12
    use XmlConvertible;
13
14
    public function testWithout()
15
    {
16
        $this->xmlChildren = null;
17
        $xml = $this->toXml();
18
        $this->assertEquals(0, $xml->childNodes->length);
19
    }
20
21
    public function testInvalid()
22
    {
23
        $this->xmlChildren = [
24
            new \UnexpectedValueException()
25
        ];
26
        $this->expectException(\TypeError::class);
27
        $this->toXml();
28
    }
29
30
    public function testOne()
31
    {
32
        $doc = new \DOMDocument();
33
        $this->xmlChildren = [$this->toXml($doc)];
34
        $xml = $this->toXml($doc);
35
        $this->assertEquals(1, $xml->childNodes->length);
36
    }
37
38
    public function testFew()
39
    {
40
        $doc = new \DOMDocument();
41
        $this->xmlChildren = [
42
            new SampleXml(),
43
            $this->toXml($doc),
44
        ];
45
        $xml = $this->toXml($doc);
46
        $this->assertEquals(2, $xml->childNodes->length);
47
    }
48
}
49