Skip to content

Commit

Permalink
MAGETWO-56941: CLONE - CLONE - [Github] Allowed countries for custome…
Browse files Browse the repository at this point in the history
…r address in admin using storeview configuration #2946
  • Loading branch information
Sergey Kovalenko committed Aug 25, 2016
1 parent 64251de commit ce8afcf
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Customer/Model/CountryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getAllowedCountries(

if ($this->customerConfigShare->isGlobalScope() && !$ignoreGlobalScope) {
//Check if we have shared accounts - than merge all website allowed countries
$filter = array_map(function(WebsiteInterface $website) {
$filter = array_map(function (WebsiteInterface $website) {
return $website->getId();
}, $this->storeManager->getWebsites());
$scope = ScopeInterface::SCOPE_WEBSITES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public function __construct(
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countriesFactory,
\Magento\Directory\Model\CountryHandlerInterface $countryHandler,
\Magento\Store\Model\StoreManagerInterface $storeManager
)
{
) {
$this->countriesFactory = $countriesFactory;
$this->countryHandler = $countryHandler;
$this->storeManager = $storeManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See COPYING.txt for license details.
*/

namespace Magento\Directory\Test\Unit\Model;
namespace Magento\Customer\Test\Unit\Model;

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

$this->assertEquals($collectionMock,
$this->countryHandler->loadByScope($collectionMock, 1, ScopeInterface::SCOPE_WEBSITE));
$this->assertEquals(
$collectionMock,
$this->countryHandler->loadByScope($collectionMock, 1, ScopeInterface::SCOPE_WEBSITE)
);
}
}
4 changes: 2 additions & 2 deletions app/code/Magento/Directory/Model/CountryHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface CountryHandlerInterface

/**
* Retrieve allowed countries list by filter and scope.
* @param null $filter
* @param int | null $filter
* @param string $scope
* @param bool $ignoreGlobalScope
* @return array
Expand All @@ -33,7 +33,7 @@ public function getAllowedCountries(
/**
* Filter directory collection by allowed in website countries.
* @param \Magento\Framework\Data\Collection\AbstractDb $collection
* @param $filter
* @param int $filter
* @param string $scope
* @return AbstractDb
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ define([

this._super(value, field);

result = _.filter(this.initialOptions, function (item) {
result = _.filter(this.initialOptions, function (item) {

if (item[field]) {
return ~item[field].indexOf(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ define([
initialize: function () {
this._super();

if (this.customerId || this.isGlobalScope) { //disable element if customer exists
if (this.customerId || this.isGlobalScope) {//disable element if customer exists
this.disable(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

/**
* Customer addresses edit block.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Addresses extends Tab
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ class AssertChangingWebsiteChangeCountries extends AbstractConstraint
* @param array $expectedRequiredFields
* @return void
*/
public function processAssert(CustomerIndexNew $customerIndexNew, Customer $customer, \Magento\Customer\Test\Fixture\Address $address, $expectedList)
{
public function processAssert(
CustomerIndexNew $customerIndexNew,
Customer $customer,
$expectedList
) {
$customerIndexNew->getCustomerForm()
->openTab('account_information');
$customerIndexNew->getCustomerForm()->fillCustomer($customer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class CreateCustomerBackendEntityTest extends Injectable
*/
private $address;


/** @var array */
private $allowedCountriesData = [];

Expand Down Expand Up @@ -100,7 +99,7 @@ public function test(
Address $address = null,
array $steps = [],
array $beforeActionCallback = []
) {
) {
///Process initialize steps
foreach ($steps as $methodName => $stepData) {
if (method_exists($this, $methodName)) {
Expand All @@ -127,7 +126,7 @@ public function test(
* Assert that allowed countries renders in correct way.
* @return void
*/
private function assertAllowedCountries()
protected function assertAllowedCountries()
{
/** @var \Magento\Customer\Test\Constraint\AssertChangingWebsiteChangeCountries $assert */
$assert = $this->objectManager->get(
Expand All @@ -146,7 +145,6 @@ private function assertAllowedCountries()
$assert->processAssert(
$this->pageCustomerIndexNew,
$customerWithWebsite,
$this->address,
$dataPerWebsite['countries']
);
}
Expand Down Expand Up @@ -200,11 +198,10 @@ private function createWebsiteFixture()
return $websiteFixture;
}


/**
* @param array $countryList
*/
private function configureAllowedCountries(array $countryList = [])
protected function configureAllowedCountries(array $countryList = [])
{
foreach ($countryList as $countries) {
$websiteFixture = $this->createWebsiteFixture();
Expand Down

0 comments on commit ce8afcf

Please sign in to comment.