Skip to content

Commit

Permalink
Merge pull request solariumphp#431 from vlastv/patch-1
Browse files Browse the repository at this point in the history
Allows key and exclude for interval facet
  • Loading branch information
basdenooijer authored Oct 14, 2016
2 parents 6009b94 + 2c1b0c1 commit 7511302
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,8 @@ public function addFacetInterval($request, $facet)
$request->addParam(
'facet.interval',
$this->renderLocalParams(
$field
// key & ex not supported for interval
//,array('key' => $facet->getKey(), 'ex' => $facet->getExcludes())
$field,
array('key' => $facet->getKey(), 'ex' => $facet->getExcludes())
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
Expand Down Expand Up @@ -69,7 +69,7 @@ public function testBuildEmptyFacetSet()
{
$request = $this->builder->buildComponent($this->component, $this->request);

$this->assertEquals(
static::assertEquals(
array(),
$request->getParams()
);
Expand All @@ -86,12 +86,12 @@ public function testBuildWithFacets()

$request = $this->builder->buildComponent($this->component, $this->request);

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

$this->assertEquals(
static::assertEquals(
'?facet=true&facet.field={!key=f1}owner&facet.query={!key=f2}category:23&facet.query={!key=f4}category:40',
urldecode($request->getUri())
);
Expand All @@ -114,12 +114,12 @@ public function testBuildWithRangeFacet()

$request = $this->builder->buildComponent($this->component, $this->request);

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

$this->assertEquals(
static::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&f.price.facet.mincount=123&f.price.facet.range.other=all&f.price.facet.range.include=outer',
urldecode($request->getUri())
);
Expand All @@ -141,12 +141,12 @@ public function testBuildWithRangeFacetExcludingOptionalParams()

$request = $this->builder->buildComponent($this->component, $this->request);

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

$this->assertEquals(
static::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())
Expand All @@ -165,12 +165,12 @@ public function testBuildWithFacetsAndGlobalFacetSettings()

$request = $this->builder->buildComponent($this->component, $this->request);

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

$this->assertEquals(
static::assertEquals(
'?facet=true&facet.missing=true&facet.limit=10&facet.field={!key=f1}owner&facet.query={!key=f2}category:23'.
'&facet.query={!key=f4}category:40',
urldecode($request->getUri())
Expand Down Expand Up @@ -199,12 +199,12 @@ public function testBuildWithPivotFacet()

$request = $this->builder->buildComponent($this->component, $this->request);

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

$this->assertEquals(
static::assertEquals(
'?facet=true&facet.pivot={!key=f1 ex=owner}cat,inStock&facet.pivot.mincount=123',
urldecode($request->getUri())
);
Expand All @@ -223,12 +223,12 @@ public function testBuildWithPivotStatFacet()

$request = $this->builder->buildComponent($this->component, $this->request);

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

$this->assertEquals(
static::assertEquals(
'?facet=true&facet.pivot={!stats=piv1}cat,inStock',
urldecode($request->getUri())
);
Expand All @@ -250,18 +250,18 @@ public function testBuildWithContainsSettings()

$request = $this->builder->buildComponent($this->component, $this->request);

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

$this->assertEquals(
static::assertEquals(
'?facet=true&facet.contains=bar&facet.contains.ignoreCase=false&facet.field={!key=f1}owner&f.owner.facet.contains=foo&f.owner.facet.contains.ignoreCase=true',
urldecode($request->getUri())
);
}

public function testBuildeWithIntervalFacet()
public function testBuildWithIntervalFacet()
{
$facet = new FacetInterval(
array(
Expand All @@ -275,13 +275,13 @@ public function testBuildeWithIntervalFacet()

$request = $this->builder->buildComponent($this->component, $this->request);

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

$this->assertEquals(
'?facet=true&f..facet.interval.set=int1&f..facet.interval.set={!key="one"}int2',
static::assertEquals(
'?facet=true&facet.interval={!key=f1}&f..facet.interval.set=int1&f..facet.interval.set={!key="one"}int2',
urldecode($request->getUri())
);
}
Expand Down

0 comments on commit 7511302

Please sign in to comment.