1212namespace Symfony \Component \Form \Tests \Extension \Core \Type ;
1313
1414use Symfony \Component \Form \CallbackTransformer ;
15- use Symfony \Component \Form \Test \TypeTestCase ;
1615
17- class CheckboxTypeTest extends TypeTestCase
16+ class CheckboxTypeTest extends BaseTypeTest
1817{
18+ const TESTED_TYPE = 'checkbox ' ;
19+
1920 public function testDataIsFalseByDefault ()
2021 {
21- $ form = $ this ->factory ->create (' checkbox ' );
22+ $ form = $ this ->factory ->create (static :: TESTED_TYPE );
2223
2324 $ this ->assertFalse ($ form ->getData ());
2425 $ this ->assertFalse ($ form ->getNormData ());
@@ -27,42 +28,42 @@ public function testDataIsFalseByDefault()
2728
2829 public function testPassValueToView ()
2930 {
30- $ form = $ this ->factory ->create (' checkbox ' , null , array ('value ' => 'foobar ' ));
31- $ view = $ form ->createView ();
31+ $ view = $ this ->factory ->create (static :: TESTED_TYPE , null , array ('value ' => 'foobar ' ))
32+ ->createView ();
3233
3334 $ this ->assertEquals ('foobar ' , $ view ->vars ['value ' ]);
3435 }
3536
3637 public function testCheckedIfDataTrue ()
3738 {
38- $ form = $ this ->factory ->create (' checkbox ' );
39- $ form ->setData (true );
40- $ view = $ form ->createView ();
39+ $ view = $ this ->factory ->create (static :: TESTED_TYPE )
40+ ->setData (true )
41+ ->createView ();
4142
4243 $ this ->assertTrue ($ view ->vars ['checked ' ]);
4344 }
4445
4546 public function testCheckedIfDataTrueWithEmptyValue ()
4647 {
47- $ form = $ this ->factory ->create (' checkbox ' , null , array ('value ' => '' ));
48- $ form ->setData (true );
49- $ view = $ form ->createView ();
48+ $ view = $ this ->factory ->create (static :: TESTED_TYPE , null , array ('value ' => '' ))
49+ ->setData (true )
50+ ->createView ();
5051
5152 $ this ->assertTrue ($ view ->vars ['checked ' ]);
5253 }
5354
5455 public function testNotCheckedIfDataFalse ()
5556 {
56- $ form = $ this ->factory ->create (' checkbox ' );
57- $ form ->setData (false );
58- $ view = $ form ->createView ();
57+ $ view = $ this ->factory ->create (static :: TESTED_TYPE )
58+ ->setData (false )
59+ ->createView ();
5960
6061 $ this ->assertFalse ($ view ->vars ['checked ' ]);
6162 }
6263
6364 public function testSubmitWithValueChecked ()
6465 {
65- $ form = $ this ->factory ->create (' checkbox ' , null , array (
66+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
6667 'value ' => 'foobar ' ,
6768 ));
6869 $ form ->submit ('foobar ' );
@@ -73,7 +74,7 @@ public function testSubmitWithValueChecked()
7374
7475 public function testSubmitWithRandomValueChecked ()
7576 {
76- $ form = $ this ->factory ->create (' checkbox ' , null , array (
77+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
7778 'value ' => 'foobar ' ,
7879 ));
7980 $ form ->submit ('krixikraxi ' );
@@ -84,7 +85,7 @@ public function testSubmitWithRandomValueChecked()
8485
8586 public function testSubmitWithValueUnchecked ()
8687 {
87- $ form = $ this ->factory ->create (' checkbox ' , null , array (
88+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
8889 'value ' => 'foobar ' ,
8990 ));
9091 $ form ->submit (null );
@@ -95,7 +96,7 @@ public function testSubmitWithValueUnchecked()
9596
9697 public function testSubmitWithEmptyValueChecked ()
9798 {
98- $ form = $ this ->factory ->create (' checkbox ' , null , array (
99+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
99100 'value ' => '' ,
100101 ));
101102 $ form ->submit ('' );
@@ -106,7 +107,7 @@ public function testSubmitWithEmptyValueChecked()
106107
107108 public function testSubmitWithEmptyValueUnchecked ()
108109 {
109- $ form = $ this ->factory ->create (' checkbox ' , null , array (
110+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
110111 'value ' => '' ,
111112 ));
112113 $ form ->submit (null );
@@ -117,7 +118,7 @@ public function testSubmitWithEmptyValueUnchecked()
117118
118119 public function testSubmitWithEmptyValueAndFalseUnchecked ()
119120 {
120- $ form = $ this ->factory ->create (' checkbox ' , null , array (
121+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
121122 'value ' => '' ,
122123 ));
123124 $ form ->submit (false );
@@ -128,7 +129,7 @@ public function testSubmitWithEmptyValueAndFalseUnchecked()
128129
129130 public function testSubmitWithEmptyValueAndTrueChecked ()
130131 {
131- $ form = $ this ->factory ->create (' checkbox ' , null , array (
132+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
132133 'value ' => '' ,
133134 ));
134135 $ form ->submit (true );
@@ -152,7 +153,7 @@ function ($value) {
152153 }
153154 );
154155
155- $ form = $ this ->factory ->createBuilder (' checkbox ' )
156+ $ form = $ this ->factory ->createBuilder (static :: TESTED_TYPE )
156157 ->addModelTransformer ($ transformer )
157158 ->getForm ();
158159
@@ -171,4 +172,9 @@ public function provideCustomModelTransformerData()
171172 array ('unchecked ' , false ),
172173 );
173174 }
175+
176+ public function testSubmitNull ($ expected = null , $ norm = null , $ view = null )
177+ {
178+ parent ::testSubmitNull (false , false , null );
179+ }
174180}
0 commit comments