Forráskód Böngészése

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

Fabien Potencier 14 éve
szülő
commit
81b73dc9e6

+ 4 - 1
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;
         }
     }

+ 7 - 0
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.
      *