Issues (112)

Bpost/Order/Box/Option/CashOnDeliveryTest.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Tests\Bpost\Order\Box\Option;
4
5
use Bpost\BpostApiClient\Bpost\Order\Box\Option\CashOnDelivery;
6
use DOMDocument;
7
use PHPUnit_Framework_TestCase;
0 ignored issues
show
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 CashOnDeliveryTest 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 CashOnDelivery->toXML
27
     */
28
    public function testToXML()
29
    {
30
        $data = array(
31
            'cod' => array(
32
                'codAmount' => 1251,
33
                'iban' => 'BE19210023508812',
34
                'bic' => 'GEBABEBB',
35
            ),
36
        );
37
38
        $expectedDocument = self::createDomDocument();
39
        $cod = $expectedDocument->createElement('common:cod');
40
        foreach ($data['cod'] as $key => $value) {
41
            $cod->appendChild(
42
                $expectedDocument->createElement('common:' . $key, $value)
43
            );
44
        }
45
        $expectedDocument->appendChild($cod);
46
47
        $actualDocument = self::createDomDocument();
48
        $cashOnDelivery = new CashOnDelivery(
49
            $data['cod']['codAmount'],
50
            $data['cod']['iban'],
51
            $data['cod']['bic']
52
        );
53
        $actualDocument->appendChild(
54
            $cashOnDelivery->toXML($actualDocument)
55
        );
56
57
        $this->assertEquals($expectedDocument->saveXML(), $actualDocument->saveXML());
58
59
        $data = array(
60
            'cod' => array(
61
                'codAmount' => 1251,
62
                'iban' => 'BE19210023508812',
63
                'bic' => 'GEBABEBB',
64
            ),
65
        );
66
67
        $expectedDocument = self::createDomDocument();
68
        $cod = $expectedDocument->createElement('foo:cod');
69
        foreach ($data['cod'] as $key => $value) {
70
            $cod->appendChild(
71
                $expectedDocument->createElement('foo:' . $key, $value)
72
            );
73
        }
74
        $expectedDocument->appendChild($cod);
75
76
        $actualDocument = self::createDomDocument();
77
        $cashOnDelivery = new CashOnDelivery(
78
            $data['cod']['codAmount'],
79
            $data['cod']['iban'],
80
            $data['cod']['bic']
81
        );
82
        $actualDocument->appendChild(
83
            $cashOnDelivery->toXML($actualDocument, 'foo')
84
        );
85
86
        $this->assertSame($expectedDocument->saveXML(), $actualDocument->saveXML());
87
    }
88
}
89