Skip to content

Commit fb108a7

Browse files
author
Oleksandr Gorkun
committed
MAGETWO-55858: Output escaping methods shouldn't be part of AbstractBlock
1 parent cef605f commit fb108a7

File tree

3 files changed

+91
-24
lines changed

3 files changed

+91
-24
lines changed

app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,15 @@ public function testGetDateFormat(string $locale, string $expectedFormat)
354354
public function getDateFormatDataProvider(): array
355355
{
356356
return [
357-
['ar_SA', 'd/M/y'],
357+
[
358+
'ar_SA',
359+
preg_replace(
360+
'/[^MmDdYy\/\.\-]/',
361+
'',
362+
(new \IntlDateFormatter('ar_SA', \IntlDateFormatter::SHORT, \IntlDateFormatter::NONE))
363+
->getPattern()
364+
)
365+
],
358366
[Resolver::DEFAULT_LOCALE, self::DATE_FORMAT],
359367
];
360368
}

lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ public function testGetHashRandomSaltSpecifiedLength(): void
135135
*
136136
* @dataProvider validateHashDataProvider
137137
*/
138-
public function testValidateHash($password, $hash, $expected): void
138+
public function testValidateHash($password, $hash, $expected, int $requiresVersion): void
139139
{
140+
if ($requiresVersion > $this->encryptor->getLatestHashVersion()) {
141+
$this->markTestSkipped('On current installation encryptor does not support algo #' .$requiresVersion);
142+
}
140143
$actual = $this->encryptor->validateHash($password, $hash);
141144
$this->assertEquals($expected, $actual);
142145
}
@@ -149,10 +152,14 @@ public function testValidateHash($password, $hash, $expected): void
149152
public function validateHashDataProvider(): array
150153
{
151154
return [
152-
['password', 'hash:salt:1', false],
153-
['password', '67a1e09bb1f83f5007dc119c14d663aa:salt:0', true],
154-
['password', '13601bda4ea78e55a07b98866d2be6be0744e3866f13c00c811cab608a28f322:salt:1', true],
155-
['password', 'c6aad9e058f6c4b06187c06d2b69bf506a786af030f81fb6d83778422a68205e:salt:1:2', true],
155+
['password', 'hash:salt:1', false, 1],
156+
['password', '67a1e09bb1f83f5007dc119c14d663aa:salt:0', true, 0],
157+
['password', '13601bda4ea78e55a07b98866d2be6be0744e3866f13c00c811cab608a28f322:salt:1', true, 1],
158+
//Hashes after customer:hash:upgrade command issued
159+
//Upgraded from version #1 to #2
160+
['password', 'c6aad9e058f6c4b06187c06d2b69bf506a786af030f81fb6d83778422a68205e:salt:1:2', true, 2],
161+
//From #0 to #1
162+
['password', '3b68ca4706cbae291455e4340478076c1e1618e742b6144cfcc3e50f648903e4:salt:0:1', true, 1]
156163
];
157164
}
158165

lib/internal/Magento/Framework/Locale/Test/Unit/TranslatedListsTest.php

Lines changed: 70 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,36 @@ class TranslatedListsTest extends TestCase
4444
* @var array
4545
*/
4646
private $expectedLocales = [
47-
'en_US' => 'English (United States)',
48-
'en_GB' => 'English (United Kingdom)',
49-
'uk_UA' => 'Ukrainian (Ukraine)',
50-
'de_DE' => 'German (Germany)',
51-
'sr_Cyrl_RS' => 'Serbian (Cyrillic, Serbia)',
52-
'sr_Latn_RS' => 'Serbian (Latin, Serbia)'
47+
'en_US',
48+
'en_GB',
49+
'uk_UA',
50+
'de_DE',
51+
'sr_Cyrl_RS',
52+
'sr_Latn_RS'
5353
];
5454

5555
/**
56-
* @var array
56+
* @var string[]
57+
*/
58+
private $languages = [
59+
'en_US' => 'English',
60+
'en_GB' => 'English',
61+
'uk_UA' => 'Ukrainian',
62+
'de_DE' => 'German',
63+
'sr_Cyrl_RS' => 'Serbian',
64+
'sr_Latn_RS' => 'Serbian'
65+
];
66+
67+
/**
68+
* @var string[]
5769
*/
58-
private $expectedTranslatedLocales = [
59-
'en_US' => 'English (United States) / English (United States)',
60-
'en_GB' => 'English (United Kingdom) / English (United Kingdom)',
61-
'uk_UA' => 'українська (Україна) / Ukrainian (Ukraine)',
62-
'de_DE' => 'Deutsch (Deutschland) / German (Germany)',
63-
'sr_Cyrl_RS' => 'српски (ћирилица, Србија) / Serbian (Cyrillic, Serbia)',
64-
'sr_Latn_RS' => 'Srpski (latinica, Srbija) / Serbian (Latin, Serbia)'
70+
private $countries = [
71+
'en_US' => 'United States',
72+
'en_GB' => 'United Kingdom',
73+
'uk_UA' => 'Ukraine',
74+
'de_DE' => 'Germany',
75+
'sr_Cyrl_RS' => 'Serbia',
76+
'sr_Latn_RS' => 'Serbia'
6577
];
6678

6779
protected function setUp()
@@ -168,20 +180,22 @@ public function testGetOptionTimezones()
168180

169181
public function testGetOptionLocales()
170182
{
183+
$expected = $this->getExpectedLocales();
171184
$locales = array_intersect(
172-
$this->expectedLocales,
185+
$expected,
173186
$this->convertOptionLocales($this->listsModel->getOptionLocales())
174187
);
175-
$this->assertEquals($this->expectedLocales, $locales);
188+
$this->assertEquals($expected, $locales);
176189
}
177190

178191
public function testGetTranslatedOptionLocales()
179192
{
193+
$expected = $this->getExpectedTranslatedLocales();
180194
$locales = array_intersect(
181-
$this->expectedTranslatedLocales,
195+
$expected,
182196
$this->convertOptionLocales($this->listsModel->getTranslatedOptionLocales())
183197
);
184-
$this->assertEquals($this->expectedTranslatedLocales, $locales);
198+
$this->assertEquals($expected, $locales);
185199
}
186200

187201
/**
@@ -198,4 +212,42 @@ private function convertOptionLocales($optionLocales): array
198212

199213
return $result;
200214
}
215+
216+
/**
217+
* Expected translated locales list.
218+
*
219+
* @return string[]
220+
*/
221+
private function getExpectedTranslatedLocales(): array
222+
{
223+
$expected = [];
224+
foreach ($this->expectedLocales as $locale) {
225+
$script = \Locale::getDisplayScript($locale);
226+
$scriptTranslated = $script ? \Locale::getDisplayScript($locale, $locale) .', ' : '';
227+
$expected[$locale] = ucwords(\Locale::getDisplayLanguage($locale, $locale))
228+
. ' (' . $scriptTranslated
229+
. \Locale::getDisplayRegion($locale, $locale) . ') / '
230+
. $this->languages[$locale]
231+
. ' (' . ($script ? $script .', ' : '') . $this->countries[$locale] . ')';
232+
}
233+
234+
return $expected;
235+
}
236+
237+
/**
238+
* Expected locales list.
239+
*
240+
* @return string[]
241+
*/
242+
private function getExpectedLocales(): array
243+
{
244+
$expected = [];
245+
foreach ($this->expectedLocales as $locale) {
246+
$script = \Locale::getScript($locale);
247+
$scriptDisplayed = $script ? \Locale::getDisplayScript($locale) . ', ' : '';
248+
$expected[$locale] = $this->languages[$locale] .' (' .$scriptDisplayed .$this->countries[$locale] .')';
249+
}
250+
251+
return $expected;
252+
}
201253
}

0 commit comments

Comments
 (0)