Skip to content

Commit c5fec9c

Browse files
author
Joan He
committed
Merge remote-tracking branch 'arcticfoxes/MC-13644' into pr
2 parents 4c02749 + ed37f5b commit c5fec9c

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
use Magento\Framework\View\Result\PageFactory;
2727

2828
/**
29+
* Customer Address Form Post Controller
30+
*
2931
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3032
*/
3133
class FormPost extends \Magento\Customer\Controller\Address implements HttpPostActionInterface
@@ -120,8 +122,18 @@ protected function _extractAddress()
120122
\Magento\Customer\Api\Data\AddressInterface::class
121123
);
122124
$addressDataObject->setCustomerId($this->_getSession()->getCustomerId())
123-
->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
124-
->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
125+
->setIsDefaultBilling(
126+
$this->getRequest()->getParam(
127+
'default_billing',
128+
isset($existingAddressData['default_billing']) ? $existingAddressData['default_billing'] : false
129+
)
130+
)
131+
->setIsDefaultShipping(
132+
$this->getRequest()->getParam(
133+
'default_shipping',
134+
isset($existingAddressData['default_shipping']) ? $existingAddressData['default_shipping'] : false
135+
)
136+
);
125137

126138
return $addressDataObject;
127139
}

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)