@@ -179,6 +179,59 @@ public function testMethodOverrideHeaderIgnoredIfNotPost()
179
179
$ this ->assertFalse ($ form ->isSubmitted ());
180
180
}
181
181
182
+ public function testFormIgnoresMethodFieldIfRequestMethodIsMatched ()
183
+ {
184
+ $ form = $ this ->createForm ('foo ' , 'PUT ' , true );
185
+ $ form ->add ($ this ->createForm ('bar ' ));
186
+
187
+ $ this ->setRequestData ('PUT ' , [
188
+ 'foo ' => [
189
+ '_method ' => 'PUT ' ,
190
+ 'bar ' => 'baz ' ,
191
+ ],
192
+ ]);
193
+
194
+ $ this ->requestHandler ->handleRequest ($ form , $ this ->request );
195
+
196
+ $ this ->assertSame ([], $ form ->getExtraData ());
197
+ }
198
+
199
+ public function testFormDoesNotIgnoreMethodFieldIfRequestMethodIsNotMatched ()
200
+ {
201
+ $ form = $ this ->createForm ('foo ' , 'PUT ' , true );
202
+ $ form ->add ($ this ->createForm ('bar ' ));
203
+
204
+ $ this ->setRequestData ('PUT ' , [
205
+ 'foo ' => [
206
+ '_method ' => 'DELETE ' ,
207
+ 'bar ' => 'baz ' ,
208
+ ],
209
+ ]);
210
+
211
+ $ this ->requestHandler ->handleRequest ($ form , $ this ->request );
212
+
213
+ $ this ->assertSame (['_method ' => 'DELETE ' ], $ form ->getExtraData ());
214
+ }
215
+
216
+ public function testMethodSubFormIsSubmitted ()
217
+ {
218
+ $ form = $ this ->createForm ('foo ' , 'PUT ' , true );
219
+ $ form ->add ($ this ->createForm ('_method ' ));
220
+ $ form ->add ($ this ->createForm ('bar ' ));
221
+
222
+ $ this ->setRequestData ('PUT ' , [
223
+ 'foo ' => [
224
+ '_method ' => 'PUT ' ,
225
+ 'bar ' => 'baz ' ,
226
+ ],
227
+ ]);
228
+
229
+ $ this ->requestHandler ->handleRequest ($ form , $ this ->request );
230
+
231
+ $ this ->assertTrue ($ form ->get ('_method ' )->isSubmitted ());
232
+ $ this ->assertSame ('PUT ' , $ form ->get ('_method ' )->getData ());
233
+ }
234
+
182
235
protected function setRequestData ($ method , $ data , $ files = [])
183
236
{
184
237
if ('GET ' === $ method ) {
0 commit comments