Exemplo n.º 1
0
 public function testSetPivots()
 {
     $this->field->clearPivots();
     $this->field->addPivots(array('pivot1', 'pivot2'));
     $this->field->setPivots(array('pivot3', 'pivot4'));
     $this->assertEquals(array('pivot3', 'pivot4'), $this->field->getPivots());
 }
Exemplo n.º 2
0
 public function testSetFacets()
 {
     $this->field->clearFacets();
     $this->field->addFacets(array('facet1', 'facet2'));
     $this->field->setFacets(array('facet3', 'facet4'));
     $this->assertEquals(array('facet3', 'facet4'), $this->field->getFacets());
 }
Exemplo n.º 3
0
 /**
  * Add a field
  *
  * Supports a field instance or a config array, in that case a new
  * field instance wil be created based on the options.
  *
  * @throws InvalidArgumentException
  * @param  Field|array              $field
  * @return self                     Provides fluent interface
  */
 public function addField($field)
 {
     if (is_array($field)) {
         $field = new Field($field);
     }
     $key = $field->getKey();
     if (0 === strlen($key)) {
         throw new InvalidArgumentException('A field must have a key value');
     }
     //double add calls for the same field are ignored, but non-unique keys cause an exception
     //@todo add trigger_error with a notice for double add calls?
     if (array_key_exists($key, $this->fields) && $this->fields[$key] !== $field) {
         throw new InvalidArgumentException('A field must have a unique key value');
     } else {
         $this->fields[$key] = $field;
     }
     return $this;
 }
Exemplo n.º 4
0
 public function testSetFields()
 {
     $f1 = new Field();
     $f1->setKey('f1');
     $f2 = new Field();
     $f2->setKey('f2');
     $fields = array($f1, $f2);
     $this->stats->addFields($fields);
     $f3 = new Field();
     $f3->setKey('f3');
     $f4 = new Field();
     $f4->setKey('f4');
     $fields2 = array('f3' => $f3, 'f4' => $f4);
     $this->stats->setFields($fields2);
     $this->assertEquals($fields2, $this->stats->getFields());
 }
Exemplo n.º 5
0
 public function testSetExcludes()
 {
     $this->field->addExcludes(array('e1', 'e2'));
     $this->field->setExcludes(array('e3', 'e4'));
     $this->assertEquals(array('e3', 'e4'), $this->field->getExcludes());
 }