Skip to content

Commit

Permalink
Collection fieldsets are dublicated when calling form bind two times,…
Browse files Browse the repository at this point in the history
… one more test to demonstrate regression since zendframework#5636
  • Loading branch information
thestanislav committed Apr 9, 2014
1 parent a50c36c commit 8fd40f9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/ZendTest/Form/Element/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,30 @@ public function testCreatesNewObjectsIfSpecified()
$this->assertNotSame($categories[1], $cat2);
}

public function testCreateExtraCollectionFieldsetOnMultipleBind()
{
$form = new \Zend\Form\Form();
$this->productFieldset->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods());
$form->add($this->productFieldset);
$form->setHydrator(new \Zend\Stdlib\Hydrator\ObjectProperty());

$product = new Product();
$categories = array(new \ZendTest\Form\TestAsset\Entity\Category(), new \ZendTest\Form\TestAsset\Entity\Category());
$product->setCategories($categories);

$market = new \StdClass();
$market->product = $product;

// this will pass the test
$form->bind($market);
$this->assertSame(count($categories), iterator_count($form->get('product')->get('categories')->getIterator()));

// this won't pass, but must
$form->bind($market);
$this->assertSame(count($categories), iterator_count($form->get('product')->get('categories')->getIterator()));

}

public function testExtractDefaultIsEmptyArray()
{
$collection = $this->form->get('fieldsets');
Expand Down

0 comments on commit 8fd40f9

Please sign in to comment.