@@ -31,6 +31,9 @@ class AuthenticationPopupTest extends \PHPUnit_Framework_TestCase
31
31
/** @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject */
32
32
private $ urlBuilderMock ;
33
33
34
+ /** @var \Magento\Framework\Serialize\Serializer\Json|\PHPUnit_Framework_MockObject_MockObject */
35
+ private $ serializerMock ;
36
+
34
37
protected function setUp ()
35
38
{
36
39
$ this ->contextMock = $ this ->getMockBuilder (Context::class)
@@ -72,8 +75,13 @@ function ($string) {
72
75
->method ('getEscaper ' )
73
76
->willReturn ($ escaperMock );
74
77
78
+ $ this ->serializerMock = $ this ->getMockBuilder (\Magento \Framework \Serialize \Serializer \Json::class)
79
+ ->getMock ();
80
+
75
81
$ this ->model = new AuthenticationPopup (
76
- $ this ->contextMock
82
+ $ this ->contextMock ,
83
+ [],
84
+ $ this ->serializerMock
77
85
);
78
86
}
79
87
@@ -83,6 +91,7 @@ function ($string) {
83
91
* @param string $registerUrl
84
92
* @param string $forgotUrl
85
93
* @param array $result
94
+ * @throws \PHPUnit_Framework_Exception
86
95
*
87
96
* @dataProvider dataProviderGetConfig
88
97
*/
@@ -172,4 +181,51 @@ public function dataProviderGetConfig()
172
181
],
173
182
];
174
183
}
184
+
185
+ /**
186
+ * @param mixed $isAutocomplete
187
+ * @param string $baseUrl
188
+ * @param string $registerUrl
189
+ * @param string $forgotUrl
190
+ * @param array $result
191
+ * @throws \PHPUnit_Framework_Exception
192
+ *
193
+ * @dataProvider dataProviderGetConfig
194
+ */
195
+ public function testGetSerializedConfig ($ isAutocomplete , $ baseUrl , $ registerUrl , $ forgotUrl , array $ result )
196
+ {
197
+ $ this ->scopeConfigMock ->expects ($ this ->any ())
198
+ ->method ('getValue ' )
199
+ ->with (Form::XML_PATH_ENABLE_AUTOCOMPLETE , ScopeInterface::SCOPE_STORE , null )
200
+ ->willReturn ($ isAutocomplete );
201
+
202
+ /** @var StoreInterface||\PHPUnit_Framework_MockObject_MockObject $storeMock */
203
+ $ storeMock = $ this ->getMockBuilder (StoreInterface::class)
204
+ ->setMethods (['getBaseUrl ' ])
205
+ ->getMockForAbstractClass ();
206
+
207
+ $ this ->storeManagerMock ->expects ($ this ->any ())
208
+ ->method ('getStore ' )
209
+ ->with (null )
210
+ ->willReturn ($ storeMock );
211
+
212
+ $ storeMock ->expects ($ this ->any ())
213
+ ->method ('getBaseUrl ' )
214
+ ->willReturn ($ baseUrl );
215
+
216
+ $ this ->urlBuilderMock ->expects ($ this ->any ())
217
+ ->method ('getUrl ' )
218
+ ->willReturnMap (
219
+ [
220
+ ['customer/account/create ' , [], $ registerUrl ],
221
+ ['customer/account/forgotpassword ' , [], $ forgotUrl ],
222
+ ]
223
+ );
224
+ $ this ->serializerMock ->expects ($ this ->any ())->method ('serialize ' )
225
+ ->willReturn (
226
+ json_encode ($ this ->model ->getConfig ())
227
+ );
228
+
229
+ $ this ->assertEquals (json_encode ($ result ), $ this ->model ->getSerializedConfig ());
230
+ }
175
231
}
0 commit comments