This repository was archived by the owner on Apr 30, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,27 @@ public function testSettingSimpleObjectOnFormWithObjectToFormDataConverter()
191191 $ this ->assertInstanceOf (Movie::class, $ newMedia );
192192 $ this ->assertSame ('bar ' , $ newMedia ->getAuthor ());
193193 }
194+
195+ public function tesNonMappedField ()
196+ {
197+ $ builder = $ this ->factory ->createBuilder (FormType::class, new Book ('foo ' ), ['data_class ' => Media::class])
198+ ->add ('author ' )
199+ ->add ('mediaType ' , null , ['mapped ' => false ])
200+ ;
201+
202+ $ builder ->setDataMapper (new SimpleObjectMapper (new MediaConverter ()));
203+ $ form = $ builder ->getForm ();
204+
205+ $ this ->assertSame ('foo ' , $ form ->get ('author ' )->getData ());
206+ $ this ->assertSame (null , $ form ->get ('mediaType ' )->getData ());
207+
208+ $ form ->submit (['author ' => 'bar ' , 'mediaType ' => 'movie ' ]);
209+
210+ $ newMedia = $ form ->getData ();
211+
212+ $ this ->assertInstanceOf (Movie::class, $ newMedia );
213+ $ this ->assertSame ('bar ' , $ newMedia ->getAuthor ());
214+ }
194215}
195216
196217class FormDataToMoneyConverter extends \PHPUnit_Framework_TestCase implements FormDataToObjectConverterInterface
You can’t perform that action at this time.
0 commit comments