我已经上交throw Exception,handler.php以便我可以捕捉exceptions并看到,errors但发生的事情是,当我尝试这样做时,validation checks它会抛出一个异常,这是正确的,但在我的测试用例中,我没有捕捉到exception我断言会话有错误。
/** @test*/
public function a_thread_requires_a_title(){
$thread = make('App\Thread', ['title'=> null]);
$this->post('threads', $thread->toArray())
->assertSessionHasErrors('title');
}
因为,validation error是一个异常,所以它会抛出一个异常,因为我已将handler.php文件修改为
if(app()->environment() === "testing") throw $exception;
所以,我想做的是改变这个测试的环境,这样它就不会给我一个“异常”