Commit 3a1b3458 authored by Bas de Nooijer's avatar Bas de Nooijer

Updated spellcheck responseparser and result tests

parent cc84bd33
...@@ -194,6 +194,10 @@ class SpellcheckTest extends \PHPUnit_Framework_TestCase ...@@ -194,6 +194,10 @@ class SpellcheckTest extends \PHPUnit_Framework_TestCase
'suggestion' => array ( 'suggestion' => array (
0 => array ( 0 => array (
'word' => 'ultrasharp', 'word' => 'ultrasharp',
'freq' => 2
),
1 => array (
'word' => 'ultrasharpy',
'freq' => 1 'freq' => 1
), ),
), ),
...@@ -209,6 +213,9 @@ class SpellcheckTest extends \PHPUnit_Framework_TestCase ...@@ -209,6 +213,9 @@ class SpellcheckTest extends \PHPUnit_Framework_TestCase
$result = $this->parser->parse($this->query, null, $data); $result = $this->parser->parse($this->query, null, $data);
$collations = $result->getCollations(); $collations = $result->getCollations();
$this->assertEquals('dell ultrasharp', $collations[0]->getQuery()); $this->assertEquals('dell ultrasharp', $collations[0]->getQuery());
$words = $result->getSuggestion(1)->getWords();
$this->assertEquals(array('word' => 'ultrasharpy', 'freq' => 1), $words[1]);
} }
public function testParseNoData() public function testParseNoData()
......
...@@ -40,7 +40,7 @@ class SuggestionTest extends \PHPUnit_Framework_TestCase ...@@ -40,7 +40,7 @@ class SuggestionTest extends \PHPUnit_Framework_TestCase
*/ */
protected $result; protected $result;
protected $numFound, $startOffset, $endOffset, $originalFrequency, $word, $frequency; protected $numFound, $startOffset, $endOffset, $originalFrequency, $words, $frequency;
public function setUp() public function setUp()
{ {
...@@ -48,11 +48,19 @@ class SuggestionTest extends \PHPUnit_Framework_TestCase ...@@ -48,11 +48,19 @@ class SuggestionTest extends \PHPUnit_Framework_TestCase
$this->startOffset = 2; $this->startOffset = 2;
$this->endOffset = 3; $this->endOffset = 3;
$this->originalFrequency = 4; $this->originalFrequency = 4;
$this->word = 'dummyword'; $this->words = array(
$this->frequency = 5; array(
'word' => 'dummyword',
'freq' => 5
),
array(
'word' => 'secondword',
'freq' => 1
)
);
$this->result = new Suggestion( $this->result = new Suggestion(
$this->numFound, $this->startOffset, $this->endOffset, $this->originalFrequency, $this->word, $this->frequency $this->numFound, $this->startOffset, $this->endOffset, $this->originalFrequency, $this->words
); );
} }
...@@ -78,12 +86,17 @@ class SuggestionTest extends \PHPUnit_Framework_TestCase ...@@ -78,12 +86,17 @@ class SuggestionTest extends \PHPUnit_Framework_TestCase
public function testGetWord() public function testGetWord()
{ {
$this->assertEquals($this->word, $this->result->getWord()); $this->assertEquals($this->words[0]['word'], $this->result->getWord());
} }
public function testGetFrequency() public function testGetFrequency()
{ {
$this->assertEquals($this->frequency, $this->result->getFrequency()); $this->assertEquals($this->words[0]['freq'], $this->result->getFrequency());
}
public function testGetWords()
{
$this->assertEquals($this->words, $this->result->getWords());
} }
} }
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