dataMapperFactoryMock = $this->getMockBuilder(DataMapperFactory::class) ->disableOriginalConstructor() ->getMock(); $this->dataMapperEntity = $this->getMockBuilder(BatchDataMapperInterface::class) ->disableOriginalConstructor() ->getMock(); $this->model = (new ObjectManagerHelper($this))->getObject( \Magento\Elasticsearch\Model\Adapter\BatchDataMapper\DataMapperResolver::class, [ 'dataMapperFactory' => $this->dataMapperFactoryMock ] ); } public function testMapWithDefaultEntityType() { $this->dataMapperEntity->expects($this->once())->method('map')->withAnyParameters(); $this->dataMapperFactoryMock->expects($this->once())->method('create') ->with('product') ->willReturn($this->dataMapperEntity); $this->model->map(['data'], 1, []); } public function testMapWithSpecifiedEntityType() { $this->dataMapperEntity->expects($this->once())->method('map')->withAnyParameters(); $this->dataMapperFactoryMock->expects($this->once())->method('create') ->with('specific-type') ->willReturn($this->dataMapperEntity); $this->model->map(['data'], 1, ['entityType' => 'specific-type']); } }