[Form] fixed problem with PHPUnit mocks (ugly hack but it works for now)

This commit is contained in:
Fabien Potencier 2010-09-03 09:56:52 +02:00
parent 26e4b2e2ef
commit 81b73dc9e6
2 changed files with 11 additions and 1 deletions

View File

@ -59,7 +59,10 @@ class FieldGroup extends Field implements \IteratorAggregate, FieldGroupInterfac
{
foreach ($this->fields as $name => $field) {
$field = clone $field;
$field->setParent($this);
// this condition is only to "bypass" a PHPUnit bug with mocks
if (null !== $field->getParent()) {
$field->setParent($this);
}
$this->fields[$name] = $field;
}
}

View File

@ -36,6 +36,13 @@ interface FieldInterface extends Localizable, Translatable
*/
public function setParent(FieldInterface $parent = null);
/**
* Returns the parent field.
*
* @return FieldInterface The parent field
*/
public function getParent();
/**
* Sets the key by which the field is identified in field groups.
*