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
/**
20
21
* @group legacy
21
22
*/
@@ -28,7 +29,7 @@ public function testLegacyName()
28
29
29
30
public function testDataIsFalseByDefault ()
30
31
{
31
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' );
32
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE );
32
33
33
34
$ this ->assertFalse ($ form ->getData ());
34
35
$ this ->assertFalse ($ form ->getNormData ());
@@ -37,42 +38,42 @@ public function testDataIsFalseByDefault()
37
38
38
39
public function testPassValueToView ()
39
40
{
40
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array ('value ' => 'foobar ' ));
41
- $ view = $ form ->createView ();
41
+ $ view = $ this ->factory ->create (static :: TESTED_TYPE , null , array ('value ' => 'foobar ' ))
42
+ ->createView ();
42
43
43
44
$ this ->assertEquals ('foobar ' , $ view ->vars ['value ' ]);
44
45
}
45
46
46
47
public function testCheckedIfDataTrue ()
47
48
{
48
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' );
49
- $ form ->setData (true );
50
- $ view = $ form ->createView ();
49
+ $ view = $ this ->factory ->create (static :: TESTED_TYPE )
50
+ ->setData (true )
51
+ ->createView ();
51
52
52
53
$ this ->assertTrue ($ view ->vars ['checked ' ]);
53
54
}
54
55
55
56
public function testCheckedIfDataTrueWithEmptyValue ()
56
57
{
57
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array ('value ' => '' ));
58
- $ form ->setData (true );
59
- $ view = $ form ->createView ();
58
+ $ view = $ this ->factory ->create (static :: TESTED_TYPE , null , array ('value ' => '' ))
59
+ ->setData (true )
60
+ ->createView ();
60
61
61
62
$ this ->assertTrue ($ view ->vars ['checked ' ]);
62
63
}
63
64
64
65
public function testNotCheckedIfDataFalse ()
65
66
{
66
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' );
67
- $ form ->setData (false );
68
- $ view = $ form ->createView ();
67
+ $ view = $ this ->factory ->create (static :: TESTED_TYPE )
68
+ ->setData (false )
69
+ ->createView ();
69
70
70
71
$ this ->assertFalse ($ view ->vars ['checked ' ]);
71
72
}
72
73
73
74
public function testSubmitWithValueChecked ()
74
75
{
75
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
76
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
76
77
'value ' => 'foobar ' ,
77
78
));
78
79
$ form ->submit ('foobar ' );
@@ -83,7 +84,7 @@ public function testSubmitWithValueChecked()
83
84
84
85
public function testSubmitWithRandomValueChecked ()
85
86
{
86
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
87
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
87
88
'value ' => 'foobar ' ,
88
89
));
89
90
$ form ->submit ('krixikraxi ' );
@@ -94,7 +95,7 @@ public function testSubmitWithRandomValueChecked()
94
95
95
96
public function testSubmitWithValueUnchecked ()
96
97
{
97
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
98
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
98
99
'value ' => 'foobar ' ,
99
100
));
100
101
$ form ->submit (null );
@@ -105,7 +106,7 @@ public function testSubmitWithValueUnchecked()
105
106
106
107
public function testSubmitWithEmptyValueChecked ()
107
108
{
108
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
109
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
109
110
'value ' => '' ,
110
111
));
111
112
$ form ->submit ('' );
@@ -116,7 +117,7 @@ public function testSubmitWithEmptyValueChecked()
116
117
117
118
public function testSubmitWithEmptyValueUnchecked ()
118
119
{
119
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
120
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
120
121
'value ' => '' ,
121
122
));
122
123
$ form ->submit (null );
@@ -127,7 +128,7 @@ public function testSubmitWithEmptyValueUnchecked()
127
128
128
129
public function testSubmitWithEmptyValueAndFalseUnchecked ()
129
130
{
130
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
131
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
131
132
'value ' => '' ,
132
133
));
133
134
$ form ->submit (false );
@@ -138,7 +139,7 @@ public function testSubmitWithEmptyValueAndFalseUnchecked()
138
139
139
140
public function testSubmitWithEmptyValueAndTrueChecked ()
140
141
{
141
- $ form = $ this ->factory ->create (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' , null , array (
142
+ $ form = $ this ->factory ->create (static :: TESTED_TYPE , null , array (
142
143
'value ' => '' ,
143
144
));
144
145
$ form ->submit (true );
@@ -162,7 +163,7 @@ function ($value) {
162
163
}
163
164
);
164
165
165
- $ form = $ this ->factory ->createBuilder (' Symfony\Component\Form\Extension\Core\Type\CheckboxType ' )
166
+ $ form = $ this ->factory ->createBuilder (static :: TESTED_TYPE )
166
167
->addModelTransformer ($ transformer )
167
168
->getForm ();
168
169
@@ -181,4 +182,9 @@ public function provideCustomModelTransformerData()
181
182
array ('unchecked ' , false ),
182
183
);
183
184
}
185
+
186
+ public function testSubmitNull ($ expected = null , $ norm = null , $ view = null )
187
+ {
188
+ parent ::testSubmitNull (false , false , null );
189
+ }
184
190
}
0 commit comments