ZF-11589: PHP Fatal Error in Zend_Controller_Broker_PluginTest
Description
When running the Zend_Controller_Plugin test suite ({{./runtests.sh Controller_Plugin}}) I get the following error:
Starting test 'Zend_Controller_Plugin_BrokerTest::testBrokerCatchesExceptions'.
PHP Fatal error: Call to a member function setDispatched() on a non-object in /usr/local/apache2/htdocs/lib/zfdev/trunk/library/Zend/Controller/Plugin/Broker.php on line 316
Comments
Posted by Adam Lundrigan (adamlundrigan) on 2011-07-21T23:01:53.000+0000
In unit test {{Zend_Controller_Plugin_BrokerTest::testBrokerCatchesExceptions}}, the broker instance is only given the request object as a parameter to the hook methods (in this case, {{preDispatch}}), and not injected via {{setRequest}}. This causes {{Zend_Controller_Plugin_Broker::preDispatch}} to throw a PHP fatal error because it calls {{$this->getRequest()->setDispatched(false)}}:
and {{getRequest()}} returns null as {{setRequest}} wasn't given a request instance.
As I see it, there are two ways to fix this: 1. Fix the unit test: Inject {{$request}} via {{setRequest}}
(Yes, that line and comment above it are tabbed and not space-indented. That should be fixed)
Thoughts? Both options fix this specific issue, but which fix is best overall (ie: is this an implementation issue with the broker or a just a test construction issue?)
Posted by Mickael Perraud (mikaelkael) on 2011-07-28T21:58:08.000+0000
Fixed by r24295