Skip to content

Commit bb25f9a

Browse files
committed
magento/graphql-ce#903: [Checkout] Replace use_for_shipping with same_as_shipping
1 parent 4939719 commit bb25f9a

File tree

3 files changed

+9
-118
lines changed

3 files changed

+9
-118
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
6565
{
6666
$customerAddressId = $billingAddressInput['customer_address_id'] ?? null;
6767
$addressInput = $billingAddressInput['address'] ?? null;
68-
$sameAsShipping = isset($billingAddressInput['same_as_shipping'])
69-
? (bool)$billingAddressInput['same_as_shipping'] : false;
68+
// Need to keep this for BC of `use_for_shipping` field
7069
$sameAsShipping = isset($billingAddressInput['use_for_shipping'])
71-
? (bool)$billingAddressInput['use_for_shipping'] : $sameAsShipping;
70+
? (bool)$billingAddressInput['use_for_shipping'] : false;
71+
$sameAsShipping = isset($billingAddressInput['same_as_shipping'])
72+
? (bool)$billingAddressInput['same_as_shipping'] : $sameAsShipping;
7273

7374
if (null === $customerAddressId && null === $addressInput) {
7475
throw new GraphQlInputException(

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -86,64 +86,6 @@ public function testSetNewBillingAddress()
8686

8787
$query = <<<QUERY
8888
mutation {
89-
setBillingAddressOnCart(
90-
input: {
91-
cart_id: "$maskedQuoteId"
92-
billing_address: {
93-
address: {
94-
firstname: "test firstname"
95-
lastname: "test lastname"
96-
company: "test company"
97-
street: ["test street 1", "test street 2"]
98-
city: "test city"
99-
region: "test region"
100-
postcode: "887766"
101-
country_code: "US"
102-
telephone: "88776655"
103-
}
104-
}
105-
}
106-
) {
107-
cart {
108-
billing_address {
109-
firstname
110-
lastname
111-
company
112-
street
113-
city
114-
postcode
115-
telephone
116-
country {
117-
code
118-
label
119-
}
120-
__typename
121-
}
122-
}
123-
}
124-
}
125-
QUERY;
126-
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
127-
128-
self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']);
129-
$cartResponse = $response['setBillingAddressOnCart']['cart'];
130-
self::assertArrayHasKey('billing_address', $cartResponse);
131-
$billingAddressResponse = $cartResponse['billing_address'];
132-
$this->assertNewAddressFields($billingAddressResponse);
133-
}
134-
135-
/**
136-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
137-
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
138-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
139-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
140-
*/
141-
public function testSetNewBillingAddressWithSameAsShippingParameter()
142-
{
143-
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
144-
145-
$query = <<<QUERY
146-
mutation {
14789
setBillingAddressOnCart(
14890
input: {
14991
cart_id: "$maskedQuoteId"
@@ -209,6 +151,8 @@ public function testSetNewBillingAddressWithSameAsShippingParameter()
209151
}
210152

211153
/**
154+
* Test case for deprecated `use_for_shipping` param.
155+
*
212156
* @magentoApiDataFixture Magento/Customer/_files/customer.php
213157
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
214158
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -38,63 +38,6 @@ public function testSetNewBillingAddress()
3838

3939
$query = <<<QUERY
4040
mutation {
41-
setBillingAddressOnCart(
42-
input: {
43-
cart_id: "$maskedQuoteId"
44-
billing_address: {
45-
address: {
46-
firstname: "test firstname"
47-
lastname: "test lastname"
48-
company: "test company"
49-
street: ["test street 1", "test street 2"]
50-
city: "test city"
51-
region: "test region"
52-
postcode: "887766"
53-
country_code: "US"
54-
telephone: "88776655"
55-
}
56-
}
57-
}
58-
) {
59-
cart {
60-
billing_address {
61-
firstname
62-
lastname
63-
company
64-
street
65-
city
66-
postcode
67-
telephone
68-
country {
69-
code
70-
label
71-
}
72-
__typename
73-
}
74-
}
75-
}
76-
}
77-
QUERY;
78-
$response = $this->graphQlMutation($query);
79-
80-
self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']);
81-
$cartResponse = $response['setBillingAddressOnCart']['cart'];
82-
self::assertArrayHasKey('billing_address', $cartResponse);
83-
$billingAddressResponse = $cartResponse['billing_address'];
84-
$this->assertNewAddressFields($billingAddressResponse);
85-
}
86-
87-
/**
88-
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
89-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
90-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
91-
*/
92-
public function testSetNewBillingAddressWithSameAsShippingParameter()
93-
{
94-
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
95-
96-
$query = <<<QUERY
97-
mutation {
9841
setBillingAddressOnCart(
9942
input: {
10043
cart_id: "$maskedQuoteId"
@@ -153,13 +96,16 @@ public function testSetNewBillingAddressWithSameAsShippingParameter()
15396
$cartResponse = $response['setBillingAddressOnCart']['cart'];
15497
self::assertArrayHasKey('billing_address', $cartResponse);
15598
$billingAddressResponse = $cartResponse['billing_address'];
99+
$this->assertNewAddressFields($billingAddressResponse);
156100
self::assertArrayHasKey('shipping_addresses', $cartResponse);
157101
$shippingAddressResponse = current($cartResponse['shipping_addresses']);
158102
$this->assertNewAddressFields($billingAddressResponse);
159103
$this->assertNewAddressFields($shippingAddressResponse, 'ShippingCartAddress');
160104
}
161105

162106
/**
107+
* Test case for deprecated `use_for_shipping` param.
108+
*
163109
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
164110
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
165111
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php

0 commit comments

Comments
 (0)