Exception 如何使用phpspec2捕获异常
我正试图捕捉我的规范中的异常,但我无法让它正常工作。这是我的代码:Exception 如何使用phpspec2捕获异常,exception,phpspec,Exception,Phpspec,我正试图捕捉我的规范中的异常,但我无法让它正常工作。这是我的代码: $this->edit('updated comment', $comment, $user) ->shouldReturnAnInstanceOf('\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException'); 我做错了什么?根据,您可以使用Matcher来测试异常: $this ->shouldThrow('Symf
$this->edit('updated comment', $comment, $user)
->shouldReturnAnInstanceOf('\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException');
我做错了什么?根据,您可以使用Matcher
来测试异常:
$this
->shouldThrow('Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException')
->during('edit', array('updated comment', $comment, $user));
您还可以查看Github上phpspec存储库中的内容