Skip to content

Commit cc1cadf

Browse files
author
Joan He
committed
MC-13644: Default billing and default shipping address lose their status after edit
1 parent 97fd70f commit cc1cadf

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

app/code/Magento/Customer/Controller/Address/FormPost.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,18 @@ protected function _extractAddress()
120120
\Magento\Customer\Api\Data\AddressInterface::class
121121
);
122122
$addressDataObject->setCustomerId($this->_getSession()->getCustomerId())
123-
->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
124-
->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
123+
->setIsDefaultBilling(
124+
$this->getRequest()->getParam(
125+
'default_billing',
126+
isset($existingAddressData['default_billing']) ? $existingAddressData['default_billing'] : false
127+
)
128+
)
129+
->setIsDefaultShipping(
130+
$this->getRequest()->getParam(
131+
'default_shipping',
132+
isset($existingAddressData['default_shipping']) ? $existingAddressData['default_shipping'] : false
133+
)
134+
);
125135

126136
return $addressDataObject;
127137
}

app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressTest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
<testCaseId value="MAGETWO-97501"/>
1919
<group value="customer"/>
2020
<group value="update"/>
21-
<skip>
22-
<issueId value="MAGETWO-97504"/>
23-
</skip>
2421
</annotations>
2522
<before>
2623
<createData entity="Simple_US_Customer_With_Different_Billing_Shipping_Addresses" stepKey="createCustomer"/>

app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -455,14 +455,20 @@ public function testExecute(
455455
$regionCode,
456456
$newRegionId,
457457
$newRegion,
458-
$newRegionCode
458+
$newRegionCode,
459+
$existingDefaultBilling = false,
460+
$existingDefaultShipping = false,
461+
$setDefaultBilling = false,
462+
$setDefaultShipping = false
459463
): void {
460464
$existingAddressData = [
461465
'country_id' => $countryId,
462466
'region_id' => $regionId,
463467
'region' => $region,
464468
'region_code' => $regionCode,
465-
'customer_id' => $customerId
469+
'customer_id' => $customerId,
470+
'default_billing' => $existingDefaultBilling,
471+
'default_shipping' => $existingDefaultShipping,
466472
];
467473
$newAddressData = [
468474
'country_id' => $countryId,
@@ -486,8 +492,8 @@ public function testExecute(
486492
->method('getParam')
487493
->willReturnMap([
488494
['id', null, $addressId],
489-
['default_billing', false, $addressId],
490-
['default_shipping', false, $addressId],
495+
['default_billing', $existingDefaultBilling, $setDefaultBilling],
496+
['default_shipping', $existingDefaultShipping, $setDefaultShipping],
491497
]);
492498

493499
$this->addressRepository->expects($this->once())
@@ -565,11 +571,11 @@ public function testExecute(
565571
->willReturnSelf();
566572
$this->addressData->expects($this->once())
567573
->method('setIsDefaultBilling')
568-
->with()
574+
->with($setDefaultBilling)
569575
->willReturnSelf();
570576
$this->addressData->expects($this->once())
571577
->method('setIsDefaultShipping')
572-
->with()
578+
->with($setDefaultShipping)
573579
->willReturnSelf();
574580

575581
$this->messageManager->expects($this->once())
@@ -628,11 +634,11 @@ public function dataProviderTestExecute(): array
628634

629635
[1, 1, 1, 2, null, null, 12, null, null],
630636
[1, 1, 1, 2, 'Alaska', null, 12, null, 'CA'],
631-
[1, 1, 1, 2, 'Alaska', 'AK', 12, 'California', null],
637+
[1, 1, 1, 2, 'Alaska', 'AK', 12, 'California', null, true, true, true, false],
632638

633-
[1, 1, 1, 2, null, null, 12, null, null],
634-
[1, 1, 1, 2, 'Alaska', null, 12, null, 'CA'],
635-
[1, 1, 1, 2, 'Alaska', 'AK', 12, 'California', null],
639+
[1, 1, 1, 2, null, null, 12, null, null, false, false, true, false],
640+
[1, 1, 1, 2, 'Alaska', null, 12, null, 'CA', true, false, true, false],
641+
[1, 1, 1, 2, 'Alaska', 'AK', 12, 'California', null, true, true, true, true],
636642
];
637643
}
638644

0 commit comments

Comments
 (0)