/** * Rejects activation if exit() as it leads to untestable code. * * @param boolean $flag * @return Mol_Test_Controller_Action_Helper_Redirector Provides a fluent interface. * @throws Mol_Test_Exception If method is called to activate exit behavior. */ public function setExit($flag) { if ($flag) { $message = __METHOD__ . '(): Do not force calls to exit() as these will terminate ' . 'the whole test run and therefore make the code untestable.'; throw new Mol_Test_Exception($message); } return parent::setExit($flag); }
private function performRedirect($action, $message = null, $controller = null, $module = null, $params = array(), $exit = false) { if (!is_null($message)) { if (is_array($message) && count($message) !== 0) { $keys = array_keys($message); $key = $keys[0]; if ($key === 'failure' || $key === 'notice') { $this->_flashMessenger->addMessage(array('level' => $key, 'message' => $message[$key])); } else { $this->_flashMessenger->addMessage(array('level' => 'notice', 'message' => $message[$key])); } } else { if (is_string($message) && $message != '') { $this->_flashMessenger->addMessage(array('level' => 'notice', 'message' => $message)); } } } $this->getLogger()->debug("redirect to module: {$module} controller: {$controller} action: {$action}"); $this->_redirector->gotoSimple($action, $controller, $module, $params); $this->_redirector->setExit($exit); return; }
public function testExit() { $this->assertFalse($this->redirector->getExit()); $this->redirector->setExit(true); $this->assertTrue($this->redirector->getExit()); }