@@ -975,4 +975,33 @@ public function testSubmitNullWithSingleText()
975975 $ this ->assertNull ($ form ->getNormData ());
976976 $ this ->assertSame ('' , $ form ->getViewData ());
977977 }
978+
979+ public function testSubmitNullUsesDefaultEmptyData ($ emptyData = array (), $ expectedData = null )
980+ {
981+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , array (
982+ 'empty_data ' => $ emptyData ,
983+ ));
984+ $ form ->submit (null );
985+
986+ // view transformer write back empty strings in the view data
987+ $ this ->assertSame (array ('year ' => '' , 'month ' => '' , 'day ' => '' ), $ form ->getViewData ());
988+ $ this ->assertSame ($ expectedData , $ form ->getNormData ());
989+ $ this ->assertSame ($ expectedData , $ form ->getData ());
990+ }
991+
992+ public function testSingleTextSubmitNullUsesDefaultEmptyData ()
993+ {
994+ $ emptyData = '2018-11-11 ' ;
995+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , array (
996+ 'widget ' => 'single_text ' ,
997+ 'empty_data ' => $ emptyData ,
998+ ));
999+ $ form ->submit (null );
1000+
1001+ $ date = new \DateTime ($ emptyData );
1002+
1003+ $ this ->assertSame ($ emptyData , $ form ->getViewData ());
1004+ $ this ->assertEquals ($ date , $ form ->getNormData ());
1005+ $ this ->assertEquals ($ date , $ form ->getData ());
1006+ }
9781007}
0 commit comments