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()); }
/** * Create a field instance * * If you supply a string as the first arguments ($options) it will be used as the key for the field * and it will be added to this query component. * If you supply an options array/object that contains a key the field will also be added to the component. * * When no key is supplied the field cannot be added, in that case you will need to add it manually * after setting the key, by using the addField method. * * @param mixed $options * @return Field */ public function createField($options = null) { if (is_string($options)) { $fq = new Field(); $fq->setKey($options); } else { $fq = new Field($options); } if ($fq->getKey() !== null) { $this->addField($fq); } return $fq; }
public function testSetAndGetKey() { $this->field->setKey('testkey'); $this->assertEquals('testkey', $this->field->getKey()); }