Skip to content

Commit f6c9a2b

Browse files
committed
Merge remote-tracking branch 'origin/AC-9340' into spartans_pr_06092023
2 parents 3dbd757 + c74c326 commit f6c9a2b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

app/code/Magento/Customer/Model/Address/AbstractAddress.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,9 @@ public function getRegionId()
453453
(string)$this->getRegionCode(),
454454
(string)$this->getCountryId()
455455
);
456+
if (empty($regionId)) {
457+
$regionId = $this->getData('region_id');
458+
}
456459
$this->setData('region_id', $regionId);
457460
}
458461

app/code/Magento/Customer/Test/Unit/Model/Address/AbstractAddressTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,29 @@ public function testGetRegionCodeWithRegionId()
162162
$this->assertEquals('UK', $this->model->getRegionCode());
163163
}
164164

165+
/**
166+
* Test regionid for empty value
167+
*
168+
* @inheritdoc
169+
* @return void
170+
*/
171+
public function testGetRegionId()
172+
{
173+
$this->model->setData('region_id', 0);
174+
$this->model->setData('region', '');
175+
$this->model->setData('country_id', 'GB');
176+
$region = $this->getMockBuilder(Region::class)
177+
->addMethods(['getCountryId', 'getCode'])
178+
->onlyMethods(['__wakeup', 'load', 'loadByCode','getId'])
179+
->disableOriginalConstructor()
180+
->getMock();
181+
$region->method('loadByCode')
182+
->willReturnSelf();
183+
$this->regionFactoryMock->method('create')
184+
->willReturn($region);
185+
$this->assertEquals(0, $this->model->getRegionId());
186+
}
187+
165188
public function testGetRegionCodeWithRegion()
166189
{
167190
$countryId = 2;

0 commit comments

Comments
 (0)