@@ -52,7 +52,7 @@ class ContextTest extends \PHPUnit\Framework\TestCase
52
52
/**
53
53
* @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
54
54
*/
55
- protected $ storeMock ;
55
+ protected $ store ;
56
56
57
57
/**
58
58
* @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
@@ -62,7 +62,7 @@ class ContextTest extends \PHPUnit\Framework\TestCase
62
62
/**
63
63
* @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject
64
64
*/
65
- protected $ websiteMock ;
65
+ protected $ website ;
66
66
67
67
/**
68
68
* @var AbstractAction|\PHPUnit_Framework_MockObject_MockObject
@@ -87,9 +87,9 @@ protected function setUp()
87
87
->willReturn (null );
88
88
$ this ->storeManager = $ this ->createMock (\Magento \Store \Model \StoreManagerInterface::class);
89
89
$ this ->storeCookieManager = $ this ->createMock (\Magento \Store \Api \StoreCookieManagerInterface::class);
90
- $ this ->storeMock = $ this ->createMock (\Magento \Store \Model \Store::class);
90
+ $ this ->store = $ this ->createMock (\Magento \Store \Model \Store::class);
91
91
$ this ->currentStoreMock = $ this ->createMock (\Magento \Store \Model \Store::class);
92
- $ this ->websiteMock = $ this ->createPartialMock (
92
+ $ this ->website = $ this ->createPartialMock (
93
93
\Magento \Store \Model \Website::class,
94
94
['getDefaultStore ' , '__wakeup ' ]
95
95
);
@@ -108,8 +108,6 @@ protected function setUp()
108
108
]
109
109
);
110
110
111
- $ this ->storeManager ->method ('getDefaultStoreView ' )
112
- ->willReturn ($ this ->storeMock );
113
111
$ this ->storeCookieManager ->expects ($ this ->once ())
114
112
->method ('getStoreCodeFromCookie ' )
115
113
->will ($ this ->returnValue ('storeCookie ' ));
@@ -122,16 +120,16 @@ public function testBeforeDispatchCurrencyFromSession()
122
120
{
123
121
$ this ->storeManager ->expects ($ this ->once ())
124
122
->method ('getWebsite ' )
125
- ->will ($ this ->returnValue ($ this ->websiteMock ));
126
- $ this ->websiteMock ->expects ($ this ->once ())
123
+ ->will ($ this ->returnValue ($ this ->website ));
124
+ $ this ->website ->expects ($ this ->once ())
127
125
->method ('getDefaultStore ' )
128
- ->will ($ this ->returnValue ($ this ->storeMock ));
126
+ ->will ($ this ->returnValue ($ this ->store ));
129
127
130
- $ this ->storeMock ->expects ($ this ->once ())
128
+ $ this ->store ->expects ($ this ->once ())
131
129
->method ('getDefaultCurrencyCode ' )
132
130
->will ($ this ->returnValue (self ::CURRENCY_DEFAULT ));
133
131
134
- $ this ->storeMock ->expects ($ this ->once ())
132
+ $ this ->store ->expects ($ this ->once ())
135
133
->method ('getCode ' )
136
134
->willReturn ('default ' );
137
135
$ this ->currentStoreMock ->expects ($ this ->once ())
@@ -173,41 +171,39 @@ public function testBeforeDispatchCurrencyFromSession()
173
171
);
174
172
}
175
173
176
- public function testDispatchCurrentStoreCurrency ()
174
+ public function testDispatchCurrentStoreAndCurrency ()
177
175
{
178
- $ this ->storeManager ->expects ($ this ->once ())
179
- ->method ('getWebsite ' )
180
- ->will ($ this ->returnValue ($ this ->websiteMock ));
181
- $ this ->websiteMock ->expects ($ this ->once ())
182
- ->method ('getDefaultStore ' )
183
- ->will ($ this ->returnValue ($ this ->storeMock ));
176
+ $ defaultStoreCode = 'default_store ' ;
177
+ $ customStoreCode = 'custom_store ' ;
184
178
185
- $ this ->storeMock ->expects ($ this ->once ())
186
- ->method ('getDefaultCurrencyCode ' )
187
- ->will ($ this ->returnValue (self ::CURRENCY_DEFAULT ));
179
+ $ this ->storeManager ->method ('getWebsite ' )
180
+ ->willReturn ($ this ->website );
181
+ $ this ->website ->method ('getDefaultStore ' )
182
+ ->willReturn ($ this ->store );
188
183
189
- $ this ->storeMock ->expects ($ this ->once ())
190
- ->method ('getCode ' )
191
- ->willReturn ('default ' );
192
- $ this ->currentStoreMock ->expects ($ this ->once ())
193
- ->method ('getCode ' )
194
- ->willReturn ('custom_store ' );
184
+ $ this ->store ->method ('getDefaultCurrencyCode ' )
185
+ ->willReturn (self ::CURRENCY_DEFAULT );
186
+
187
+ $ this ->store ->method ('getCode ' )
188
+ ->willReturn ($ defaultStoreCode );
189
+ $ this ->currentStoreMock ->method ('getCode ' )
190
+ ->willReturn ($ customStoreCode );
195
191
196
192
$ this ->requestMock ->expects ($ this ->once ())
197
193
->method ('getParam ' )
198
194
->with ($ this ->equalTo ('___store ' ))
199
- ->will ( $ this -> returnValue ( ' default ' ) );
195
+ ->willReturn ( $ defaultStoreCode );
200
196
201
197
$ this ->storeManager ->method ('getStore ' )
202
- ->with (' default ' )
198
+ ->with ($ defaultStoreCode )
203
199
->willReturn ($ this ->currentStoreMock );
204
200
205
201
$ this ->httpContextMock ->expects ($ this ->at (1 ))
206
202
->method ('setValue ' )
207
203
->with (
208
204
StoreManagerInterface::CONTEXT_STORE ,
209
- ' custom_store ' ,
210
- ' default '
205
+ $ customStoreCode ,
206
+ $ defaultStoreCode
211
207
);
212
208
// Make sure that current currency is taken from current store
213
209
//if no value is provided in session.
@@ -229,16 +225,16 @@ public function testDispatchStoreParameterIsArray()
229
225
{
230
226
$ this ->storeManager ->expects ($ this ->once ())
231
227
->method ('getWebsite ' )
232
- ->will ($ this ->returnValue ($ this ->websiteMock ));
233
- $ this ->websiteMock ->expects ($ this ->once ())
228
+ ->will ($ this ->returnValue ($ this ->website ));
229
+ $ this ->website ->expects ($ this ->once ())
234
230
->method ('getDefaultStore ' )
235
- ->will ($ this ->returnValue ($ this ->storeMock ));
231
+ ->will ($ this ->returnValue ($ this ->store ));
236
232
237
- $ this ->storeMock ->expects ($ this ->once ())
233
+ $ this ->store ->expects ($ this ->once ())
238
234
->method ('getDefaultCurrencyCode ' )
239
235
->will ($ this ->returnValue (self ::CURRENCY_DEFAULT ));
240
236
241
- $ this ->storeMock ->expects ($ this ->once ())
237
+ $ this ->store ->expects ($ this ->once ())
242
238
->method ('getCode ' )
243
239
->willReturn ('default ' );
244
240
$ this ->currentStoreMock ->expects ($ this ->once ())
@@ -291,15 +287,15 @@ public function testDispatchStoreParameterIsInvalidArray()
291
287
{
292
288
$ this ->storeManager ->expects ($ this ->once ())
293
289
->method ('getWebsite ' )
294
- ->will ($ this ->returnValue ($ this ->websiteMock ));
295
- $ this ->websiteMock ->expects ($ this ->once ())
290
+ ->will ($ this ->returnValue ($ this ->website ));
291
+ $ this ->website ->expects ($ this ->once ())
296
292
->method ('getDefaultStore ' )
297
- ->will ($ this ->returnValue ($ this ->storeMock ));
298
- $ this ->storeMock ->expects ($ this ->exactly (2 ))
293
+ ->will ($ this ->returnValue ($ this ->store ));
294
+ $ this ->store ->expects ($ this ->exactly (2 ))
299
295
->method ('getDefaultCurrencyCode ' )
300
296
->will ($ this ->returnValue (self ::CURRENCY_DEFAULT ));
301
297
302
- $ this ->storeMock ->expects ($ this ->exactly (2 ))
298
+ $ this ->store ->expects ($ this ->exactly (2 ))
303
299
->method ('getCode ' )
304
300
->willReturn ('default ' );
305
301
$ this ->currentStoreMock ->expects ($ this ->never ())
@@ -319,7 +315,7 @@ public function testDispatchStoreParameterIsInvalidArray()
319
315
$ this ->storeManager ->expects ($ this ->once ())
320
316
->method ('getStore ' )
321
317
->with ()
322
- ->willReturn ($ this ->storeMock );
318
+ ->willReturn ($ this ->store );
323
319
$ this ->plugin ->beforeDispatch (
324
320
$ this ->subjectMock ,
325
321
$ this ->requestMock
@@ -343,18 +339,18 @@ public function testDispatchNonExistingStore()
343
339
$ this ->storeManager ->expects ($ this ->at (1 ))
344
340
->method ('getStore ' )
345
341
->with ()
346
- ->willReturn ($ this ->storeMock );
342
+ ->willReturn ($ this ->store );
347
343
$ this ->storeManager ->expects ($ this ->once ())
348
344
->method ('getWebsite ' )
349
- ->will ($ this ->returnValue ($ this ->websiteMock ));
350
- $ this ->websiteMock ->expects ($ this ->once ())
345
+ ->will ($ this ->returnValue ($ this ->website ));
346
+ $ this ->website ->expects ($ this ->once ())
351
347
->method ('getDefaultStore ' )
352
- ->will ($ this ->returnValue ($ this ->storeMock ));
353
- $ this ->storeMock ->expects ($ this ->exactly (2 ))
348
+ ->will ($ this ->returnValue ($ this ->store ));
349
+ $ this ->store ->expects ($ this ->exactly (2 ))
354
350
->method ('getDefaultCurrencyCode ' )
355
351
->will ($ this ->returnValue (self ::CURRENCY_DEFAULT ));
356
352
357
- $ this ->storeMock ->expects ($ this ->exactly (2 ))
353
+ $ this ->store ->expects ($ this ->exactly (2 ))
358
354
->method ('getCode ' )
359
355
->willReturn ('default ' );
360
356
$ this ->currentStoreMock ->expects ($ this ->never ())
0 commit comments