[Form] added tests for previous merge

This commit is contained in:
Fabien Potencier 2011-09-27 10:12:54 +02:00
parent 3ad395c74c
commit 9b37637184
2 changed files with 22 additions and 0 deletions

View File

@ -42,6 +42,7 @@ To get the diff between two versions, go to https://github.com/symfony/symfony/c
### Form
* added Form::getErrorsAsString() to help debugging forms
* allowed setting different options for RepeatedType fields (like the label)
### HttpFoundation

View File

@ -1003,6 +1003,27 @@ class FormTest extends \PHPUnit_Framework_TestCase
$this->assertSame($parent, $view->getParent());
}
public function testGetErrorsAsString()
{
$form = $this->getBuilder()->getForm();
$form->addError(new FormError('Error!'));
$this->assertEquals("ERROR: Error!\n", $form->getErrorsAsString());
}
public function testGetErrorsAsStringDeep()
{
$form = $this->getBuilder()->getForm();
$form->addError(new FormError('Error!'));
$parent = $this->getBuilder()->getForm();
$parent->add($form);
$parent->add($this->getBuilder('foo')->getForm());
$this->assertEquals("name:\n ERROR: Error!\nfoo:\n No errors\n", $parent->getErrorsAsString());
}
protected function getBuilder($name = 'name', EventDispatcherInterface $dispatcher = null)
{
return new FormBuilder($name, $this->factory, $dispatcher ?: $this->dispatcher);