bug #15117 [Form] fixed sending non array data on submit to ResizeListener (BruceWouaigne)

This PR was merged into the 2.3 branch.

Discussion
----------

[Form] fixed sending non array data on submit to ResizeListener

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #13804, #13851
| License       | MIT
| Doc PR        |

I agree with @Tobion that #13851 is a bug fix and therefore should be applied on the `2.3` branch too.

Commits
-------

0f185c9 [Form] [EventListener] fixed sending non array data on submit to ResizeListener
This commit is contained in:
Fabien Potencier 2015-06-27 16:14:07 +02:00
commit 3ef7a1f6d6
2 changed files with 4 additions and 5 deletions

View File

@ -101,7 +101,7 @@ class ResizeFormListener implements EventSubscriberInterface
}
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
$data = array();
}
// Remove all empty rows

View File

@ -167,15 +167,14 @@ class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($this->form->has('2'));
}
/**
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
*/
public function testPreSubmitRequiresArrayOrTraversable()
public function testPreSubmitDealsWithNoArrayOrTraversable()
{
$data = 'no array or traversable';
$event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, false);
$listener->preSubmit($event);
$this->assertFalse($this->form->has('1'));
}
public function testPreSubmitDealsWithNullData()