1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Tests\Bpost\HttpRequestBuilder; |
4
|
|
|
|
5
|
|
|
use Bpost\BpostApiClient\Bpost\HttpRequestBuilder\CreateOrReplaceOrder; |
6
|
|
|
use Bpost\BpostApiClient\Bpost\Order; |
7
|
|
|
use Bpost\BpostApiClient\Bpost\Order\Address; |
8
|
|
|
use Bpost\BpostApiClient\Bpost\Order\Box; |
9
|
|
|
use Bpost\BpostApiClient\Bpost\Order\Box\AtBpost; |
10
|
|
|
use Bpost\BpostApiClient\Bpost\Order\Box\Option\CashOnDelivery; |
11
|
|
|
use Bpost\BpostApiClient\Bpost\Order\Box\Option\Messaging; |
12
|
|
|
use Bpost\BpostApiClient\Bpost\Order\Box\Option\SaturdayDelivery; |
13
|
|
|
use Bpost\BpostApiClient\Bpost\Order\Line; |
14
|
|
|
use Bpost\BpostApiClient\Bpost\Order\PugoAddress; |
15
|
|
|
use Bpost\BpostApiClient\Bpost\Order\Sender; |
16
|
|
|
use PHPUnit_Framework_TestCase; |
|
|
|
|
17
|
|
|
|
18
|
|
|
class CreateOrReplaceOrderTest extends PHPUnit_Framework_TestCase |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @param array $input |
22
|
|
|
* @param string $url |
23
|
|
|
* @param string $xml |
24
|
|
|
* @param string $method |
25
|
|
|
* @param bool $isExpectXml |
26
|
|
|
* @param array $headers |
27
|
|
|
* |
28
|
|
|
* @return void |
29
|
|
|
* |
30
|
|
|
* @dataProvider dataResults |
31
|
|
|
*/ |
32
|
|
|
public function testResults(array $input, $url, $xml, $headers, $method, $isExpectXml) |
33
|
|
|
{ |
34
|
|
|
$builder = new CreateOrReplaceOrder($input[0], $input[1]); |
35
|
|
|
|
36
|
|
|
$this->assertSame($url, $builder->getUrl()); |
37
|
|
|
$this->assertSame($method, $builder->getMethod()); |
38
|
|
|
$this->assertSame($xml, $builder->getXml()); |
39
|
|
|
$this->assertSame($isExpectXml, $builder->isExpectXml()); |
40
|
|
|
$this->assertSame($headers, $builder->getHeaders()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function dataResults() |
44
|
|
|
{ |
45
|
|
|
$accountId = '123456789'; |
46
|
|
|
|
47
|
|
|
return array( |
48
|
|
|
array( |
49
|
|
|
'input' => array($this->getOrder(), $accountId), |
50
|
|
|
'url' => '/orders', |
51
|
|
|
'xml' => $this->getOrderXml(), |
52
|
|
|
'headers' => array('Content-type: application/vnd.bpost.shm-order-v3.3+XML'), |
53
|
|
|
'method' => 'POST', |
54
|
|
|
'isExpectXml' => false, |
55
|
|
|
), |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return Order |
61
|
|
|
*/ |
62
|
|
|
private function getOrder() |
63
|
|
|
{ |
64
|
|
|
$order = new Order('ref_1'); |
65
|
|
|
|
66
|
|
|
$order->setCostCenter('Cost Center'); |
67
|
|
|
|
68
|
|
|
$order->setLines(array(new Line('Product 1', 1))); |
69
|
|
|
$order->addLine(new Line('Product 1', 5)); |
70
|
|
|
|
71
|
|
|
$senderAddress = new Address(); |
72
|
|
|
$senderAddress->setStreetName('MUNT'); |
73
|
|
|
$senderAddress->setNumber(1); |
74
|
|
|
$senderAddress->setBox(1); |
75
|
|
|
$senderAddress->setPostalCode(1000); |
76
|
|
|
$senderAddress->setLocality('Brussel'); |
77
|
|
|
$senderAddress->setCountryCode('BE'); |
78
|
|
|
$senderAddress->setBox(1); |
79
|
|
|
|
80
|
|
|
$pugoAddress = new PugoAddress(); |
81
|
|
|
$pugoAddress->setStreetName('Turnhoutsebaan'); |
82
|
|
|
$pugoAddress->setNumber(468); |
83
|
|
|
$pugoAddress->setBox('A'); |
84
|
|
|
$pugoAddress->setPostalCode(2110); |
85
|
|
|
$pugoAddress->setLocality('Wijnegem'); |
86
|
|
|
$pugoAddress->setCountryCode('BE'); |
87
|
|
|
|
88
|
|
|
$sender = new Sender(); |
89
|
|
|
$sender->setName('SENDER NAME'); |
90
|
|
|
$sender->setCompany('SENDER COMPANY'); |
91
|
|
|
$sender->setAddress($senderAddress); |
92
|
|
|
$sender->setEmailAddress('[email protected]'); |
93
|
|
|
$sender->setPhoneNumber('022011111'); |
94
|
|
|
|
95
|
|
|
$atBpost = new AtBpost(); |
96
|
|
|
|
97
|
|
|
$atBpost->setOptions(array( |
98
|
|
|
new Messaging('infoDistributed', 'EN', null, '0476123456'), |
99
|
|
|
new Messaging('keepMeInformed', 'EN', null, '0032475123456'), |
100
|
|
|
)); |
101
|
|
|
$atBpost->addOption(new SaturdayDelivery()); |
102
|
|
|
$atBpost->addOption(new CashOnDelivery(1251, 'BE19210023508812', 'GEBABEBB')); |
103
|
|
|
|
104
|
|
|
$atBpost->setWeight(2000); |
105
|
|
|
|
106
|
|
|
$atBpost->setPugoId(207500); |
107
|
|
|
$atBpost->setPugoName('WIJNEGEM'); |
108
|
|
|
$atBpost->setPugoAddress($pugoAddress); |
109
|
|
|
$atBpost->setReceiverName('RECEIVER NAME'); |
110
|
|
|
$atBpost->setReceiverCompany('RECEIVER COMPANY'); |
111
|
|
|
$atBpost->setRequestedDeliveryDate('2020-10-22'); |
112
|
|
|
|
113
|
|
|
$box = new Box(); |
114
|
|
|
$box->setSender($sender); |
115
|
|
|
$box->setNationalBox($atBpost); |
116
|
|
|
$box->setRemark('bpack@bpost VAS 038 - COD+SAT+iD'); |
117
|
|
|
$box->setAdditionalCustomerReference('Reference that can be used for cross-referencing'); |
118
|
|
|
|
119
|
|
|
$order->setBoxes(array()); |
120
|
|
|
$this->assertCount(0, $order->getBoxes()); |
121
|
|
|
$order->addBox($box); |
122
|
|
|
|
123
|
|
|
return $order; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
private function getOrderXml() |
127
|
|
|
{ |
128
|
|
|
return <<< XML |
129
|
|
|
<?xml version="1.0" encoding="utf-8"?> |
130
|
|
|
<tns:order xmlns="http://schema.post.be/shm/deepintegration/v3/national" xmlns:common="http://schema.post.be/shm/deepintegration/v3/common" xmlns:tns="http://schema.post.be/shm/deepintegration/v3/" xmlns:international="http://schema.post.be/shm/deepintegration/v3/international" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.post.be/shm/deepintegration/v3/"> |
131
|
|
|
<tns:accountId>123456789</tns:accountId> |
132
|
|
|
<tns:reference>ref_1</tns:reference> |
133
|
|
|
<tns:costCenter>Cost Center</tns:costCenter> |
134
|
|
|
<tns:orderLine> |
135
|
|
|
<tns:text>Product 1</tns:text> |
136
|
|
|
<tns:nbOfItems>1</tns:nbOfItems> |
137
|
|
|
</tns:orderLine> |
138
|
|
|
<tns:orderLine> |
139
|
|
|
<tns:text>Product 1</tns:text> |
140
|
|
|
<tns:nbOfItems>5</tns:nbOfItems> |
141
|
|
|
</tns:orderLine> |
142
|
|
|
<tns:box> |
143
|
|
|
<tns:sender> |
144
|
|
|
<common:name>SENDER NAME</common:name> |
145
|
|
|
<common:company>SENDER COMPANY</common:company> |
146
|
|
|
<common:address> |
147
|
|
|
<common:streetName>MUNT</common:streetName> |
148
|
|
|
<common:number>1</common:number> |
149
|
|
|
<common:box>1</common:box> |
150
|
|
|
<common:postalCode>1000</common:postalCode> |
151
|
|
|
<common:locality>Brussel</common:locality> |
152
|
|
|
<common:countryCode>BE</common:countryCode> |
153
|
|
|
</common:address> |
154
|
|
|
<common:emailAddress>[email protected]</common:emailAddress> |
155
|
|
|
<common:phoneNumber>022011111</common:phoneNumber> |
156
|
|
|
</tns:sender> |
157
|
|
|
<tns:nationalBox> |
158
|
|
|
<atBpost> |
159
|
|
|
<product>bpack@bpost</product> |
160
|
|
|
<options> |
161
|
|
|
<common:infoDistributed language="EN"> |
162
|
|
|
<common:mobilePhone>0476123456</common:mobilePhone> |
163
|
|
|
</common:infoDistributed> |
164
|
|
|
<common:keepMeInformed language="EN"> |
165
|
|
|
<common:mobilePhone>0032475123456</common:mobilePhone> |
166
|
|
|
</common:keepMeInformed> |
167
|
|
|
<common:saturdayDelivery/> |
168
|
|
|
<common:cod> |
169
|
|
|
<common:codAmount>1251</common:codAmount> |
170
|
|
|
<common:iban>BE19210023508812</common:iban> |
171
|
|
|
<common:bic>GEBABEBB</common:bic> |
172
|
|
|
</common:cod> |
173
|
|
|
</options> |
174
|
|
|
<weight>2000</weight> |
175
|
|
|
<pugoId>207500</pugoId> |
176
|
|
|
<pugoName>WIJNEGEM</pugoName> |
177
|
|
|
<pugoAddress> |
178
|
|
|
<common:streetName>Turnhoutsebaan</common:streetName> |
179
|
|
|
<common:number>468</common:number> |
180
|
|
|
<common:box>A</common:box> |
181
|
|
|
<common:postalCode>2110</common:postalCode> |
182
|
|
|
<common:locality>Wijnegem</common:locality> |
183
|
|
|
<common:countryCode>BE</common:countryCode> |
184
|
|
|
</pugoAddress> |
185
|
|
|
<receiverName>RECEIVER NAME</receiverName> |
186
|
|
|
<receiverCompany>RECEIVER COMPANY</receiverCompany> |
187
|
|
|
<requestedDeliveryDate>2020-10-22</requestedDeliveryDate> |
188
|
|
|
</atBpost> |
189
|
|
|
</tns:nationalBox> |
190
|
|
|
<tns:remark>bpack@bpost VAS 038 - COD+SAT+iD</tns:remark> |
191
|
|
|
<tns:additionalCustomerReference>Reference that can be used for cross-referencing</tns:additionalCustomerReference> |
192
|
|
|
</tns:box> |
193
|
|
|
</tns:order> |
194
|
|
|
|
195
|
|
|
XML; |
196
|
|
|
} |
197
|
|
|
} |
198
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths