8
8
9
9
namespace Magento \Eav \Test \Unit \Model \ResourceModel \Entity ;
10
10
11
+ use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
12
+
11
13
class AttributeTest extends \PHPUnit_Framework_TestCase
12
14
{
13
15
/**
@@ -22,7 +24,6 @@ class AttributeTest extends \PHPUnit_Framework_TestCase
22
24
23
25
protected function setUp ()
24
26
{
25
- $ this ->markTestSkipped ();
26
27
$ this ->contextMock = $ this ->getMock (
27
28
'\Magento\Framework\Model\Context ' ,
28
29
['getCacheManager ' , 'getEventDispatcher ' , 'getLogger ' , 'getAppState ' , 'getActionValidator ' ],
@@ -41,8 +42,8 @@ protected function setUp()
41
42
public function testSaveOptionSystemAttribute ()
42
43
{
43
44
/** @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 ();
46
47
47
48
$ attributeData = [
48
49
'attribute_id ' => '123 ' ,
@@ -103,7 +104,7 @@ public function testSaveOptionSystemAttribute()
103
104
);
104
105
$ connectionMock ->expects ($ this ->never ())->method ('delete ' );
105
106
106
- $ resourceModelMock ->save ($ model );
107
+ $ resourceModel ->save ($ model );
107
108
}
108
109
109
110
/**
@@ -112,8 +113,8 @@ public function testSaveOptionSystemAttribute()
112
113
public function testSaveOptionNewUserDefinedAttribute ()
113
114
{
114
115
/** @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 ();
117
118
118
119
$ attributeData = [
119
120
'entity_type_id ' => 4 ,
@@ -198,7 +199,7 @@ public function testSaveOptionNewUserDefinedAttribute()
198
199
)
199
200
);
200
201
201
- $ resourceModelMock ->save ($ model );
202
+ $ resourceModel ->save ($ model );
202
203
}
203
204
204
205
/**
@@ -207,8 +208,8 @@ public function testSaveOptionNewUserDefinedAttribute()
207
208
public function testSaveOptionNoValue ()
208
209
{
209
210
/** @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 ();
212
213
213
214
$ objectManagerHelper = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
214
215
/** @var $model \Magento\Framework\Model\AbstractModel */
@@ -221,7 +222,7 @@ public function testSaveOptionNoValue()
221
222
$ connectionMock ->expects ($ this ->never ())->method ('delete ' );
222
223
$ connectionMock ->expects ($ this ->never ())->method ('update ' );
223
224
224
- $ resourceModelMock ->save ($ model );
225
+ $ resourceModel ->save ($ model );
225
226
}
226
227
227
228
/**
@@ -331,18 +332,29 @@ protected function _prepareResourceModel()
331
332
$ contextMock ->expects ($ this ->once ())->method ('getResources ' )->willReturn ($ resource );
332
333
$ contextMock ->expects ($ this ->once ())->method ('getObjectRelationProcessor ' )->willReturn ($ relationProcessorMock );
333
334
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 ();
334
339
$ arguments = [
335
340
'context ' => $ contextMock ,
336
341
'storeManager ' => $ storeManager ,
337
342
'eavEntityType ' => $ eavEntityType ,
338
343
];
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
343
350
);
344
-
345
- return [$ connectionMock , $ resourceModelMock ];
351
+ $ helper ->setBackwardCompatibleProperty (
352
+ $ resourceModel ,
353
+ 'attributeCache ' ,
354
+ $ attributeCacheMock
355
+ );
356
+
357
+ return [$ connectionMock , $ resourceModel ];
346
358
}
347
359
348
360
/**
0 commit comments