[Form] Replace broken ServerParams mock
This commit is contained in:
parent
dffdc71adb
commit
77c2d69f19
@ -44,7 +44,21 @@ abstract class AbstractRequestHandlerTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->serverParams = $this->getMockBuilder(ServerParams::class)->setMethods(['getNormalizedIniPostMaxSize', 'getContentLength'])->getMock();
|
$this->serverParams = new class() extends ServerParams {
|
||||||
|
public $contentLength;
|
||||||
|
public $postMaxSize = '';
|
||||||
|
|
||||||
|
public function getContentLength(): ?int
|
||||||
|
{
|
||||||
|
return $this->contentLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNormalizedIniPostMaxSize(): string
|
||||||
|
{
|
||||||
|
return $this->postMaxSize;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$this->requestHandler = $this->getRequestHandler();
|
$this->requestHandler = $this->getRequestHandler();
|
||||||
$this->factory = Forms::createFormFactoryBuilder()->getFormFactory();
|
$this->factory = Forms::createFormFactoryBuilder()->getFormFactory();
|
||||||
$this->request = null;
|
$this->request = null;
|
||||||
@ -310,14 +324,10 @@ abstract class AbstractRequestHandlerTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider getPostMaxSizeFixtures
|
* @dataProvider getPostMaxSizeFixtures
|
||||||
*/
|
*/
|
||||||
public function testAddFormErrorIfPostMaxSizeExceeded($contentLength, $iniMax, $shouldFail, array $errorParams = [])
|
public function testAddFormErrorIfPostMaxSizeExceeded(?int $contentLength, string $iniMax, bool $shouldFail, array $errorParams = [])
|
||||||
{
|
{
|
||||||
$this->serverParams->expects($this->once())
|
$this->serverParams->contentLength = $contentLength;
|
||||||
->method('getContentLength')
|
$this->serverParams->postMaxSize = $iniMax;
|
||||||
->willReturn($contentLength);
|
|
||||||
$this->serverParams->expects($this->any())
|
|
||||||
->method('getNormalizedIniPostMaxSize')
|
|
||||||
->willReturn($iniMax);
|
|
||||||
|
|
||||||
$options = ['post_max_size_message' => 'Max {{ max }}!'];
|
$options = ['post_max_size_message' => 'Max {{ max }}!'];
|
||||||
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, $options);
|
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, $options);
|
||||||
|
Reference in New Issue
Block a user