Skip to content

Commit 61636fc

Browse files
pradeep.rauthanpradeep.rauthan
authored andcommitted
MC-42623:Countries list is incorrect when using different countries per website and Global Customer Account settings - Integration test coverage implemented
1 parent 44a1c69 commit 61636fc

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

app/code/Magento/Customer/Model/ResourceModel/Address/StoreAddressCollection.php

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
namespace Magento\Customer\Model\ResourceModel\Address;
77

88
use Magento\Directory\Model\AllowedCountries;
9-
use Magento\Framework\ObjectManagerInterface;
109
use Magento\Sales\Block\Adminhtml\Order\Create\Form\Address as AddressBlock;
1110
use Magento\Store\Model\ScopeInterface;
1211

@@ -15,13 +14,6 @@
1514
*/
1615
class StoreAddressCollection extends Collection
1716
{
18-
/**
19-
* Object Manager instance
20-
*
21-
* @var ObjectManagerInterface
22-
*/
23-
private $objectManager;
24-
2517
/**
2618
* @var AddressBlock
2719
*/
@@ -43,7 +35,8 @@ class StoreAddressCollection extends Collection
4335
* @param \Magento\Eav\Model\ResourceModel\Helper $resourceHelper
4436
* @param \Magento\Framework\Validator\UniversalFactory $universalFactory
4537
* @param \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot
46-
* @param ObjectManagerInterface $objectManager
38+
* @param AddressBlock $addressBlock
39+
* @param AllowedCountries $allowedCountryReader
4740
* @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection
4841
*
4942
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -59,10 +52,12 @@ public function __construct(
5952
\Magento\Eav\Model\ResourceModel\Helper $resourceHelper,
6053
\Magento\Framework\Validator\UniversalFactory $universalFactory,
6154
\Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot,
62-
ObjectManagerInterface $objectManager,
55+
AddressBlock $addressBlock,
56+
AllowedCountries $allowedCountryReader,
6357
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null
6458
) {
65-
$this->objectManager = $objectManager;
59+
$this->addressBlock = $addressBlock;
60+
$this->allowedCountryReader = $allowedCountryReader;
6661

6762
parent::__construct(
6863
$entityFactory,
@@ -79,19 +74,6 @@ public function __construct(
7974
);
8075
}
8176

82-
/**
83-
* Resource initialization
84-
*
85-
* @return void
86-
*/
87-
public function _construct()
88-
{
89-
parent::_construct();
90-
91-
$this->addressBlock = $this->objectManager->create(AddressBlock::class);
92-
$this->allowedCountryReader = $this->objectManager->create(AllowedCountries::class);
93-
}
94-
9577
/**
9678
* Set allowed country filter for customer's addresses
9779
*

dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/Address/StoreAddressCollectionTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public function testSetCustomerFilter()
3232
$storeId = $customer->getStoreId();
3333
$allowedCountries = $allowedCountriesObj->getAllowedCountries(ScopeInterface::SCOPE_STORE, $storeId);
3434
$strAllowedCountries = implode("%S, %S", $allowedCountries);
35-
$format = '%AWHERE%S(%Sparent_id%S IN(%S1%S, %S2%S))%SAND%S(%Sparent_id%S = %S-1%S)' .
35+
$format = '%AWHERE' .
36+
'%S(%Sparent_id%S IN(%S1%S, %S2%S))%SAND%S(%Scountry_id%S IN(%S' . $strAllowedCountries . '%S))' .
37+
'%SAND%S(%Sparent_id%S = %S-1%S)%SAND%S(%Scountry_id%S IN(%S' . $strAllowedCountries . '%S))' .
3638
'%SAND%S(%Sparent_id%S = %S3%S)%SAND%S(%Scountry_id%S IN(%S' . $strAllowedCountries . '%S))%A';
3739
$this->assertStringMatchesFormat($format, (string)$select);
3840
}

0 commit comments

Comments
 (0)