Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 6a48ee1

Browse files
author
Stanislav Idolov
authored
ENGCOM-748: [Forwardport] Remove not-allowed currencies from the currencies dropdown in Setup #13782
2 parents 03e4e3a + 7a019a2 commit 6a48ee1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/internal/Magento/Framework/Setup/Lists.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@ class Lists
2121
*/
2222
protected $allowedLocales;
2323

24+
/**
25+
* List of allowed currencies
26+
*
27+
* @var array
28+
*/
29+
private $allowedCurrencies;
30+
2431
/**
2532
* @param ConfigInterface $localeConfig
2633
*/
2734
public function __construct(ConfigInterface $localeConfig)
2835
{
2936
$this->allowedLocales = $localeConfig->getAllowedLocales();
37+
$this->allowedCurrencies = $localeConfig->getAllowedCurrencies();
3038
}
3139

3240
/**
@@ -64,6 +72,10 @@ public function getCurrencyList()
6472
$currencies = (new CurrencyBundle())->get(Resolver::DEFAULT_LOCALE)['Currencies'];
6573
$list = [];
6674
foreach ($currencies as $code => $data) {
75+
$isAllowedCurrency = array_search($code, $this->allowedCurrencies) !== false;
76+
if (!$isAllowedCurrency) {
77+
continue;
78+
}
6779
$list[$code] = $data[1] . ' (' . $code . ')';
6880
}
6981
asort($list);

lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ protected function setUp()
5858
$this->mockConfig->expects($this->any())
5959
->method('getAllowedLocales')
6060
->willReturn($this->expectedLocales);
61+
$this->mockConfig->expects($this->any())
62+
->method('getAllowedCurrencies')
63+
->willReturn($this->expectedCurrencies);
6164

6265
$this->lists = new Lists($this->mockConfig);
6366
}
@@ -73,4 +76,13 @@ public function testGetLocaleList()
7376
$locales = array_intersect($this->expectedLocales, array_keys($this->lists->getLocaleList()));
7477
$this->assertEquals($this->expectedLocales, $locales);
7578
}
79+
80+
/**
81+
* Test Lists:getCurrencyList() considering allowed currencies config values.
82+
*/
83+
public function testGetCurrencyList()
84+
{
85+
$currencies = array_intersect($this->expectedCurrencies, array_keys($this->lists->getCurrencyList()));
86+
$this->assertEquals($this->expectedCurrencies, $currencies);
87+
}
7688
}

0 commit comments

Comments
 (0)