@@ -20,6 +20,9 @@ class ResolverTest extends \PHPUnit\Framework\TestCase
20
20
*/
21
21
protected $ _model ;
22
22
23
+ /**
24
+ * {@inheritDoc}
25
+ */
23
26
protected function setUp ()
24
27
{
25
28
parent ::setUp ();
@@ -29,15 +32,15 @@ protected function setUp()
29
32
}
30
33
31
34
/**
32
- * @covers \Magento\Backend\Model\Locale\Resolver:: setLocale
35
+ * Tests setLocale() with default locale
33
36
*/
34
37
public function testSetLocaleWithDefaultLocale ()
35
38
{
36
39
$ this ->_checkSetLocale (Resolver::DEFAULT_LOCALE );
37
40
}
38
41
39
42
/**
40
- * @covers \Magento\Backend\Model\Locale\Resolver:: setLocale
43
+ * Tests setLocale() with interface locale
41
44
*/
42
45
public function testSetLocaleWithBaseInterfaceLocale ()
43
46
{
@@ -55,7 +58,7 @@ public function testSetLocaleWithBaseInterfaceLocale()
55
58
}
56
59
57
60
/**
58
- * @covers \Magento\Backend\Model\Locale\Resolver:: setLocale
61
+ * Tests setLocale() with session locale
59
62
*/
60
63
public function testSetLocaleWithSessionLocale ()
61
64
{
@@ -68,7 +71,7 @@ public function testSetLocaleWithSessionLocale()
68
71
}
69
72
70
73
/**
71
- * @covers \Magento\Backend\Model\Locale\Resolver:: setLocale
74
+ * Tests setLocale() with post parameter
72
75
*/
73
76
public function testSetLocaleWithRequestLocale ()
74
77
{
@@ -78,13 +81,45 @@ public function testSetLocaleWithRequestLocale()
78
81
$ this ->_checkSetLocale ('de_DE ' );
79
82
}
80
83
84
+ /**
85
+ * Tests setLocale() with parameter
86
+ *
87
+ * @param string|null $localeParam
88
+ * @param string|null $localeRequestParam
89
+ * @param string $localeExpected
90
+ * @dataProvider setLocaleWithParameterDataProvider
91
+ */
92
+ public function testSetLocaleWithParameter (
93
+ ?string $ localeParam ,
94
+ ?string $ localeRequestParam ,
95
+ string $ localeExpected
96
+ ) {
97
+ $ request = Bootstrap::getObjectManager ()
98
+ ->get (\Magento \Framework \App \RequestInterface::class);
99
+ $ request ->setPostValue (['locale ' => $ localeRequestParam ]);
100
+ $ this ->_model ->setLocale ($ localeParam );
101
+ $ this ->assertEquals ($ localeExpected , $ this ->_model ->getLocale ());
102
+ }
103
+
104
+ /**
105
+ * @return array
106
+ */
107
+ public function setLocaleWithParameterDataProvider (): array
108
+ {
109
+ return [
110
+ ['ko_KR ' , 'ja_JP ' , 'ja_JP ' ],
111
+ ['ko_KR ' , null , 'ko_KR ' ],
112
+ [null , 'ja_JP ' , 'ja_JP ' ],
113
+ ];
114
+ }
115
+
81
116
/**
82
117
* Check set locale
83
118
*
84
119
* @param string $localeCodeToCheck
85
120
* @return void
86
121
*/
87
- protected function _checkSetLocale ($ localeCodeToCheck )
122
+ private function _checkSetLocale ($ localeCodeToCheck )
88
123
{
89
124
$ this ->_model ->setLocale ();
90
125
$ localeCode = $ this ->_model ->getLocale ();
0 commit comments