Skip to content

Commit 379878e

Browse files
committed
MAGETWO-34390: Stabilization of replacing Zend_Locale with Native PHP Implementation
1 parent c09b314 commit 379878e

File tree

2 files changed

+51
-66
lines changed

2 files changed

+51
-66
lines changed

dev/tests/unit/testsuite/Magento/Framework/Locale/ListsTest.php

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -48,50 +48,49 @@ public function testGetCountryTranslation()
4848

4949
public function testGetOptionAllCurrencies()
5050
{
51-
// clearly English results
52-
$expectedResults = [
53-
['value' => 'BAM', 'label' => 'Bosnia-Herzegovina Convertible Mark'],
54-
['value' => 'TTD', 'label' => 'Trinidad and Tobago Dollar'],
55-
['value' => 'USN', 'label' => 'US Dollar (Next day)'],
56-
['value' => 'USS', 'label' => 'US Dollar (Same day)'],
57-
];
51+
$expectedResults = ['USD', 'EUR', 'GBP', 'UAH'];
5852

5953
$currencyList = $this->listsModel->getOptionAllCurrencies();
6054
foreach ($expectedResults as $value) {
61-
$this->assertContains($value, $currencyList);
55+
$found = false;
56+
foreach ($currencyList as $item) {
57+
$found = $found || ($value == $item['value']);
58+
}
59+
$this->assertTrue($found);
6260
}
6361
}
6462

6563
public function testGetOptionCurrencies()
6664
{
67-
$allowedCurrencies = ['USD', 'GBP', 'EUR'];
65+
$allowedCurrencies = ['USD', 'EUR', 'GBP', 'UAH'];
6866

6967
$this->mockConfig->expects($this->once())
7068
->method('getAllowedCurrencies')
7169
->will($this->returnValue($allowedCurrencies));
7270

73-
$expectedArray = [
74-
['value' => 'GBP', 'label' => 'British Pound Sterling'],
75-
['value' => 'EUR', 'label' => 'Euro'],
76-
['value' => 'USD', 'label' => 'US Dollar'],
77-
];
71+
$expectedResults = ['USD', 'EUR', 'GBP', 'UAH'];
7872

79-
$this->assertSame($expectedArray, $this->listsModel->getOptionCurrencies());
73+
$currencyList = $this->listsModel->getOptionCurrencies();
74+
foreach ($expectedResults as $value) {
75+
$found = false;
76+
foreach ($currencyList as $item) {
77+
$found = $found || ($value == $item['value']);
78+
}
79+
$this->assertTrue($found);
80+
}
8081
}
8182

8283
public function testGetOptionCountries()
8384
{
84-
// clearly English results
85-
$expectedResults = [
86-
['value' => 'AG', 'label' => 'Antigua and Barbuda'],
87-
['value' => 'BA', 'label' => 'Bosnia and Herzegovina'],
88-
['value' => 'GS', 'label' => 'South Georgia & South Sandwich Islands'],
89-
['value' => 'PM', 'label' => 'Saint Pierre and Miquelon'],
90-
];
85+
$expectedResults = ['US', 'GB', 'DE', 'UA'];
9186

92-
$optionCountries = $this->listsModel->getOptionCountries();
87+
$list = $this->listsModel->getOptionCountries();
9388
foreach ($expectedResults as $value) {
94-
$this->assertContains($value, $optionCountries);
89+
$found = false;
90+
foreach ($list as $item) {
91+
$found = $found || ($value == $item['value']);
92+
}
93+
$this->assertTrue($found);
9594
}
9695
}
9796

@@ -112,56 +111,56 @@ public function testGetOptionsWeekdays()
112111

113112
public function testGetOptionTimezones()
114113
{
115-
$expectedResults = [
116-
['value' => 'Australia/Darwin', 'label' => 'Australian Central Standard Time (Australia/Darwin)'],
117-
['value' => 'America/Los_Angeles', 'label' => 'Pacific Standard Time (America/Los_Angeles)'],
118-
['value' => 'Europe/Kiev', 'label' => 'Eastern European Standard Time (Europe/Kiev)'],
119-
['value' => 'Asia/Jerusalem', 'label' => 'Israel Standard Time (Asia/Jerusalem)'],
120-
];
114+
$expectedResults = ['Australia/Darwin', 'America/Los_Angeles', 'Asia/Jerusalem'];
121115

122-
$timeZones = $this->listsModel->getOptionTimezones();
116+
$list = $this->listsModel->getOptionTimezones();
123117
foreach ($expectedResults as $value) {
124-
$this->assertContains($value, $timeZones);
125-
}
126-
127-
$timeZoneList = \DateTimeZone::listIdentifiers(\DateTimeZone::ALL_WITH_BC);
128-
foreach ($timeZones as $timeZone) {
129-
$this->assertContains($timeZone['value'], $timeZoneList);
118+
$found = false;
119+
foreach ($list as $item) {
120+
$found = $found || ($value == $item['value']);
121+
}
122+
$this->assertTrue($found);
130123
}
131124
}
132125

133126
public function testGetOptionLocales()
134127
{
135128
$this->setupForOptionLocales();
136129

137-
$this->assertEquals(
138-
[
139-
['value' => 'en_US', 'label' => 'English (United States)'],
140-
['value' => 'uk_UA', 'label' => 'Ukrainian (Ukraine)'],
141-
],
142-
$this->listsModel->getOptionLocales()
143-
);
130+
$expectedResults = ['en_US', 'uk_UA', 'de_DE'];
131+
132+
$list = $this->listsModel->getOptionLocales();
133+
foreach ($expectedResults as $value) {
134+
$found = false;
135+
foreach ($list as $item) {
136+
$found = $found || ($value == $item['value']);
137+
}
138+
$this->assertTrue($found);
139+
}
144140
}
145141

146142
public function testGetTranslatedOptionLocales()
147143
{
148144
$this->setupForOptionLocales();
149145

150-
$this->assertEquals(
151-
[
152-
['value' => 'en_US', 'label' => 'English (United States) / English (United States)'],
153-
['value' => 'uk_UA', 'label' => 'українська (Україна) / Ukrainian (Ukraine)'],
154-
],
155-
$this->listsModel->getTranslatedOptionLocales()
156-
);
146+
$expectedResults = ['en_US', 'uk_UA', 'de_DE'];
147+
148+
$list = $this->listsModel->getOptionLocales();
149+
foreach ($expectedResults as $value) {
150+
$found = false;
151+
foreach ($list as $item) {
152+
$found = $found || ($value == $item['value']);
153+
}
154+
$this->assertTrue($found);
155+
}
157156
}
158157

159158
/**
160159
* Setup for option locales
161160
*/
162161
protected function setupForOptionLocales()
163162
{
164-
$allowedLocales = ['en_US', 'uk_UA'];
163+
$allowedLocales = ['en_US', 'uk_UA', 'de_DE'];
165164
$this->mockConfig->expects($this->once())
166165
->method('getAllowedLocales')
167166
->will($this->returnValue($allowedLocales));

dev/tests/unit/testsuite/Magento/Payment/Model/ConfigTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,6 @@ public function testGetGroups()
179179

180180
public function testGetMonths()
181181
{
182-
$months = [
183-
'01 - January',
184-
'02 - February',
185-
'03 - March',
186-
'04 - April',
187-
'05 - May',
188-
'06 - June',
189-
'07 - July',
190-
'08 - August',
191-
'09 - September',
192-
'10 - October',
193-
'11 - November',
194-
'12 - December',
195-
];
196182
$this->localeResolver->expects($this->once())->method('getLocale')->willReturn('en_US');
197183
$this->assertEquals($this->expectedMonthList, $this->config->getMonths());
198184
}

0 commit comments

Comments
 (0)