[Form] [EventListener] fixed sending non array data on submit to ResizeListener
This commit is contained in:
parent
04ae391318
commit
74d794b6e4
|
@ -107,7 +107,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
|
||||
|
|
|
@ -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()
|
||||
|
|
Reference in New Issue