Esempio n. 1
0
 public function testApplyDefaultValues()
 {
     $form = new \Foundation\Form();
     $name = 'elementName' . uniqid();
     $value = 'newValue' . uniqid();
     $element = $this->getMock('\\Foundation\\Form\\Element');
     $element->expects($this->any())->method('getName')->will($this->returnValue($name));
     $element->expects($this->once())->method('getDefaultValue')->will($this->returnValue($value));
     $element->expects($this->once())->method('setValue')->with($value);
     $field = $this->getMockBuilder('\\Foundation\\Form\\Field')->disableOriginalConstructor()->getMock();
     $field->expects($this->any())->method('getElements')->will($this->returnValue(array($name => $element)));
     $form->addField($field);
     $form->applyDefaultValues();
 }