Beispiel #1
0
 public function testAdvancedSearch()
 {
     $searchResults = ['one', 'two', 'three'];
     $this->engine->expects($this->any())->method('search')->will($this->returnCallback(function (Query $query) use($searchResults) {
         return new Result($query, $searchResults, count($searchResults));
     }));
     $sourceQuery = 'from test_product' . ' where (name ~ "test string" and integer count > 10 and (decimal price = 10 or integer qty in (2, 5)))' . ' order_by name offset 10 max_results 5';
     $expectedQuery = 'select from test_product where ((integer qty in (2, 5) or decimal price = 10) ' . 'and integer count > 10 and text name ~ "test string") order by name ASC limit 5 offset 10';
     $result = $this->indexService->advancedSearch($sourceQuery);
     $actualQuery = $result->getQuery()->getStringQuery();
     $this->assertEquals($searchResults, $result->getElements());
     $this->assertEquals(count($searchResults), $result->getRecordsCount());
     $this->assertEquals($expectedQuery, $actualQuery);
 }
Beispiel #2
0
 public function testAdvancedSearch()
 {
     $searchResults = array('one', 'two', 'three');
     $this->engine->expects($this->any())->method('search')->will($this->returnCallback(function (Query $query) use($searchResults) {
         return new Result($query, $searchResults, count($searchResults));
     }));
     $sourceQuery = 'from (test_product, test_category)' . ' where name ~ "test string" and integer count = 10 and decimal price in (10, 12, 15)' . ' order_by name offset 10 max_results 5';
     $expectedQuery = 'select from test_product' . ' where and((text)name ~ test string) and((integer)count = 10) and((decimal)price in (10, 12, 15))' . ' order by name asc limit 5 offset 10';
     $result = $this->indexService->advancedSearch($sourceQuery);
     $actualQuery = $this->combineQueryString($result->getQuery());
     $this->assertEquals($searchResults, $result->getElements());
     $this->assertEquals(count($searchResults), $result->getRecordsCount());
     $this->assertEquals($expectedQuery, $actualQuery);
 }