Skip to content

Commit 007eb8a

Browse files
committed
MAGETWO-52836: Enable EAV attributes caching - unskip unit
1 parent fe35cb1 commit 007eb8a

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

app/code/Magento/Eav/Test/Unit/Model/ResourceModel/Entity/AttributeTest.php

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace Magento\Eav\Test\Unit\Model\ResourceModel\Entity;
1010

11+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
12+
1113
class AttributeTest extends \PHPUnit_Framework_TestCase
1214
{
1315
/**
@@ -22,7 +24,6 @@ class AttributeTest extends \PHPUnit_Framework_TestCase
2224

2325
protected function setUp()
2426
{
25-
$this->markTestSkipped();
2627
$this->contextMock = $this->getMock(
2728
'\Magento\Framework\Model\Context',
2829
['getCacheManager', 'getEventDispatcher', 'getLogger', 'getAppState', 'getActionValidator'],
@@ -41,8 +42,8 @@ protected function setUp()
4142
public function testSaveOptionSystemAttribute()
4243
{
4344
/** @var $connectionMock \PHPUnit_Framework_MockObject_MockObject */
44-
/** @var $resourceModelMock \Magento\Eav\Model\ResourceModel\Entity\Attribute */
45-
list($connectionMock, $resourceModelMock) = $this->_prepareResourceModel();
45+
/** @var $resourceModel \Magento\Eav\Model\ResourceModel\Entity\Attribute */
46+
list($connectionMock, $resourceModel) = $this->_prepareResourceModel();
4647

4748
$attributeData = [
4849
'attribute_id' => '123',
@@ -103,7 +104,7 @@ public function testSaveOptionSystemAttribute()
103104
);
104105
$connectionMock->expects($this->never())->method('delete');
105106

106-
$resourceModelMock->save($model);
107+
$resourceModel->save($model);
107108
}
108109

109110
/**
@@ -112,8 +113,8 @@ public function testSaveOptionSystemAttribute()
112113
public function testSaveOptionNewUserDefinedAttribute()
113114
{
114115
/** @var $connectionMock \PHPUnit_Framework_MockObject_MockObject */
115-
/** @var $resourceModelMock \Magento\Eav\Model\ResourceModel\Entity\Attribute */
116-
list($connectionMock, $resourceModelMock) = $this->_prepareResourceModel();
116+
/** @var $resourceModel \Magento\Eav\Model\ResourceModel\Entity\Attribute */
117+
list($connectionMock, $resourceModel) = $this->_prepareResourceModel();
117118

118119
$attributeData = [
119120
'entity_type_id' => 4,
@@ -198,7 +199,7 @@ public function testSaveOptionNewUserDefinedAttribute()
198199
)
199200
);
200201

201-
$resourceModelMock->save($model);
202+
$resourceModel->save($model);
202203
}
203204

204205
/**
@@ -207,8 +208,8 @@ public function testSaveOptionNewUserDefinedAttribute()
207208
public function testSaveOptionNoValue()
208209
{
209210
/** @var $connectionMock \PHPUnit_Framework_MockObject_MockObject */
210-
/** @var $resourceModelMock \Magento\Eav\Model\ResourceModel\Entity\Attribute */
211-
list($connectionMock, $resourceModelMock) = $this->_prepareResourceModel();
211+
/** @var $resourceModel \Magento\Eav\Model\ResourceModel\Entity\Attribute */
212+
list($connectionMock, $resourceModel) = $this->_prepareResourceModel();
212213

213214
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
214215
/** @var $model \Magento\Framework\Model\AbstractModel */
@@ -221,7 +222,7 @@ public function testSaveOptionNoValue()
221222
$connectionMock->expects($this->never())->method('delete');
222223
$connectionMock->expects($this->never())->method('update');
223224

224-
$resourceModelMock->save($model);
225+
$resourceModel->save($model);
225226
}
226227

227228
/**
@@ -331,18 +332,29 @@ protected function _prepareResourceModel()
331332
$contextMock->expects($this->once())->method('getResources')->willReturn($resource);
332333
$contextMock->expects($this->once())->method('getObjectRelationProcessor')->willReturn($relationProcessorMock);
333334

335+
$configMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class)->disableOriginalConstructor()->getMock();
336+
$attributeCacheMock = $this->getMockBuilder(
337+
\Magento\Eav\Model\Entity\AttributeCache::class
338+
)->disableOriginalConstructor()->getMock();
334339
$arguments = [
335340
'context' => $contextMock,
336341
'storeManager' => $storeManager,
337342
'eavEntityType' => $eavEntityType,
338343
];
339-
$resourceModelMock = $this->getMock(
340-
'Magento\Eav\Model\ResourceModel\Entity\Attribute',
341-
['getAdditionalAttributeTable'],
342-
$arguments
344+
$helper = new ObjectManager($this);
345+
$resourceModel = $helper->getObject(\Magento\Eav\Model\ResourceModel\Entity\Attribute::class, $arguments);
346+
$helper->setBackwardCompatibleProperty(
347+
$resourceModel,
348+
'config',
349+
$configMock
343350
);
344-
345-
return [$connectionMock, $resourceModelMock];
351+
$helper->setBackwardCompatibleProperty(
352+
$resourceModel,
353+
'attributeCache',
354+
$attributeCacheMock
355+
);
356+
357+
return [$connectionMock, $resourceModel];
346358
}
347359

348360
/**

0 commit comments

Comments
 (0)