From 0e75d2d6a9b2ace738e957b6b6ea8bdc094e43af Mon Sep 17 00:00:00 2001 From: Bartosz Gorski Date: Mon, 18 Oct 2021 17:19:04 +0200 Subject: [PATCH 1/3] #18668: Fixed store reinitialization on projects with plugins on \Magento\TestFramework\App\Config --- .../Magento/TestFramework/Store/StoreManager.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dev/tests/integration/framework/Magento/TestFramework/Store/StoreManager.php b/dev/tests/integration/framework/Magento/TestFramework/Store/StoreManager.php index c462b4a74180e..1b3021928fa51 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Store/StoreManager.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Store/StoreManager.php @@ -128,7 +128,13 @@ public function reinitStores() //In order to restore configFixture values $testAppConfig = ObjectManager::getInstance()->get(Config::class); $reflection = new \ReflectionClass($testAppConfig); - $dataProperty = $reflection->getProperty('data'); + + if (\substr($reflection->getName(), -12) === '\Interceptor') { + $dataProperty = $reflection->getParentClass()->getProperty('data'); + } else { + $dataProperty = $reflection->getProperty('data'); + } + $dataProperty->setAccessible(true); $savedConfig = $dataProperty->getValue($testAppConfig); From 50c0264c94415ba5dbc56d1307ef0342c98d8448 Mon Sep 17 00:00:00 2001 From: Bartosz Gorski Date: Tue, 19 Oct 2021 01:34:48 +0200 Subject: [PATCH 2/3] #18668: Fixed @inheritdoc annotations on methods from \Magento\TestFramework\Store\StoreManager --- .../TestFramework/Store/StoreManager.php | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/dev/tests/integration/framework/Magento/TestFramework/Store/StoreManager.php b/dev/tests/integration/framework/Magento/TestFramework/Store/StoreManager.php index 1b3021928fa51..e8b2c6a6e122d 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Store/StoreManager.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Store/StoreManager.php @@ -10,8 +10,6 @@ /** * Integration tests decoration of store manager - * - * @package Magento\TestFramework\Store */ class StoreManager implements \Magento\Store\Model\StoreManagerInterface { @@ -43,7 +41,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function setCurrentStore($store) { @@ -52,7 +50,7 @@ public function setCurrentStore($store) } /** - * {@inheritdoc} + * @inheritdoc */ public function setIsSingleStoreModeAllowed($value) { @@ -61,7 +59,7 @@ public function setIsSingleStoreModeAllowed($value) } /** - * {@inheritdoc} + * @inheritdoc */ public function hasSingleStore() { @@ -71,7 +69,7 @@ public function hasSingleStore() } /** - * {@inheritdoc} + * @inheritdoc */ public function isSingleStoreMode() { @@ -81,7 +79,7 @@ public function isSingleStoreMode() } /** - * {@inheritdoc} + * @inheritdoc */ public function getStore($storeId = null) { @@ -91,7 +89,7 @@ public function getStore($storeId = null) } /** - * {@inheritdoc} + * @inheritdoc */ public function getStores($withDefault = false, $codeKey = false) { @@ -101,7 +99,7 @@ public function getStores($withDefault = false, $codeKey = false) } /** - * {@inheritdoc} + * @inheritdoc */ public function getWebsite($websiteId = null) { @@ -111,7 +109,7 @@ public function getWebsite($websiteId = null) } /** - * {@inheritdoc} + * @inheritdoc */ public function getWebsites($withDefault = false, $codeKey = false) { @@ -121,7 +119,7 @@ public function getWebsites($withDefault = false, $codeKey = false) } /** - * {@inheritdoc} + * @inheritdoc */ public function reinitStores() { @@ -145,7 +143,7 @@ public function reinitStores() } /** - * {@inheritdoc} + * @inheritdoc */ public function getDefaultStoreView() { @@ -155,7 +153,7 @@ public function getDefaultStoreView() } /** - * {@inheritdoc} + * @inheritdoc */ public function getGroup($groupId = null) { @@ -165,7 +163,7 @@ public function getGroup($groupId = null) } /** - * {@inheritdoc} + * @inheritdoc */ public function getGroups($withDefault = false) { From ab73fc3c67e08e9011b9833e99f25650fa54aad2 Mon Sep 17 00:00:00 2001 From: Bartosz Gorski Date: Tue, 19 Oct 2021 01:52:57 +0200 Subject: [PATCH 3/3] #18668: Fixed an error stating that \Magento\TestFramework\App\Config should be requested in the constructor of \Magento\TestFramework\Store\StoreManager --- .../TestFramework/Store/StoreManager.php | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/dev/tests/integration/framework/Magento/TestFramework/Store/StoreManager.php b/dev/tests/integration/framework/Magento/TestFramework/Store/StoreManager.php index e8b2c6a6e122d..ba921de0aa4dc 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Store/StoreManager.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Store/StoreManager.php @@ -13,15 +13,9 @@ */ 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 @@ -34,10 +28,12 @@ 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; } /** @@ -124,8 +120,7 @@ public function getWebsites($withDefault = false, $codeKey = false) public function reinitStores() { //In order to restore configFixture values - $testAppConfig = ObjectManager::getInstance()->get(Config::class); - $reflection = new \ReflectionClass($testAppConfig); + $reflection = new \ReflectionClass($this->config); if (\substr($reflection->getName(), -12) === '\Interceptor') { $dataProperty = $reflection->getParentClass()->getProperty('data'); @@ -134,11 +129,11 @@ public function reinitStores() } $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(); }