Skip to content

Commit 8b838d7

Browse files
authored
ENGCOM-4441: address_type is null after setting billing and shipping addresses on cart #415
2 parents bf4f0e7 + e44ff49 commit 8b838d7

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function execute(QuoteAddress $address): array
4242

4343
$addressData = array_merge($addressData, [
4444
'address_id' => $address->getId(),
45+
'address_type' => $address->getAddressType(),
4546
'country' => [
4647
'code' => $address->getCountryId(),
4748
'label' => $address->getCountry()

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public function testSetNewBillingAddress()
9090
code
9191
label
9292
}
93+
address_type
9394
}
9495
}
9596
}
@@ -147,6 +148,7 @@ public function testSetNewBillingAddressWithUseForShippingParameter()
147148
code
148149
label
149150
}
151+
address_type
150152
}
151153
shipping_addresses {
152154
firstname
@@ -160,6 +162,7 @@ public function testSetNewBillingAddressWithUseForShippingParameter()
160162
code
161163
label
162164
}
165+
address_type
163166
}
164167
}
165168
}
@@ -174,7 +177,7 @@ public function testSetNewBillingAddressWithUseForShippingParameter()
174177
self::assertArrayHasKey('shipping_addresses', $cartResponse);
175178
$shippingAddressResponse = current($cartResponse['shipping_addresses']);
176179
$this->assertNewAddressFields($billingAddressResponse);
177-
$this->assertNewAddressFields($shippingAddressResponse);
180+
$this->assertNewAddressFields($shippingAddressResponse, 'shipping');
178181
}
179182

180183
/**
@@ -403,9 +406,10 @@ public function testSetBillingAddressIfCustomerIsNotOwnerOfAddress()
403406
/**
404407
* Verify the all the whitelisted fields for a New Address Object
405408
*
406-
* @param array $billingAddressResponse
409+
* @param array $addressResponse
410+
* @param string $addressType
407411
*/
408-
private function assertNewAddressFields(array $billingAddressResponse): void
412+
private function assertNewAddressFields(array $addressResponse, string $addressType = 'billing'): void
409413
{
410414
$assertionMap = [
411415
['response_field' => 'firstname', 'expected_value' => 'test firstname'],
@@ -416,9 +420,10 @@ private function assertNewAddressFields(array $billingAddressResponse): void
416420
['response_field' => 'postcode', 'expected_value' => '887766'],
417421
['response_field' => 'telephone', 'expected_value' => '88776655'],
418422
['response_field' => 'country', 'expected_value' => ['code' => 'US', 'label' => 'US']],
423+
['response_field' => 'address_type', 'expected_value' => $addressType]
419424
];
420425

421-
$this->assertResponseFields($billingAddressResponse, $assertionMap);
426+
$this->assertResponseFields($addressResponse, $assertionMap);
422427
}
423428

424429
/**

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function testSetNewBillingAddress()
8282
code
8383
label
8484
}
85+
address_type
8586
}
8687
}
8788
}
@@ -138,6 +139,7 @@ public function testSetNewBillingAddressWithUseForShippingParameter()
138139
code
139140
label
140141
}
142+
address_type
141143
}
142144
shipping_addresses {
143145
firstname
@@ -151,6 +153,7 @@ public function testSetNewBillingAddressWithUseForShippingParameter()
151153
code
152154
label
153155
}
156+
address_type
154157
}
155158
}
156159
}
@@ -165,7 +168,7 @@ public function testSetNewBillingAddressWithUseForShippingParameter()
165168
self::assertArrayHasKey('shipping_addresses', $cartResponse);
166169
$shippingAddressResponse = current($cartResponse['shipping_addresses']);
167170
$this->assertNewAddressFields($billingAddressResponse);
168-
$this->assertNewAddressFields($shippingAddressResponse);
171+
$this->assertNewAddressFields($shippingAddressResponse, 'shipping');
169172
}
170173

171174
/**
@@ -244,9 +247,10 @@ public function testSetBillingAddressFromAddressBook()
244247
/**
245248
* Verify the all the whitelisted fields for a New Address Object
246249
*
247-
* @param array $billingAddressResponse
250+
* @param array $addressResponse
251+
* @param string $addressType
248252
*/
249-
private function assertNewAddressFields(array $billingAddressResponse): void
253+
private function assertNewAddressFields(array $addressResponse, string $addressType = 'billing'): void
250254
{
251255
$assertionMap = [
252256
['response_field' => 'firstname', 'expected_value' => 'test firstname'],
@@ -257,9 +261,10 @@ private function assertNewAddressFields(array $billingAddressResponse): void
257261
['response_field' => 'postcode', 'expected_value' => '887766'],
258262
['response_field' => 'telephone', 'expected_value' => '88776655'],
259263
['response_field' => 'country', 'expected_value' => ['code' => 'US', 'label' => 'US']],
264+
['response_field' => 'address_type', 'expected_value' => $addressType]
260265
];
261266

262-
$this->assertResponseFields($billingAddressResponse, $assertionMap);
267+
$this->assertResponseFields($addressResponse, $assertionMap);
263268
}
264269

265270
/**

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public function testSetNewShippingAddressByGuest()
9494
code
9595
label
9696
}
97+
address_type
9798
}
9899
}
99100
}
@@ -184,6 +185,7 @@ public function testSetNewShippingAddressByRegisteredCustomer()
184185
label
185186
code
186187
}
188+
address_type
187189
}
188190
}
189191
}
@@ -472,6 +474,7 @@ private function assertNewShippingAddressFields(array $shippingAddressResponse):
472474
['response_field' => 'postcode', 'expected_value' => '887766'],
473475
['response_field' => 'telephone', 'expected_value' => '88776655'],
474476
['response_field' => 'country', 'expected_value' => ['code' => 'US', 'label' => 'US']],
477+
['response_field' => 'address_type', 'expected_value' => 'shipping']
475478
];
476479

477480
$this->assertResponseFields($shippingAddressResponse, $assertionMap);

0 commit comments

Comments
 (0)