SignatureTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 21
dl 0
loc 46
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createDomDocument() 0 7 1
A testToXML() 0 27 1
1
<?php
2
3
namespace Tests\Bpost\Order\Box\Option;
4
5
use Bpost\BpostApiClient\Bpost\Order\Box\Option\Signature;
0 ignored issues
show
Bug introduced by
The type Bpost\BpostApiClient\Bpo...er\Box\Option\Signature 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...
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 SignatureTest 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 Signature->toXML
27
     */
28
    public function testToXML()
29
    {
30
        $expectedDocument = self::createDomDocument();
31
        $expectedDocument->appendChild(
32
            $expectedDocument->createElement('signed')
33
        );
34
35
        $actualDocument = self::createDomDocument();
36
        $signature = new Signature();
37
        $actualDocument->appendChild(
38
            $signature->toXML($actualDocument)
39
        );
40
41
        $this->assertEquals($expectedDocument, $actualDocument);
42
43
        $expectedDocument = self::createDomDocument();
44
        $expectedDocument->appendChild(
45
            $expectedDocument->createElement('foo:signed')
46
        );
47
48
        $actualDocument = self::createDomDocument();
49
        $signature = new Signature();
50
        $actualDocument->appendChild(
51
            $signature->toXML($actualDocument, 'foo')
52
        );
53
54
        $this->assertSame($expectedDocument->saveXML(), $actualDocument->saveXML());
55
    }
56
}
57