Skip to content

Commit 49cfa88

Browse files
author
Vitaliy Boyko
committed
graphQl-892: fixed billing address return implementation
1 parent 75deec1 commit 49cfa88

File tree

4 files changed

+10
-47
lines changed

4 files changed

+10
-47
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/BillingAddress.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
4444
$cart = $value['model'];
4545

4646
$billingAddress = $cart->getBillingAddress();
47-
if (null === $billingAddress) {
47+
if (null === $billingAddress ||
48+
null === $billingAddress->getFirstname() ||
49+
null === $billingAddress->getLastname() ||
50+
null === $billingAddress->getCity() ||
51+
null === $billingAddress->getCountry() ||
52+
null === $billingAddress->getTelephone() ||
53+
null === $billingAddress->getStreet()) {
4854
return null;
4955
}
5056

app/code/Magento/QuoteGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ type Cart {
194194
applied_coupon: AppliedCoupon @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\AppliedCoupon")
195195
email: String @resolver (class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\CartEmail")
196196
shipping_addresses: [ShippingCartAddress]! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddresses")
197-
billing_address: BillingCartAddress! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\BillingAddress")
197+
billing_address: BillingCartAddress @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\BillingAddress")
198198
available_payment_methods: [AvailablePaymentMethod] @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\AvailablePaymentMethods") @doc(description: "Available payment methods")
199199
selected_payment_method: SelectedPaymentMethod @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\SelectedPaymentMethod")
200200
prices: CartPrices @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\CartPrices")

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

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -91,29 +91,7 @@ public function testGetSpecifiedBillingAddressIfBillingAddressIsNotSet()
9191
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap());
9292
self::assertArrayHasKey('cart', $response);
9393
self::assertArrayHasKey('billing_address', $response['cart']);
94-
95-
$expectedBillingAddressData = [
96-
'firstname' => null,
97-
'lastname' => null,
98-
'company' => null,
99-
'street' => [
100-
''
101-
],
102-
'city' => null,
103-
'region' => [
104-
'code' => null,
105-
'label' => null,
106-
],
107-
'postcode' => null,
108-
'country' => [
109-
'code' => null,
110-
'label' => null,
111-
],
112-
'telephone' => null,
113-
'__typename' => 'BillingCartAddress',
114-
'customer_notes' => null,
115-
];
116-
self::assertEquals($expectedBillingAddressData, $response['cart']['billing_address']);
94+
self::assertNull($response['cart']['billing_address']);
11795
}
11896

11997
/**

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,28 +81,7 @@ public function testGetSpecifiedBillingAddressIfBillingAddressIsNotSet()
8181
$response = $this->graphQlQuery($query);
8282
self::assertArrayHasKey('cart', $response);
8383
self::assertArrayHasKey('billing_address', $response['cart']);
84-
85-
$expectedBillingAddressData = [
86-
'firstname' => null,
87-
'lastname' => null,
88-
'company' => null,
89-
'street' => [
90-
''
91-
],
92-
'city' => null,
93-
'region' => [
94-
'code' => null,
95-
'label' => null,
96-
],
97-
'postcode' => null,
98-
'country' => [
99-
'code' => null,
100-
'label' => null,
101-
],
102-
'telephone' => null,
103-
'__typename' => 'BillingCartAddress',
104-
];
105-
self::assertEquals($expectedBillingAddressData, $response['cart']['billing_address']);
84+
self::assertNull($response['cart']['billing_address']);
10685
}
10786

10887
/**

0 commit comments

Comments
 (0)