diff --git a/src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php b/src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php index 299b93c274..4a7190ddb1 100644 --- a/src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php +++ b/src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php @@ -440,6 +440,14 @@ class PropertyPathTest extends \PHPUnit_Framework_TestCase new PropertyPath('property.$form'); } + /** + * @expectedException Symfony\Component\Form\Exception\InvalidPropertyPathException + */ + public function testInvalidPropertyPath_empty() + { + new PropertyPath(''); + } + /** * @expectedException Symfony\Component\Form\Exception\InvalidPropertyPathException */ diff --git a/src/Symfony/Component/Form/Util/PropertyPath.php b/src/Symfony/Component/Form/Util/PropertyPath.php index 8371b6f873..11769ff287 100644 --- a/src/Symfony/Component/Form/Util/PropertyPath.php +++ b/src/Symfony/Component/Form/Util/PropertyPath.php @@ -77,7 +77,7 @@ class PropertyPath implements \IteratorAggregate */ public function __construct($propertyPath) { - if (null === $propertyPath) { + if ('' === $propertyPath || null === $propertyPath) { throw new InvalidPropertyPathException('The property path must not be empty'); }