@@ -56,43 +56,42 @@ protected function getExtensions()
56
56
));
57
57
}
58
58
59
- public function testCsrfProtectionByDefaultIfRootAndChildren ()
59
+ public function testCsrfProtectionByDefaultIfRootAndNotPrimitive ()
60
60
{
<
57AE
/code>
61
61
$ view = $ this ->factory
62
- ->createBuilder ('form ' , null , array (
62
+ ->create ('form ' , null , array (
63
63
'csrf_field_name ' => 'csrf ' ,
64
+ 'primitive ' => false ,
64
65
))
65
- ->add ($ this ->factory ->createNamedBuilder ('form ' , 'child ' ))
66
- ->getForm ()
67
66
->createView ();
68
67
69
68
$ this ->assertTrue ($ view ->hasChild ('csrf ' ));
70
69
}
71
70
72
- public function testNoCsrfProtectionByDefaultIfChildrenButNotRoot ()
71
+ public function testNoCsrfProtectionByDefaultIfNotPrimitiveButNotRoot ()
73
72
{
74
73
$ view = $ this ->factory
75
74
->createNamedBuilder ('form ' , 'root ' )
76
75
->add ($ this ->factory
77
76
->createNamedBuilder ('form ' , 'form ' , null , array (
78
77
'csrf_field_name ' => 'csrf ' ,
78
+ 'primitive ' => false ,
79
79
))
80
- ->add ($ this ->factory ->createNamedBuilder ('form ' , 'child ' ))
81
80
)
82
81
->getForm ()
83
- ->get ( ' form ' )
84
- ->createView ( );
82
+ ->createView ( )
83
+ ->getChild ( ' form ' );
85
84
86
85
$ this ->assertFalse ($ view ->hasChild ('csrf ' ));
87
86
}
88
87
89
- public function testNoCsrfProtectionByDefaultIfRootButNoChildren ()
88
+ public function testNoCsrfProtectionByDefaultIfRootButPrimitive ()
90
89
{
91
90
$ view = $ this ->factory
92
- ->createBuilder ('form ' , null , array (
91
+ ->create ('form ' , null , array (
93
92
'csrf_field_name ' => 'csrf ' ,
93
+ 'primitive ' => true ,
94
94
))
95
- ->getForm ()
96
95
->createView ();
97
96
98
97
$ this ->assertFalse ($ view ->hasChild ('csrf ' ));
@@ -101,12 +100,11 @@ public function testNoCsrfProtectionByDefaultIfRootButNoChildren()
101
100
public function testCsrfProtectionCanBeDisabled ()
102
101
{
103
102
$ view = $ this ->factory
104
- ->createBuilder ('form ' , null , array (
103
+ ->create ('form ' , null , array (
105
104
'csrf_field_name ' => 'csrf ' ,
106
105
'csrf_protection ' => false ,
106
+ 'primitive ' => false ,
107
107
))
108
- ->add ($ this ->factory ->createNamedBuilder ('form ' , 'child ' ))
109
- ->getForm ()
110
108
->createView ();
111
109
112
110
$ this ->assertFalse ($ view ->hasChild ('csrf ' ));
@@ -120,13 +118,12 @@ public function testGenerateCsrfToken()
120
118
->will ($ this ->returnValue ('token ' ));
121
119
122
120
$ view = $ this ->factory
123
- ->createBuilder ('form ' , null , array (
121
+ ->create ('form ' , null , array (
124
122
'csrf_field_name ' => 'csrf ' ,
125
123
'csrf_provider ' => $ this ->csrfProvider ,
126
- 'intention ' => '%INTENTION% '
124
+ 'intention ' => '%INTENTION% ' ,
125
+ 'primitive ' => false ,
127
126
))
128
- ->add ($ this ->factory ->createNamedBuilder ('form ' , 'child ' ))
129
- ->getForm ()
130
127
->createView ();
131
128
132
129
$ this ->assertEquals ('token ' , $ view ->getChild ('csrf ' )->get ('value ' ));
@@ -143,21 +140,20 @@ public function provideBoolean()
143
140
/**
144
141
* @dataProvider provideBoolean
145
142
*/
146
- public function testValidateTokenOnBindIfRootAndChildren ($ valid )
143
+ public function testValidateTokenOnBindIfRootAndNotPrimitive ($ valid )
147
144
{
148
145
$ this ->csrfProvider ->expects ($ this ->once ())
149
146
->method ('isCsrfTokenValid ' )
150
147
->with ('%INTENTION% ' , 'token ' )
151
148
->will ($ this ->returnValue ($ valid ));
152
149
153
150
$ form = $ this ->factory
154
- ->createBuilder ('form ' , null , array (
151
+ ->create ('form ' , null , array (
155
152
'csrf_field_name ' => 'csrf ' ,
156
153
'csrf_provider ' => $ this ->csrfProvider ,
157
- 'intention ' => '%INTENTION% '
158
- ))
159
- ->add ($ this ->factory ->createNamedBuilder ('form ' , 'child ' ))
160
- ->getForm ();
154
+ 'intention ' => '%INTENTION% ' ,
155
+ 'primitive ' => false ,
156
+ ));
161
157
162
158
$ form ->bind (array (
163
159
'child ' => 'foobar ' ,
@@ -171,19 +167,18 @@ public function testValidateTokenOnBindIfRootAndChildren($valid)
171
167
$ this ->assertSame ($ valid , $ form ->isValid ());
172
168
}
173
169
174
- public function testFailIfRootAndChildrenAndTokenMissing ()
170
+ public function testFailIfRootAndNotPrimitiveAndTokenMissing ()
175
171
{
176
172
$ this ->csrfProvider ->expects ($ this ->never ())
177
173
->method ('isCsrfTokenValid ' );
178
174
179
175
$ form = $ this ->factory
180
- ->createBuilder ('form ' , null , array (
176
+ ->create ('form ' , null , array (
181
177
'csrf_field_name ' => 'csrf ' ,
182
178
'csrf_provider ' => $ this ->csrfProvider ,
183
- 'intention ' => '%INTENTION% '
184
- ))
185
- ->add ($ this ->factory ->createNamedBuilder ('form ' , 'child ' ))
186
- ->getForm ();
179
+ 'intention ' => '%INTENTION% ' ,
180
+ 'primitive ' => false ,
181
+ ));
187
182
188
183
$ form ->bind (array (
189
184
'child ' => 'foobar ' ,
@@ -197,7 +192,7 @@ public function testFailIfRootAndChildrenAndTokenMissing()
197
192
$ this ->assertFalse ($ form ->isValid ());
198
193
}
199
194
200
- public function testDontValidateTokenIfChildrenButNoRoot ()
195
+ public function testDontValidateTokenIfNotPrimitiveButNoRoot ()
201
196
{
202
197
$ this ->csrfProvider ->expects ($ this ->never ())
203
198
->method ('isCsrfTokenValid ' );
@@ -208,9 +203,9 @@ public function testDontValidateTokenIfChildrenButNoRoot()
208
203
->createNamedBuilder ('form ' , 'form ' , null , array (
209
204
'csrf_field_name ' => 'csrf ' ,
210
205
'csrf_provider ' => $ this ->csrfProvider ,
211
- 'intention ' => '%INTENTION% '
206
+ 'intention ' => '%INTENTION% ' ,
207
+ 'primitive ' => false ,
212
208
))
213
- ->add ($ this ->factory ->createNamedBuilder ('form ' , 'child ' ))
214
209
)
215
210
->getForm ()
216
211
->get ('form ' );
@@ -221,18 +216,18 @@ public function testDontValidateTokenIfChildrenButNoRoot()
221
216
));
222
217
}
223
218
224
- public function testDontValidateTokenIfRootButNoChildren ()
219
+ public function testDontValidateTokenIfRootButPrimitive ()
225
220
{
226
221
$ this ->csrfProvider ->expects ($ this ->never ())
227
222
->method ('isCsrfTokenValid ' );
228
223
229
224
$ form = $ this ->factory
230
- ->createBuilder ('form ' , null , array (
225
+ ->create ('form ' , null , array (
231
226
'csrf_field_name ' => 'csrf ' ,
232
227
'csrf_provider ' => $ this ->csrfProvider ,
233
- 'intention ' => '%INTENTION% '
234
- ))
235
- -> getForm ( );
228
+ 'intention ' => '%INTENTION% ' ,
229
+ ' primitive ' => true ,
230
+ ) );
236
231
237
232
$ form ->bind (array (
238
233
'csrf ' => 'token ' ,
0 commit comments