/** * @return \Magento\Framework\DB\QueryInterface * @throws \Magento\Framework\Exception\LocalizedException */ public function create() { $mapper = $this->criteria->getMapperInterfaceName(); $mapperInstance = $this->mapperFactory->create($mapper); $select = $mapperInstance->map($this->criteria); $query = $this->queryFactory->create('Magento\\Framework\\DB\\Query', ['select' => $select, 'criteria' => $this->criteria, 'resource' => $this->resource]); return $query; }
/** * Run test mapCriteriaList method * * @return void */ public function testMapCriteriaList() { $criteriaMock = $this->getMockForAbstractClass('Magento\\Framework\\Api\\CriteriaInterface', [], '', false, true, true, ['getMapperInterfaceName']); $mapperInstanceMock = $this->getMockForAbstractClass('Magento\\Framework\\DB\\MapperInterface', [], '', false, true, true, ['map']); $criteriaMock->expects($this->any())->method('getMapperInterfaceName')->will($this->returnValue('mapper-name')); $this->mapperFactoryMock->expects($this->exactly(4))->method('create')->with('mapper-name', ['select' => $this->selectMock])->will($this->returnValue($mapperInstanceMock)); $mapperInstanceMock->expects($this->exactly(4))->method('map')->will($this->returnValue($this->selectMock)); $this->geneticMapper->mapCriteriaList(array_fill(0, 4, $criteriaMock)); }