Commit 682b4d00 authored by Bas de Nooijer's avatar Bas de Nooijer

Merge commit '0939d724' into develop for PR #217

Conflicts:
	library/Solarium/QueryType/Select/Result/Debug/Detail.php
	tests/Solarium/Tests/QueryType/Select/Result/Debug/DetailTest.php
parents f602c202 0939d724
...@@ -135,11 +135,16 @@ class Debug implements ComponentParserInterface ...@@ -135,11 +135,16 @@ class Debug implements ComponentParserInterface
$details = array(); $details = array();
if (isset($documentData['details']) && is_array($documentData['details'])) { if (isset($documentData['details']) && is_array($documentData['details'])) {
foreach ($documentData['details'] as $detailData) { foreach ($documentData['details'] as $detailData) {
$details[] = new Detail( $detail = new Detail(
$detailData['match'], $detailData['match'],
$detailData['value'], $detailData['value'],
$detailData['description'] $detailData['description']
); );
if (isset($detailData['details']) && is_array($detailData['details'])) {
$detail->setSubDetails($detailData['details']);
}
$details[] = $detail;
} }
} }
......
...@@ -64,6 +64,11 @@ class Detail ...@@ -64,6 +64,11 @@ class Detail
*/ */
protected $description; protected $description;
/**
* @var array
*/
protected $subDetails;
/** /**
* Constructor * Constructor
* *
...@@ -107,4 +112,21 @@ class Detail ...@@ -107,4 +112,21 @@ class Detail
{ {
return $this->description; return $this->description;
} }
/**
* @param array $subDetails
*/
public function setSubDetails($subDetails)
{
$this->subDetails = $subDetails;
}
/**
* @return array
*/
public function getSubDetails()
{
return $this->subDetails;
}
} }
...@@ -63,7 +63,19 @@ class DebugTest extends \PHPUnit_Framework_TestCase ...@@ -63,7 +63,19 @@ class DebugTest extends \PHPUnit_Framework_TestCase
array( array(
'match' => true, 'match' => true,
'value' => 0.5, 'value' => 0.5,
'description' => 'tf(termFreq(text:ipod)=1)', 'description' => 'sum of:',
'details' => array(
array(
'match' => true,
'value' => 0.25,
'description' => 'weight(dummyfield:flachdach^250.0 in 1311) [], result of:'
),
array(
'match' => true,
'value' => 0.25,
'description' => 'tf(termFreq(text:ipod)=1)',
)
)
) )
), ),
), ),
...@@ -117,11 +129,23 @@ class DebugTest extends \PHPUnit_Framework_TestCase ...@@ -117,11 +129,23 @@ class DebugTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(0.5, $doc->getValue()); $this->assertEquals(0.5, $doc->getValue());
$this->assertEquals(true, $doc->getMatch()); $this->assertEquals(true, $doc->getMatch());
$this->assertEquals('fieldWeight(text:ipod in 5), product of:', $doc->getDescription()); $this->assertEquals('fieldWeight(text:ipod in 5), product of:', $doc->getDescription());
$this->assertEquals(
array(new Detail(true, 0.5, 'tf(termFreq(text:ipod)=1)')),
$doc->getDetails()
);
$expectedDetail = new Detail(true, 0.5, 'sum of:');
$expectedDetail->setSubDetails(
array(
array(
'match' => true,
'value' => 0.25,
'description' => 'weight(dummyfield:flachdach^250.0 in 1311) [], result of:'
),
array(
'match' => true,
'value' => 0.25,
'description' => 'tf(termFreq(text:ipod)=1)',
)
)
);
$this->assertEquals(array($expectedDetail), $doc->getDetails());
$this->assertEquals(1, count($result->getExplainOther())); $this->assertEquals(1, count($result->getExplainOther()));
$doc = $result->getExplainOther()->getDocument('IW-02'); $doc = $result->getExplainOther()->getDocument('IW-02');
$this->assertEquals(0.6, $doc->getValue()); $this->assertEquals(0.6, $doc->getValue());
......
...@@ -71,4 +71,12 @@ class DetailTest extends \PHPUnit_Framework_TestCase ...@@ -71,4 +71,12 @@ class DetailTest extends \PHPUnit_Framework_TestCase
{ {
$this->assertEquals($this->description, $this->result->getDescription()); $this->assertEquals($this->description, $this->result->getDescription());
} }
public function testSetSubDetails()
{
$subDetailsDummy = array('dummy', 'testing');
$this->result->setSubDetails($subDetailsDummy);
$this->assertEquals($subDetailsDummy, $this->result->getSubDetails());
}
} }
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