Ejemplo n.º 1
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Unreachable field "0"
  */
 public function testFormRegistrySetArrayOnNotCompoundField()
 {
     $registry = new FormFieldRegistry();
     $registry->add($this->getFormFieldMock('bar'));
     $registry->set('bar', array('baz'));
 }
Ejemplo n.º 2
0
 /**
  * Sets the value of a field.
  *
  * @param string       $name  The field name
  * @param string|array $value The value of the field
  *
  * @throws \InvalidArgumentException if the field does not exist
  */
 public function offsetSet($name, $value)
 {
     $this->fields->set($name, $value);
 }
Ejemplo n.º 3
0
 public function testFormRegistrySetValues()
 {
     $registry = new FormFieldRegistry();
     $registry->add($f2 = $this->getFormFieldMock('foo[2]'));
     $registry->add($f3 = $this->getFormFieldMock('foo[3]'));
     $registry->add($fbb = $this->getFormFieldMock('foo[bar][baz]'));
     $f2->expects($this->exactly(2))->method('setValue')->with(2);
     $f3->expects($this->exactly(2))->method('setValue')->with(3);
     $fbb->expects($this->exactly(2))->method('setValue')->with('fbb');
     $registry->set('foo[2]', 2);
     $registry->set('foo[3]', 3);
     $registry->set('foo[bar][baz]', 'fbb');
     $registry->set('foo', array(2 => 2, 3 => 3, 'bar' => array('baz' => 'fbb')));
 }