LineTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 21
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createDomDocument() 0 7 1
A testToXML() 0 26 2
1
<?php
2
3
namespace Tests\Bpost\Order;
4
5
use Bpost\BpostApiClient\Bpost\Order\Line;
6
use DOMDocument;
7
use PHPUnit_Framework_TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit_Framework_TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
class LineTest extends PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * Create a generic DOM Document
13
     *
14
     * @return DOMDocument
15
     */
16
    private static function createDomDocument()
17
    {
18
        $document = new DOMDocument('1.0', 'utf-8');
19
        $document->preserveWhiteSpace = false;
20
        $document->formatOutput = true;
21
22
        return $document;
23
    }
24
25
    /**
26
     * Tests Line->toXML
27
     */
28
    public function testToXML()
29
    {
30
        $data = array(
31
            'text' => 'just a random text',
32
            'nbOfItems' => time(),
33
        );
34
35
        $expectedDocument = self::createDomDocument();
36
        $line = $expectedDocument->createElement('orderLine');
37
        foreach ($data as $key => $value) {
38
            $line->appendChild(
39
                $expectedDocument->createElement($key, $value)
40
            );
41
        }
42
        $expectedDocument->appendChild($line);
43
44
        $actualDocument = self::createDomDocument();
45
        $line = new Line(
46
            $data['text'],
47
            $data['nbOfItems']
48
        );
49
        $actualDocument->appendChild(
50
            $line->toXML($actualDocument, null)
51
        );
52
53
        $this->assertEquals($expectedDocument, $actualDocument);
54
    }
55
}
56