8000 finished previous commit · symfony/symfony@e204913 · GitHub
[go: up one dir, main page]

Skip to content

Commit e204913

Browse files
committed
finished previous commit
1 parent 953a383 commit e204913

File tree

3 files changed

+10
-53
lines changed

3 files changed

+10
-53
lines changed

src/Symfony/Component/DomCrawler/Form.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,6 @@ public function has($name)
246246
* Removes a field from the form.
247247
*
248248
* @param string $name The field name
249-
*
250-
* @throws \InvalidArgumentException when the name is malformed
251249
*/
252250
public function remove($name)
253251
{

src/Symfony/Component/DomCrawler/FormFieldRegistry.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ class FormFieldRegistry
2626
* Adds a field to the registry.
2727
*
2828
* @param FormField $field The field
29-
*
30-
* @throws \InvalidArgumentException when the name is malformed
3129
*/
3230
public function add(FormField $field)
3331
{
@@ -52,8 +50,6 @@ public function add(FormField $field)
5250
* Removes a field and its children from the registry.
5351
*
5452
* @param string $name The fully qualified name of the base field
55-
*
56-
* @throws \InvalidArgumentException when the name is malformed
5753
*/
5854
public function remove($name)
5955
{
@@ -76,7 +72,6 @@ public function remove($name)
7672
*
7773
* @return mixed The value of the field
7874
*
79-
* @throws \InvalidArgumentException when the name is malformed
8075
* @throws \InvalidArgumentException if the field does not exist
8176
*/
8277
public function &get($name)
@@ -118,7 +113,6 @@ public function has($name)
118113
* @param string $name The fully qualified name of the field
119114
* @param mixed $value The value
120115
*
121-
* @throws \InvalidArgumentException when the name is malformed
122116
* @throws \InvalidArgumentException if the field does not exist
123117
*/
124118
public function set($name, $value)
@@ -199,8 +193,6 @@ private function walk(array $array, $base = '', array &$output = array())
199193
* @param string $name The name of the field
200194
*
201195
* @return string[] The list of segments
202-
*
203-
* @throws \InvalidArgumentException when the name is malformed
204196
*/
205197
private function getSegments($name)
206198
{
@@ -218,6 +210,6 @@ private function getSegments($name)
218210
return $segments;
219211
}
220212

221-
return [$name];
213+
return array($name);
222214
}
223215
}

src/Symfony/Component/DomCrawler/Tests/FormTest.php

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -345,18 +345,6 @@ public function testGetSetValue()
345345
}
346346
}
347347

348-
public function testSetValueOnMultiValuedFieldsWithMalformedName()
349-
{
350-
$form = $this->createForm('<form><input type="text" name="foo[bar]" value="bar" /><input type="text" name="foo[baz]" value="baz" /><input type="submit" /></form>');
351-
352-
try {
353-
$form['foo[bar'] = 'bar';
354-
$this->fail('->offsetSet() throws an \InvalidArgumentException exception if the name is malformed.');
355-
} catch (\InvalidArgumentException $e) {
356-
$this->assertTrue(true, '->offsetSet() throws an \InvalidArgumentException exception if the name is malformed.');
357-
}
358-
}
359-
360348
public function testDisableValidation()
361349
{
362350
$form = $this->createForm('<form>
@@ -681,31 +669,19 @@ public function testTypeAttributeIsCaseInsensitive()
681669
$this->assertTrue($form->has('example.y'), '->has() returns true if the image input was correctly turned into an x and a y fields');
682670
}
683671

684-
/**
685-
* @expectedException \InvalidArgumentException
686-
*/
687-
public function testFormFieldRegistryAddThrowAnExceptionWhenTheNameIsMalformed()
672+
public function testFormFieldRegistryAcceptAnyNames()
688673
{
689-
$registry = new FormFieldRegistry();
690-
$registry->add($this->getFormFieldMock('[foo]'));
691-
}
674+
$field = $this->getFormFieldMock('[t:dbt%3adate;]data_daterange_enddate_value');
692675

693-
/**
694-
* @expectedException \InvalidArgumentException
695-
*/
696-
public function testFormFieldRegistryRemoveThrowAnExceptionWhenTheNameIsMalformed()
697-
{
698676
$registry = new FormFieldRegistry();
699-
$registry->remove('[foo]');
700-
}
677+
$registry->add($field);
678+
$this->assertEquals($field, $registry->get('[t:dbt%3adate;]data_daterange_enddate_value'));
679+
$registry->set('[t:dbt%3adate;]data_daterange_enddate_value', null);
701680

702-
/**
703-
* @expectedException \InvalidArgumentException
704-
*/
705-
public function testFormFieldRegistryGetThrowAnExceptionWhenTheNameIsMalformed()
706-
{
707-
$registry = new FormFieldRegistry();
708-
$registry->get('[foo]');
681+
$form = $this->createForm('<form><input type="text" name="[t:dbt%3adate;]data_daterange_enddate_value" value="bar" /><input type="submit" /></form>');
682+
$form['[t:dbt%3adate;]data_daterange_enddate_value'] = 'bar';
683+
684+
$registry->remove('[t:dbt%3adate;]data_daterange_enddate_value');
709685
}
710686

711687
/**
@@ -717,15 +693,6 @@ public function testFormFieldRegistryGetThrowAnExceptionWhenTheFieldDoesNotExist
717693
$registry->get('foo');
718694
}
719695

720-
/**
721-
* @expectedException \InvalidArgumentException
722-
*/
723-
public function testFormFieldRegistrySetThrowAnExceptionWhenTheNameIsMalformed()
724-
{
725-
$registry = new FormFieldRegistry();
726-
$registry->set('[foo]', null);
727-
}
728-
729696
/**
730697
* @expectedException \InvalidArgumentException
731698
*/

0 commit comments

Comments
 (0)
0