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
6565 const XML_PATH_WEIGHT_UNIT = 'general/locale/weight_unit ' ;
6666
6767 /**
68- * Country collection
69- *
7068 * @var Collection
7169 */
7270 protected $ _countryCollection ;
7371
7472 /**
75- * Region collection
76- *
7773 * @var \Magento\Directory\Model\ResourceModel\Region\Collection
7874 */
7975 protected $ _regionCollection ;
8076
8177 /**
82- * Json representation of regions data
83- *
8478 * @var string
8579 */
8680 protected $ _regionJson ;
8781
8882 /**
89- * Currency cache
90- *
9183 * @var array
9284 */
9385 protected $ _currencyCache = [];
9486
9587 /**
96- * ISO2 country codes which have optional Zip/Postal pre-configured
97- *
9888 * @var array
9989 */
10090 protected $ _optZipCountries = null ;
@@ -409,6 +399,7 @@ public function getWeightUnit()
409399 * Get current scope from request
410400 *
411401 * @return array
402+ * @throws \Magento\Framework\Exception\NoSuchEntityException
412403 */
413404 private function getCurrentScope (): array
414405 {
@@ -432,6 +423,14 @@ private function getCurrentScope(): array
432423 'type ' => ScopeInterface::SCOPE_STORE ,
433424 'value ' => $ request ->getParam (self ::STORE_ID ),
434425 ];
426+ } else {
427+ $ storeId = $ this ->_storeManager ->getStore ()->getId () ?? null ;
428+ if ($ storeId ) {
429+ $ scope = [
430+ 'type ' => ScopeInterface::SCOPE_STORE ,
431+ 'value ' => $ storeId ,
432+ ];
433+ }
435434 }
436435
437436 return $ scope ;
Original file line number Diff line number Diff line change @@ -294,4 +294,28 @@ public function topCountriesDataProvider()
294294 ['US,RU ' , ['US ' , 'RU ' ]],
295295 ];
296296 }
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+ }
297321}
You can’t perform that action at this time.
0 commit comments