objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->fieldMapperEntity = $this->getMockBuilder( \Magento\Elasticsearch\Model\Adapter\FieldMapperInterface::class ) ->disableOriginalConstructor() ->getMock(); $this->fieldMappers = [ 'product' => 'productFieldMapper', ]; $objectManager = new ObjectManagerHelper($this); $this->model = $objectManager->getObject( \Magento\Elasticsearch\Model\Adapter\FieldMapper\FieldMapperResolver::class, [ 'objectManager' => $this->objectManagerMock, 'fieldMappers' => $this->fieldMappers ] ); } /** * Test getFieldName() with Exception * @return void * @expectedException \Exception */ public function testGetFieldNameEmpty() { $this->model->getFieldName('attribute', ['entityType' => '']); } /** * Test getFieldName() with Exception * @return void * @expectedException \LogicException */ public function testGetFieldNameWrongType() { $this->model->getFieldName('attribute', ['entityType' => 'error']); } /** * Test getFieldName() with Exception * @return void * @expectedException \InvalidArgumentException */ public function testGetFieldNameFailure() { $this->objectManagerMock->expects($this->once()) ->method('create') ->willReturn(false); $this->model->getFieldName('attribute', ['entityType' => 'product']); } /** * Test getFieldName() method * @return void */ public function testGetFieldName() { $this->objectManagerMock->expects($this->once()) ->method('create') ->willReturn($this->fieldMapperEntity); $this->model->getFieldName('attribute', []); } /** * Test getAllAttributesTypes() method * @return void */ public function testGetAllAttributesTypes() { $this->objectManagerMock->expects($this->once()) ->method('create') ->willReturn($this->fieldMapperEntity); $this->model->getAllAttributesTypes([]); } }