diff --git a/Suggester/CompletionTest.php b/Suggester/CompletionTest.php index cbe6e4d66a44193a9627d09bbff1b3c35ed8f506..be16697fd25ef29b5dc615713f1bfc682b360692 100644 --- a/Suggester/CompletionTest.php +++ b/Suggester/CompletionTest.php @@ -12,8 +12,16 @@ namespace ONGR\ElasticsearchBundle\Tests\Unit\DSL\Suggester; use ONGR\ElasticsearchBundle\DSL\Suggester\Completion; +use ONGR\ElasticsearchBundle\Tests\app\fixture\AbstractEntityTest; -class CompletionTest extends \PHPUnit_Framework_TestCase +/** + * Test for Completion. + * + * Class CompletionTest + * + * @package ONGR\ElasticsearchBundle\Tests\Unit\DSL\Suggester + */ +class CompletionTest extends AbstractEntityTest { /** * @return array @@ -90,12 +98,60 @@ class CompletionTest extends \PHPUnit_Framework_TestCase * Tests toArray method. * * @param array $expected - * @param Completion $phrase + * @param Completion $completion * * @dataProvider getTestToArrayData */ - public function testToArray($expected, $phrase) + public function testToArray($expected, $completion) + { + $this->assertEquals($expected, $completion->toArray()); + } + + /** + * Tests if toArray method throws Logic Exception. + * + * @expectedException \LogicException + */ + public function testToArrayException() + { + $completion = new Completion('foo', 'bar'); + $completion->setField(null); + $completion->setText(null); + $completion->toArray(); + } + + /** + * Tests useFuzzy property. + */ + public function testUseFuzzy() { - $this->assertEquals($expected, $phrase->toArray()); + $completion = new Completion('foo', 'bar'); + $completion->useFuzzy(true); + $this->assertEquals(true, $completion->isFuzzy()); + } + + /** + * @return string + */ + public function getClassName() + { + $this->setStub(new Completion('foo', 'bar')); + $this->addIgnoredField('useFuzzy'); + + return 'ONGR\ElasticsearchBundle\DSL\Suggester\Completion'; + } + + /** + * @return array + */ + public function getFieldsData() + { + return [ + ['fuzziness'], + ['transpositions', 'boolean'], + ['minLength'], + ['prefixLength'], + ['unicodeAware'], + ]; } }