/** * @return void */ public function testGetList() { $entityTypeCode = 'entity_type_code_value'; $entityTypeId = 41; $searchCriteriaMock = $this->getMock('\\Magento\\Framework\\Api\\SearchCriteriaInterface'); $filterGroupMock = $this->getMock('\\Magento\\Framework\\Api\\Search\\FilterGroup', [], [], '', false); $searchCriteriaMock->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroupMock]); $filterMock = $this->getMock('\\Magento\\Framework\\Api\\Filter', [], [], '', false); $filterGroupMock->expects($this->once())->method('getFilters')->willReturn([$filterMock]); $filterMock->expects($this->once())->method('getField')->willReturn('entity_type_code'); $filterMock->expects($this->once())->method('getValue')->willReturn($entityTypeCode); $collectionMock = $this->getMock('\\Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter', 'setCurPage', 'setPageSize', 'getItems', 'getSize'], [], '', false); $entityTypeMock = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Type', [], [], '', false); $entityTypeMock->expects($this->once())->method('getId')->willReturn($entityTypeId); $this->eavConfigMock->expects($this->once())->method('getEntityType')->with($entityTypeCode)->willReturn($entityTypeMock); $this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($collectionMock); $collectionMock->expects($this->once())->method('setEntityTypeFilter')->with($entityTypeId)->willReturnSelf(); $searchCriteriaMock->expects($this->once())->method('getCurrentPage')->willReturn(1); $searchCriteriaMock->expects($this->once())->method('getPageSize')->willReturn(10); $collectionMock->expects($this->once())->method('setCurPage')->with(1)->willReturnSelf(); $collectionMock->expects($this->once())->method('setPageSize')->with(10)->willReturnSelf(); $attributeSetMock = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Attribute\\Set', [], [], '', false); $collectionMock->expects($this->once())->method('getItems')->willReturn([$attributeSetMock]); $collectionMock->expects($this->once())->method('getSize')->willReturn(1); $resultMock = $this->getMock('\\Magento\\Eav\\Api\\Data\\AttributeSetSearchResultsInterface', [], [], '', false); $resultMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock)->willReturnSelf(); $resultMock->expects($this->once())->method('setItems')->with([$attributeSetMock])->willReturnSelf(); $resultMock->expects($this->once())->method('setTotalCount')->with(1)->willReturnSelf(); $this->resultFactoryMock->expects($this->once())->method('create')->willReturn($resultMock); $this->model->getList($searchCriteriaMock); }
/** * @return void */ public function testGetListIfEntityTypeCodeIsNull() { $searchCriteriaMock = $this->getMock('\\Magento\\Framework\\Api\\SearchCriteriaInterface'); $searchCriteriaMock->expects($this->once())->method('getFilterGroups')->willReturn([]); $collectionMock = $this->getMock('\\Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Set\\Collection', ['setCurPage', 'setPageSize', 'getItems', 'getSize'], [], '', false); $this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($collectionMock); $searchCriteriaMock->expects($this->once())->method('getCurrentPage')->willReturn(1); $searchCriteriaMock->expects($this->once())->method('getPageSize')->willReturn(10); $collectionMock->expects($this->once())->method('setCurPage')->with(1)->willReturnSelf(); $collectionMock->expects($this->once())->method('setPageSize')->with(10)->willReturnSelf(); $attributeSetMock = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Attribute\\Set', [], [], '', false); $collectionMock->expects($this->once())->method('getItems')->willReturn([$attributeSetMock]); $collectionMock->expects($this->once())->method('getSize')->willReturn(1); $resultMock = $this->getMock('\\Magento\\Eav\\Api\\Data\\AttributeSetSearchResultsInterface', [], [], '', false); $resultMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock)->willReturnSelf(); $resultMock->expects($this->once())->method('setItems')->with([$attributeSetMock])->willReturnSelf(); $resultMock->expects($this->once())->method('setTotalCount')->with(1)->willReturnSelf(); $this->resultFactoryMock->expects($this->once())->method('create')->willReturn($resultMock); $this->model->getList($searchCriteriaMock); }