[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)) {
|
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
|
// Remove all empty rows
|
||||||
|
@ -167,15 +167,14 @@ class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertFalse($this->form->has('2'));
|
$this->assertFalse($this->form->has('2'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function testPreSubmitDealsWithNoArrayOrTraversable()
|
||||||
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
|
|
||||||
*/
|
|
||||||
public function testPreSubmitRequiresArrayOrTraversable()
|
|
||||||
{
|
{
|
||||||
$data = 'no array or traversable';
|
$data = 'no array or traversable';
|
||||||
$event = new FormEvent($this->form, $data);
|
$event = new FormEvent($this->form, $data);
|
||||||
$listener = new ResizeFormListener('text', array(), false, false);
|
$listener = new ResizeFormListener('text', array(), false, false);
|
||||||
$listener->preSubmit($event);
|
$listener->preSubmit($event);
|
||||||
|
|
||||||
|
$this->assertFalse($this->form->has('1'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPreSubmitDealsWithNullData()
|
public function testPreSubmitDealsWithNullData()
|
||||||
|
Reference in New Issue
Block a user