public function forceExit() { if (APPLICATION_ENV != "testing") { Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true); } $plugins = Zend_Controller_Front::getInstance()->getPlugins(); $broker = new Zend_Controller_Plugin_Broker(); $broker->setRequest(Zend_Controller_Front::getInstance()->getRequest()); $broker->setResponse(Zend_Controller_Front::getInstance()->getResponse()); foreach ($plugins as $index => $plugin) { $broker->registerPlugin($plugin, $index); } try { $broker->postDispatch($broker->getRequest()); } catch (Exception $e) { \App::log()->crit('Error executing "postDispatch" after stream'); \App::log()->crit($e); } try { $broker->dispatchLoopShutdown(); } catch (Exception $e) { \App::log()->crit('Error executing "dispatchLoopShutdown" after stream'); \App::log()->crit($e); } if (APPLICATION_ENV !== 'testing') { exit; } }
/** * Test for ZF-2305 * @return void */ public function testRegisterPluginSetsRequestAndResponse() { $broker = new Zend_Controller_Plugin_Broker(); $request = new Zend_Controller_Request_Simple(); $response = new Zend_Controller_Response_Cli(); $broker->setRequest($request); $broker->setResponse($response); $plugin = new Zend_Controller_Plugin_BrokerTest_TestPlugin(); $broker->registerPlugin($plugin); $this->assertSame($request, $plugin->getRequest()); $this->assertSame($response, $plugin->getResponse()); }
public function testBrokerCatchesExceptions() { $request = new Zend_Controller_Request_Http('http://framework.zend.com/empty'); $response = new Zend_Controller_Response_Cli(); $broker = new Zend_Controller_Plugin_Broker(); $broker->setResponse($response); $broker->registerPlugin(new Zend_Controller_Plugin_BrokerTest_ExceptionTestPlugin()); try { $broker->routeStartup($request); $broker->routeShutdown($request); $broker->dispatchLoopStartup($request); $broker->preDispatch($request); $broker->postDispatch($request); $broker->dispatchLoopShutdown(); } catch (Exception $e) { $this->fail('Broker should catch exceptions'); } $this->assertTrue($response->hasExceptionOfMessage('routeStartup triggered exception')); $this->assertTrue($response->hasExceptionOfMessage('routeShutdown triggered exception')); $this->assertTrue($response->hasExceptionOfMessage('dispatchLoopStartup triggered exception')); $this->assertTrue($response->hasExceptionOfMessage('preDispatch triggered exception')); $this->assertTrue($response->hasExceptionOfMessage('postDispatch triggered exception')); $this->assertTrue($response->hasExceptionOfMessage('dispatchLoopShutdown triggered exception')); }