Skip to content

Commit aabed9c

Browse files
MAGETWO-92693: Some improvements on product create|edit page in admin area
1 parent f2a82b1 commit aabed9c

File tree

1 file changed

+23
-2
lines changed
  • app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier

1 file changed

+23
-2
lines changed

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Catalog\Model\ResourceModel\Eav\Attribute as EavAttribute;
2121
use Magento\Eav\Model\Entity\Type as EntityType;
2222
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection as AttributeCollection;
23+
use Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory as AttributeCollectionFactory;
2324
use Magento\Ui\DataProvider\Mapper\FormElement as FormElementMapper;
2425
use Magento\Ui\DataProvider\Mapper\MetaProperties as MetaPropertiesMapper;
2526
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -88,6 +89,11 @@ class EavTest extends AbstractModifierTest
8889
*/
8990
private $entityTypeMock;
9091

92+
/**
93+
* @var AttributeCollectionFactory|\PHPUnit_Framework_MockObject_MockObject
94+
*/
95+
private $attributeCollectionFactoryMock;
96+
9197
/**
9298
* @var AttributeCollection|\PHPUnit_Framework_MockObject_MockObject
9399
*/
@@ -226,6 +232,10 @@ protected function setUp()
226232
$this->entityTypeMock = $this->getMockBuilder(EntityType::class)
227233
->disableOriginalConstructor()
228234
->getMock();
235+
$this->attributeCollectionFactoryMock = $this->getMockBuilder(AttributeCollectionFactory::class)
236+
->disableOriginalConstructor()
237+
->setMethods(['create'])
238+
->getMock();
229239
$this->attributeCollectionMock = $this->getMockBuilder(AttributeCollection::class)
230240
->disableOriginalConstructor()
231241
->getMock();
@@ -332,7 +342,7 @@ protected function setUp()
332342
$this->eavAttributeMock->expects($this->any())
333343
->method('load')
334344
->willReturnSelf();
335-
345+
336346
$this->eav =$this->getModel();
337347
$this->objectManager->setBackwardCompatibleProperty(
338348
$this->eav,
@@ -361,7 +371,8 @@ protected function createModel()
361371
'attributeRepository' => $this->attributeRepositoryMock,
362372
'arrayManager' => $this->arrayManagerMock,
363373
'eavAttributeFactory' => $this->eavAttributeFactoryMock,
364-
'_eventManager' => $this->eventManagerMock
374+
'_eventManager' => $this->eventManagerMock,
375+
'attributeCollectionFactory' => $this->attributeCollectionFactoryMock
365376
]);
366377
}
367378

@@ -375,6 +386,16 @@ public function testModifyData()
375386
]
376387
];
377388

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+
378399
$this->locatorMock->expects($this->any())
379400
->method('getProduct')
380401
->willReturn($this->productMock);

0 commit comments

Comments
 (0)