@@ -690,6 +690,21 @@ public function testSubmitSingleChoiceWithEmptyData()
690
690
$ this ->assertSame ('test ' , $ form ->getData ());
691
691
}
692
692
693
+ public function testSubmitSingleChoiceWithEmptyDataAndInitialData ()
694
+ {
695
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , 'initial ' , array (
696
+ 'multiple ' => false ,
697
+ 'expanded ' => false ,
698
+ 'choices ' => array ('initial ' , 'test ' ),
699
+ 'choices_as_values ' => true ,
700
+ 'empty_data ' => 'test ' ,
701
+ ));
702
+
703
+ $ form ->submit (null );
704
+
705
+ $ this ->assertSame ('test ' , $ form ->getData ());
706
+ }
707
+
693
708
public function testSubmitMultipleChoiceWithEmptyData ()
694
709
{
695
710
$ form = $ this ->factory ->create (static ::TESTED_TYPE , null , array (
@@ -705,6 +720,36 @@ public function testSubmitMultipleChoiceWithEmptyData()
705
720
$ this ->assertSame (array ('test ' ), $ form ->getData ());
706
721
}
707
722
723
+ public function testSubmitMultipleChoiceWithEmptyDataAndInitialEmptyArray ()
724
+ {
725
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , array (), array (
726
+ 'multiple ' => true ,
727
+ 'expanded ' => false ,
728
+ 'choices ' => array ('test ' ),
729
+ 'choices_as_values ' => true ,
730
+ 'empty_data ' => array ('test ' ),
731
+ ));
732
+
733
+ $ form ->submit (null );
734
+
735
+ $ this ->assertSame (array ('test ' ), $ form ->getData ());
736
+ }
737
+
738
+ public function testSubmitMultipleChoiceWithEmptyDataAndInitialData ()
739
+ {
740
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , array ('initial ' ), array (
741
+ 'multiple ' => true ,
742
+ 'expanded ' => false ,
743
+ 'choices ' => array ('initial ' , 'test ' ),
744
+ 'choices_as_values ' => true ,
745
+ 'empty_data ' => array ('test ' ),
746
+ ));
747
+
748
+ $ form ->submit (null );
749
+
750
+ $ this ->assertSame (array ('test ' ), $ form ->getData ());
751
+ }
752
+
708
753
public function testSubmitSingleChoiceExpandedWithEmptyData ()
709
754
{
710
755
$ form = $ this ->factory ->create (static ::TESTED_TYPE , null , array (
@@ -720,6 +765,21 @@ public function testSubmitSingleChoiceExpandedWithEmptyData()
720
765
$ this ->assertSame ('test ' , $ form ->getData ());
721
766
}
722
767
768
+ public function testSubmitSingleChoiceExpandedWithEmptyDataAndInitialData ()
769
+ {
770
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , 'initial ' , array (
771
+ 'multiple ' => false ,
772
+ 'expanded ' => true ,
773
+ 'choices ' => array ('initial ' , 'test ' ),
774
+ 'choices_as_values ' => true ,
775
+ 'empty_data ' => 'test ' ,
776
+ ));
777
+
778
+ $ form ->submit (null );
779
+
780
+ $ this ->assertSame ('test ' , $ form ->getData ());
781
+ }
782
+
723
783
public function testSubmitMultipleChoiceExpandedWithEmptyData ()
724
784
{
725
785
$ form = $ this ->factory ->create (static ::TESTED_TYPE , null , array (
@@ -735,6 +795,36 @@ public function testSubmitMultipleChoiceExpandedWithEmptyData()
735
795
$ this ->assertSame (array ('test ' ), $ form ->getData ());
736
796
}
737
797
798
+ public function testSubmitMultipleChoiceExpandedWithEmptyDataAndInitialEmptyArray ()
799
+ {
800
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , array (), array (
801
+ 'multiple ' => true ,
802
+ 'expanded ' => true ,
803
+ 'choices ' => array ('test ' ),
804
+ 'choices_as_values ' => true ,
805
+ 'empty_data ' => array ('test ' ),
806
+ ));
807
+
808
+ $ form ->submit (null );
809
+
810
+ $ this ->assertSame (array ('test ' ), $ form ->getData ());
811
+ }
812
+
813
+ public function testSubmitMultipleChoiceExpandedWithEmptyDataAndInitialData ()
814
+ {
815
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , array ('init ' ), array (
816
+ 'multiple ' => true ,
817
+ 'expanded ' => true ,
818
+ 'choices ' => array ('init ' , 'test ' ),
819
+ 'choices_as_values ' => true ,
820
+ 'empty_data ' => array ('test ' ),
821
+ ));
822
+
823
+ $ form ->submit (null );
824
+
825
+ $ this ->assertSame (array ('test ' ), $ form ->getData ());
826
+ }
827
+
738
828
/**
739
829
* @group legacy
740
830
*/
0 commit comments