Skip to content

Commit 8581baa

Browse files
ACPT-1186
fixing unit test failures
1 parent 5500dc6 commit 8581baa

File tree

6 files changed

+31
-52
lines changed

6 files changed

+31
-52
lines changed

app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Magento\Framework\App\ObjectManager;
99
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1010
use Magento\Store\Model\StoreManagerInterface;
11-
use Magento\Store\Model\StoreManagerInterface\Proxy as StoreManagerInterfaceProxy;
1211

1312
/**
1413
* Eav attribute default source when values are coming from another table
@@ -43,18 +42,17 @@ class Table extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource im
4342
/**
4443
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory
4544
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $attrOptionFactory
46-
* @param StoreManagerInterfaceProxy|null $StoreManagerInterfaceProxy
45+
* @param StoreManagerInterface|null $storeManager
4746
* @codeCoverageIgnore
4847
*/
4948
public function __construct(
5049
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory,
5150
\Magento\Eav\Model\ResourceModel\Entity\Attribute\OptionFactory $attrOptionFactory,
52-
StoreManagerInterfaceProxy $StoreManagerInterfaceProxy = null
51+
StoreManagerInterface $storeManager = null
5352
) {
5453
$this->_attrOptionCollectionFactory = $attrOptionCollectionFactory;
5554
$this->_attrOptionFactory = $attrOptionFactory;
56-
$this->storeManager = $StoreManagerInterfaceProxy
57-
?? ObjectManager::getInstance()->get(StoreManagerInterfaceProxy::class);
55+
$this->storeManager = $storeManager ?? ObjectManager::getInstance()->get(StoreManagerInterface::class);
5856
}
5957

6058
/**

app/code/Magento/Eav/etc/di.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,10 @@
221221
<argument name="cache" xsi:type="object">configured_eav_cache</argument>
222222
</arguments>
223223
</type>
224+
225+
<type name="Magento\Eav\Model\Entity\Attribute\Source\Table">
226+
<arguments>
227+
<argument name="storeManager" xsi:type="object">Magento\Store\Model\StoreManagerInterface\Proxy</argument>
228+
</arguments>
229+
</type>
224230
</config>

app/code/Magento/Theme/Model/Theme/ThemeProvider.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Magento\Framework\Serialize\Serializer\Json;
1010
use Magento\Framework\View\Design\Theme\ListInterface;
1111
use Magento\Framework\App\DeploymentConfig;
12-
use Magento\Framework\App\DeploymentConfig\Proxy as DeploymentConfigProxy;
1312

1413
/**
1514
* Provide data for theme grid and for theme edit page
@@ -58,21 +57,20 @@ class ThemeProvider implements \Magento\Framework\View\Design\Theme\ThemeProvide
5857
* @param \Magento\Theme\Model\ThemeFactory $themeFactory
5958
* @param \Magento\Framework\App\CacheInterface $cache
6059
* @param Json $serializer
61-
* @param DeploymentConfigProxy|null $deploymentConfigProxy
60+
* @param DeploymentConfig|null $deploymentConfig
6261
*/
6362
public function __construct(
6463
\Magento\Theme\Model\ResourceModel\Theme\CollectionFactory $collectionFactory,
6564
\Magento\Theme\Model\ThemeFactory $themeFactory,
6665
\Magento\Framework\App\CacheInterface $cache,
6766
Json $serializer = null,
68-
DeploymentConfigProxy $deploymentConfigProxy = null
67+
DeploymentConfig $deploymentConfig = null
6968
) {
7069
$this->collectionFactory = $collectionFactory;
7170
$this->themeFactory = $themeFactory;
7271
$this->cache = $cache;
7372
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class);
74-
$this->deploymentConfig = $deploymentConfigProxy
75-
?? ObjectManager::getInstance()->get(DeploymentConfigProxy::class);
73+
$this->deploymentConfig = $deploymentConfig ?? ObjectManager::getInstance()->get(DeploymentConfig::class);
7674
}
7775

7876
/**

app/code/Magento/Theme/Test/Unit/Model/Theme/ThemeProviderTest.php

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Framework\App\Area;
1111
use Magento\Framework\App\CacheInterface;
1212
use Magento\Framework\App\DeploymentConfig;
13-
use Magento\Framework\ObjectManagerInterface;
1413
use Magento\Framework\Serialize\Serializer\Json;
1514
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1615
use Magento\Framework\View\Design\ThemeInterface;
@@ -31,21 +30,24 @@ class ThemeProviderTest extends TestCase
3130
/** Theme ID used by tests */
3231
const THEME_ID = 755;
3332

34-
/** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */
33+
/** @var ObjectManagerHelper */
3534
private $objectManager;
3635

37-
/** @var \Magento\Theme\Model\ResourceModel\Theme\CollectionFactory|MockObject */
36+
/** @var \Magento\Theme\Model\ResourceModel\Theme\CollectionFactory&MockObject */
3837
private $collectionFactory;
3938

40-
/** @var \Magento\Theme\Model\ThemeFactory|MockObject */
39+
/** @var \Magento\Theme\Model\ThemeFactory&MockObject */
4140
private $themeFactory;
4241

43-
/** @var CacheInterface|MockObject */
42+
/** @var CacheInterface&MockObject */
4443
private $cache;
4544

46-
/** @var Json|MockObject */
45+
/** @var Json&MockObject */
4746
private $serializer;
4847

48+
/** @var DeploymentConfig&MockObject */
49+
private DeploymentConfig $deploymentConfig;
50+
4951
/** @var ThemeProvider|MockObject */
5052
private $themeProvider;
5153

@@ -64,13 +66,17 @@ protected function setUp(): void
6466
->disableOriginalConstructor()
6567
->getMockForAbstractClass();
6668
$this->serializer = $this->createMock(Json::class);
69+
$this->deploymentConfig = $this->getMockBuilder(DeploymentConfig::class)
70+
->disableOriginalConstructor()
71+
->getMock();
6772
$this->themeProvider = $this->objectManager->getObject(
6873
ThemeProvider::class,
6974
[
7075
'collectionFactory' => $this->collectionFactory,
7176
'themeFactory' => $this->themeFactory,
7277
'cache' => $this->cache,
73-
'serializer' => $this->serializer
78+
'serializer' => $this->serializer,
79+
'deploymentConfig' => $this->deploymentConfig,
7480
]
7581
);
7682
$this->theme = $this->createMock(Theme::class);
@@ -85,7 +91,6 @@ public function testGetByFullPath()
8591
$this->theme->expects($this->exactly(2))
8692
->method('toArray')
8793
->willReturn($themeArray);
88-
8994
$collectionMock = $this->createMock(Collection::class);
9095
$collectionMock->expects($this->once())
9196
->method('getThemeByFullPath')
@@ -98,22 +103,9 @@ public function testGetByFullPath()
98103
->method('serialize')
99104
->with($themeArray)
100105
->willReturn('serialized theme');
101-
102-
$deploymentConfig = $this->getMockBuilder(DeploymentConfig::class)
103-
->disableOriginalConstructor()
104-
->getMock();
105-
$deploymentConfig->expects($this->once())
106+
$this->deploymentConfig->expects($this->once())
106107
->method('isDbAvailable')
107108
->willReturn(true);
108-
109-
$objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
110-
$objectManagerMock->expects($this->any())
111-
->method('get')
112-
->willReturnMap([
113-
[DeploymentConfig::class, $deploymentConfig],
114-
]);
115-
\Magento\Framework\App\ObjectManager::setInstance($objectManagerMock);
116-
117109
$this->assertSame(
118110
$this->theme,
119111
$this->themeProvider->getThemeByFullPath(self::THEME_PATH),
@@ -128,21 +120,9 @@ public function testGetByFullPath()
128120

129121
public function testGetByFullPathWithCache()
130122
{
131-
$deploymentConfig = $this->getMockBuilder(DeploymentConfig::class)
132-
->disableOriginalConstructor()
133-
->getMock();
134-
$deploymentConfig->expects($this->once())
123+
$this->deploymentConfig->expects($this->once())
135124
->method('isDbAvailable')
136125
->willReturn(true);
137-
138-
$objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class);
139-
$objectManagerMock->expects($this->any())
140-
->method('get')
141-
->willReturnMap([
142-
[DeploymentConfig::class, $deploymentConfig],
143-
]);
144-
\Magento\Framework\App\ObjectManager::setInstance($objectManagerMock);
145-
146126
$serializedTheme = '{"theme_data":"theme_data"}';
147127
$themeArray = ['theme_data' => 'theme_data'];
148128
$this->theme->expects($this->once())
@@ -152,17 +132,14 @@ public function testGetByFullPathWithCache()
152132
$this->themeFactory->expects($this->once())
153133
->method('create')
154134
->willReturn($this->theme);
155-
156135
$this->serializer->expects($this->once())
157136
->method('unserialize')
158137
->with($serializedTheme)
159138
->willReturn($themeArray);
160-
161139
$this->cache->expects($this->once())
162140
->method('load')
163141
->with('theme' . self::THEME_PATH)
164142
->willReturn($serializedTheme);
165-
166143
$this->assertSame(
167144
$this->theme,
168145
$this->themeProvider->getThemeByFullPath(self::THEME_PATH),

app/code/Magento/Theme/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@
312312
<type name="Magento\Theme\Model\Theme\ThemeProvider">
313313
<arguments>
314314
<argument name="cache" xsi:type="object">configured_design_cache</argument>
315+
<argument name="deploymentConfig" xsi:type="object">Magento\Framework\App\DeploymentConfig\Proxy</argument>
315316
</arguments>
316317
</type>
317318
<type name="Magento\Theme\Model\Theme\StoreThemesResolver">

lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
use Magento\Framework\ObjectManager\ConfigLoaderInterface;
1111
use Magento\Framework\Serialize\Serializer\Serialize;
12-
use Magento\Framework\Serialize\Serializer\Serialize\Proxy as SerializeProxy;
1312
use Magento\Framework\Serialize\SerializerInterface;
1413

1514
class ConfigLoader implements ConfigLoaderInterface
@@ -43,17 +42,17 @@ class ConfigLoader implements ConfigLoaderInterface
4342
/**
4443
* @param \Magento\Framework\Config\CacheInterface $cache
4544
* @param \Magento\Framework\ObjectManager\Config\Reader\DomFactory $readerFactory
46-
* @param SerializeProxy|null $serializer
45+
* @param Serialize|null $serializer
4746
*/
4847
public function __construct(
4948
\Magento\Framework\Config\CacheInterface $cache,
5049
\Magento\Framework\ObjectManager\Config\Reader\DomFactory $readerFactory,
51-
SerializeProxy $serializer = null
50+
Serialize $serializer = null
5251
) {
5352
$this->_cache = $cache;
5453
$this->_readerFactory = $readerFactory;
5554
$this->serializer = $serializer
56-
?? \Magento\Framework\App\ObjectManager::getInstance()->get(SerializeProxy::class);
55+
?? \Magento\Framework\App\ObjectManager::getInstance()->get(Serialize::class);
5756
}
5857

5958
/**

0 commit comments

Comments
 (0)