蔭100%的代碼覆蓋率的粉絲,但我不知道如何測試Zend框架的ErrorController。單元測試誤差控制在Zend框架
這是沒有問題的測試404Action和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');
}
但是如何測試應用程序錯誤(500)? 也許我需要這樣的東西?
public function testDispatch500()
{
throw new Exception('test');
$this->dispatch('/error/error');
$this->assertResponseCode(500);
$this->assertController('error');
$this->assertAction('error');
}