Je suis un fan de 100% de couverture de code, mais je n'ai aucune idée de comment tester le ErrorController dans Zend Framework.Contrôleur d'erreur UnitTest dans Zend Framework
Il n'y a aucun problème pour tester la 404Action et errorAction:
public function testDispatchErrorAction()
{
$this->dispatch('/error/error');
$this->assertResponseCode(200);
$this->assertController('error');
$this->assertAction('error');
}
public function testDispatch404()
{
$this->dispatch('/error/errorxxxxx');
$this->assertResponseCode(404);
$this->assertController('error');
$this->assertAction('error');
}
Mais comment tester une erreur d'application (500)? peut-être que j'ai besoin de quelque chose comme ça?
public function testDispatch500()
{
throw new Exception('test');
$this->dispatch('/error/error');
$this->assertResponseCode(500);
$this->assertController('error');
$this->assertAction('error');
}