Skip to content
Snippets Groups Projects
Commit 2be4f267 authored by Simonas Šerlinskas's avatar Simonas Šerlinskas
Browse files

Merge pull request #22 from GrandLTU/FuzzyLikeThis-field

Change FuzzyLikeThisTestQuery to accept single field as string.
parents 101c4598 fd2b28f1
No related branches found
No related tags found
No related merge requests found
......@@ -32,12 +32,16 @@ class FuzzyLikeThisQuery implements BuilderInterface
private $likeText;
/**
* @param string[] $fields
* @param string $likeText
* @param array $parameters
* @param string|string[] $fields
* @param string $likeText
* @param array $parameters
*/
public function __construct(array $fields, $likeText, array $parameters = [])
public function __construct($fields, $likeText, array $parameters = [])
{
if (!is_array($fields)) {
$fields = [$fields];
}
$this->fields = $fields;
$this->likeText = $likeText;
$this->setParameters($parameters);
......
......@@ -52,4 +52,25 @@ class FuzzyLikeThisQueryTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('fuzzy_like_this', $fuzzyLikeThisQuery->getType());
}
/**
* Tests if query accepts single field as string.
*/
public function testSingleField()
{
$fuzzyLikeThisQuery = new FuzzyLikeThisQuery(
'name.first',
'text like this one',
[ 'max_query_terms' => 12 ]
);
$this->assertSame(
[
'fields' => ['name.first'],
'like_text' => 'text like this one',
'max_query_terms' => 12,
],
$fuzzyLikeThisQuery->toArray()
);
}
}
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