/** * @dataProvider getPostMaxSizeFixtures */ public function testAddFormErrorIfPostMaxSizeExceeded($contentLength, $iniMax, $shouldFail, array $errorParams = array()) { $this->serverParams->expects($this->once()) ->method('getContentLength') ->will($this->returnValue($contentLength)); $this->serverParams->expects($this->any()) ->method('getNormalizedIniPostMaxSize') ->will($this->returnValue($iniMax)); $options = array('post_max_size_message' => 'Max {{ max }}!'); $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, $options); $this->setRequestData('POST', array(), array()); $this->requestHandler->handleRequest($form, $this->request); if ($shouldFail) { $error = new FormError($options['post_max_size_message'], null, $errorParams); $error->setOrigin($form); $this->assertEquals(array($error), iterator_to_array($form->getErrors())); $this->assertTrue($form->isSubmitted()); } else { $this->assertCount(0, $form->getErrors()); $this->assertFalse($form->isSubmitted()); } }
/** * @dataProvider methodExceptGetProvider */ public function testSubmitFileIfNoParam($method) { $form = $this->getMockForm('param1', $method); $file = $this->getMockFile(); $this->setRequestData($method, array('param1' => null), array('param1' => $file)); $form->expects($this->once())->method('submit')->with($file, 'PATCH' !== $method); $this->requestHandler->handleRequest($form, $this->request); }