opH*_*AME 5 phpunit zend-framework
我是100%代码覆盖率的粉丝,但我不知道如何在Zend Framework中测试ErrorController.
测试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');
}
Run Code Online (Sandbox Code Playgroud)
但是如何测试应用程序错误(500)?也许我需要这样的东西?
public function testDispatch500()
{
throw new Exception('test');
$this->dispatch('/error/error');
$this->assertResponseCode(500);
$this->assertController('error');
$this->assertAction('error');
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1217 次 |
| 最近记录: |