@@ -35,31 +35,11 @@ class CurrencysymbolTest extends \PHPUnit_Framework_TestCase
35
35
*/
36
36
protected $ systemStoreMock ;
37
37
38
- /**
39
- * @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject
40
- */
41
- protected $ websiteMock ;
42
-
43
- /**
44
- * @var \Magento\Store\Model\Group|\PHPUnit_Framework_MockObject_MockObject
45
- */
46
- protected $ groupMock ;
47
-
48
- /**
49
- * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
50
- */
51
- protected $ storeMock ;
52
-
53
38
/**
54
39
* @var \Magento\Config\Model\Config\Factory|\PHPUnit_Framework_MockObject_MockObject
55
40
*/
56
41
protected $ configFactoryMock ;
57
42
58
- /**
59
- * @var \Magento\Config\Model\Config|\PHPUnit_Framework_MockObject_MockObject
60
- */
61
- protected $ configMock ;
62
-
63
43
/**
64
44
* @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
65
45
*/
@@ -153,17 +133,6 @@ protected function setUp()
153
133
'' ,
154
134
false
155
135
);
156
- $ this ->configMock = $ this ->getMock (
157
- 'Magento\Config\Model\Config ' ,
158
- ['setSection ' , 'setWebsite ' , 'setStore ' , 'setGroups ' , 'save ' ],
159
- [],
160
- '' ,
161
- false
162
- );
163
- $ this ->websiteMock = $ this ->getMock ('Magento\Store\Model\Website ' , ['getId ' , 'getConfig ' ], [], '' , false );
164
- $ this ->groupMock = $ this ->getMock ('Magento\Store\Model\Group ' , ['getId ' , 'getWebsiteId ' ], [], '' , false );
165
- $ this ->storeMock = $ this ->getMock ('Magento\Store\Model\Store ' , ['getGroupId ' ], [], '' , false );
166
-
167
136
168
137
$ this ->model = $ this ->objectManagerHelper ->getObject (
169
138
'Magento\CurrencySymbol\Model\System\Currencysymbol ' ,
@@ -219,14 +188,25 @@ public function testSetCurrencySymbolData()
219
188
220
189
$ this ->prepareMocksForGetCurrencySymbolsData ($ websiteId , $ groupId , $ currencies );
221
190
222
- $ this ->configFactoryMock ->expects ($ this ->any ())->method ('create ' )->willReturn ($ this ->configMock );
223
- $ this ->configMock ->expects ($ this ->any ())
191
+ /**
192
+ * @var \Magento\Config\Model\Config|\PHPUnit_Framework_MockObject_MockObject
193
+ */
194
+ $ configMock = $ this ->getMock (
195
+ 'Magento\Config\Model\Config ' ,
196
+ ['setSection ' , 'setWebsite ' , 'setStore ' , 'setGroups ' , 'save ' ],
197
+ [],
198
+ '' ,
199
+ false
200
+ );
201
+
202
+ $ this ->configFactoryMock ->expects ($ this ->any ())->method ('create ' )->willReturn ($ configMock );
203
+ $ configMock ->expects ($ this ->any ())
224
204
->method ('setSection ' )
225
205
->with (Currencysymbol::CONFIG_SECTION )
226
206
->willReturnSelf ();
227
- $ this -> configMock ->expects ($ this ->any ())->method ('setWebsite ' )->with (null )->willReturnSelf ();
228
- $ this -> configMock ->expects ($ this ->any ())->method ('setStore ' )->with (null )->willReturnSelf ();
229
- $ this -> configMock ->expects ($ this ->any ())->method ('setGroups ' )->with ($ value )->willReturnSelf ();
207
+ $ configMock ->expects ($ this ->any ())->method ('setWebsite ' )->with (null )->willReturnSelf ();
208
+ $ configMock ->expects ($ this ->any ())->method ('setStore ' )->with (null )->willReturnSelf ();
209
+ $ configMock ->expects ($ this ->any ())->method ('setGroups ' )->with ($ value )->willReturnSelf ();
230
210
231
211
$ this ->coreConfigMock ->expects ($ this ->once ())->method ('reinit ' );
232
212
$ this ->storeManagerMock ->expects ($ this ->once ())->method ('reinitStores ' );
@@ -292,15 +272,30 @@ public function getCurrencySymbolDataProvider()
292
272
*/
293
273
protected function prepareMocksForGetCurrencySymbolsData ($ websiteId , $ groupId , $ currencies )
294
274
{
275
+ /**
276
+ * @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject
277
+ */
278
+ $ websiteMock = $ this ->getMock ('Magento\Store\Model\Website ' , ['getId ' , 'getConfig ' ], [], '' , false );
279
+
280
+ /**
281
+ * @var \Magento\Store\Model\Group|\PHPUnit_Framework_MockObject_MockObject
282
+ */
283
+ $ groupMock = $ this ->getMock ('Magento\Store\Model\Group ' , ['getId ' , 'getWebsiteId ' ], [], '' , false );
284
+
285
+ /**
286
+ * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
287
+ */
288
+ $ storeMock = $ this ->getMock ('Magento\Store\Model\Store ' , ['getGroupId ' ], [], '' , false );
289
+
295
290
$ this ->systemStoreMock ->expects ($ this ->once ())
296
291
->method ('getWebsiteCollection ' )
297
- ->willReturn ([$ this -> websiteMock ]);
298
- $ this ->systemStoreMock ->expects ($ this ->once ())->method ('getGroupCollection ' )->willReturn ([$ this -> groupMock ]);
299
- $ this ->systemStoreMock ->expects ($ this ->once ())->method ('getStoreCollection ' )->willReturn ([$ this -> storeMock ]);
300
- $ this -> websiteMock ->expects ($ this ->any ())->method ('getId ' )->willReturn ($ websiteId );
301
- $ this -> groupMock ->expects ($ this ->any ())->method ('getWebsiteId ' )->willReturn ($ websiteId );
302
- $ this -> groupMock ->expects ($ this ->any ())->method ('getId ' )->willReturn ($ groupId );
303
- $ this -> storeMock ->expects ($ this ->any ())->method ('getGroupId ' )->willReturn ($ groupId );
292
+ ->willReturn ([$ websiteMock ]);
293
+ $ this ->systemStoreMock ->expects ($ this ->once ())->method ('getGroupCollection ' )->willReturn ([$ groupMock ]);
294
+ $ this ->systemStoreMock ->expects ($ this ->once ())->method ('getStoreCollection ' )->willReturn ([$ storeMock ]);
295
+ $ websiteMock ->expects ($ this ->any ())->method ('getId ' )->willReturn ($ websiteId );
296
+ $ groupMock ->expects ($ this ->any ())->method ('getWebsiteId ' )->willReturn ($ websiteId );
297
+ $ groupMock ->expects ($ this ->any ())->method ('getId ' )->willReturn ($ groupId );
298
+ $ storeMock ->expects ($ this ->any ())->method ('getGroupId ' )->willReturn ($ groupId );
304
299
305
300
$ this ->scopeConfigMock ->expects ($ this ->any ())
306
301
->method ('getValue ' )
@@ -310,24 +305,23 @@ protected function prepareMocksForGetCurrencySymbolsData($websiteId, $groupId, $
310
305
[
311
306
CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES ,
312
307
ScopeInterface::SCOPE_STORE ,
313
- $ this -> storeMock ,
308
+ $ storeMock ,
314
309
$ currencies
315
310
],
316
311
[CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES , ScopeInterface::SCOPE_STORE , null , $ currencies ],
317
312
[
318
313
CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES ,
319
314
ScopeInterface::SCOPE_STORE ,
320
- $ this -> storeMock ,
315
+ $ storeMock ,
321
316
$ currencies
322
317
]
323
318
]
324
319
);
325
320
326
- $ this -> websiteMock ->expects ($ this ->any ())
321
+ $ websiteMock ->expects ($ this ->any ())
327
322
->method ('getConfig ' )
328
323
->with (CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES )
329
324
->willReturn ($ currencies );
330
325
$ this ->localeResolverMock ->expects ($ this ->any ())->method ('getLocale ' )->willReturn ('en ' );
331
326
}
332
-
333
327
}
0 commit comments