Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,12 @@

/**
* Integration tests decoration of store manager
*
* @package Magento\TestFramework\Store
*/
class StoreManager implements \Magento\Store\Model\StoreManagerInterface
{
/**
* @var \Magento\Store\Model\StoreManager
*/
protected $decoratedStoreManager;

/**
* @var \Magento\Framework\Event\ManagerInterface
*/
protected $eventManager;
private \Magento\Store\Model\StoreManager $decoratedStoreManager;
private \Magento\Framework\Event\ManagerInterface $eventManager;
private \Magento\TestFramework\App\Config $config;

/**
* @var null|bool
Expand All @@ -36,14 +28,16 @@ class StoreManager implements \Magento\Store\Model\StoreManagerInterface
*/
public function __construct(
\Magento\Store\Model\StoreManager $decoratedStoreManager,
\Magento\Framework\Event\ManagerInterface $eventManager
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\TestFramework\App\Config $config
) {
$this->decoratedStoreManager = $decoratedStoreManager;
$this->eventManager = $eventManager;
$this->config = $config;
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function setCurrentStore($store)
{
Expand All @@ -52,7 +46,7 @@ public function setCurrentStore($store)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function setIsSingleStoreModeAllowed($value)
{
Expand All @@ -61,7 +55,7 @@ public function setIsSingleStoreModeAllowed($value)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function hasSingleStore()
{
Expand All @@ -71,7 +65,7 @@ public function hasSingleStore()
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function isSingleStoreMode()
{
Expand All @@ -81,7 +75,7 @@ public function isSingleStoreMode()
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getStore($storeId = null)
{
Expand All @@ -91,7 +85,7 @@ public function getStore($storeId = null)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getStores($withDefault = false, $codeKey = false)
{
Expand All @@ -101,7 +95,7 @@ public function getStores($withDefault = false, $codeKey = false)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getWebsite($websiteId = null)
{
Expand All @@ -111,7 +105,7 @@ public function getWebsite($websiteId = null)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getWebsites($withDefault = false, $codeKey = false)
{
Expand All @@ -121,25 +115,30 @@ public function getWebsites($withDefault = false, $codeKey = false)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function reinitStores()
{
//In order to restore configFixture values
$testAppConfig = ObjectManager::getInstance()->get(Config::class);
$reflection = new \ReflectionClass($testAppConfig);
$dataProperty = $reflection->getProperty('data');
$reflection = new \ReflectionClass($this->config);

if (\substr($reflection->getName(), -12) === '\Interceptor') {
$dataProperty = $reflection->getParentClass()->getProperty('data');
} else {
$dataProperty = $reflection->getProperty('data');
}

$dataProperty->setAccessible(true);
$savedConfig = $dataProperty->getValue($testAppConfig);
$savedConfig = $dataProperty->getValue($this->config);

$this->decoratedStoreManager->reinitStores();

$dataProperty->setValue($testAppConfig, $savedConfig);
$dataProperty->setValue($this->config, $savedConfig);
$this->dispatchInitCurrentStoreAfterEvent();
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getDefaultStoreView()
{
Expand All @@ -149,7 +148,7 @@ public function getDefaultStoreView()
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getGroup($groupId = null)
{
Expand All @@ -159,7 +158,7 @@ public function getGroup($groupId = null)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getGroups($withDefault = false)
{
Expand Down