1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

パスワードのテストでHash::check()がtrueを返し続けた件。

Posted at
$this->assertTrue(Hash::check($password, User::latest()->first()->password));

なぜ?あぜ?と思ったが、原因は、

User::latest()->first()->password;

で、最後のレコードが取れていないことが原因だった。というのもテストでは複数のレコードにおいてcreate_atの時間が同じになるので、結果、一番最初のレコードが取れてきてしまっていた。

で、解決策はこれ。

$this->assertTrue(Hash::check($password, User::all()->last()->password));

これで、最後のレコードのパスワードがとれるようになった。めでたしめでたし。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?