Commit 5bec101d authored by borisson_'s avatar borisson_ Committed by borisson_

Issue #2910828 by borisson_, Xano, dawehner, bircher, ekes, drunken monkey:...

Issue #2910828 by borisson_, Xano, dawehner, bircher, ekes, drunken monkey: Some search results can be out of range when using facets_range_widget
parent 32c74e52
......@@ -43,6 +43,7 @@ class SliderProcessor extends ProcessorPluginBase implements PostQueryProcessorI
return $a['value'] < $b['value'] ? -1 : 1;
});
$step = $config['step'];
if ($config['min_type'] == 'fixed') {
$min = $config['min_value'];
$max = $config['max_value'];
......@@ -50,9 +51,12 @@ class SliderProcessor extends ProcessorPluginBase implements PostQueryProcessorI
else {
$min = reset($simple_results)['value'];
$max = end($simple_results)['value'];
// If max is not divisible by step, we should add the remainder to max to
// make sure that we don't lose any possible values.
if ($max % $step !== 0) {
$max = $max + ($step - $max % $step);
}
}
$step = $config['step'];
// Creates an array of all results between min and max by the step from the
// configuration.
......
......@@ -121,6 +121,29 @@ class SliderProcessorTest extends UnitTestCase {
$this->assertEquals(200, $new_results[195]->getRawValue());
}
/**
* Adds a regression test for the out of range values.
*/
public function testOutOfRange() {
$widgetconfig = ['min_type' => 'foo', 'step' => 7];
$facet = new Facet([], 'facets_facet');
$facet->setWidget('raw', $widgetconfig);
$this->configureContainer($widgetconfig);
$result_lower = new Result($facet, 5, '5', 4);
$result_higher = new Result($facet, 15, '15', 4);
$facet->setResults([$result_lower, $result_higher]);
// Process the data.
$this->processor->postQuery($facet);
$new_results = $facet->getResults();
$this->assertCount(3, $new_results);
$this->assertEquals(5, $new_results[0]->getRawValue());
$this->assertEquals(12, $new_results[1]->getRawValue());
$this->assertEquals(19, $new_results[2]->getRawValue());
}
/**
* Tests the post query method with fixed min/max.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment