protected function SearchApiDbTest::regressionTests2 in Search API Database Search 7
Executes regression tests which are unpractical to run in between.
1 call to SearchApiDbTest::regressionTests2()
File
- ./
search_api_db.test, line 940
Class
- SearchApiDbTest
- Class for testing index and search capabilities using the Database search module.
Code
protected function regressionTests2() {
// Regression test for #1916474.
$index = search_api_index_load($this->index_id, TRUE);
$index->options['fields']['prices']['type'] = 'list<decimal>';
$success = $index
->save();
$this
->assertTrue($success, 'The index field settings were successfully changed.');
// Reset the internal cache so the new values will be available.
search_api_server_load($this->server_id, TRUE);
search_api_index_load($this->index_id, TRUE);
$this
->indexItems();
$this
->drupalGet('search_api_test/insert');
$mb_string = 'äöüßáŧæøðđŋħĸµäöüßáŧæøðđŋħĸµ';
$this
->insertItem(array(
'id' => 6,
'body' => $mb_string,
'prices' => '3.5,3.25,3.75,3.5',
));
$query = $this
->buildSearch(NULL, array(
'prices,3.25',
));
$results = $query
->execute();
$this
->assertEqual($results['result count'], 1, 'Filter on decimal field returned correct number of results.');
$this
->assertEqual(array_keys($results['results']), array(
6,
), 'Filter on decimal field returned correct result.');
$this
->assertEqual($results['warnings'], array(), 'No warnings were displayed.');
$query = $this
->buildSearch(NULL, array(
'prices,3.5',
));
$results = $query
->execute();
$this
->assertEqual($results['result count'], 1, 'Filter on decimal field returned correct number of results.');
$this
->assertEqual(array_keys($results['results']), array(
6,
), 'Filter on decimal field returned correct result.');
$this
->assertEqual($results['warnings'], array(), 'No warnings were displayed.');
// Regression test for #2616804.
// The word has 28 Unicode characters but 56 bytes. Verify that it was still
// indexed correctly.
$query = $this
->buildSearch($mb_string);
$results = $query
->execute();
$this
->assertEqual($results['result count'], 1, 'Search for word with 28 multi-byte characters returned correct number of results.');
$this
->assertEqual(array_keys($results['results']), array(
6,
), 'Search for word with 28 multi-byte characters returned correct result.');
$this
->assertEqual($results['ignored'], array(), 'No keys were ignored.');
$this
->assertEqual($results['warnings'], array(), 'No warnings were displayed.');
$query = $this
->buildSearch($mb_string . 'ä');
$results = $query
->execute();
$this
->assertEqual($results['result count'], 0, 'Search for unknown word with 29 multi-byte characters returned no results.');
$this
->assertEqual($results['ignored'], array(), 'No keys were ignored.');
$this
->assertEqual($results['warnings'], array(), 'No warnings were displayed.');
// Regression tests for #2745655.
$results = $this
->buildSearch()
->condition('title', NULL)
->execute();
// "Minimum chars" is 3 at this point, so all items with no longer words in
// their titles will be returned, too.
$this
->assertEqual($results['result count'], 4, 'Search for items without title returned correct number of results.');
$this
->assertEqual(array_keys($results['results']), array(
3,
4,
5,
6,
), 'Search for items without title returned correct result.');
$this
->assertEqual($results['ignored'], array(), 'No keys were ignored.');
$this
->assertEqual($results['warnings'], array(), 'No warnings were displayed.');
$results = $this
->buildSearch()
->condition('title', NULL, '<>')
->execute();
$this
->assertEqual($results['result count'], 2, 'Search for items with title returned correct number of results.');
$this
->assertEqual(array_keys($results['results']), array(
1,
2,
), 'Search for items with title returned correct result.');
$this
->assertEqual($results['ignored'], array(), 'No keys were ignored.');
$this
->assertEqual($results['warnings'], array(), 'No warnings were displayed.');
// Regression tests for #2795245.
// Make sure changing a field's type from something else to "text" works
// correctly.
$index->options['fields']['type']['type'] = 'text';
$index
->save();
search_api_index_items($index);
$results = $this
->buildSearch()
->condition('type', NULL)
->execute();
$this
->assertEqual($results['result count'], 2, 'Search for items without type returned correct number of results.');
$this
->assertEqual(array_keys($results['results']), array(
3,
6,
), 'Search for items without type returned correct result.');
$this
->assertEqual($results['ignored'], array(), 'No keys were ignored.');
$this
->assertEqual($results['warnings'], array(), 'No warnings were displayed.');
$results = $this
->buildSearch()
->condition('type', NULL, '<>')
->execute();
$this
->assertEqual($results['result count'], 4, 'Search for items with type returned correct number of results.');
$this
->assertEqual(array_keys($results['results']), array(
1,
2,
4,
5,
), 'Search for items with type returned correct result.');
$this
->assertEqual($results['ignored'], array(), 'No keys were ignored.');
$this
->assertEqual($results['warnings'], array(), 'No warnings were displayed.');
}