Exemplo n.º 1
0
 /**
  * @expectedException        \Symfony\Component\Form\Exception\TransformationFailedException
  * @expectedExceptionMessage Unable to transform value for property path "name": No mapping for value "arg"
  */
 public function testDataTransformationFailure()
 {
     $model = new FixedDataTransformer(array('default' => 'foo'));
     $view = new FixedDataTransformer(array('foo' => 'bar'));
     $config = new FormConfigBuilder('name', null, $this->dispatcher);
     $config->addViewTransformer($view);
     $config->addModelTransformer($model);
     $config->setData('arg');
     $form = new Form($config);
     $form->getData();
 }
Exemplo n.º 2
0
 public function testDataIsInitializedToConfiguredValue()
 {
     $model = new FixedDataTransformer(array('default' => 'foo'));
     $view = new FixedDataTransformer(array('foo' => 'bar'));
     $config = new FormConfigBuilder('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());
 }