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.
|
* Removes a field from the form.
|
||||||
*
|
*
|
||||||
* @param string $name The field name
|
* @param string $name The field name
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException when the name is malformed
|
|
||||||
*/
|
*/
|
||||||
public function remove($name)
|
public function remove($name)
|
||||||
{
|
{
|
||||||
|
@ -26,8 +26,6 @@ class FormFieldRegistry
|
|||||||
* Adds a field to the registry.
|
* Adds a field to the registry.
|
||||||
*
|
*
|
||||||
* @param FormField $field The field
|
* @param FormField $field The field
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException when the name is malformed
|
|
||||||
*/
|
*/
|
||||||
public function add(FormField $field)
|
public function add(FormField $field)
|
||||||
{
|
{
|
||||||
@ -52,8 +50,6 @@ class FormFieldRegistry
|
|||||||
* Removes a field and its children from the registry.
|
* Removes a field and its children from the registry.
|
||||||
*
|
*
|
||||||
* @param string $name The fully qualified name of the base field
|
* @param string $name The fully qualified name of the base field
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException when the name is malformed
|
|
||||||
*/
|
*/
|
||||||
public function remove($name)
|
public function remove($name)
|
||||||
{
|
{
|
||||||
@ -76,7 +72,6 @@ class FormFieldRegistry
|
|||||||
*
|
*
|
||||||
* @return mixed The value of the field
|
* @return mixed The value of the field
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException when the name is malformed
|
|
||||||
* @throws \InvalidArgumentException if the field does not exist
|
* @throws \InvalidArgumentException if the field does not exist
|
||||||
*/
|
*/
|
||||||
public function &get($name)
|
public function &get($name)
|
||||||
@ -118,7 +113,6 @@ class FormFieldRegistry
|
|||||||
* @param string $name The fully qualified name of the field
|
* @param string $name The fully qualified name of the field
|
||||||
* @param mixed $value The value
|
* @param mixed $value The value
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException when the name is malformed
|
|
||||||
* @throws \InvalidArgumentException if the field does not exist
|
* @throws \InvalidArgumentException if the field does not exist
|
||||||
*/
|
*/
|
||||||
public function set($name, $value)
|
public function set($name, $value)
|
||||||
@ -199,8 +193,6 @@ class FormFieldRegistry
|
|||||||
* @param string $name The name of the field
|
* @param string $name The name of the field
|
||||||
*
|
*
|
||||||
* @return string[] The list of segments
|
* @return string[] The list of segments
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException when the name is malformed
|
|
||||||
*/
|
*/
|
||||||
private function getSegments($name)
|
private function getSegments($name)
|
||||||
{
|
{
|
||||||
@ -218,6 +210,6 @@ class FormFieldRegistry
|
|||||||
return $segments;
|
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()
|
public function testDisableValidation()
|
||||||
{
|
{
|
||||||
$form = $this->createForm('<form>
|
$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');
|
$this->assertTrue($form->has('example.y'), '->has() returns true if the image input was correctly turned into an x and a y fields');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function testFormFieldRegistryAcceptAnyNames()
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testFormFieldRegistryAddThrowAnExceptionWhenTheNameIsMalformed()
|
|
||||||
{
|
{
|
||||||
$registry = new FormFieldRegistry();
|
$field = $this->getFormFieldMock('[t:dbt%3adate;]data_daterange_enddate_value');
|
||||||
$registry->add($this->getFormFieldMock('[foo]'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testFormFieldRegistryRemoveThrowAnExceptionWhenTheNameIsMalformed()
|
|
||||||
{
|
|
||||||
$registry = new FormFieldRegistry();
|
$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);
|
||||||
|
|
||||||
/**
|
$form = $this->createForm('<form><input type="text" name="[t:dbt%3adate;]data_daterange_enddate_value" value="bar" /><input type="submit" /></form>');
|
||||||
* @expectedException \InvalidArgumentException
|
$form['[t:dbt%3adate;]data_daterange_enddate_value'] = 'bar';
|
||||||
*/
|
|
||||||
public function testFormFieldRegistryGetThrowAnExceptionWhenTheNameIsMalformed()
|
$registry->remove('[t:dbt%3adate;]data_daterange_enddate_value');
|
||||||
{
|
|
||||||
$registry = new FormFieldRegistry();
|
|
||||||
$registry->get('[foo]');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -717,15 +693,6 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
|||||||
$registry->get('foo');
|
$registry->get('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testFormFieldRegistrySetThrowAnExceptionWhenTheNameIsMalformed()
|
|
||||||
{
|
|
||||||
$registry = new FormFieldRegistry();
|
|
||||||
$registry->set('[foo]', null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \InvalidArgumentException
|
* @expectedException \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user