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()
191
191
$ this ->assertInstanceOf (Movie::class, $ newMedia );
192
192
$ this ->assertSame ('bar ' , $ newMedia ->getAuthor ());
193
193
}
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
+ }
194
215
}
195
216
196
217
class FormDataToMoneyConverter extends \PHPUnit_Framework_TestCase implements FormDataToObjectConverterInterface
You can’t perform that action at this time.
0 commit comments