From 81b73dc9e67ff3608f558ed286283381f120534c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 3 Sep 2010 09:56:52 +0200 Subject: [PATCH] [Form] fixed problem with PHPUnit mocks (ugly hack but it works for now) --- src/Symfony/Component/Form/FieldGroup.php | 5 ++++- src/Symfony/Component/Form/FieldInterface.php | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/FieldGroup.php b/src/Symfony/Component/Form/FieldGroup.php index dfa24b1627..794a0df6d5 100644 --- a/src/Symfony/Component/Form/FieldGroup.php +++ b/src/Symfony/Component/Form/FieldGroup.php @@ -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; } } diff --git a/src/Symfony/Component/Form/FieldInterface.php b/src/Symfony/Component/Form/FieldInterface.php index fc89f315a6..7be1824e43 100644 --- a/src/Symfony/Component/Form/FieldInterface.php +++ b/src/Symfony/Component/Form/FieldInterface.php @@ -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. *