@@ -1003,4 +1003,33 @@ public function testSubmitNullWithSingleText()
10031003 $ this ->assertNull ($ form ->getNormData ());
10041004 $ this ->assertSame ('' , $ form ->getViewData ());
10051005 }
1006+
1007+ public function testSubmitNullUsesDefaultEmptyData ($ emptyData = array (), $ expectedData = null )
1008+ {
1009+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , array (
1010+ 'empty_data ' => $ emptyData ,
1011+ ));
1012+ $ form ->submit (null );
1013+
1014+ // view transformer write back empty strings in the view data
1015+ $ this ->assertSame (array ('year ' => '' , 'month ' => '' , 'day ' => '' ), $ form ->getViewData ());
1016+ $ this ->assertSame ($ expectedData , $ form ->getNormData ());
1017+ $ this ->assertSame ($ expectedData , $ form ->getData ());
1018+ }
1019+
1020+ public function testSingleTextSubmitNullUsesDefaultEmptyData ()
1021+ {
1022+ $ emptyData = '2018-11-11 ' ;
1023+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , array (
1024+ 'widget ' => 'single_text ' ,
1025+ 'empty_data ' => $ emptyData ,
1026+ ));
1027+ $ form ->submit (null );
1028+
1029+ $ date = new \DateTime ($ emptyData );
1030+
1031+ $ this ->assertSame ($ emptyData , $ form ->getViewData ());
1032+ $ this ->assertEquals ($ date , $ form ->getNormData ());
1033+ $ this ->assertEquals ($ date , $ form ->getData ());
1034+ }
10061035}
0 commit comments