Skip to content

Commit

Permalink
Removed sending of other and include options for facet ranges if they…
Browse files Browse the repository at this point in the history
… are not set
shieldo committed Apr 3, 2012
1 parent 72ffa05 commit 28fd082
Showing 2 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -175,14 +175,18 @@ public function addFacetRange($request, $facet)
$request->addParam("f.$field.facet.range.gap", $facet->getGap());
$request->addParam("f.$field.facet.range.hardend", $facet->getHardend());

$other = explode(',', $facet->getOther());
foreach ($other AS $otherValue) {
$request->addParam("f.$field.facet.range.other", trim($otherValue));
if (null !== $facet->getOther()) {
$other = explode(',', $facet->getOther());
foreach ($other AS $otherValue) {
$request->addParam("f.$field.facet.range.other", trim($otherValue));
}
}

$include = explode(',', $facet->getInclude());
foreach ($include AS $includeValue) {
$request->addParam("f.$field.facet.range.include", trim($includeValue));
if (null !== $facet->getOther()) {
$include = explode(',', $facet->getInclude());
foreach ($include AS $includeValue) {
$request->addParam("f.$field.facet.range.include", trim($includeValue));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -111,6 +111,31 @@ public function testBuildWithRangeFacet()
);
}

public function testBuildWithRangeFacetExcludingOptionalParams()
{
$this->_component->addFacet(new Solarium_Query_Select_Component_Facet_Range(
array(
'key' => 'f1',
'field' => 'price',
'start' => '1',
'end' => 100,
'gap' => 10,
)
));

$request = $this->_builder->buildComponent($this->_component, $this->_request);

$this->assertEquals(
null,
$request->getRawData()
);

$this->assertEquals(
'?facet=true&facet.range={!key=f1}price&f.price.facet.range.start=1&f.price.facet.range.end=100&f.price.facet.range.gap=10',
urldecode($request->getUri())
);
}

public function testBuildWithFacetsAndGlobalFacetSettings()
{
$this->_component->setMissing(true);

0 comments on commit 28fd082

Please sign in to comment.