Skip to content

Commit ce8afcf

Browse files
author
Sergey Kovalenko
committed
MAGETWO-56941: CLONE - CLONE - [Github] Allowed countries for customer address in admin using storeview configuration #2946
1 parent 64251de commit ce8afcf

File tree

9 files changed

+20
-18
lines changed

9 files changed

+20
-18
lines changed

app/code/Magento/Customer/Model/CountryHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function getAllowedCountries(
6565

6666
if ($this->customerConfigShare->isGlobalScope() && !$ignoreGlobalScope) {
6767
//Check if we have shared accounts - than merge all website allowed countries
68-
$filter = array_map(function(WebsiteInterface $website) {
68+
$filter = array_map(function (WebsiteInterface $website) {
6969
return $website->getId();
7070
}, $this->storeManager->getWebsites());
7171
$scope = ScopeInterface::SCOPE_WEBSITES;

app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsites.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public function __construct(
5555
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countriesFactory,
5656
\Magento\Directory\Model\CountryHandlerInterface $countryHandler,
5757
\Magento\Store\Model\StoreManagerInterface $storeManager
58-
)
59-
{
58+
) {
6059
$this->countriesFactory = $countriesFactory;
6160
$this->countryHandler = $countryHandler;
6261
$this->storeManager = $storeManager;

app/code/Magento/Customer/Test/Unit/Model/CountryHandlerTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\Directory\Test\Unit\Model;
7+
namespace Magento\Customer\Test\Unit\Model;
88

99
use Magento\Customer\Model\Config\Share;
1010
use Magento\Customer\Model\CountryHandler;
@@ -141,7 +141,9 @@ public function testLoadByScope()
141141
->method('addFieldToFilter')
142142
->with('country_id', ['in' => ['AM' => 'AM']]);
143143

144-
$this->assertEquals($collectionMock,
145-
$this->countryHandler->loadByScope($collectionMock, 1, ScopeInterface::SCOPE_WEBSITE));
144+
$this->assertEquals(
145+
$collectionMock,
146+
$this->countryHandler->loadByScope($collectionMock, 1, ScopeInterface::SCOPE_WEBSITE)
147+
);
146148
}
147149
}

app/code/Magento/Directory/Model/CountryHandlerInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface CountryHandlerInterface
1919

2020
/**
2121
* Retrieve allowed countries list by filter and scope.
22-
* @param null $filter
22+
* @param int | null $filter
2323
* @param string $scope
2424
* @param bool $ignoreGlobalScope
2525
* @return array
@@ -33,7 +33,7 @@ public function getAllowedCountries(
3333
/**
3434
* Filter directory collection by allowed in website countries.
3535
* @param \Magento\Framework\Data\Collection\AbstractDb $collection
36-
* @param $filter
36+
* @param int $filter
3737
* @param string $scope
3838
* @return AbstractDb
3939
*/

app/code/Magento/Ui/view/base/web/js/form/element/country.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ define([
3333

3434
this._super(value, field);
3535

36-
result = _.filter(this.initialOptions, function (item) {
36+
result = _.filter(this.initialOptions, function (item) {
3737

3838
if (item[field]) {
3939
return ~item[field].indexOf(value);

app/code/Magento/Ui/view/base/web/js/form/element/website.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ define([
2323
initialize: function () {
2424
this._super();
2525

26-
if (this.customerId || this.isGlobalScope) { //disable element if customer exists
26+
if (this.customerId || this.isGlobalScope) {//disable element if customer exists
2727
this.disable(true);
2828
}
2929

dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/Tab/Addresses.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
/**
2222
* Customer addresses edit block.
23+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2324
*/
2425
class Addresses extends Tab
2526
{

dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertChangingWebsiteChangeCountries.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ class AssertChangingWebsiteChangeCountries extends AbstractConstraint
2222
* @param array $expectedRequiredFields
2323
* @return void
2424
*/
25-
public function processAssert(CustomerIndexNew $customerIndexNew, Customer $customer, \Magento\Customer\Test\Fixture\Address $address, $expectedList)
26-
{
25+
public function processAssert(
26+
CustomerIndexNew $customerIndexNew,
27+
Customer $customer,
28+
$expectedList
29+
) {
2730
$customerIndexNew->getCustomerForm()
2831
->openTab('account_information');
2932
$customerIndexNew->getCustomerForm()->fillCustomer($customer);

dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerBackendEntityTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class CreateCustomerBackendEntityTest extends Injectable
4848
*/
4949
private $address;
5050

51-
5251
/** @var array */
5352
private $allowedCountriesData = [];
5453

@@ -100,7 +99,7 @@ public function test(
10099
Address $address = null,
101100
array $steps = [],
102101
array $beforeActionCallback = []
103-
) {
102+
) {
104103
///Process initialize steps
105104
foreach ($steps as $methodName => $stepData) {
106105
if (method_exists($this, $methodName)) {
@@ -127,7 +126,7 @@ public function test(
127126
* Assert that allowed countries renders in correct way.
128127
* @return void
129128
*/
130-
private function assertAllowedCountries()
129+
protected function assertAllowedCountries()
131130
{
132131
/** @var \Magento\Customer\Test\Constraint\AssertChangingWebsiteChangeCountries $assert */
133132
$assert = $this->objectManager->get(
@@ -146,7 +145,6 @@ private function assertAllowedCountries()
146145
$assert->processAssert(
147146
$this->pageCustomerIndexNew,
148147
$customerWithWebsite,
149-
$this->address,
150148
$dataPerWebsite['countries']
151149
);
152150
}
@@ -200,11 +198,10 @@ private function createWebsiteFixture()
200198
return $websiteFixture;
201199
}
202200

203-
204201
/**
205202
* @param array $countryList
206203
*/
207-
private function configureAllowedCountries(array $countryList = [])
204+
protected function configureAllowedCountries(array $countryList = [])
208205
{
209206
foreach ($countryList as $countries) {
210207
$websiteFixture = $this->createWebsiteFixture();

0 commit comments

Comments
 (0)