protected function BackendTestBase::regressionTest1916474 in Search API 8
Regression tests for correctly indexing multiple float/decimal fields.
See also
https://www.drupal.org/node/1916474
1 call to BackendTestBase::regressionTest1916474()
- BackendTestBase::regressionTests2 in tests/
src/ Kernel/ BackendTestBase.php - Executes regression tests which are unpractical to run in between.
File
- tests/
src/ Kernel/ BackendTestBase.php, line 936
Class
- BackendTestBase
- Provides a base class for backend tests.
Namespace
Drupal\Tests\search_api\KernelCode
protected function regressionTest1916474() {
$index = $this
->getIndex();
$this
->addField($index, 'prices', 'decimal');
$success = $index
->save();
$this
->assertNotEmpty($success, 'The index field settings were successfully changed.');
// Reset the static cache so the new values will be available.
$this
->resetEntityCache('server');
$this
->resetEntityCache();
$this
->addTestEntity(6, [
'prices' => [
'3.5',
'3.25',
'3.75',
'3.5',
],
'type' => 'item',
]);
$this
->indexItems($this->indexId);
$query = $this
->buildSearch(NULL, [
'prices,3.25',
]);
$results = $query
->execute();
$this
->assertResults([
6,
], $results, 'Filter on decimal field');
$query = $this
->buildSearch(NULL, [
'prices,3.5',
]);
$results = $query
->execute();
$this
->assertResults([
6,
], $results, 'Filter on decimal field');
// Use the "prices" field, since we've added it now, to also check for
// proper handling of (NOT) BETWEEN for multi-valued fields.
$query = $this
->buildSearch()
->addCondition('prices', [
3.6,
3.8,
], 'BETWEEN');
$results = $query
->execute();
$this
->assertResults([
6,
], $results, 'BETWEEN filter on multi-valued field');
$query = $this
->buildSearch()
->addCondition('prices', [
3.6,
3.8,
], 'NOT BETWEEN');
$results = $query
->execute();
$this
->assertResults([
1,
2,
3,
4,
5,
], $results, 'NOT BETWEEN filter on multi-valued field');
}