55use Fazland \ApiPlatformBundle \Form \Extension \AutoSubmitRequestHandler ;
66use Symfony \Component \Form \RequestHandlerInterface ;
77use Symfony \Component \Form \Tests \Extension \HttpFoundation \HttpFoundationRequestHandlerTest ;
8- use Symfony \Component \HttpFoundation \Request ;
98
109class AutoSubmitRequestHandlerTest extends HttpFoundationRequestHandlerTest
1110{
@@ -22,22 +21,24 @@ protected function getRequestHandler(): RequestHandlerInterface
2221 */
2322 public function testDoNotSubmitFormWithEmptyNameIfNoFieldInRequest ($ method ): void
2423 {
25- $ form = $ this -> getMockForm ( '' , $ method );
26- $ form -> expects ( self :: any ())
27- -> method ( ' all ' )
28- -> will ( self :: returnValue ([
29- ' param1 ' => $ this -> getMockForm ( ' param1 ' ),
30- ' param2 ' => $ this -> getMockForm ( ' param2 ' ),
31- ]))
32- ;
33-
34- $ this -> setRequestData ( $ method , [ ' paramx ' => ' submitted value ' ] );
35-
36- $ form -> expects ( self :: once ())
37- -> method ( ' submit ' )
38- -> with ([ 'paramx ' => 'submitted value ' ], Request:: METHOD_PATCH !== $ method )
39- ;
24+ self :: markTestSkipped ( ' Not applicable to this request handler ' );
25+ }
26+
27+ /**
28+ * @dataProvider methodProvider
29+ */
30+ public function testDoSubmitFormWithEmptyNameIfNoFieldInRequest ( string $ method ): void
31+ {
32+ $ form = $ this -> createForm ( '' , $ method , true );
33+ $ form -> add ( $ this -> createForm ( ' param1 ' ) );
34+ $ form -> add ( $ this -> createForm ( ' param2 ' ));
35+
36+ $ this -> setRequestData ( $ method , [
37+ 'paramx ' => 'submitted value ' ,
38+ ]) ;
4039
4140 $ this ->requestHandler ->handleRequest ($ form , $ this ->request );
41+
42+ $ this ->assertTrue ($ form ->isSubmitted ());
4243 }
4344}
0 commit comments