Skip to content
Snippets Groups Projects
Commit 384220c7 authored by Oliver Skroblin's avatar Oliver Skroblin
Browse files

Only overwrite field parameter of...

Only overwrite field parameter of \ONGR\ElasticsearchDSL\Suggest\CompletionSuggest if parameter not configured
parent 806267bc
No related branches found
No related tags found
No related merge requests found
......@@ -62,7 +62,9 @@ class CompletionSuggest implements BuilderInterface
*/
public function toArray()
{
$this->addParameter('field', 'suggest');
if (!$this->hasParameter('field')) {
$this->addParameter('field', 'suggest');
}
if (!$this->hasParameter('size')) {
$this->addParameter('size', self::DEFAULT_SIZE);
......
......@@ -56,6 +56,27 @@ class CompletionSuggestTest extends \PHPUnit_Framework_TestCase
'fuzzy' => ['fuzziness' => 2]
]
);
$expected = ['foo' => [
'text' => 'bar',
'completion' => [
'field' => 'title',
'size' => 5,
'fuzzy' => ['fuzziness' => 2]
],
]];
$this->assertEquals($expected, $suggest->toArray());
}
public function testToArrayWithoutField()
{
$suggest = new CompletionSuggest(
'foo',
'bar',
[
'size' => 5,
'fuzzy' => ['fuzziness' => 2]
]
);
$expected = ['foo' => [
'text' => 'bar',
'completion' => [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment