Skip to content

Commit 73ef9ef

Browse files
committed
MAGETWO-59649: Current store resolver does not work for global scope
2 parents d43cc10 + f21ac70 commit 73ef9ef

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

app/code/Magento/Store/Model/StoreManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function isSingleStoreMode()
152152
public function getStore($storeId = null)
153153
{
154154
if (!isset($storeId) || '' === $storeId || $storeId === true) {
155-
if (!$this->currentStoreId) {
155+
if (null === $this->currentStoreId) {
156156
\Magento\Framework\Profiler::start('store.resolve');
157157
$this->currentStoreId = $this->storeResolver->getCurrentStoreId();
158158
\Magento\Framework\Profiler::stop('store.resolve');
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Store\Model;
7+
8+
use Magento\Framework\ObjectManagerInterface as ObjectManager;
9+
use Magento\Store\Model\Store;
10+
use Magento\Store\Model\StoreManagerInterface;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
13+
class StoreManagerTest extends \PHPUnit_Framework_TestCase
14+
{
15+
/**
16+
* @var StoreManagerInterface
17+
*/
18+
private $storeManager;
19+
20+
/**
21+
* @var ObjectManager
22+
*/
23+
private $objectManager;
24+
25+
/**
26+
* Class dependencies initialization
27+
*
28+
* @return void
29+
*/
30+
protected function setUp()
31+
{
32+
$this->objectManager = Bootstrap::getObjectManager();
33+
$this->storeManager = $this->objectManager->get(StoreManagerInterface::class);
34+
}
35+
36+
/**
37+
* Check that behavior of setting and getting store into StoreManager is correct
38+
* Setting: Magento\Store\Model\StoreManagerInterface::setCurrentStore
39+
* Getting: Magento\Store\Model\StoreManagerInterface::getStore
40+
*
41+
* @return void
42+
*/
43+
public function testDefaultStoreIdIsSetCorrectly()
44+
{
45+
$this->storeManager->setCurrentStore(Store::DEFAULT_STORE_ID);
46+
$this->assertEquals(Store::DEFAULT_STORE_ID, $this->storeManager->getStore()->getId());
47+
}
48+
}

0 commit comments

Comments
 (0)