Issues (112)

tests/Bpost/Order/PugoAddressTest.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Tests\Bpost\Order;
4
5
use Bpost\BpostApiClient\Bpost\Order\PugoAddress;
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 PugoAddressTest 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 PugoAddress->toXML
27
     */
28
    public function testToXML()
29
    {
30
        $data = array(
31
            'streetName' => 'Afrikalaan',
32
            'number' => '2890',
33
            'box' => '3',
34
            'postalCode' => '9000',
35
            'locality' => 'Gent',
36
            'countryCode' => 'BE',
37
        );
38
39
        $expectedDocument = self::createDomDocument();
40
        $address = $expectedDocument->createElement('pugoAddress');
41
        foreach ($data as $key => $value) {
42
            $address->appendChild(
43
                $expectedDocument->createElement($key, $value)
44
            );
45
        }
46
        $expectedDocument->appendChild($address);
47
48
        $actualDocument = self::createDomDocument();
49
        $address = new PugoAddress(
50
            $data['streetName'],
51
            $data['number'],
52
            $data['box'],
53
            $data['postalCode'],
54
            $data['locality'],
55
            $data['countryCode']
56
        );
57
        $actualDocument->appendChild(
58
            $address->toXML($actualDocument, null)
59
        );
60
61
        $this->assertEquals($expectedDocument, $actualDocument);
62
    }
63
64
    /**
65
     * @expectedException \Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException
66
     */
67
    public function testFaultyBoxProperties()
68
    {
69
        $address = new PugoAddress();
70
        $address->setBox(str_repeat('a', 9));
71
    }
72
73
    /**
74
     * @expectedException \Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException
75
     */
76
    public function testFaultyCountryCodeProperties()
77
    {
78
        $address = new PugoAddress();
79
        $address->setCountryCode(str_repeat('a', 3));
80
    }
81
82
    /**
83
     * @expectedException \Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException
84
     */
85
    public function testFaultyLocalityProperties()
86
    {
87
        $address = new PugoAddress();
88
        $address->setLocality(str_repeat('a', 41));
89
    }
90
91
    /**
92
     * @expectedException \Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException
93
     */
94
    public function testFaultyNumberProperties()
95
    {
96
        $address = new PugoAddress();
97
        $address->setNumber(str_repeat('a', 9));
98
    }
99
100
    /**
101
     * @expectedException \Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException
102
     */
103
    public function testFaultyPostalCodeProperties()
104
    {
105
        $address = new PugoAddress();
106
        $address->setPostalCode(str_repeat('a', 41));
107
    }
108
109
    /**
110
     * @expectedException \Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException
111
     */
112
    public function testFaultyStreetNameProperties()
113
    {
114
        $address = new PugoAddress();
115
        $address->setStreetName(str_repeat('a', 41));
116
    }
117
}
118