From bb25f9a9809cd08573f71adefaf18ddcdeec9197 Mon Sep 17 00:00:00 2001 From: Lena Orobei Date: Wed, 23 Oct 2019 14:07:08 -0500 Subject: [PATCH] magento/graphql-ce#903: [Checkout] Replace use_for_shipping with same_as_shipping --- .../Model/Cart/SetBillingAddressOnCart.php | 7 ++- .../Customer/SetBillingAddressOnCartTest.php | 60 +------------------ .../Guest/SetBillingAddressOnCartTest.php | 60 +------------------ 3 files changed, 9 insertions(+), 118 deletions(-) diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php index 0d937cc64a857..7c8126194777f 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php @@ -65,10 +65,11 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b { $customerAddressId = $billingAddressInput['customer_address_id'] ?? null; $addressInput = $billingAddressInput['address'] ?? null; - $sameAsShipping = isset($billingAddressInput['same_as_shipping']) - ? (bool)$billingAddressInput['same_as_shipping'] : false; + // Need to keep this for BC of `use_for_shipping` field $sameAsShipping = isset($billingAddressInput['use_for_shipping']) - ? (bool)$billingAddressInput['use_for_shipping'] : $sameAsShipping; + ? (bool)$billingAddressInput['use_for_shipping'] : false; + $sameAsShipping = isset($billingAddressInput['same_as_shipping']) + ? (bool)$billingAddressInput['same_as_shipping'] : $sameAsShipping; if (null === $customerAddressId && null === $addressInput) { throw new GraphQlInputException( 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 65497a993da6a..065354114b301 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 @@ -86,64 +86,6 @@ public function testSetNewBillingAddress() $query = <<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); - } - - /** - * @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 testSetNewBillingAddressWithSameAsShippingParameter() - { - $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); - - $query = <<graphQlMutation($query); - - self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']); - $cartResponse = $response['setBillingAddressOnCart']['cart']; - self::assertArrayHasKey('billing_address', $cartResponse); - $billingAddressResponse = $cartResponse['billing_address']; - $this->assertNewAddressFields($billingAddressResponse); - } - - /** - * @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 - */ - public function testSetNewBillingAddressWithSameAsShippingParameter() - { - $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); - - $query = <<assertNewAddressFields($billingAddressResponse); self::assertArrayHasKey('shipping_addresses', $cartResponse); $shippingAddressResponse = current($cartResponse['shipping_addresses']); $this->assertNewAddressFields($billingAddressResponse); @@ -160,6 +104,8 @@ public function testSetNewBillingAddressWithSameAsShippingParameter() } /** + * Test case for deprecated `use_for_shipping` param. + * * @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