@@ -44,7 +44,21 @@ abstract class AbstractRequestHandlerTest extends TestCase
44
44
45
45
protected function setUp (): void
46
46
{
47
- $ this ->serverParams = $ this ->getMockBuilder (ServerParams::class)->setMethods (['getNormalizedIniPostMaxSize ' , 'getContentLength ' ])->getMock ();
47
+ $ this ->serverParams = new class () extends ServerParams {
48
+ public $ contentLength ;
49
+ public $ postMaxSize = '' ;
50
+
51
+ public function getContentLength (): ?int
52
+ {
53
+ return $ this ->contentLength ;
54
+ }
55
+
56
+ public function getNormalizedIniPostMaxSize (): string
57
+ {
58
+ return $ this ->postMaxSize ;
59
+ }
60
+ };
61
+
48
62
$ this ->requestHandler = $ this ->getRequestHandler ();
49
63
$ this ->factory = Forms::createFormFactoryBuilder ()->getFormFactory ();
50
64
$ this ->request = null ;
@@ -310,14 +324,10 @@ public function testSubmitFileWithNamelessForm($method)
310
324
/**
311
325
* @dataProvider getPostMaxSizeFixtures
312
326
*/
313
- public function testAddFormErrorIfPostMaxSizeExceeded ($ contentLength , $ iniMax , $ shouldFail , array $ errorParams = [])
327
+ public function testAddFormErrorIfPostMaxSizeExceeded (? int $ contentLength , string $ iniMax , bool $ shouldFail , array $ errorParams = [])
314
328
{
315
- $ this ->serverParams ->expects ($ this ->once ())
316
- ->method ('getContentLength ' )
317
- ->willReturn ($ contentLength );
318
- $ this ->serverParams ->expects ($ this ->any ())
319
- ->method ('getNormalizedIniPostMaxSize ' )
320
- ->willReturn ($ iniMax );
329
+ $ this ->serverParams ->contentLength = $ contentLength ;
330
+ $ this ->serverParams ->postMaxSize = $ iniMax ;
321
331
322
332
$ options = ['post_max_size_message ' => 'Max {{ max }}! ' ];
323
333
$ form = $ this ->factory ->createNamed ('name ' , 'Symfony\Component\Form\Extension\Core\Type\TextType ' , null , $ options );
0 commit comments