/**
  * @return \Magento\Framework\Search\Response\QueryResponse
  */
 private function executeQuery()
 {
     /** @var \Magento\Framework\Search\Response\QueryResponse $queryRequest */
     $queryRequest = $this->requestBuilder->create();
     $queryResponse = $this->adapter->query($queryRequest);
     return $queryResponse;
 }
Example #2
0
 public function testQuery()
 {
     $selectResult = ['documents' => [['product_id' => 1, 'sku' => 'Product']], 'aggregations' => ['aggregation_name' => ['aggregation1' => [1, 3], 'aggregation2' => [2, 4]]]];
     $this->connectionAdapter->expects($this->at(0))->method('fetchAssoc')->will($this->returnValue($selectResult['documents']));
     $this->mapper->expects($this->once())->method('buildQuery')->with($this->request)->will($this->returnValue($this->select));
     $this->responseFactory->expects($this->once())->method('create')->with($selectResult)->will($this->returnArgument(0));
     $this->aggregatioBuilder->expects($this->once())->method('build')->willReturn($selectResult['aggregations']);
     $response = $this->adapter->query($this->request);
     $this->assertEquals($selectResult, $response);
 }
 private function executeQuery($requestName, $bindValues)
 {
     $this->reindexAll();
     /** @var \Magento\Framework\Search\Request $queryRequest */
     $queryRequest = $this->requestFactory->create($requestName, $bindValues);
     $queryResponse = $this->adapter->query($queryRequest);
     return $queryResponse;
 }
Example #4
0
 public function testQuery()
 {
     $selectResult = ['documents' => [['product_id' => 1, 'sku' => 'Product']], 'aggregations' => ['aggregation_name' => ['aggregation1' => [1, 3], 'aggregation2' => [2, 4]]]];
     $select = $this->getMockBuilder('Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->getMock();
     $this->connectionAdapter->expects($this->once())->method('select')->willReturn($select);
     $table = $this->getMockBuilder('Magento\\Framework\\DB\\Ddl\\Table')->disableOriginalConstructor()->getMock();
     $this->temporaryStorage->expects($this->any())->method('storeDocumentsFromSelect')->willReturn($table);
     $this->connectionAdapter->expects($this->any())->method('fetchAssoc')->will($this->returnValue($selectResult['documents']));
     $this->mapper->expects($this->once())->method('buildQuery')->with($this->request)->will($this->returnValue($this->select));
     $this->responseFactory->expects($this->once())->method('create')->with($selectResult)->will($this->returnArgument(0));
     $this->aggregatioBuilder->expects($this->once())->method('build')->willReturn($selectResult['aggregations']);
     $response = $this->adapter->query($this->request);
     $this->assertEquals($selectResult, $response);
 }