From e4c07521ba9836c19cc7ba53b27c669488b02fd5 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Wed, 24 Jul 2019 14:38:13 +0300 Subject: [PATCH 1/6] graphQl-784: added validation for the lowercase country id --- .../Model/Cart/QuoteAddressFactory.php | 6 +++ .../Model/Cart/SetShippingAddressesOnCart.php | 1 - .../Customer/SetBillingAddressOnCartTest.php | 44 ++++++++++++++++++ .../Customer/SetShippingAddressOnCartTest.php | 46 +++++++++++++++++++ 4 files changed, 96 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php index a66c0ddb1a536..d70ebec2a39ca 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php @@ -61,6 +61,11 @@ public function __construct( public function createBasedOnInputData(array $addressInput): QuoteAddress { $addressInput['country_id'] = $addressInput['country_code'] ?? ''; + if ($addressInput['country_id'] && !ctype_upper($addressInput['country_code'] )) { + throw new GraphQlInputException( + __('"Country Code" cannot contain lowercase characters.') + ); + } $maxAllowedLineCount = $this->addressHelper->getStreetLines(); if (is_array($addressInput['street']) && count($addressInput['street']) > $maxAllowedLineCount) { @@ -69,6 +74,7 @@ public function createBasedOnInputData(array $addressInput): QuoteAddress ); } + $quoteAddress = $this->quoteAddressFactory->create(); $quoteAddress->addData($addressInput); return $quoteAddress; diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php index de1d93003ab12..77719bed5b16f 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php @@ -66,7 +66,6 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s } if (null === $customerAddressId) { - $addressInput['country_code'] = strtoupper($addressInput['country_code']); $shippingAddress = $this->quoteAddressFactory->createBasedOnInputData($addressInput); } else { if (false === $context->getExtensionAttributes()->getIsCustomer()) { diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php index 9ff4d3bd0f605..927160c31d0a4 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php @@ -637,6 +637,50 @@ public function testSetNewBillingAddressWithRedundantStreetLine() $this->graphQlMutation($query, [], '', $this->getHeaderMap()); } + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + * @expectedException \Exception + * @expectedExceptionMessage "Country Code" cannot contain lowercase characters. + */ + public function testSetNewBillingAddressWithLowercaseCountryCode() + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + + $query = <<graphQlMutation($query, [], '', $this->getHeaderMap()); + } + /** * Verify the all the whitelisted fields for a New Address Object * diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php index 15ee125955062..747eeb21d665c 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php @@ -655,6 +655,52 @@ public function testSetShippingAddressWithLowerCaseCountry() $this->assertEquals('CA', $address['region']['code']); } + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + * @expectedException \Exception + * @expectedExceptionMessage "Country Code" cannot contain lowercase characters. + */ + public function testSetNewShippingAddressOnCartWithLowercaseCountryCode() + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + + $query = <<graphQlMutation($query, [], '', $this->getHeaderMap()); + } + /** * Verify the all the whitelisted fields for a New Address Object * From 28c5a881d23e99b847d16161f028a926bfc60ddb Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Wed, 24 Jul 2019 14:41:08 +0300 Subject: [PATCH 2/6] graphQl-784: code style fix --- app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php index d70ebec2a39ca..c3b89fc48daef 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php @@ -74,7 +74,6 @@ public function createBasedOnInputData(array $addressInput): QuoteAddress ); } - $quoteAddress = $this->quoteAddressFactory->create(); $quoteAddress->addData($addressInput); return $quoteAddress; From e9b63347f026274dc8c9c2a16d3181ebac0eb950 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Thu, 25 Jul 2019 13:32:27 +0300 Subject: [PATCH 3/6] graphQl-784: added guest tests --- .../Model/Cart/QuoteAddressFactory.php | 2 +- .../Customer/SetBillingAddressOnCartTest.php | 2 +- .../Customer/SetShippingAddressOnCartTest.php | 55 +------------------ .../Guest/SetBillingAddressOnCartTest.php | 43 +++++++++++++++ .../Guest/SetShippingAddressOnCartTest.php | 10 +--- 5 files changed, 49 insertions(+), 63 deletions(-) diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php index c3b89fc48daef..af45831e61028 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php @@ -61,7 +61,7 @@ public function __construct( public function createBasedOnInputData(array $addressInput): QuoteAddress { $addressInput['country_id'] = $addressInput['country_code'] ?? ''; - if ($addressInput['country_id'] && !ctype_upper($addressInput['country_code'] )) { + if ($addressInput['country_id'] && !ctype_upper($addressInput['country_code'])) { throw new GraphQlInputException( __('"Country Code" cannot contain lowercase characters.') ); diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php index 927160c31d0a4..a2b2d2e82e602 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php @@ -645,7 +645,7 @@ public function testSetNewBillingAddressWithRedundantStreetLine() * @expectedException \Exception * @expectedExceptionMessage "Country Code" cannot contain lowercase characters. */ - public function testSetNewBillingAddressWithLowercaseCountryCode() + public function testSetBillingAddressWithLowerCaseCountry() { $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php index 747eeb21d665c..9f2bb5e2a35d9 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php @@ -602,59 +602,6 @@ public function testSetShippingAddressToGuestCart() $this->graphQlMutation($query, [], '', $this->getHeaderMap()); } - /** - * @magentoApiDataFixture Magento/Customer/_files/customer.php - * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php - * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php - */ - public function testSetShippingAddressWithLowerCaseCountry() - { - $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); - - $query = <<graphQlMutation($query, [], '', $this->getHeaderMap()); - - self::assertCount(1, $result['setShippingAddressesOnCart']['cart']['shipping_addresses']); - $address = reset($result['setShippingAddressesOnCart']['cart']['shipping_addresses']); - - $this->assertEquals('US', $address['country']['code']); - $this->assertEquals('CA', $address['region']['code']); - } - /** * @magentoApiDataFixture Magento/Customer/_files/customer.php * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php @@ -663,7 +610,7 @@ public function testSetShippingAddressWithLowerCaseCountry() * @expectedException \Exception * @expectedExceptionMessage "Country Code" cannot contain lowercase characters. */ - public function testSetNewShippingAddressOnCartWithLowercaseCountryCode() + public function testSetShippingAddressWithLowerCaseCountry() { $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php index 4afcfb2aef9db..796beea877f85 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php @@ -455,6 +455,49 @@ public function testSetNewBillingAddressRedundantStreetLine() $this->graphQlMutation($query); } + /** + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + * @expectedException \Exception + * @expectedExceptionMessage "Country Code" cannot contain lowercase characters. + */ + public function testSetBillingAddressWithLowerCaseCountry() + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + + $query = <<graphQlMutation($query); + } + /** * Verify the all the whitelisted fields for a New Address Object * diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php index 537c8f09a0a98..553b498d7b9d5 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php @@ -411,6 +411,8 @@ public function testSetShippingAddressOnNonExistentCart() * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + * @expectedException \Exception + * @expectedExceptionMessage "Country Code" cannot contain lowercase characters. */ public function testSetShippingAddressWithLowerCaseCountry() { @@ -450,13 +452,7 @@ public function testSetShippingAddressWithLowerCaseCountry() } } QUERY; - $result = $this->graphQlMutation($query); - - self::assertCount(1, $result['setShippingAddressesOnCart']['cart']['shipping_addresses']); - $address = reset($result['setShippingAddressesOnCart']['cart']['shipping_addresses']); - - $this->assertEquals('US', $address['country']['code']); - $this->assertEquals('CA', $address['region']['code']); + $this->graphQlMutation($query); } /** From 9078004b6a2a01f0ceb1ccfcf13da97674f3ac2c Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Thu, 25 Jul 2019 19:14:44 +0300 Subject: [PATCH 4/6] graphQl-784: removed validation, added the text convert instead --- .../Model/Cart/QuoteAddressFactory.php | 8 ++--- .../Customer/SetBillingAddressOnCartTest.php | 21 +++++++++-- .../Customer/SetShippingAddressOnCartTest.php | 35 +++++++++++-------- .../Guest/SetBillingAddressOnCartTest.php | 25 ++++++++++--- .../Guest/SetShippingAddressOnCartTest.php | 10 ++++-- 5 files changed, 69 insertions(+), 30 deletions(-) diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php index af45831e61028..3ab93e2f0a19d 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php @@ -60,12 +60,10 @@ public function __construct( */ public function createBasedOnInputData(array $addressInput): QuoteAddress { - $addressInput['country_id'] = $addressInput['country_code'] ?? ''; - if ($addressInput['country_id'] && !ctype_upper($addressInput['country_code'])) { - throw new GraphQlInputException( - __('"Country Code" cannot contain lowercase characters.') - ); + if ($addressInput['country_code']) { + $addressInput['country_code'] = strtoupper($addressInput['country_code']); } + $addressInput['country_id'] = $addressInput['country_code'] ?? ''; $maxAllowedLineCount = $this->addressHelper->getStreetLines(); if (is_array($addressInput['street']) && count($addressInput['street']) > $maxAllowedLineCount) { diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php index a2b2d2e82e602..011930e723273 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php @@ -642,8 +642,6 @@ public function testSetNewBillingAddressWithRedundantStreetLine() * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php - * @expectedException \Exception - * @expectedExceptionMessage "Country Code" cannot contain lowercase characters. */ public function testSetBillingAddressWithLowerCaseCountry() { @@ -673,12 +671,29 @@ public function testSetBillingAddressWithLowerCaseCountry() cart { billing_address { firstname + lastname + company + street + city + postcode + telephone + country { + code + label + } + __typename } } } } QUERY; - $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + $response = $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + + self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']); + $cartResponse = $response['setBillingAddressOnCart']['cart']; + self::assertArrayHasKey('billing_address', $cartResponse); + $billingAddressResponse = $cartResponse['billing_address']; + $this->assertNewAddressFields($billingAddressResponse); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php index 9f2bb5e2a35d9..15ee125955062 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php @@ -607,8 +607,6 @@ public function testSetShippingAddressToGuestCart() * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php - * @expectedException \Exception - * @expectedExceptionMessage "Country Code" cannot contain lowercase characters. */ public function testSetShippingAddressWithLowerCaseCountry() { @@ -618,20 +616,18 @@ public function testSetShippingAddressWithLowerCaseCountry() mutation { setShippingAddressesOnCart( input: { - cart_id: "$maskedQuoteId" + cart_id: "{$maskedQuoteId}" shipping_addresses: [ { address: { - firstname: "test firstname" - lastname: "test lastname" - company: "test company" - street: ["test street 1", "test street 2"] - city: "test city" - region: "test region" - postcode: "887766" + firstname: "John" + lastname: "Doe" + street: ["6161 West Centinella Avenue"] + city: "Culver City" + region: "CA" + postcode: "90230" country_code: "us" - telephone: "88776655" - save_in_address_book: false + telephone: "555-555-55-55" } } ] @@ -639,13 +635,24 @@ public function testSetShippingAddressWithLowerCaseCountry() ) { cart { shipping_addresses { - firstname + region { + code + } + country { + code + } } } } } QUERY; - $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + $result = $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + + self::assertCount(1, $result['setShippingAddressesOnCart']['cart']['shipping_addresses']); + $address = reset($result['setShippingAddressesOnCart']['cart']['shipping_addresses']); + + $this->assertEquals('US', $address['country']['code']); + $this->assertEquals('CA', $address['region']['code']); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php index 796beea877f85..730e65b4ba8aa 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php @@ -459,8 +459,6 @@ public function testSetNewBillingAddressRedundantStreetLine() * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php - * @expectedException \Exception - * @expectedExceptionMessage "Country Code" cannot contain lowercase characters. */ public function testSetBillingAddressWithLowerCaseCountry() { @@ -472,7 +470,7 @@ public function testSetBillingAddressWithLowerCaseCountry() input: { cart_id: "$maskedQuoteId" billing_address: { - address: { + address: { firstname: "test firstname" lastname: "test lastname" company: "test company" @@ -483,19 +481,36 @@ public function testSetBillingAddressWithLowerCaseCountry() country_code: "us" telephone: "88776655" save_in_address_book: false - } + } } } ) { cart { billing_address { firstname + lastname + company + street + city + postcode + telephone + country { + code + label + } + __typename } } } } QUERY; - $this->graphQlMutation($query); + $response = $this->graphQlMutation($query); + + self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']); + $cartResponse = $response['setBillingAddressOnCart']['cart']; + self::assertArrayHasKey('billing_address', $cartResponse); + $billingAddressResponse = $cartResponse['billing_address']; + $this->assertNewAddressFields($billingAddressResponse); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php index 553b498d7b9d5..537c8f09a0a98 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php @@ -411,8 +411,6 @@ public function testSetShippingAddressOnNonExistentCart() * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php - * @expectedException \Exception - * @expectedExceptionMessage "Country Code" cannot contain lowercase characters. */ public function testSetShippingAddressWithLowerCaseCountry() { @@ -452,7 +450,13 @@ public function testSetShippingAddressWithLowerCaseCountry() } } QUERY; - $this->graphQlMutation($query); + $result = $this->graphQlMutation($query); + + self::assertCount(1, $result['setShippingAddressesOnCart']['cart']['shipping_addresses']); + $address = reset($result['setShippingAddressesOnCart']['cart']['shipping_addresses']); + + $this->assertEquals('US', $address['country']['code']); + $this->assertEquals('CA', $address['region']['code']); } /** From 03949568f3deb0ec97b0736a559c19dfbd63cf87 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Thu, 25 Jul 2019 21:58:35 +0300 Subject: [PATCH 5/6] graphQl-784: optimized the code --- .../Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php index 3ab93e2f0a19d..28017a1f7aca0 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php @@ -60,10 +60,11 @@ public function __construct( */ public function createBasedOnInputData(array $addressInput): QuoteAddress { + $addressInput['country_id'] = ''; if ($addressInput['country_code']) { $addressInput['country_code'] = strtoupper($addressInput['country_code']); } - $addressInput['country_id'] = $addressInput['country_code'] ?? ''; + $addressInput['country_id'] = $addressInput['country_code']; $maxAllowedLineCount = $this->addressHelper->getStreetLines(); if (is_array($addressInput['street']) && count($addressInput['street']) > $maxAllowedLineCount) { From dd0e02b50cbc87cd223434f9738358cf03581213 Mon Sep 17 00:00:00 2001 From: Vitaliy Boyko Date: Thu, 25 Jul 2019 21:59:22 +0300 Subject: [PATCH 6/6] graphQl-784: optimized the code --- .../Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php index 28017a1f7aca0..afc88f026ed62 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php @@ -63,8 +63,8 @@ public function createBasedOnInputData(array $addressInput): QuoteAddress $addressInput['country_id'] = ''; if ($addressInput['country_code']) { $addressInput['country_code'] = strtoupper($addressInput['country_code']); + $addressInput['country_id'] = $addressInput['country_code']; } - $addressInput['country_id'] = $addressInput['country_code']; $maxAllowedLineCount = $this->addressHelper->getStreetLines(); if (is_array($addressInput['street']) && count($addressInput['street']) > $maxAllowedLineCount) {