/** * {@inheritDoc} */ public function setValue($value) { $multiple = $this->getAttribute('multiple'); if (true === $multiple || 'multiple' === $multiple) { if ($value instanceof Traversable) { $value = ArrayUtils::iteratorToArray($value); } elseif ($value == null) { return parent::setValue([]); } elseif (!is_array($value)) { $value = (array) $value; } return parent::setValue(array_map([$this, 'getValueOption'], $value)); } return parent::setValue($this->getValueOption($value)); }
public function testSetValueSingleValue() { $value = $this->values->toArray(); $this->element->setValue($value[0]); $this->assertEquals(1, $this->element->getValue()); }