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); } /**