@@ -1482,4 +1482,43 @@ public function testSetDataNonEmptyArraySubmitNullMultiple()
14821482 $ this ->assertEquals (array (), $ form ->getNormData ());
14831483 $ this ->assertSame (array (), $ form ->getViewData (), 'View data is always an array ' );
14841484 }
1485+
1486+ public function testSubmitNullUsesDefaultEmptyData ($ emptyData = 'empty ' , $ expectedData = null )
1487+ {
1488+ $ emptyData = '1 ' ;
1489+ $ entity1 = new SingleIntIdEntity (1 , 'Foo ' );
1490+ $ this ->persist (array ($ entity1 ));
1491+
1492+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , array (
1493+ 'em ' => 'default ' ,
1494+ 'class ' => self ::SINGLE_IDENT_CLASS ,
1495+ 'empty_data ' => $ emptyData ,
1496+ ));
1497+ $ form ->submit (null );
1498+
1499+ $ this ->assertSame ($ emptyData , $ form ->getViewData ());
1500+ $ this ->assertSame ($ entity1 , $ form ->getNormData ());
1501+ $ this ->assertSame ($ entity1 , $ form ->getData ());
1502+ }
1503+
1504+ public function testSubmitNullMultipleUsesDefaultEmptyData ()
1505+ {
1506+ $ emptyData = array ('1 ' );
1507+ $ entity1 = new SingleIntIdEntity (1 , 'Foo ' );
1508+ $ this ->persist (array ($ entity1 ));
1509+
1510+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , array (
1511+ 'em ' => 'default ' ,
1512+ 'class ' => self ::SINGLE_IDENT_CLASS ,
1513+ 'multiple ' => true ,
1514+ 'empty_data ' => $ emptyData ,
1515+ ));
1516+ $ form ->submit (null );
1517+
1518+ $ collection = new ArrayCollection (array ($ entity1 ));
1519+
1520+ $ this ->assertSame ($ emptyData , $ form ->getViewData ());
1521+ $ this ->assertEquals ($ collection , $ form ->getNormData ());
1522+ $ this ->assertEquals ($ collection , $ form ->getData ());
1523+ }
14851524}
0 commit comments