Skip to content

Commit

Permalink
[Form] [EventListener] fixed sending non array data on submit to Resi…
Browse files Browse the repository at this point in the history
…zeListener
  • Loading branch information
BruceWouaigne authored and xabbuh committed Jun 26, 2015
1 parent 058bacd commit 0f185c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Expand Up @@ -101,7 +101,7 @@ public function preSubmit(FormEvent $event)
}

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
Expand Down
Expand Up @@ -167,15 +167,14 @@ public function testPreSubmitDoesNothingIfNotAllowAddNorAllowDelete()
$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()
Expand Down

0 comments on commit 0f185c9

Please sign in to comment.