Commit 97b94e14 authored by Bas de Nooijer's avatar Bas de Nooijer

Merge commit 'acfbc18e' into develop (PR #104)

Conflicts:
	library/Solarium/Result/Select/Spellcheck.php
	tests/Solarium/Result/Select/SpellcheckTest.php
parents b56f4406 acfbc18e
......@@ -41,13 +41,16 @@ foreach($spellcheckResult as $suggestion) {
echo '<hr/>';
}
$collation = $spellcheckResult->getCollation();
echo '<h1>Collation</h1>';
echo 'Query: '.$collation->getQuery().'<br/>';
echo 'Hits: '.$collation->getHits().'<br/>';
$collations = $spellcheckResult->getCollations();
echo '<h1>Collations</h1>';
foreach($collations as $collation) {
echo 'Query: '.$collation->getQuery().'<br/>';
echo 'Hits: '.$collation->getHits().'<br/>';
echo '<hr/>';
}
echo 'Corrections:<br/>';
foreach($collation->getCorrections() as $input => $correction) {
echo $input . ' => ' . $correction .'<br/>';
}
htmlFooter();
\ No newline at end of file
htmlFooter();
......@@ -173,4 +173,4 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck
$numFound, $startOffset, $endOffset, $originalFrequency, $word, $frequency
);
}
}
\ No newline at end of file
}
......@@ -70,7 +70,7 @@ class Solarium_Result_Select_Spellcheck implements IteratorAggregate, Countable
* Constructor
*
* @param array $suggestions
* @param Solarium_Result_Select_Spellcheck_Collation $collation
* @param array $collations
* @param boolean $correctlySpelled
* @return void
*/
......@@ -83,7 +83,7 @@ class Solarium_Result_Select_Spellcheck implements IteratorAggregate, Countable
/**
* Get the collation result
*
*
* @param int $key
* @return Solarium_Result_Select_Spellcheck_Collation
*/
......@@ -95,7 +95,7 @@ class Solarium_Result_Select_Spellcheck implements IteratorAggregate, Countable
} else {
if ($key === null) {
$key = $nrOfCollations - 1; // for backwards compatibility
return reset($this->_collations);
}
return $this->_collations[$key];
......@@ -128,7 +128,7 @@ class Solarium_Result_Select_Spellcheck implements IteratorAggregate, Countable
* Get a result by key
*
* @param mixed $key
* @return Solarium_Result_Select_Highlighting_Suggestion|null
* @return Solarium_Result_Select_Spellcheck_Suggestion|null
*/
public function getSuggestion($key)
{
......@@ -168,4 +168,4 @@ class Solarium_Result_Select_Spellcheck implements IteratorAggregate, Countable
{
return count($this->_suggestions);
}
}
\ No newline at end of file
}
......@@ -85,6 +85,21 @@ class Solarium_Client_ResponseParser_Select_Component_SpellcheckTest extends PHP
3 => 'ultrasharp'
),
),
8 => 'collation',
9 => array (
0 => 'collationQuery',
1 => 'dell ultrasharp new',
2 => 'hits',
3 => 0,
4 => 'misspellingsAndCorrections',
5 => array (
0 => 'delll',
1 => 'dell',
2 => 'ultrashar',
3 => 'ultrasharp'
),
),
)
)
);
......@@ -95,6 +110,9 @@ class Solarium_Client_ResponseParser_Select_Component_SpellcheckTest extends PHP
$this->assertEquals(false, $result->getCorrectlySpelled());
$this->assertEquals('dell', $suggestions[0]->getWord());
$this->assertEquals('dell ultrasharp', $result->getCollation()->getQuery());
$collations = $result->getCollations();
$this->assertEquals('dell ultrasharp', $collations[0]->getQuery());
$this->assertEquals('dell ultrasharp new', $collations[1]->getQuery());
}
public function testParse()
......@@ -129,6 +147,8 @@ class Solarium_Client_ResponseParser_Select_Component_SpellcheckTest extends PHP
5 => false,
6 => 'collation',
7 => 'dell ultrasharp',
8 => 'collation',
9 => 'dell ultrasharp new',
)
)
);
......@@ -139,6 +159,10 @@ class Solarium_Client_ResponseParser_Select_Component_SpellcheckTest extends PHP
$this->assertEquals(false, $result->getCorrectlySpelled());
$this->assertEquals('dell', $suggestions[0]->getWord());
$this->assertEquals('dell ultrasharp', $result->getCollation()->getQuery());
$collations = $result->getCollations();
$this->assertEquals('dell ultrasharp', $collations[0]->getQuery());
$this->assertEquals('dell ultrasharp new', $collations[1]->getQuery());
}
public function testParseNoData()
......
......@@ -37,7 +37,7 @@ class Solarium_Result_Select_SpellcheckTest extends PHPUnit_Framework_TestCase
*/
protected $_result;
protected $_suggestions, $_collation, $_correctlySpelled;
protected $_suggestions, $_collations, $_correctlySpelled;
public function setUp()
{
......@@ -45,15 +45,19 @@ class Solarium_Result_Select_SpellcheckTest extends PHPUnit_Framework_TestCase
'key1' => 'content1',
'key2' => 'content2',
);
$this->_collation = 'dummy1';
$this->_collations = array(
'dummy1',
'dummy2',
);
$this->_correctlySpelled = false;
$this->_result = new Solarium_Result_Select_Spellcheck($this->_suggestions, array($this->_collation), $this->_correctlySpelled);
$this->_result = new Solarium_Result_Select_Spellcheck($this->_suggestions, $this->_collations, $this->_correctlySpelled);
}
public function testGetCollation()
{
$this->assertEquals($this->_collation, $this->_result->getCollation());
$this->assertEquals($this->_collations, $this->_result->getCollations());
$this->assertEquals(reset($this->_collations), $this->_result->getCollation());
}
public function testGetCorrectlySpelled()
......
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