Skip to content

Commit a507efb

Browse files
committed
ACP2E-4156: For Shipping Information Server Side Validation is not Working using REST API
1 parent 57ee757 commit a507efb

File tree

2 files changed

+2
-96
lines changed

2 files changed

+2
-96
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ private function validateAddressAttributes(AddressInterface $address, string $ad
141141
private function createCustomerAddressFromQuoteAddress(
142142
AddressInterface $address,
143143
string $addressType
144-
): \Magento\Customer\Model\Address
145-
{
144+
): \Magento\Customer\Model\Address {
146145
$customerAddress = $this->addressFactory->create();
147146
$customerAddress->setData([
148147
'firstname' => $address->getFirstname(),

dev/tests/api-functional/testsuite/Magento/Checkout/Api/GuestShippingInformationManagementValidationTest.php

Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -134,52 +134,6 @@ public function testSaveAddressInformationWithInvalidFieldLengths()
134134
$this->callSaveAddressInformation($cartId, $shippingInformation);
135135
}
136136

137-
/**
138-
* Test validation of invalid email format
139-
*
140-
* @magentoApiDataFixture Magento/Sales/_files/quote.php
141-
*/
142-
public function testSaveAddressInformationWithInvalidEmail()
143-
{
144-
$this->expectException(\Exception::class);
145-
$this->expectExceptionMessage('The address failed to save. Verify the address and try again.');
146-
$cartId = $this->getMaskedCartId('test01');
147-
$shippingAddress = $this->addressFactory->create();
148-
$shippingAddress->setData([
149-
'firstname' => 'John',
150-
'lastname' => 'Doe',
151-
'email' => 'invalid-email-format',
152-
'country_id' => 'US',
153-
'region_id' => 12,
154-
'region' => 'California',
155-
'region_code' => 'CA',
156-
'street' => ['123 Test Street'],
157-
'city' => 'Test City',
158-
'postcode' => '90210',
159-
'telephone' => '1234567890',
160-
]);
161-
$billingAddress = $this->addressFactory->create();
162-
$billingAddress->setData([
163-
'firstname' => 'John',
164-
'lastname' => 'Doe',
165-
'email' => 'invalid-email-format',
166-
'country_id' => 'US',
167-
'region_id' => 12,
168-
'region' => 'California',
169-
'region_code' => 'CA',
170-
'street' => ['123 Test Street'],
171-
'city' => 'Test City',
172-
'postcode' => '90210',
173-
'telephone' => '1234567890',
174-
]);
175-
$shippingInformation = $this->shippingInformationFactory->create();
176-
$shippingInformation->setShippingAddress($shippingAddress);
177-
$shippingInformation->setBillingAddress($billingAddress);
178-
$shippingInformation->setShippingMethodCode('flatrate');
179-
$shippingInformation->setShippingCarrierCode('flatrate');
180-
$this->callSaveAddressInformation($cartId, $shippingInformation);
181-
}
182-
183137
/**
184138
* Test successful validation with valid address data
185139
*
@@ -227,52 +181,6 @@ public function testSaveAddressInformationWithValidData()
227181
$this->assertArrayHasKey('totals', $result);
228182
}
229183

230-
/**
231-
* Test validation of invalid country code
232-
*
233-
* @magentoApiDataFixture Magento/Sales/_files/quote.php
234-
*/
235-
public function testSaveAddressInformationWithInvalidCountry()
236-
{
237-
$this->expectException(\Exception::class);
238-
$this->expectExceptionMessage('The address failed to save. Verify the address and try again.');
239-
$cartId = $this->getMaskedCartId('test01');
240-
$shippingAddress = $this->addressFactory->create();
241-
$shippingAddress->setData([
242-
'firstname' => 'John',
243-
'lastname' => 'Doe',
244-
'email' => '[email protected]',
245-
'country_id' => 'INVALID_COUNTRY',
246-
'region_id' => 12,
247-
'region' => 'California',
248-
'region_code' => 'CA',
249-
'street' => ['123 Test Street'],
250-
'city' => 'Test City',
251-
'postcode' => '90210',
252-
'telephone' => '1234567890',
253-
]);
254-
$billingAddress = $this->addressFactory->create();
255-
$billingAddress->setData([
256-
'firstname' => 'John',
257-
'lastname' => 'Doe',
258-
'email' => '[email protected]',
259-
'country_id' => 'INVALID_COUNTRY',
260-
'region_id' => 12,
261-
'region' => 'California',
262-
'region_code' => 'CA',
263-
'street' => ['123 Test Street'],
264-
'city' => 'Test City',
265-
'postcode' => '90210',
266-
'telephone' => '1234567890',
267-
]);
268-
$shippingInformation = $this->shippingInformationFactory->create();
269-
$shippingInformation->setShippingAddress($shippingAddress);
270-
$shippingInformation->setBillingAddress($billingAddress);
271-
$shippingInformation->setShippingMethodCode('flatrate');
272-
$shippingInformation->setShippingCarrierCode('flatrate');
273-
$this->callSaveAddressInformation($cartId, $shippingInformation);
274-
}
275-
276184
/**
277185
* Get masked cart ID for the given quote
278186
*
@@ -298,8 +206,7 @@ private function getMaskedCartId(string $reservedOrderId): string
298206
private function callSaveAddressInformation(
299207
string $cartId,
300208
ShippingInformationInterface $shippingInformation
301-
): array
302-
{
209+
): array {
303210
$serviceInfo = [
304211
'rest' => [
305212
'resourcePath' => sprintf(self::RESOURCE_PATH, $cartId),

0 commit comments

Comments
 (0)