12
12
namespace Symfony \Component \Form \Tests \Extension \Core \Type ;
13
13
14
14
use Symfony \Component \Form \CallbackTransformer ;
15
- use Symfony \Component \Form \Test \TypeTestCase ;
16
15
17
- class CheckboxTypeTest extends TypeTestCase
16
+ class CheckboxTypeTest extends BaseTypeTest
18
17
{
18
+ const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\CheckboxType ' ;
19
+
19
20
public function testDataIsFalseByDefault ()
20
21
{
21
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' );
22
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE );
22
23
23
24
$ this ->assertFalse ($ form ->getData ());
24
25
$ this ->assertFalse ($ form ->getNormData ());
@@ -27,42 +28,42 @@ public function testDataIsFalseByDefault()
27
28
28
29
public function testPassValueToView ()
29
30
{
30
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array ('value ' => 'foobar ' ));
31
- $ view = $ form ->createView ();
31
+ $ view = $ this ->factory ->create (static :: TESTED_TYPE , null , array ('value ' => 'foobar ' ))
32
+ ->createView ();
32
33
33
34
$ this ->assertEquals ('foobar ' , $ view ->vars ['value ' ]);
34
35
}
35
36
36
37
public function testCheckedIfDataTrue ()
37
38
{
38
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' );
39
- $ form ->setData (true );
40
- $ view = $ form ->createView ();
39
+ $ view = $ this ->factory ->create (static :: TESTED_TYPE )
40
+ ->setData (true )
41
+ ->createView ();
41
42
42
43
$ this ->assertTrue ($ view ->vars ['checked ' ]);
43
44
}
44
45
45
46
public function testCheckedIfDataTrueWithEmptyValue ()
46
47
{
47
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , 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 ();
50
51
51
52
$ this ->assertTrue ($ view ->vars ['checked ' ]);
52
53
}
53
54
54
55
public function testNotCheckedIfDataFalse ()
55
56
{
56
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' );
57
- $ form ->setData (false );
58
- $ view = $ form ->createView ();
57
+ $ view = $ this ->factory ->create (static :: TESTED_TYPE )
58
+ ->setData (false )
59
+ ->createView ();
59
60
60
61
$ this ->assertFalse ($ view ->vars ['checked ' ]);
61
62
}
62
63
63
64
public function testSubmitWithValueChecked ()
64
65
{
65
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
66
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
66
67
'value ' => 'foobar ' ,
67
68
));
68
69
$ form ->submit ('foobar ' );
@@ -73,7 +74,7 @@ public function testSubmitWithValueChecked()
73
74
74
75
public function testSubmitWithRandomValueChecked ()
75
76
{
76
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
77
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
77
78
'value ' => 'foobar ' ,
78
79
));
79
80
$ form ->submit ('krixikraxi ' );
@@ -84,7 +85,7 @@ public function testSubmitWithRandomValueChecked()
84
85
85
86
public function testSubmitWithValueUnchecked ()
86
87
{
87
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
88
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
88
89
'value ' => 'foobar ' ,
89
90
));
90
91
$ form ->submit (null );
@@ -95,7 +96,7 @@ public function testSubmitWithValueUnchecked()
95
96
96
97
public function testSubmitWithEmptyValueChecked ()
97
98
{
98
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
99
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
99
100
'value ' => '' ,
100
101
));
101
102
$ form ->submit ('' );
@@ -106,7 +107,7 @@ public function testSubmitWithEmptyValueChecked()
106
107
107
108
public function testSubmitWithEmptyValueUnchecked ()
108
109
{
109
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
110
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
110
111
'value ' => '' ,
111
112
));
112
113
$ form ->submit (null );
@@ -117,7 +118,7 @@ public function testSubmitWithEmptyValueUnchecked()
117
118
118
119
public function testSubmitWithEmptyValueAndFalseUnchecked ()
119
120
{
120
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
121
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
121
122
'value ' => '' ,
122
123
));
123
124
$ form ->submit (false );
@@ -128,7 +129,7 @@ public function testSubmitWithEmptyValueAndFalseUnchecked()
128
129
129
130
public function testSubmitWithEmptyValueAndTrueChecked ()
130
131
{
131
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
132
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
132
133
'value ' => '' ,
133
134
));
134
135
$ form ->submit (true );
@@ -152,7 +153,7 @@ function ($value) {
152
153
}
153
154
);
154
155
155
- $ form = $ this ->factory ->createBuilder (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' )
156
+ $ form = $ this ->factory ->createBuilder (static :: TESTED_TYPE )
156
157
->addModelTransformer ($ transformer )
157
158
->getForm ();
158
159
@@ -171,4 +172,9 @@ public function provideCustomModelTransformerData()
171
172
array ('unchecked ' , false ),
172
173
);
173
174
}
175
+
176
+ public function testSubmitNull ($ expected = null , $ norm = null , $ view = null )
177
+ {
178
+ parent ::testSubmitNull (false , false , null );
179
+ }
174
180
}
0 commit comments