/** * {@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; }
public function testGetMaxQueryLength() { $return = 'some_value'; $this->scopeConfigMock->expects($this->once())->method('getValue')->with(\Magento\Search\Model\Query::XML_PATH_MAX_QUERY_LENGTH, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null)->will($this->returnValue($return)); $this->assertEquals($return, $this->model->getMaxQueryLength()); }