Issue Type: Bug Created: 2008-04-18T04:36:59.000+0000 Last Updated: 2008-09-02T10:39:19.000+0000 Status: Resolved Fix version(s): - 1.6.0 (02/Sep/08)
Reporter: Piotr Czachur (zimnyx) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Controller
Related issues: Attachments:
I have find this bug when writing unit tests. After resetting front controller, redirector helper still existed, with all redirection params set earlier. I had to manually reset redirector before every test.
In my opinion when resetting FrontControllers all helpers should be cleared too\ - this would help much in unit testing of controllers.
Posted by julien PAULI (doctorrock83) on 2008-04-18T07:28:03.000+0000
Zend_Controller_Action_HelperBroker::resetHelpers() should be called, yes
Posted by Wil Sinclair (wil) on 2008-04-18T13:16:14.000+0000
Please evaluate and categorize as necessary.
Posted by Piotr Czachur (zimnyx) on 2008-04-22T08:09:05.000+0000
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).
Posted by Matthew Weier O'Phinney (matthew) on 2008-04-22T13:15:23.000+0000
Scheduling for next minor release.
Posted by Matthew Weier O'Phinney (matthew) on 2008-07-15T12:51:02.000+0000
I've added a call to the helper broker's resetHelpers() method within Z_C_F's resetInstance(). Additionally, we now have the Zend_Test_PHPUnit_ControllerTestCase, which provides infrastructure for testing and solves most (if not all) issues reported.
Changes are current as of r10111.
Posted by Wil Sinclair (wil) on 2008-09-02T10:39:19.000+0000
Updating for the 1.6.0 release.
Have you found an issue?
See the Overview section for more details.