public function setData($collection) { if (!is_array($collection) && !$collection instanceof \Traversable) { throw new UnexpectedTypeException('The data must be an array'); } foreach ($collection as $name => $value) { $this->add($this->newField($name, $name)); } parent::setData($collection); }
public function testGetDataReturnsObject() { $group = new FieldGroup('author'); $object = new \stdClass(); $group->setData($object); $this->assertEquals($object, $group->getData()); }