Added a check to see if the type is a string if it's not a FormTypeInterface
This commit is contained in:
parent
e3421a0b1d
commit
d97d7e93c0
@ -225,8 +225,10 @@ class FormFactory implements FormFactoryInterface
|
||||
}
|
||||
|
||||
$this->addType($type);
|
||||
} else {
|
||||
} elseif (is_string($type)) {
|
||||
$type = $this->getType($type);
|
||||
} else {
|
||||
throw new UnexpectedTypeException($type, 'string or Symfony\Component\Form\FormTypeInterface');
|
||||
}
|
||||
|
||||
$defaultOptions = $type->getDefaultOptions($options);
|
||||
|
@ -320,6 +320,15 @@ class FormFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($this->factory->hasType('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\UnexpectedTypeException
|
||||
* @expectedExceptionMessage Expected argument of type "string or Symfony\Component\Form\FormTypeInterface", "stdClass" given
|
||||
*/
|
||||
public function testCreateNamedBuilderThrowsUnderstandableException()
|
||||
{
|
||||
$this->factory->createNamedBuilder(new \StdClass, 'name');
|
||||
}
|
||||
|
||||
public function testCreateUsesTypeNameAsName()
|
||||
{
|
||||
$type = new FooType();
|
||||
|
Reference in New Issue
Block a user