public function testDataIsInitializedToConfiguredValue() { $model = new FixedDataTransformer(array('default' => 'foo')); $view = new FixedDataTransformer(array('foo' => 'bar')); $config = new FormConfig('name', null, $this->dispatcher); $config->addViewTransformer($view); $config->addModelTransformer($model); $config->setData('default'); $form = new Form($config); $this->assertSame('default', $form->getData()); $this->assertSame('foo', $form->getNormData()); $this->assertSame('bar', $form->getViewData()); }
public function testMapFormsToDataSkipsVirtualForms() { $car = new \stdClass(); $engine = new \stdClass(); $parentPath = $this->getPropertyPath('name'); $childPath = $this->getPropertyPath('engine'); $parentPath->expects($this->never())->method('getValue'); $parentPath->expects($this->never())->method('setValue'); $childPath->expects($this->once())->method('setValue')->with($car, $engine); $config = new FormConfig('name', '\\stdClass', $this->dispatcher); $config->setPropertyPath($parentPath); $config->setVirtual(true); $config->setCompound(true); $config->setDataMapper($this->getDataMapper()); $form = $this->getForm($config); $config = new FormConfig('engine', '\\stdClass', $this->dispatcher); $config->setByReference(true); $config->setPropertyPath($childPath); $config->setData($engine); $child = $this->getForm($config); $form->add($child); $this->mapper->mapFormsToData(array($form), $car); }