From 50527ccdcd4f00b40c90b9814b03ac01663ec7a5 Mon Sep 17 00:00:00 2001 From: mramosp Date: Wed, 12 Jun 2024 12:02:11 -0400 Subject: [PATCH 1/4] feat: support additional billing information --- .../Order/ExtraBillingAttributesFactory.php | 50 +++++ src/Factory/Xml/Order/OrderFactory.php | 4 + src/Model/Order/ExtraBillingAttributes.php | 186 ++++++++++++++++++ src/Model/Order/Order.php | 13 ++ tests/Unit/Order/OrderTest.php | 14 +- tests/_schemas/Order/Order.json | 15 ++ tests/_schemas/Order/Order.xml | 15 ++ tests/_schemas/Order/OrderResponse.xml | 15 ++ tests/_schemas/Order/OrderWithOrderItems.json | 1 + tests/_schemas/Order/Orders.xml | 15 ++ tests/_schemas/Order/OrdersResponse.xml | 15 ++ 11 files changed, 342 insertions(+), 1 deletion(-) create mode 100644 src/Factory/Xml/Order/ExtraBillingAttributesFactory.php create mode 100644 src/Model/Order/ExtraBillingAttributes.php diff --git a/src/Factory/Xml/Order/ExtraBillingAttributesFactory.php b/src/Factory/Xml/Order/ExtraBillingAttributesFactory.php new file mode 100644 index 0000000..653bfac --- /dev/null +++ b/src/Factory/Xml/Order/ExtraBillingAttributesFactory.php @@ -0,0 +1,50 @@ +LegalId, + (string) $element->FiscalPerson, + (string) $element->DocumentType, + (string) $element->ReceiverRegion, + (string) $element->ReceiverAddress, + (string) $element->ReceiverPostcode, + (string) $element->ReceiverLegalName, + (string) $element->ReceiverMunicipality, + (string) $element->ReceiverTypeRegimen, + (string) $element->CustomerVerifierDigit, + (string) $element->ReceiverLocality, + (string) $element->ReceiverEmail, + (string) $element->ReceiverPhonenumber + ); + } +} diff --git a/src/Factory/Xml/Order/OrderFactory.php b/src/Factory/Xml/Order/OrderFactory.php index 72c6a70..bdabb69 100644 --- a/src/Factory/Xml/Order/OrderFactory.php +++ b/src/Factory/Xml/Order/OrderFactory.php @@ -82,6 +82,9 @@ public static function make(SimpleXMLElement $element): Order : null ); + $extraBillingAttributes = !empty($element->ExtraBillingAttributes) ? + ExtraBillingAttributesFactory::make($element->ExtraBillingAttributes) : null; + return Order::fromData( (int) $element->OrderId, $orderNumber, @@ -103,6 +106,7 @@ public static function make(SimpleXMLElement $element): Order (int) $element->ItemsCount, $promisedShippingTime, (string) $element->ExtraAttributes, + $extraBillingAttributes, $statuses, $businessInvoiceRequired, $shippingType, diff --git a/src/Model/Order/ExtraBillingAttributes.php b/src/Model/Order/ExtraBillingAttributes.php new file mode 100644 index 0000000..a19ed36 --- /dev/null +++ b/src/Model/Order/ExtraBillingAttributes.php @@ -0,0 +1,186 @@ +legalId = !empty($legalId) ? $legalId : null; + $this->fiscalPerson = !empty($fiscalPerson) ? $fiscalPerson : null; + $this->documentType = !empty($documentType) ? $documentType : null; + $this->receiverRegion = !empty($receiverRegion) ? $receiverRegion : null; + $this->receiverAddress = !empty($receiverAddress) ? $receiverAddress : null; + $this->receiverPostcode = !empty($receiverPostcode) ? $receiverPostcode : null; + $this->receiverLegalName = !empty($receiverLegalName) ? $receiverLegalName : null; + $this->receiverMunicipality = !empty($receiverMunicipality) ? $receiverMunicipality : null; + $this->receiverTypeRegimen = !empty($receiverTypeRegimen) ? $receiverTypeRegimen : null; + $this->customerVerifierDigit = !empty($customerVerifierDigit) ? $customerVerifierDigit : null; + $this->receiverLocality = !empty($receiverLocality) ? $receiverLocality : null; + $this->receiverEmail = !empty($receiverEmail) ? $receiverEmail : null; + $this->receiverPhonenumber = !empty($receiverPhonenumber) ? $receiverPhonenumber : null; + } + + public function getLegalId(): ?string + { + return $this->legalId; + } + + public function getFiscalPerson(): ?string + { + return $this->fiscalPerson; + } + + public function getDocumentType(): ?string + { + return $this->documentType; + } + + public function getReceiverRegion(): ?string + { + return $this->receiverRegion; + } + + public function getReceiverAddress(): ?string + { + return $this->receiverAddress; + } + + public function getReceiverPostCode(): ?string + { + return $this->receiverPostcode; + } + + public function getReceiverLegalName(): ?string + { + return $this->receiverLegalName; + } + + public function getReceiverMunicipality(): ?string + { + return $this->receiverMunicipality; + } + + public function getReceiverTypeRegimen(): ?string + { + return $this->receiverTypeRegimen; + } + + public function getCustomerVerifierDigit(): ?string + { + return $this->customerVerifierDigit; + } + + public function getReceiverLocality(): ?string + { + return $this->receiverLocality; + } + + public function getReceiverPhoneNumber(): ?string + { + return $this->receiverPhonenumber; + } + + public function jsonSerialize(): stdClass + { + $serialized = new stdClass(); + $serialized->legalId = $this->legalId; + $serialized->fiscalPerson = $this->fiscalPerson; + $serialized->documentType = $this->documentType; + $serialized->receiverRegion = $this->receiverRegion; + $serialized->receiverAddress = $this->receiverAddress; + $serialized->receiverPostcode = $this->receiverPostcode; + $serialized->receiverLegalName = $this->receiverLegalName; + $serialized->receiverMunicipality = $this->receiverMunicipality; + $serialized->receiverTypeRegimen = $this->receiverTypeRegimen; + $serialized->customerVerifierDigit = $this->customerVerifierDigit; + $serialized->receiverLocality = $this->receiverLocality; + $serialized->receiverEmail = $this->receiverEmail; + $serialized->receiverPhonenumber = $this->receiverPhonenumber; + + return $serialized; + } +} diff --git a/src/Model/Order/Order.php b/src/Model/Order/Order.php index 7eab0fa..79b4b40 100644 --- a/src/Model/Order/Order.php +++ b/src/Model/Order/Order.php @@ -135,6 +135,11 @@ class Order implements JsonSerializable */ protected $shippingType; + /** + * @var ExtraBillingAttributes|null + */ + protected $extraBillingAttributes; + /** * @param string[] $statuses * @param string|int $orderNumber @@ -160,6 +165,7 @@ public static function fromData( int $itemsCount, ?DateTimeInterface $promisedShippingTime, ?string $extraAttributes, + ?ExtraBillingAttributes $extraBillingAttributes, array $statuses, ?bool $businessInvoiceRequired, ?string $shippingType, @@ -190,6 +196,7 @@ public static function fromData( $order->statuses = $statuses; $order->businessInvoiceRequired = $businessInvoiceRequired; $order->shippingType = $shippingType; + $order->extraBillingAttributes = $extraBillingAttributes; $order->operatorCode = $operatorCode; return $order; @@ -340,6 +347,11 @@ public function getShippingType(): ?string return $this->shippingType; } + public function getExtraBillingAttributes(): ?ExtraBillingAttributes + { + return $this->extraBillingAttributes; + } + public function setOrderItems(OrderItems $orderItems): void { $this->orderItems = $orderItems; @@ -372,6 +384,7 @@ public function jsonSerialize(): stdClass $serialized->orderItems = $this->orderItems; $serialized->businessInvoiceRequired = $this->businessInvoiceRequired; $serialized->shippingType = $this->shippingType; + $serialized->extraBillingAttributes = $this->extraBillingAttributes; $serialized->operatorCode = $this->operatorCode; return $serialized; diff --git a/tests/Unit/Order/OrderTest.php b/tests/Unit/Order/OrderTest.php index 74ad9d1..1cebf4c 100644 --- a/tests/Unit/Order/OrderTest.php +++ b/tests/Unit/Order/OrderTest.php @@ -41,7 +41,19 @@ class OrderTest extends LinioTestCase protected $city = 'city'; protected $postCode = '10117'; protected $country = 'country'; - + protected $legalId = '77656276-9'; + protected $fiscalPerson = 'business'; + protected $documentType = 'RUT'; + protected $receiverRegion = 'METROPOLITANA DE SANTIAGO'; + protected $receiverAddress = 'JOSE MANUEL INFANTE 1155, 902 PROVIDENCIA'; + protected $receiverPostcode = '97873'; + protected $receiverLegalName = 'COMERCIALIZADORA VIPAZ SPA'; + protected $receiverMunicipality = 'PROVIDENCIA'; + protected $receiverTypeRegimen = '475201 - VENTA AL POR MENOR DE ARTÍCULOS DE FERRETERÍA Y MATERIALES DE CONSTRUCCIÓN'; + protected $customerVerifierDigit = '9'; + protected $receiverLocality = 'PROVIDENCIA'; + protected $receiverEmail = 'comercializadora.vipaz@gmail.com'; + protected $receiverPhonenumber = '+56999100109'; protected $nationalRegistrationNumber = '72201776'; protected $itemsCount = 1; protected $promisedShippingTime = '2018-07-18 23:59:59'; diff --git a/tests/_schemas/Order/Order.json b/tests/_schemas/Order/Order.json index 5ca7bfc..9bd9457 100644 --- a/tests/_schemas/Order/Order.json +++ b/tests/_schemas/Order/Order.json @@ -55,6 +55,21 @@ "%s", "%s" ], + "extraBillingAttributes": { + "legalId": null, + "fiscalPerson": null, + "documentType": null, + "receiverRegion": null, + "receiverAddress": null, + "receiverPostcode": null, + "receiverLegalName":null, + "receiverMunicipality": null, + "receiverTypeRegimen": null, + "customerVerifierDigit": null, + "receiverLocality": null, + "receiverEmail": null, + "receiverPhonenumber": null + }, "businessInvoiceRequired": null, "shippingType": null, "orderItems": null diff --git a/tests/_schemas/Order/Order.xml b/tests/_schemas/Order/Order.xml index 2252499..dd79f6e 100644 --- a/tests/_schemas/Order/Order.xml +++ b/tests/_schemas/Order/Order.xml @@ -52,6 +52,21 @@ %s %s %s + + + + + + + + + + + + + + + %s %s diff --git a/tests/_schemas/Order/OrderResponse.xml b/tests/_schemas/Order/OrderResponse.xml index eba66be..85952b3 100644 --- a/tests/_schemas/Order/OrderResponse.xml +++ b/tests/_schemas/Order/OrderResponse.xml @@ -61,6 +61,21 @@ 1 2018-08-28 16:00:00 + + + + + + + + + + + + + + + delivered pending diff --git a/tests/_schemas/Order/OrderWithOrderItems.json b/tests/_schemas/Order/OrderWithOrderItems.json index 382c975..8b5b024 100644 --- a/tests/_schemas/Order/OrderWithOrderItems.json +++ b/tests/_schemas/Order/OrderWithOrderItems.json @@ -20,6 +20,7 @@ "promisedShippingTime": null, "extraAttributes": null, "statuses": null, + "extraBillingAttributes": null, "businessInvoiceRequired": null, "shippingType": null, "operatorCode": null, diff --git a/tests/_schemas/Order/Orders.xml b/tests/_schemas/Order/Orders.xml index 60891ed..e54d26f 100644 --- a/tests/_schemas/Order/Orders.xml +++ b/tests/_schemas/Order/Orders.xml @@ -112,6 +112,21 @@ 1 2018-08-28 16:00:00 + + + + + + + + + + + + + + + true delivered diff --git a/tests/_schemas/Order/OrdersResponse.xml b/tests/_schemas/Order/OrdersResponse.xml index 00be922..a620ced 100644 --- a/tests/_schemas/Order/OrdersResponse.xml +++ b/tests/_schemas/Order/OrdersResponse.xml @@ -61,6 +61,21 @@ 1 2018-08-28 16:00:00 + + 77656276-9 + business + RUT + METROPOLITANA DE SANTIAGO + JOSE MANUEL INFANTE 1155, 902 PROVIDENCIA + - + COMERCIALIZADORA VIPAZ SPA + PROVIDENCIA + 475201 - VENTA AL POR MENOR DE ARTÍCULOS DE FERRETERÍA Y MATERIALES DE CONSTRUCCIÓN + 9 + PROVIDENCIA + comercializadora.vipaz@gmail.com + +56999100109 + delivered shipped From 49bee6380caf89ef76117514bff201b8f69d57d9 Mon Sep 17 00:00:00 2001 From: mramosp Date: Thu, 13 Jun 2024 10:21:59 -0400 Subject: [PATCH 2/4] fix: order params --- src/Factory/Xml/Order/OrderFactory.php | 4 +- src/Model/Order/ExtraBillingAttributes.php | 5 + src/Model/Order/Order.php | 4 +- .../Unit/Order/ExtraBillingAttributesTest.php | 135 ++++++++++++++++++ .../Order/ExtraBillingAttributes.json | 15 ++ .../_schemas/Order/ExtraBillingAttributes.xml | 16 +++ 6 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 tests/Unit/Order/ExtraBillingAttributesTest.php create mode 100644 tests/_schemas/Order/ExtraBillingAttributes.json create mode 100644 tests/_schemas/Order/ExtraBillingAttributes.xml diff --git a/src/Factory/Xml/Order/OrderFactory.php b/src/Factory/Xml/Order/OrderFactory.php index bdabb69..bb81ace 100644 --- a/src/Factory/Xml/Order/OrderFactory.php +++ b/src/Factory/Xml/Order/OrderFactory.php @@ -106,11 +106,11 @@ public static function make(SimpleXMLElement $element): Order (int) $element->ItemsCount, $promisedShippingTime, (string) $element->ExtraAttributes, - $extraBillingAttributes, $statuses, $businessInvoiceRequired, $shippingType, - $operatorCode + $operatorCode, + $extraBillingAttributes ); } } diff --git a/src/Model/Order/ExtraBillingAttributes.php b/src/Model/Order/ExtraBillingAttributes.php index a19ed36..355d471 100644 --- a/src/Model/Order/ExtraBillingAttributes.php +++ b/src/Model/Order/ExtraBillingAttributes.php @@ -149,6 +149,11 @@ public function getReceiverTypeRegimen(): ?string return $this->receiverTypeRegimen; } + public function getReceiverEmail(): ?string + { + return $this->receiverEmail; + } + public function getCustomerVerifierDigit(): ?string { return $this->customerVerifierDigit; diff --git a/src/Model/Order/Order.php b/src/Model/Order/Order.php index 79b4b40..d50c5d9 100644 --- a/src/Model/Order/Order.php +++ b/src/Model/Order/Order.php @@ -165,11 +165,11 @@ public static function fromData( int $itemsCount, ?DateTimeInterface $promisedShippingTime, ?string $extraAttributes, - ?ExtraBillingAttributes $extraBillingAttributes, array $statuses, ?bool $businessInvoiceRequired, ?string $shippingType, - ?string $operatorCode = null + ?string $operatorCode = null, + ?ExtraBillingAttributes $extraBillingAttributes ): Order { $order = new self(); diff --git a/tests/Unit/Order/ExtraBillingAttributesTest.php b/tests/Unit/Order/ExtraBillingAttributesTest.php new file mode 100644 index 0000000..ba60251 --- /dev/null +++ b/tests/Unit/Order/ExtraBillingAttributesTest.php @@ -0,0 +1,135 @@ +createXmlStringForBillingInformation()); + + $billingInformation = ExtraBillingAttributesFactory::make($simpleXml); + + $this->assertInstanceOf(ExtraBillingAttributes::class, $billingInformation); + $this->assertEquals($simpleXml->LegalId, $billingInformation->getLegalId()); + $this->assertEquals($simpleXml->FiscalPerson, $billingInformation->getFiscalPerson()); + $this->assertEquals($simpleXml->DocumentType, $billingInformation->getDocumentType()); + $this->assertEquals($simpleXml->ReceiverRegion, $billingInformation->getReceiverRegion()); + $this->assertEquals($simpleXml->ReceiverAddress, $billingInformation->getReceiverAddress()); + $this->assertEquals($simpleXml->ReceiverPostcode, $billingInformation->getReceiverPostCode()); + $this->assertEquals($simpleXml->ReceiverLegalName, $billingInformation->getReceiverLegalName()); + $this->assertEquals($simpleXml->ReceiverMunicipality, $billingInformation->getReceiverMunicipality()); + $this->assertEquals($simpleXml->ReceiverTypeRegimen, $billingInformation->getReceiverTypeRegimen()); + $this->assertEquals($simpleXml->CustomerVerifierDigit, $billingInformation->getCustomerVerifierDigit()); + $this->assertEquals($simpleXml->ReceiverLocality, $billingInformation->getReceiverLocality()); + $this->assertEquals($simpleXml->ReceiverEmail, $billingInformation->getReceiverEmail()); + $this->assertEquals($simpleXml->ReceiverPhonenumber, $billingInformation->getReceiverPhoneNumber()); + } + + /** + * @dataProvider invalidXmlStructure + */ + public function testItThrowsAExceptionWithoutAPropertyInTheXml(string $property): void + { + $this->expectException(InvalidXmlStructureException::class); + + $this->expectExceptionMessage( + sprintf( + 'The xml structure is not valid for a BillingAttributes. The property %s should exist.', + $property + ) + ); + + $simpleXml = simplexml_load_string($this->createXmlStringForBillingInformation()); + unset($simpleXml->{$property}); + + ExtraBillingAttributesFactory::make($simpleXml); + } + + public function testItReturnsAJsonRepresentation(): void + { + $xml = $this->createXmlStringForBillingInformation(); + + $simpleXml = simplexml_load_string($xml); + + $billingInformation = ExtraBillingAttributesFactory::make($simpleXml); + + $expectedJson = Json::decode($this->getSchema('Order/ExtraBillingAttributes.json')); + $expectedJson['legalId'] = $this->legalId; + $expectedJson['fiscalPerson'] = $this->fiscalPerson; + $expectedJson['documentType'] = $this->documentType; + $expectedJson['receiverRegion'] = $this->receiverRegion; + $expectedJson['receiverAddress'] = $this->receiverAddress; + $expectedJson['receiverPostcode'] = $this->receiverPostcode; + $expectedJson['receiverLegalName'] = $this->receiverLegalName; + $expectedJson['receiverMunicipality'] = $this->receiverMunicipality; + $expectedJson['receiverTypeRegimen'] = $this->receiverTypeRegimen; + $expectedJson['customerVerifierDigit'] = $this->customerVerifierDigit; + $expectedJson['receiverLocality'] = $this->receiverLocality; + $expectedJson['receiverEmail'] = $this->receiverEmail; + $expectedJson['receiverPhonenumber'] = $this->receiverPhonenumber; + + $this->assertJsonStringEqualsJsonString(Json::encode($expectedJson), Json::encode($billingInformation)); + } + + public function createXmlStringForBillingInformation(string $schema = 'Order/ExtraBillingAttributes.xml'): string + { + return sprintf( + $this->getSchema($schema), + $this->legalId, + $this->fiscalPerson, + $this->documentType, + $this->receiverRegion, + $this->receiverAddress, + $this->receiverPostcode, + $this->receiverLegalName, + $this->receiverMunicipality, + $this->receiverTypeRegimen, + $this->customerVerifierDigit, + $this->receiverLocality, + $this->receiverEmail, + $this->receiverPhonenumber + ); + } + + public function invalidXmlStructure(): array + { + return [ + ['LegalId'], + ['FiscalPerson'], + ['DocumentType'], + ['ReceiverRegion'], + ['ReceiverAddress'], + ['ReceiverPostcode'], + ['ReceiverLegalName'], + ['ReceiverMunicipality'], + ['ReceiverTypeRegimen'], + ['CustomerVerifierDigit'], + ['ReceiverLocality'], + ['ReceiverEmail'], + ['ReceiverPhonenumber'], + ]; + } +} diff --git a/tests/_schemas/Order/ExtraBillingAttributes.json b/tests/_schemas/Order/ExtraBillingAttributes.json new file mode 100644 index 0000000..b4e8204 --- /dev/null +++ b/tests/_schemas/Order/ExtraBillingAttributes.json @@ -0,0 +1,15 @@ +{ + "legalId": "%s", + "fiscalPerson": "%s", + "documentType": "%s", + "receiverRegion": "%s", + "receiverAddress": "%s", + "receiverPostcode": "%s", + "receiverLegalName": "%s", + "receiverMunicipality": "%s", + "receiverTypeRegimen": "%s", + "customerVerifierDigit": "%s", + "receiverLocality": "%s", + "receiverEmail": "%s", + "receiverPhonenumber": "%s" +} \ No newline at end of file diff --git a/tests/_schemas/Order/ExtraBillingAttributes.xml b/tests/_schemas/Order/ExtraBillingAttributes.xml new file mode 100644 index 0000000..ae2e2bf --- /dev/null +++ b/tests/_schemas/Order/ExtraBillingAttributes.xml @@ -0,0 +1,16 @@ + + + 77656276-9 + business + RUT + METROPOLITANA DE SANTIAGO + JOSE MANUEL INFANTE 1155, 902 PROVIDENCIA + - + COMERCIALIZADORA VIPAZ SPA + PROVIDENCIA + 475201 - VENTA AL POR MENOR DE ARTÍCULOS DE FERRETERÍA Y MATERIALES DE CONSTRUCCIÓN + 9 + PROVIDENCIA + comercializadora.vipaz@gmail.com + +56999100109 + \ No newline at end of file From 0e195be7c2c34ac1ebbb99e635a766f1de5e7d85 Mon Sep 17 00:00:00 2001 From: mramosp Date: Thu, 13 Jun 2024 15:19:10 -0400 Subject: [PATCH 3/4] fix: delete xml validation --- .../Order/ExtraBillingAttributesFactory.php | 20 ---------------- .../Unit/Order/ExtraBillingAttributesTest.php | 23 +------------------ 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/src/Factory/Xml/Order/ExtraBillingAttributesFactory.php b/src/Factory/Xml/Order/ExtraBillingAttributesFactory.php index 653bfac..9124da1 100644 --- a/src/Factory/Xml/Order/ExtraBillingAttributesFactory.php +++ b/src/Factory/Xml/Order/ExtraBillingAttributesFactory.php @@ -5,32 +5,12 @@ namespace Linio\SellerCenter\Factory\Xml\Order; use Linio\SellerCenter\Model\Order\ExtraBillingAttributes; -use Linio\SellerCenter\Validator\XmlStructureValidator; use SimpleXMLElement; class ExtraBillingAttributesFactory { - private const XML_MODEL = 'BillingAttributes'; - private const REQUIRED_FIELDS = [ - 'LegalId', - 'FiscalPerson', - 'DocumentType', - 'ReceiverRegion', - 'ReceiverAddress', - 'ReceiverPostcode', - 'ReceiverLegalName', - 'ReceiverMunicipality', - 'ReceiverTypeRegimen', - 'CustomerVerifierDigit', - 'ReceiverLocality', - 'ReceiverEmail', - 'ReceiverPhonenumber', - ]; - public static function make(SimpleXMLElement $element): ExtraBillingAttributes { - XmlStructureValidator::validateStructure($element, self::XML_MODEL, self::REQUIRED_FIELDS); - return new ExtraBillingAttributes( (string) $element->LegalId, (string) $element->FiscalPerson, diff --git a/tests/Unit/Order/ExtraBillingAttributesTest.php b/tests/Unit/Order/ExtraBillingAttributesTest.php index ba60251..f35ae56 100644 --- a/tests/Unit/Order/ExtraBillingAttributesTest.php +++ b/tests/Unit/Order/ExtraBillingAttributesTest.php @@ -5,7 +5,6 @@ namespace Linio\SellerCenter\Order; use Linio\Component\Util\Json; -use Linio\SellerCenter\Exception\InvalidXmlStructureException; use Linio\SellerCenter\Factory\Xml\Order\ExtraBillingAttributesFactory; use Linio\SellerCenter\LinioTestCase; use Linio\SellerCenter\Model\Order\ExtraBillingAttributes; @@ -26,7 +25,7 @@ class ExtraBillingAttributesTest extends LinioTestCase protected $receiverEmail = 'comercializadora.vipaz@gmail.com'; protected $receiverPhonenumber = '+56999100109'; - public function testItReturnsValidAddress(): void + public function testItReturnsValidBillingAttributes(): void { $simpleXml = simplexml_load_string($this->createXmlStringForBillingInformation()); @@ -48,26 +47,6 @@ public function testItReturnsValidAddress(): void $this->assertEquals($simpleXml->ReceiverPhonenumber, $billingInformation->getReceiverPhoneNumber()); } - /** - * @dataProvider invalidXmlStructure - */ - public function testItThrowsAExceptionWithoutAPropertyInTheXml(string $property): void - { - $this->expectException(InvalidXmlStructureException::class); - - $this->expectExceptionMessage( - sprintf( - 'The xml structure is not valid for a BillingAttributes. The property %s should exist.', - $property - ) - ); - - $simpleXml = simplexml_load_string($this->createXmlStringForBillingInformation()); - unset($simpleXml->{$property}); - - ExtraBillingAttributesFactory::make($simpleXml); - } - public function testItReturnsAJsonRepresentation(): void { $xml = $this->createXmlStringForBillingInformation(); From 5866134e8b63124d464fb06e656d71bcf07311dc Mon Sep 17 00:00:00 2001 From: mramosp Date: Fri, 14 Jun 2024 11:05:18 -0400 Subject: [PATCH 4/4] fix: add default value to extra billing attributes --- src/Model/Order/Order.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Order/Order.php b/src/Model/Order/Order.php index d50c5d9..1149dfe 100644 --- a/src/Model/Order/Order.php +++ b/src/Model/Order/Order.php @@ -169,7 +169,7 @@ public static function fromData( ?bool $businessInvoiceRequired, ?string $shippingType, ?string $operatorCode = null, - ?ExtraBillingAttributes $extraBillingAttributes + ?ExtraBillingAttributes $extraBillingAttributes = null ): Order { $order = new self();