更新时间:2023-11-10 16:12:16
我也有点卡在 Laravel 5.4 测试跟随重定向案例.
I am also a bit stuck with Laravel 5.4 testing follow redirects case.
作为一种解决方法,您可以检查 $response->assertSessionHasErrors()
.这样它应该可以工作:
As a workaround, you may check $response->assertSessionHasErrors()
. This way it should work:
public function testLoginFalse()
{
$credential = [
'email' => 'user@ad.com',
'password' => 'incorrectpass'
];
$response = $this->post('login',$credential);
$response->assertSessionHasErrors();
}
另外,您可以在 testLoginTrue()
中检查该会话缺少错误:
Also, in testLoginTrue()
you may check, that session missing errors:
$response = $this->post('login',$credential);
$response->assertSessionMissing('errors');
希望这会有所帮助!