Commit 0939d724 authored by delf.tonder's avatar delf.tonder

fixes #214, returning nested debug-information

parent 05cab9bd
......@@ -135,11 +135,16 @@ class Debug implements ComponentParserInterface
$details = array();
if (isset($documentData['details']) && is_array($documentData['details'])) {
foreach ($documentData['details'] as $detailData) {
$details[] = new Detail(
$detail = new Detail(
$detailData['match'],
$detailData['value'],
$detailData['description']
);
if (isset($detailData['details']) && is_array($detailData['details'])) {
$detail->setSubDetails($detailData['details']);
}
$details[] = $detail;
}
}
......
......@@ -65,6 +65,11 @@ class Detail
*/
protected $description;
/**
* @var array
*/
protected $subDetails;
/**
* Constructor
*
......@@ -109,4 +114,19 @@ class Detail
return $this->description;
}
/**
* @param array $subDetails
*/
public function setSubDetails($subDetails)
{
$this->subDetails = $subDetails;
}
/**
* @return array
*/
public function getSubDetails()
{
return $this->subDetails;
}
}
......@@ -63,8 +63,20 @@ class DebugTest extends \PHPUnit_Framework_TestCase
array(
'match' => true,
'value' => 0.5,
'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
$this->assertEquals(0.5, $doc->getValue());
$this->assertEquals(true, $doc->getMatch());
$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()));
$doc = $result->getExplainOther()->getDocument('IW-02');
$this->assertEquals(0.6, $doc->getValue());
......
......@@ -70,4 +70,10 @@ class DetailTest extends \PHPUnit_Framework_TestCase
$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