@@ -1011,25 +1011,36 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = array(), $expect
10111011 ));
10121012 $ form ->submit (null );
10131013
1014- // view transformer write back empty strings in the view data
1014+ // view transformer writes back empty strings in the view data
10151015 $ this ->assertSame (array ('year ' => '' , 'month ' => '' , 'day ' => '' ), $ form ->getViewData ());
10161016 $ this ->assertSame ($ expectedData , $ form ->getNormData ());
10171017 $ this ->assertSame ($ expectedData , $ form ->getData ());
10181018 }
10191019
1020- public function testSingleTextSubmitNullUsesDefaultEmptyData ()
1020+ /**
1021+ * @dataProvider provideEmptyData
1022+ */
1023+ public function testSubmitNullUsesDateEmptyData ($ widget , $ emptyData , $ expectedData )
10211024 {
1022- $ emptyData = '2018-11-11 ' ;
10231025 $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , array (
1024- 'widget ' => ' single_text ' ,
1026+ 'widget ' => $ widget ,
10251027 'empty_data ' => $ emptyData ,
10261028 ));
10271029 $ form ->submit (null );
10281030
1029- $ date = new \DateTime ($ emptyData );
1030-
10311031 $ this ->assertSame ($ emptyData , $ form ->getViewData ());
1032- $ this ->assertEquals ($ date , $ form ->getNormData ());
1033- $ this ->assertEquals ($ date , $ form ->getData ());
1032+ $ this ->assertEquals ($ expectedData , $ form ->getNormData ());
1033+ $ this ->assertEquals ($ expectedData , $ form ->getData ());
1034+ }
1035+
1036+ public function provideEmptyData ()
1037+ {
1038+ $ expectedData = \DateTime::createFromFormat ('Y-m-d H:i:s ' , '2018-11-11 00:00:00 ' );
1039+
1040+ return array (
1041+ 'Simple field ' => array ('single_text ' , '2018-11-11 ' , $ expectedData ),
1042+ 'Compound text fields ' => array ('text ' , array ('year ' => '2018 ' , 'month ' => '11 ' , 'day ' => '11 ' ), $ expectedData ),
1043+ 'Compound choice fields ' => array ('choice ' , array ('year ' => '2018 ' , 'month ' => '11 ' , 'day ' => '11 ' ), $ expectedData ),
1044+ );
10341045 }
10351046}
0 commit comments