Hola,
estoy intentando testear el siguiente action helper
Código PHP:
Ver originalclass My_Helper_Message extends Zend_Controller_Action_Helper_Abstract
{
/**
* sets message and redirect to message view
*
* @param string $type Message type
* @param string $description Message description
* @param string $autorefresh OPTIONAL Autorefresh URL
* @param array $links OPTIONAL Links array. Each link should have label and href
* @param string $title OPTIONAL Title
* @return void
*/
public function setMessageAndRedirect($type,
$description,
$autorefresh = null,
$title = null)
{
$translate = Zend_Registry::get('translate');
$session = new Zend_Session_Namespace('message');
$session->type = $type;
$session->description = $description;
$session->autorefresh = $autorefresh;
$session->links = $links;
$session->title = $title;
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
$redirector->gotoSimple('message', 'index');
}
/**
* Strategy pattern: call helper as broker method
*
* @param string $type Message type
* @param string $description Message description
* @param string $autorefresh OPTIONAL Autorefresh URL
* @param array $links OPTIONAL Links array.
* Each link should have label and href
* @param string $title OPTIONAL Title
* @return void
*/
public function direct($type, $description, $autorefresh = null,
$links = array(), $title = null) {
$this->setMessageAndRedirect($type, $description, $autorefresh,
$links, $title);
}
}
lo que haces es simplemente instanciar unas variables de sesión y redirigir al usuario.
El test luce así:
Código PHP:
Ver originalclass My_Helper_Message_Test
extends ControllerTestCase
{
public function testSetMessageOk()
{
$helper = new My_Helper_Message();
$helper->setMessageAndRedirect(
'warning',
'message',
null,
array('label' => 'Link - Return to home', 'href' => '/index/index')
)
);
$this->assertRedirectTo('/index/message');
}
}
Al ejecutarlo, me da el siguiente error:
Código:
1) My_Helper_Message_Test::testSetMessageOk
Zend_Controller_Router_Exception: Route default is not defined
Añadir que si comento el assertRedirectTo sigue saliendo el mismo error. Juraría que viene del redirector->gotoSimple.
¿Cómo puedo solucionarlo?
Gracias de antemano