20
20
use Magento \Catalog \Model \ResourceModel \Eav \Attribute as EavAttribute ;
21
21
use Magento \Eav \Model \Entity \Type as EntityType ;
22
22
use Magento \Eav \Model \ResourceModel \Entity \Attribute \Collection as AttributeCollection ;
23
+ use Magento \Eav \Model \ResourceModel \Entity \Attribute \CollectionFactory as AttributeCollectionFactory ;
23
24
use Magento \Ui \DataProvider \Mapper \FormElement as FormElementMapper ;
24
25
use Magento \Ui \DataProvider \Mapper \MetaProperties as MetaPropertiesMapper ;
25
26
use Magento \Framework \Api \SearchCriteriaBuilder ;
@@ -88,6 +89,11 @@ class EavTest extends AbstractModifierTest
88
89
*/
89
90
private $ entityTypeMock ;
90
91
92
+ /**
93
+ * @var AttributeCollectionFactory|\PHPUnit_Framework_MockObject_MockObject
94
+ */
95
+ private $ attributeCollectionFactoryMock ;
96
+
91
97
/**
92
98
* @var AttributeCollection|\PHPUnit_Framework_MockObject_MockObject
93
99
*/
@@ -226,6 +232,10 @@ protected function setUp()
226
232
$ this ->entityTypeMock = $ this ->getMockBuilder (EntityType::class)
227
233
->disableOriginalConstructor ()
228
234
->getMock ();
235
+ $ this ->attributeCollectionFactoryMock = $ this ->getMockBuilder (AttributeCollectionFactory::class)
236
+ ->disableOriginalConstructor ()
237
+ ->setMethods (['create ' ])
238
+ ->getMock ();
229
239
$ this ->attributeCollectionMock = $ this ->getMockBuilder (AttributeCollection::class)
230
240
->disableOriginalConstructor ()
231
241
->getMock ();
@@ -332,7 +342,7 @@ protected function setUp()
332
342
$ this ->eavAttributeMock ->expects ($ this ->any ())
333
343
->method ('load ' )
334
344
->willReturnSelf ();
335
-
345
+
336
346
$ this ->eav =$ this ->getModel ();
337
347
$ this ->objectManager ->setBackwardCompatibleProperty (
338
348
$ this ->eav ,
@@ -361,7 +371,8 @@ protected function createModel()
361
371
'attributeRepository ' => $ this ->attributeRepositoryMock ,
362
372
'arrayManager ' => $ this ->arrayManagerMock ,
363
373
'eavAttributeFactory ' => $ this ->eavAttributeFactoryMock ,
364
- '_eventManager ' => $ this ->eventManagerMock
374
+ '_eventManager ' => $ this ->eventManagerMock ,
375
+ 'attributeCollectionFactory ' => $ this ->attributeCollectionFactoryMock
365
376
]);
366
377
}
367
378
@@ -375,6 +386,16 @@ public function testModifyData()
375
386
]
376
387
];
377
388
389
+ $ this ->attributeCollectionFactoryMock ->expects ($ this ->once ())
390
+ ->method ('create ' )
391
+ ->willReturn ($ this ->attributeCollectionMock );
392
+
393
+ $ this ->attributeCollectionMock ->expects ($ this ->any ())
394
+ ->method ('getItems ' )
395
+ ->willReturn ([
396
+ $ this ->eavAttributeMock
397
+ ]);
398
+
378
399
$ this ->locatorMock ->expects ($ this ->any ())
379
400
->method ('getProduct ' )
380
401
->willReturn ($ this ->productMock );
0 commit comments