public function setField($fieldName, $value)
{
if (!is_string($value) || !is_string($fieldName)) {
throw new InvalidException('The field and value arguments must be of type string.');
}
if (count($this->getParams()) > 0 && key($this->getParams()) !== $fieldName) {
throw new InvalidException('Fuzzy query can only support a single field.');
}
return $this->setParam($fieldName, ['value' => $value]);
}
/** * @group unit */ public function testBadArguments() { $this->setExpectedException('Elastica\\Exception\\InvalidException'); $query = new Fuzzy(); $query->addField('name', array(array('value' => 'Baden'))); $this->setExpectedException('Elastica\\Exception\\InvalidException'); $query = new Fuzzy(); $query->setField('name', array()); $this->setExpectedException('Elastica\\Exception\\InvalidException'); $query = new Fuzzy(); $query->setField('name', 'value'); $query->setField('name1', 'value1'); }