This repository was archived by the owner on Apr 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
lib/internal/Magento/Framework/Setup Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -21,12 +21,20 @@ class Lists
21
21
*/
22
22
protected $ allowedLocales ;
23
23
24
+ /**
25
+ * List of allowed currencies
26
+ *
27
+ * @var array
28
+ */
29
+ private $ allowedCurrencies ;
30
+
24
31
/**
25
32
* @param ConfigInterface $localeConfig
26
33
*/
27
34
public function __construct (ConfigInterface $ localeConfig )
28
35
{
29
36
$ this ->allowedLocales = $ localeConfig ->getAllowedLocales ();
37
+ $ this ->allowedCurrencies = $ localeConfig ->getAllowedCurrencies ();
30
38
}
31
39
32
40
/**
@@ -64,6 +72,10 @@ public function getCurrencyList()
64
72
$ currencies = (new CurrencyBundle ())->get (Resolver::DEFAULT_LOCALE )['Currencies ' ];
65
73
$ list = [];
66
74
foreach ($ currencies as $ code => $ data ) {
75
+ $ isAllowedCurrency = array_search ($ code , $ this ->allowedCurrencies ) !== false ;
76
+ if (!$ isAllowedCurrency ) {
77
+ continue ;
78
+ }
67
79
$ list [$ code ] = $ data [1 ] . ' ( ' . $ code . ') ' ;
68
80
}
69
81
asort ($ list );
Original file line number Diff line number Diff line change @@ -58,6 +58,9 @@ protected function setUp()
58
58
$ this ->mockConfig ->expects ($ this ->any ())
59
59
->method ('getAllowedLocales ' )
60
60
->willReturn ($ this ->expectedLocales );
61
+ $ this ->mockConfig ->expects ($ this ->any ())
62
+ ->method ('getAllowedCurrencies ' )
63
+ ->willReturn ($ this ->expectedCurrencies );
61
64
62
65
$ this ->lists = new Lists ($ this ->mockConfig );
63
66
}
@@ -73,4 +76,13 @@ public function testGetLocaleList()
73
76
$ locales = array_intersect ($ this ->expectedLocales , array_keys ($ this ->lists ->getLocaleList ()));
74
77
$ this ->assertEquals ($ this ->expectedLocales , $ locales );
75
78
}
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
+ }
76
88
}
You can’t perform that action at this time.
0 commit comments