8000 [Form] Replace broken ServerParams mock · symfony/symfony@77c2d69 · GitHub
[go: up one dir, main page]

Skip to content

Commit 77c2d69

Browse files
committed
[Form] Replace broken ServerParams mock
1 parent dffdc71 commit 77c2d69

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,21 @@ abstract class AbstractRequestHandlerTest extends TestCase
4444

4545
protected function setUp(): void
4646
{
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+
4862
$this->requestHandler = $this->getRequestHandler();
4963
$this->factory = Forms::createFormFactoryBuilder()->getFormFactory();
5064
$this->request = null;
@@ -310,14 +324,10 @@ public function testSubmitFileWithNamelessForm($method)
310324
/**
311325
* @dataProvider getPostMaxSizeFixtures
312326
*/
313-
public function testAddFormErrorIfPostMaxSizeExceeded($contentLength, $iniMax, $shouldFail, array $errorParams = [])
327+
public function testAddFormErrorIfPostMaxSizeExceeded(?int $contentLength, string $iniMax, bool $shouldFail, array $errorParams = [])
314328
{
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;
321331

322332
$options = ['post_max_size_message' => 'Max {{ max }}!'];
323333
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, $options);

0 commit comments

Comments
 (0)
0