protected function SearchApiDbTest::searchSuccessPartial in Search API Database Search 7
Tests whether partial searches work.
1 call to SearchApiDbTest::searchSuccessPartial()
File
- ./
search_api_db.test, line 505
Class
- SearchApiDbTest
- Class for testing index and search capabilities using the Database search module.
Code
protected function searchSuccessPartial() {
$results = $this
->buildSearch('foobaz')
->range(0, 1)
->execute();
$this
->assertEqual($results['result count'], 1, 'Partial search for »foobaz« returned correct number of results.');
$this
->assertEqual(array_keys($results['results']), array(
1,
), 'Partial search for »foobaz« returned correct result.');
$this
->assertEqual($results['ignored'], array(), 'No keys were ignored.');
$this
->assertEqual($results['warnings'], array(), 'No warnings were displayed.');
$results = $this
->buildSearch('foo')
->sort('search_api_relevance', 'DESC')
->sort('id', 'ASC')
->execute();
$this
->assertEqual($results['result count'], 5, 'Partial search for »foo« returned correct number of results.');
$this
->assertEqual(array_keys($results['results']), array(
1,
2,
4,
3,
5,
), 'Partial search for »foo« returned correct result.');
$this
->assertEqual($results['ignored'], array(), 'No keys were ignored.');
$this
->assertEqual($results['warnings'], array(), 'No warnings were displayed.');
$results = $this
->buildSearch('foo', array(
'type,item',
))
->sort('id', 'DESC')
->execute();
$this
->assertEqual($results['result count'], 2, 'Partial search for »foo« of type »item« returned correct number of results.');
$this
->assertEqual(array_keys($results['results']), array(
2,
1,
), 'Partial search for »foo« of type »item« returned correct result.');
$this
->assertEqual($results['ignored'], array(), 'No keys were ignored.');
$this
->assertEqual($results['warnings'], array(), 'No warnings were displayed.');
$query = $this
->buildSearch()
->sort('id');
$filter = $query
->createFilter('OR');
$filter
->condition('title', 'test');
$filter
->condition('body', 'test');
$query
->filter($filter);
$results = $query
->execute();
$this
->assertEqual($results['result count'], 4, 'Partial search with multi-field fulltext filter returned correct number of results.');
$this
->assertEqual(array_keys($results['results']), array(
1,
2,
3,
4,
), 'Partial search with multi-field fulltext filter returned correct result.');
$this
->assertEqual($results['ignored'], array(), 'No keys were ignored.');
$this
->assertEqual($results['warnings'], array(), 'No warnings were displayed.');
}