41 $this->attrSetRepositoryMock = $this->createMock(\
Magento\Eav\Api\AttributeSetRepositoryInterface::class);
42 $this->searchCriteriaBuilderMock = $this->createMock(\
Magento\Framework\Api\SearchCriteriaBuilder::class);
43 $this->filterBuilderMock = $this->createMock(\
Magento\Framework\Api\FilterBuilder::class);
44 $this->eavConfig = $this->createMock(\
Magento\Eav\Model\Config::class);
46 $this->model = new \Magento\Catalog\Model\Product\Attribute\SetRepository(
47 $this->attrSetRepositoryMock,
48 $this->searchCriteriaBuilderMock,
49 $this->filterBuilderMock,
56 $attributeSetMock = $this->createMock(\
Magento\Eav\Api\Data\AttributeSetInterface::class);
59 $this->attrSetRepositoryMock->expects($this->once())
61 ->with($attributeSetMock)
62 ->willReturn($attributeSetMock);
63 $this->assertEquals($attributeSetMock, $this->model->save($attributeSetMock));
72 $attributeSetMock = $this->createMock(\
Magento\Eav\Api\Data\AttributeSetInterface::class);
74 $this->attrSetRepositoryMock->expects($this->never())->method(
'save');
75 $this->model->save($attributeSetMock);
81 $attributeSetMock = $this->createMock(\
Magento\Eav\Api\Data\AttributeSetInterface::class);
84 $this->attrSetRepositoryMock->expects($this->once())
87 ->willReturn($attributeSetMock);
88 $this->assertEquals($attributeSetMock, $this->model->get(
$attributeSetId));
98 $attributeSetMock = $this->createMock(\
Magento\Eav\Api\Data\AttributeSetInterface::class);
101 $this->attrSetRepositoryMock->expects($this->once())
104 ->willReturn($attributeSetMock);
105 $this->assertEquals($attributeSetMock, $this->model->get(
$attributeSetId));
110 $attributeSetMock = $this->createMock(\
Magento\Eav\Api\Data\AttributeSetInterface::class);
112 $this->attrSetRepositoryMock->expects($this->once())
114 ->with($attributeSetMock)
116 $this->assertTrue($this->model->delete($attributeSetMock));
125 $attributeSetMock = $this->createMock(\
Magento\Eav\Api\Data\AttributeSetInterface::class);
127 $this->attrSetRepositoryMock->expects($this->never())
129 $this->assertTrue($this->model->delete($attributeSetMock));
135 $attributeSetMock = $this->createMock(\
Magento\Eav\Api\Data\AttributeSetInterface::class);
138 $this->attrSetRepositoryMock->expects($this->once())
141 ->willReturn($attributeSetMock);
143 $this->attrSetRepositoryMock->expects($this->once())
144 ->method(
'deleteById')
152 $searchResultMock = $this->createMock(\
Magento\Eav\Api\Data\AttributeSetSearchResultsInterface::class);
154 $searchCriteriaMock = $this->createMock(\
Magento\Framework\Api\SearchCriteriaInterface::class);
155 $searchCriteriaMock->expects($this->once())->method(
'getCurrentPage')->willReturn(1);
156 $searchCriteriaMock->expects($this->once())->method(
'getPageSize')->willReturn(2);
158 $filterMock = $this->createMock(\
Magento\Framework\Api\Filter::class);
160 $this->filterBuilderMock->expects($this->once())
162 ->with(
'entity_type_code')
164 $this->filterBuilderMock->expects($this->once())
168 $this->filterBuilderMock->expects($this->once())
169 ->method(
'setConditionType')
172 $this->filterBuilderMock->expects($this->once())->method(
'create')->willReturn($filterMock);
174 $this->searchCriteriaBuilderMock->expects($this->once())
175 ->method(
'addFilters')
176 ->with([$filterMock])
178 $this->searchCriteriaBuilderMock->expects($this->once())
179 ->method(
'setCurrentPage')
182 $this->searchCriteriaBuilderMock->expects($this->once())
183 ->method(
'setPageSize')
186 $this->searchCriteriaBuilderMock->expects($this->once())
188 ->willReturn($this->createMock(\
Magento\Framework\Api\SearchCriteriaInterface::class));
190 $this->attrSetRepositoryMock->expects($this->once())
192 ->with($searchCriteriaMock)
193 ->willReturn($searchResultMock);
194 $this->assertEquals($searchResultMock, $this->model->getList($searchCriteriaMock));
204 \PHPUnit_Framework_MockObject_MockObject $attributeSetMock,
207 $typeMock = $this->createMock(\
Magento\Eav\Model\Entity\Type::class);
208 $typeMock->expects($this->once())->method(
'getId')->willReturn(4);
209 $this->eavConfig->expects($this->once())
210 ->method(
'getEntityType')
212 ->willReturn($typeMock);
213 $attributeSetMock->expects($this->once())->method(
'getEntityTypeId')->willReturn($setEntityTypeId);
setMockForValidation(\PHPUnit_Framework_MockObject_MockObject $attributeSetMock, $setEntityTypeId)
testGetNonProductAttributeSet()
testSaveNonProductAttributeSet()
testDeleteNonProductAttributeSet()
$searchCriteriaBuilderMock