public function testCanInstantiateWithSettings()
 {
     $index = new SearchIndex('bob', ['field1', 'field2'], ['attr1', 'attr2'], 'MyClass', 'MyClass');
     $this->assertEquals('bob', $index->getIndexName());
     $this->assertEquals('MyClass', $index->getResultSetClass());
     $this->assertEquals('MyClass', $index->getResultClass());
     $this->assertSame(['field1', 'field2'], $index->getAvailableFields());
     $this->assertSame(['attr1', 'attr2'], $index->getAvailableAttributes());
 }
 /**
  * Creates the field criteria and validates the supplied field
  *
  * @param string  $field
  * @param integer $within
  * @param boolean $not
  *
  * @return Field
  */
 protected function createField($field, $within, $not = false)
 {
     if (null !== $field && !$this->index->isValidField($field)) {
         $m = 'Specified fields "%s" are not valid for the index "%s"';
         $i = $this->index->getIndexName();
         throw new \InvalidArgumentException(sprintf($m, $field, $i));
     }
     $this->fields[] = $field = new Field($this, $field, $within, $not);
     return $field;
 }
 /**
  * Returns the filter for $attribute
  *
  * If the filter is not currently in the bound filters, a new instance
  * of {@link Scorpio\SphinxSearch\Filter\FilterAttribute} will be created for
  * the specified attribute and that object returned. If the attribute is not
  * valid for the current index, an exception will be raised.
  *
  * @param string $attribute
  *
  * @return FilterInterface
  * @throws \InvalidArgumentException
  */
 public function getFilter($attribute)
 {
     if (array_key_exists($attribute, $this->filters)) {
         return $this->filters[$attribute];
     } else {
         if ($this->index->isValidAttribute($attribute)) {
             return $this->filters[$attribute] = new FilterAttribute($attribute);
         } else {
             throw new \InvalidArgumentException(sprintf('Filter "%s" is not valid for index "%s"', $attribute, $this->index->getIndexName()));
         }
     }
 }