Example #1
0
 /**
  * {@inheritdoc}
  */
 public function get()
 {
     if (!$this->query) {
         $maxQueryLength = $this->queryHelper->getMaxQueryLength();
         $minQueryLength = $this->queryHelper->getMinQueryLength();
         $rawQueryText = $this->getRawQueryText();
         $preparedQueryText = $this->getPreparedQueryText($rawQueryText, $maxQueryLength);
         $query = $this->create()->loadByQueryText($preparedQueryText);
         if (!$query->getId()) {
             $query->setQueryText($preparedQueryText);
         }
         $query->setIsQueryTextExceeded($this->isQueryTooLong($rawQueryText, $maxQueryLength));
         $query->setIsQueryTextShort($this->isQueryTooShort($rawQueryText, $minQueryLength));
         $this->query = $query;
     }
     return $this->query;
 }
Example #2
0
 public function testGetMinQueryLength()
 {
     $return = 'some_value';
     $this->scopeConfigMock->expects($this->once())->method('getValue')->with(\Magento\Search\Model\Query::XML_PATH_MIN_QUERY_LENGTH, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null)->will($this->returnValue($return));
     $this->assertEquals($return, $this->model->getMinQueryLength());
 }