Skip to content

Commit f7a3a90

Browse files
committed
fix: options were wrongly filled
1 parent 8c7059c commit f7a3a90

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/Bpost/Order/Box/AtIntlPugo.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
namespace Bpost\BpostApiClient\Bpost\Order\Box;
33

44
use Bpost\BpostApiClient\Bpost\Order\Box\National\ShopHandlingInstruction;
5+
use Bpost\BpostApiClient\Bpost\Order\Box\Option\Messaging;
56
use Bpost\BpostApiClient\Bpost\Order\PugoAddress;
67
use Bpost\BpostApiClient\Bpost\Order\Receiver;
78
use Bpost\BpostApiClient\Bpost\ProductConfiguration\Product;
8-
use Bpost\BpostApiClient\Bpost\Order\Box\Option\Messaging;
99
use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidValueException;
1010
use Bpost\BpostApiClient\Exception\BpostNotImplementedException;
1111

@@ -266,7 +266,8 @@ public static function createFromXML(\SimpleXMLElement $xml)
266266
) {
267267
$option = Messaging::createFromXML($optionData);
268268
} else {
269-
$className = '\\Bpost\\BpostApiClient\\Bpost\\Order\\Box\\Option\\' . ucfirst($optionData->getName());
269+
$className = '\\Bpost\\BpostApiClient\\Bpost\\Order\\Box\\Option\\'
270+
. ucfirst($optionData->getName());
270271
if (!method_exists($className, 'createFromXML')) {
271272
throw new BpostNotImplementedException();
272273
}

src/Bpost/Order/Box/Option/Messaging.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,12 @@ public static function createFromXML(SimpleXMLElement $xml)
236236
{
237237
$messaging = new Messaging($xml->getName(), (string) $xml->attributes()->language);
238238

239-
if ((string) $xml->emailAddress !== '') {
240-
$messaging->setEmailAddress((string) $xml->emailAddress);
239+
$children = $xml->children('http://schema.post.be/shm/deepintegration/v3/common');
240+
if ((string) $children->emailAddress !== '') {
241+
$messaging->setEmailAddress((string) $children->emailAddress);
241242
}
242-
if ((string) $xml->mobilePhone !== '') {
243-
$messaging->setMobilePhone((string) $xml->mobilePhone);
243+
if ((string) $children->mobilePhone !== '') {
244+
$messaging->setMobilePhone((string) $children->mobilePhone);
244245
}
245246

246247
return $messaging;

tests/BpostApiExamples/FetchOrder/AtIntlPugoTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ private function getXmlFromBpost()
4040
<ns4:options>
4141
<ns2:keepMeInformed language="FR">
4242
<ns2:emailAddress>esolutions@bpost.be</ns2:emailAddress>
43+
<ns2:mobilePhone>0470000000</ns2:mobilePhone>
4344
</ns2:keepMeInformed>
4445
</ns4:options>
4546
<ns4:receiver>
@@ -104,7 +105,6 @@ public function testCreateFromXml()
104105
$this->assertSame(11000, $internationalBox->getParcelWeight());
105106
$this->assertCount(0, $internationalBox->getParcelContents());
106107
$this->assertNotNull($internationalBox->getReceiver());
107-
$this->assertCount(1, $internationalBox->getOptions());
108108

109109
$receiver = $internationalBox->getReceiver();
110110

@@ -119,12 +119,11 @@ public function testCreateFromXml()
119119
$this->assertSame('FR', $receiver->getAddress()->getCountryCode());
120120

121121
$this->assertCount(1, $internationalBox->getOptions());
122-
123122
$optionMessaging = current($internationalBox->getOptions());
124123
$this->assertInstanceOf('Bpost\BpostApiClient\Bpost\Order\Box\Option\Messaging', $optionMessaging);
125124
$this->assertSame(Box\Option\Messaging::MESSAGING_TYPE_KEEP_ME_INFORMED, $optionMessaging->getType());
126125
$this->assertSame(Box\Option\Messaging::MESSAGING_LANGUAGE_FR, $optionMessaging->getLanguage());
127-
$this->assertNull($optionMessaging->getMobilePhone());
126+
$this->assertSame('0470000000', $optionMessaging->getMobilePhone());
128127
$this->assertSame('esolutions@bpost.be', $optionMessaging->getEmailAddress());
129128
}
130129
}

0 commit comments

Comments
 (0)