From afc40d9dd13c95f4aad90bd09a4ecdd334b3bc5d Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 14 Apr 2014 18:04:10 +0200 Subject: [PATCH] Failing test for #6132 - form element manager calls `init()` on shared form elements multiple times --- .../ZendTest/Form/FormElementManagerTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/ZendTest/Form/FormElementManagerTest.php b/tests/ZendTest/Form/FormElementManagerTest.php index 315ac86fc5e..dd2f277d636 100644 --- a/tests/ZendTest/Form/FormElementManagerTest.php +++ b/tests/ZendTest/Form/FormElementManagerTest.php @@ -104,4 +104,23 @@ public function testArrayOptionsCreationOptions() $this->assertEquals('element', $element->getName(), 'Invokable CNAME'); $this->assertEquals('bar', $element->getLabel(), 'Specified options in array[options]'); } + + /** + * @group 6132 + */ + public function testSharedFormElementsAreNotInitializedMultipleTimes() + { + $element = $this->getMock('Zend\Form\Element', array('init')); + + $element->expects($this->once())->method('init'); + + $this->manager->setFactory('sharedElement', function () use ($element) { + return $element; + }); + + $this->manager->setShared('sharedElement', true); + + $this->manager->get('sharedElement'); + $this->manager->get('sharedElement'); + } }