Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit afc40d9

Browse files
committed
Failing test for zendframework#6132 - form element manager calls init() on shared form elements multiple times
1 parent 8559caa commit afc40d9

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/ZendTest/Form/FormElementManagerTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,23 @@ public function testArrayOptionsCreationOptions()
104104
$this->assertEquals('element', $element->getName(), 'Invokable CNAME');
105105
$this->assertEquals('bar', $element->getLabel(), 'Specified options in array[options]');
106106
}
107+
108+
/**
109+
* @group 6132
110+
*/
111+
public function testSharedFormElementsAreNotInitializedMultipleTimes()
112+
{
113+
$element = $this->getMock('Zend\Form\Element', array('init'));
114+
115+
$element->expects($this->once())->method('init');
116+
117+
$this->manager->setFactory('sharedElement', function () use ($element) {
118+
return $element;
119+
});
120+
121+
$this->manager->setShared('sharedElement', true);
122+
123+
$this->manager->get('sharedElement');
124+
$this->manager->get('sharedElement');
125+
}
107126
}

0 commit comments

Comments
 (0)