Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/internal/Magento/Framework/Setup/Lists.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@ class Lists
*/
protected $allowedLocales;

/**
* List of allowed currencies
*
* @var array
*/
private $allowedCurrencies;

/**
* @param ConfigInterface $localeConfig
*/
public function __construct(ConfigInterface $localeConfig)
{
$this->allowedLocales = $localeConfig->getAllowedLocales();
$this->allowedCurrencies = $localeConfig->getAllowedCurrencies();
}

/**
Expand Down Expand Up @@ -64,6 +72,10 @@ public function getCurrencyList()
$currencies = (new CurrencyBundle())->get(Resolver::DEFAULT_LOCALE)['Currencies'];
$list = [];
foreach ($currencies as $code => $data) {
$isAllowedCurrency = array_search($code, $this->allowedCurrencies) !== false;
if (!$isAllowedCurrency) {
continue;
}
$list[$code] = $data[1] . ' (' . $code . ')';
}
asort($list);
Expand Down
12 changes: 12 additions & 0 deletions lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ protected function setUp()
$this->mockConfig->expects($this->any())
->method('getAllowedLocales')
->willReturn($this->expectedLocales);
$this->mockConfig->expects($this->any())
->method('getAllowedCurrencies')
->willReturn($this->expectedCurrencies);

$this->lists = new Lists($this->mockConfig);
}
Expand All @@ -73,4 +76,13 @@ public function testGetLocaleList()
$locales = array_intersect($this->expectedLocales, array_keys($this->lists->getLocaleList()));
$this->assertEquals($this->expectedLocales, $locales);
}

/**
* Test Lists:getCurrencyList() considering allowed currencies config values.
*/
public function testGetCurrencyList()
{
$currencies = array_intersect($this->expectedCurrencies, array_keys($this->lists->getCurrencyList()));
$this->assertEquals($this->expectedCurrencies, $currencies);
}
}