Skip to content

Commit d09a26a

Browse files
committed
ACP2E-4156: For Shipping Information Server Side Validation is not Working using REST API
1 parent 15a0a67 commit d09a26a

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

app/code/Magento/Checkout/Model/GuestShippingInformationManagement.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,9 @@ public function saveAddressInformation(
6363
ShippingInformationInterface $addressInformation
6464
) {
6565
$shippingAddress = $addressInformation->getShippingAddress();
66-
$extensionAttributes = null;
6766
if ($shippingAddress) {
68-
$extensionAttributes = $shippingAddress->getExtensionAttributes();
6967
$this->validateAddressAttributes($shippingAddress, 'shipping');
7068
}
71-
$billingAddress = $addressInformation->getBillingAddress();
72-
if ($billingAddress) {
73-
if ($extensionAttributes && empty($billingAddress->getExtensionAttributes()->__toArray())) {
74-
$billingAddress->setExtensionAttributes($extensionAttributes);
75-
}
76-
$this->validateAddressAttributes($billingAddress, 'billing');
77-
}
7869

7970
/** @var $quoteIdMask \Magento\Quote\Model\QuoteIdMask */
8071
$quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id');

app/code/Magento/Checkout/Test/Unit/Model/GuestShippingInformationManagementTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,18 @@ public function testSaveAddressInformation()
8484
$addressInformationMock->expects($this->once())
8585
->method('getBillingAddress')
8686
->willReturn($billingAddressMock);
87-
$shippingAddressMock->expects($this->exactly(2))
87+
$shippingAddressMock->expects($this->once())
8888
->method('getExtensionAttributes')
8989
->willReturn(null);
9090
$billingAddressMock->expects($this->once())
9191
->method('getExtensionAttributes')
9292
->willReturn(null);
9393
$customerAddressMock = $this->createMock(Address::class);
94-
$this->addressFactoryMock->expects($this->exactly(2))
94+
$this->addressFactoryMock->expects($this->once())
9595
->method('create')
9696
->willReturn($customerAddressMock);
9797
$validatorMock = $this->createMock(ValidatorInterface::class);
98-
$this->validatorFactoryMock->expects($this->exactly(2))
98+
$this->validatorFactoryMock->expects($this->once())
9999
->method('createValidator')
100100
->with('customer_address', 'save')
101101
->willReturn($validatorMock);
@@ -136,8 +136,6 @@ public function testSaveAddressInformationWithInvalidAddress()
136136
$addressInformationMock->expects($this->once())
137137
->method('getShippingAddress')
138138
->willReturn($shippingAddressMock);
139-
$addressInformationMock->expects($this->never())
140-
->method('getBillingAddress');
141139
$shippingAddressMock->method('getExtensionAttributes')->willReturn(null);
142140
$customerAddressMock = $this->createMock(Address::class);
143141
$this->addressFactoryMock->expects($this->once())->method('create')->willReturn($customerAddressMock);

0 commit comments

Comments
 (0)