Commit 33c31ccd authored by Bas de Nooijer's avatar Bas de Nooijer

Merge commit '3fc0b564' into develop

Conflicts:
	library/Solarium/QueryType/Select/ResponseParser/Component/FacetSet.php
	library/Solarium/QueryType/Select/Result/Facet/Range.php
	tests/Solarium/Tests/QueryType/Select/Result/Facet/RangeTest.php
parents c2b89475 3fc0b564
...@@ -179,12 +179,15 @@ class FacetSet extends ResponseParserAbstract ...@@ -179,12 +179,15 @@ class FacetSet extends ResponseParserAbstract
$before = (isset($data['before'])) ? $data['before'] : null; $before = (isset($data['before'])) ? $data['before'] : null;
$after = (isset($data['after'])) ? $data['after'] : null; $after = (isset($data['after'])) ? $data['after'] : null;
$between = (isset($data['between'])) ? $data['between'] : null; $between = (isset($data['between'])) ? $data['between'] : null;
$start = (isset($data['start'])) ? $data['start'] : null;
$end = (isset($data['end'])) ? $data['end'] : null;
$gap = (isset($data['gap'])) ? $data['gap'] : null;
if ($query->getResponseWriter() == $query::WT_JSON) { if ($query->getResponseWriter() == $query::WT_JSON) {
$data['counts'] = $this->convertToKeyValueArray($data['counts']); $data['counts'] = $this->convertToKeyValueArray($data['counts']);
} }
return new ResultFacet\Range($data['counts'], $before, $after, $between); return new ResultFacet\Range($data['counts'], $before, $after, $between, $start, $end, $gap);
} }
} }
......
...@@ -72,6 +72,27 @@ class Range extends Field ...@@ -72,6 +72,27 @@ class Range extends Field
*/ */
protected $between; protected $between;
/**
* The lower bound of the ranges
*
* @var string
*/
protected $start;
/**
* The upper bound of all ranges
*
* @var string
*/
protected $end;
/**
* The gap between each range
*
* @var string
*/
protected $gap;
/** /**
* Constructor * Constructor
* *
...@@ -79,14 +100,20 @@ class Range extends Field ...@@ -79,14 +100,20 @@ class Range extends Field
* @param int $before * @param int $before
* @param int $after * @param int $after
* @param int $between * @param int $between
* @param int $start
* @param int $end
* @param int $gap
* @return void * @return void
*/ */
public function __construct($values, $before, $after, $between) public function __construct($values, $before, $after, $between, $start, $end, $gap)
{ {
$this->values = $values; $this->values = $values;
$this->before = $before; $this->before = $before;
$this->after = $after; $this->after = $after;
$this->between = $between; $this->between = $between;
$this->start = $start;
$this->end = $end;
$this->gap = $gap;
} }
/** /**
...@@ -128,4 +155,40 @@ class Range extends Field ...@@ -128,4 +155,40 @@ class Range extends Field
return $this->between; return $this->between;
} }
/**
* Get 'start' value of the ranges
*
* The start value specified in the query facet.
*
* @return string
*/
public function getStart()
{
return $this->start;
}
/**
* Get 'end' value of the ranges
*
* The end value specified in the query facet
*
* @return string
*/
public function getEnd()
{
return $this->end;
}
/**
* Get 'gap' between the start and end of each range
*
* Get the gap specified in the query facet
*
* @return string
*/
public function getGap()
{
return $this->gap;
}
} }
...@@ -40,7 +40,8 @@ class RangeTest extends \PHPUnit_Framework_TestCase ...@@ -40,7 +40,8 @@ class RangeTest extends \PHPUnit_Framework_TestCase
*/ */
protected $facet; protected $facet;
protected $values, $before, $after, $between; protected $values, $before, $after, $between, $start, $end, $gap;
public function setUp() public function setUp()
{ {
...@@ -49,11 +50,15 @@ class RangeTest extends \PHPUnit_Framework_TestCase ...@@ -49,11 +50,15 @@ class RangeTest extends \PHPUnit_Framework_TestCase
'20.0' => 5, '20.0' => 5,
'30.0' => 3, '30.0' => 3,
); );
$this->before = 2; $this->before = 2;
$this->after = 4; $this->after = 4;
$this->between = 3; $this->between = 3;
$this->start = '10.0';
$this->end = '40.0';
$this->gap = '10.0';
$this->facet = new Range($this->values, $this->before, $this->after, $this->between); $this->facet = new Range($this->values, $this->before, $this->after, $this->between, $this->start, $this->end, $this->gap);
} }
public function testGetValues() public function testGetValues()
...@@ -91,4 +96,18 @@ class RangeTest extends \PHPUnit_Framework_TestCase ...@@ -91,4 +96,18 @@ class RangeTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($this->between, $this->facet->getBetween()); $this->assertEquals($this->between, $this->facet->getBetween());
} }
public function testGetStart()
{
$this->assertEquals($this->start, $this->facet->getStart());
}
public function testGetEnd()
{
$this->assertEquals($this->end, $this->facet->getEnd());
}
public function testGetGap()
{
$this->assertEquals($this->gap, $this->facet->getGap());
}
} }
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