Skip to content
Snippets Groups Projects
Commit 3750cd3c authored by Simonas Šerlinskas's avatar Simonas Šerlinskas Committed by GitHub
Browse files

Merge pull request #94 from OliverSkroblin/master

Only overwrite field parameter of \ONGR\ElasticsearchDSL\Suggest\Comp…
parents 0745aebc 384220c7
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