It's a larger and more complicated issue...
I have meet many issues concerning unit testing and static variables in plugins/helpers/etc that will perstist after executing Zend_Controller_Front::resetInstance() or Zend_Controller_Action_HelperBroker::resetHelpers(); which can in some situations return outdated data or behave in unexpectable way.
For example (unit testing):
My application is using Zend_Layout.
// test #1 starts here
When Zend_Layout::startMvc(array()) is called for the first time it will :
- create sigleton instance
- register Zend_Layout_Controller_Plugin_Layout in front controller
- register helper Zend_Layout_Controller_Action_Helper_Layout
So far everything wotks brilliant....
Lets say I start next test from PHPUnit test suite, bu t before I do it I call $front->resetInstance() and Zend_Controller_Action_HelperBroker::resetHelpers(); to reset environment.
After this I will launch code which will set up front controller from scratch, just like was done when application was started.
Zend_Layout::startMvc(array()) will be launched again, but Zend_Layout will notice that its singleton was already instantiated, so it won't register Zend_Layout_Controller_Plugin_Layout in front controller anymore.
// test #2 starts here
When secont unittest will be starter, there will be no Zend_Layout_Controller_Plugin_Layout plugin registered in front controller - it's not what we would expect.
There are similar issues with other plugins and helpers, I wonder wheter to file similar bugs or on generic called "Unit testing, ZF - unable to reset environment completely".
What's your feelings about this issue?
PS.
Running unit tests as separate processes would resolve my problems but so far it's not possible with PHPUnit (this functionality is in unstable branch).
Zend_Controller_Action_HelperBroker::resetHelpers() should be called, yes