File tree Expand file tree Collapse file tree 2 files changed +33
-10
lines changed
app/code/Magento/Directory Expand file tree Collapse file tree 2 files changed +33
-10
lines changed Original file line number Diff line number Diff line change @@ -65,36 +65,26 @@ class Data extends AbstractHelper
65
65
const XML_PATH_WEIGHT_UNIT = 'general/locale/weight_unit ' ;
66
66
67
67
/**
68
- * Country collection
69
- *
70
68
* @var Collection
71
69
*/
72
70
protected $ _countryCollection ;
73
71
74
72
/**
75
- * Region collection
76
- *
77
73
* @var \Magento\Directory\Model\ResourceModel\Region\Collection
78
74
*/
79
75
protected $ _regionCollection ;
80
76
81
77
/**
82
- * Json representation of regions data
83
- *
84
78
* @var string
85
79
*/
86
80
protected $ _regionJson ;
87
81
88
82
/**
89
- * Currency cache
90
- *
91
83
* @var array
92
84
*/
93
85
protected $ _currencyCache = [];
94
86
95
87
/**
96
- * ISO2 country codes which have optional Zip/Postal pre-configured
97
- *
98
88
* @var array
99
89
*/
100
90
protected $ _optZipCountries = null ;
@@ -409,6 +399,7 @@ public function getWeightUnit()
409
399
* Get current scope from request
410
400
*
411
401
* @return array
402
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
412
403
*/
413
404
private function getCurrentScope (): array
414
405
{
@@ -432,6 +423,14 @@ private function getCurrentScope(): array
432
423
'type ' => ScopeInterface::SCOPE_STORE ,
433
424
'value ' => $ request ->getParam (self ::STORE_ID ),
434
425
];
426
+ } else {
427
+ $ storeId = $ this ->_storeManager ->getStore ()->getId () ?? null ;
428
+ if ($ storeId ) {
429
+ $ scope = [
430
+ 'type ' => ScopeInterface::SCOPE_STORE ,
431
+ 'value ' => $ storeId ,
432
+ ];
433
+ }
435
434
}
436
435
437
436
return $ scope ;
Original file line number Diff line number Diff line change @@ -294,4 +294,28 @@ public function topCountriesDataProvider()
294
294
['US,RU ' , ['US ' , 'RU ' ]],
295
295
];
296
296
}
297
+
298
+ /**
299
+ * Test private method `getCurrentScope`, if no request parameter `scope type` sent.
300
+ *
301
+ * @throws \ReflectionException
302
+ */
303
+ public function testGetCurrentScopeWithoutRequestParameters ()
304
+ {
305
+ $ storeId = 1 ;
306
+ $ scope = [
307
+ 'type ' => ScopeInterface::SCOPE_STORE ,
308
+ 'value ' => $ storeId ,
309
+ ];
310
+
311
+ $ this ->_store ->expects ($ this ->atLeastOnce ())->method ('getId ' )->willReturn ($ storeId );
312
+
313
+ $ reflector = new \ReflectionClass ($ this ->_object );
314
+ $ method = $ reflector ->getMethod ('getCurrentScope ' );
315
+ $ method ->setAccessible (true );
316
+
317
+ $ result = $ method ->invoke ($ this ->_object );
318
+ $ this ->assertIsArray ($ result );
319
+ $ this ->assertEquals ($ scope , $ result );
320
+ }
297
321
}
You can’t perform that action at this time.
0 commit comments