public function setFieldWeights(array $weights) { foreach ($weights as $name => $weight) { if (!is_string($name)) { throw new \InvalidArgumentException('Field name must be a string.'); } if (!is_int($weight)) { throw new \InvalidArgumentException('Field weight must be an integer.'); } } $this->fieldweights = $weights; return $this; }
public function testSetFieldWeights() { $sphinx = new SphinxClient(); $sphinx->setFieldWeights(array('field1' => 10, 'field2' => 200)); $this->assertSame($sphinx->fieldweights, array('field1' => 10, 'field2' => 200)); }