2016-09-20 152 views

回答

0

如果用戶存在,可以登錄這一次將只檢查,但我不明白爲什麼我們需要這個測試:

$this->assertTrue(Auth::attempt(['email' => $email, 'password' => $password])); 

也許下面的測試是一個更好的單位測試用例。在這裏你要檢查你的路由重定向是否正常工作,如果登錄失敗/成功。我會把它寫成你的代碼:

$credentials=[ 
    'email'=>'[email protected]', 
    'password'=>'admin' 
]; 
$this->call('POST','login',$credentials); 
$this->assertResponseOk(); 
//or $this->assertRedirectedToRoute('login.fail');