Commit 4b4ca0d7 authored by Corentin Larose's avatar Corentin Larose Committed by Dorian Villet

Fix proposition for maxScore related notice + unit test (Issue #175)

parent 3f5b7ddf
...@@ -74,7 +74,7 @@ class MoreLikeThis implements ComponentParserInterface ...@@ -74,7 +74,7 @@ class MoreLikeThis implements ComponentParserInterface
$results[$key] = new Result( $results[$key] = new Result(
$result['numFound'], $result['numFound'],
$result['maxScore'], isset($result['maxScore']) ? $result['maxScore'] : null,
$docs $docs
); );
} }
......
...@@ -72,7 +72,7 @@ class Result implements \IteratorAggregate, \Countable ...@@ -72,7 +72,7 @@ class Result implements \IteratorAggregate, \Countable
* Constructor * Constructor
* *
* @param int $numFound * @param int $numFound
* @param float $maxScore * @param float|null $maxScore
* @param array $documents * @param array $documents
* @return void * @return void
*/ */
......
...@@ -77,4 +77,28 @@ class MoreLikeThisTest extends \PHPUnit_Framework_TestCase ...@@ -77,4 +77,28 @@ class MoreLikeThisTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array(), $result->getResults()); $this->assertEquals(array(), $result->getResults());
} }
public function testParseWithoutMaxScore()
{
$query = new Query();
$data = array(
'moreLikeThis' => array(
'id1' => array(
'numFound' => 12,
'docs' => array(
array('field1' => 'value1')
)
)
)
);
$docs = array(new Document(array('field1' => 'value1')));
$expected = array(
'id1' => new Result(12, null, $docs)
);
$result = $this->parser->parse($query, null, $data);
$this->assertEquals($expected, $result->getResults());
}
} }
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