finished previous commit
This commit is contained in:
parent
953a3835a2
commit
e204913a67
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -345,18 +345,6 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testSetValueOnMultiValuedFieldsWithMalformedName()
|
||||
{
|
||||
$form = $this->createForm('<form><input type="text" name="foo[bar]" value="bar" /><input type="text" name="foo[baz]" value="baz" /><input type="submit" /></form>');
|
||||
|
||||
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('<form>
|
||||
@ -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><input type="text" name="[t:dbt%3adate;]data_daterange_enddate_value" value="bar" /><input type="submit" /></form>');
|
||||
$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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user