diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index c9c3c139b1..78dacaa417 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -246,8 +246,6 @@ class Form extends Link implements \ArrayAccess * Removes a field from the form. * * @param string $name The field name - * - * @throws \InvalidArgumentException when the name is malformed */ public function remove($name) { diff --git a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php index 97bdacd6bf..dbd08ff720 100644 --- a/src/Symfony/Component/DomCrawler/FormFieldRegistry.php +++ b/src/Symfony/Component/DomCrawler/FormFieldRegistry.php @@ -26,8 +26,6 @@ class FormFieldRegistry * Adds a field to the registry. * * @param FormField $field The field - * - * @throws \InvalidArgumentException when the name is malformed */ public function add(FormField $field) { @@ -52,8 +50,6 @@ class FormFieldRegistry * Removes a field and its children from the registry. * * @param string $name The fully qualified name of the base field - * - * @throws \InvalidArgumentException when the name is malformed */ public function remove($name) { @@ -76,7 +72,6 @@ class FormFieldRegistry * * @return mixed The value of the field * - * @throws \InvalidArgumentException when the name is malformed * @throws \InvalidArgumentException if the field does not exist */ public function &get($name) @@ -118,7 +113,6 @@ class FormFieldRegistry * @param string $name The fully qualified name of the field * @param mixed $value The value * - * @throws \InvalidArgumentException when the name is malformed * @throws \InvalidArgumentException if the field does not exist */ public function set($name, $value) @@ -199,8 +193,6 @@ class FormFieldRegistry * @param string $name The name of the field * * @return string[] The list of segments - * - * @throws \InvalidArgumentException when the name is malformed */ private function getSegments($name) { @@ -218,6 +210,6 @@ class FormFieldRegistry return $segments; } - return [$name]; + return array($name); } } diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 5bfbfb9824..3035e8d371 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -345,18 +345,6 @@ class FormTest extends \PHPUnit_Framework_TestCase } } - public function testSetValueOnMultiValuedFieldsWithMalformedName() - { - $form = $this->createForm('
'); - - try { - $form['foo[bar'] = 'bar'; - $this->fail('->offsetSet() throws an \InvalidArgumentException exception if the name is malformed.'); - } catch (\InvalidArgumentException $e) { - $this->assertTrue(true, '->offsetSet() throws an \InvalidArgumentException exception if the name is malformed.'); - } - } - public function testDisableValidation() { $form = $this->createForm('
@@ -681,31 +669,19 @@ class FormTest extends \PHPUnit_Framework_TestCase $this->assertTrue($form->has('example.y'), '->has() returns true if the image input was correctly turned into an x and a y fields'); } - /** - * @expectedException \InvalidArgumentException - */ - public function testFormFieldRegistryAddThrowAnExceptionWhenTheNameIsMalformed() + public function testFormFieldRegistryAcceptAnyNames() { - $registry = new FormFieldRegistry(); - $registry->add($this->getFormFieldMock('[foo]')); - } + $field = $this->getFormFieldMock('[t:dbt%3adate;]data_daterange_enddate_value'); - /** - * @expectedException \InvalidArgumentException - */ - public function testFormFieldRegistryRemoveThrowAnExceptionWhenTheNameIsMalformed() - { $registry = new FormFieldRegistry(); - $registry->remove('[foo]'); - } + $registry->add($field); + $this->assertEquals($field, $registry->get('[t:dbt%3adate;]data_daterange_enddate_value')); + $registry->set('[t:dbt%3adate;]data_daterange_enddate_value', null); - /** - * @expectedException \InvalidArgumentException - */ - public function testFormFieldRegistryGetThrowAnExceptionWhenTheNameIsMalformed() - { - $registry = new FormFieldRegistry(); - $registry->get('[foo]'); + $form = $this->createForm('
'); + $form['[t:dbt%3adate;]data_daterange_enddate_value'] = 'bar'; + + $registry->remove('[t:dbt%3adate;]data_daterange_enddate_value'); } /** @@ -717,15 +693,6 @@ class FormTest extends \PHPUnit_Framework_TestCase $registry->get('foo'); } - /** - * @expectedException \InvalidArgumentException - */ - public function testFormFieldRegistrySetThrowAnExceptionWhenTheNameIsMalformed() - { - $registry = new FormFieldRegistry(); - $registry->set('[foo]', null); - } - /** * @expectedException \InvalidArgumentException */