CustomResetPassword を利用している場合は、以下を修正しないとデフォルトテストでエラーになる!
修正対象ファイル
/tests/Feature/Auth/PasswordResetTest.php
修正内容
✅ use 文を差し替え
/tests/Feature/Auth/PasswordResetTest.php
- use Illuminate\Auth\Notifications\ResetPassword;
+ use App\Notifications\CustomResetPassword;
✅ Notification テスト対象も差し替え
/tests/Feature/Auth/PasswordResetTest.php
- Notification::assertSentTo($user, ResetPassword::class);
+ Notification::assertSentTo($user, CustomResetPassword::class);
(3箇所すべて同様に修正)
全体コード
/tests/Feature/Auth/PasswordResetTest.php
<?php
namespace Tests\Feature\Auth;
// 修正前
// use Illuminate\Auth\Notifications\ResetPassword;
// 修正後
use App\Notifications\CustomResetPassword;
class PasswordResetTest extends TestCase
{
public function test_reset_password_link_can_be_requested(): void
{
// 修正前
// Notification::assertSentTo($user, ResetPassword::class);
// 修正後
Notification::assertSentTo($user, CustomResetPassword::class);
}
public function test_reset_password_screen_can_be_rendered(): void
{
// 修正前
// Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
// 修正後
Notification::assertSentTo($user, CustomResetPassword::class, function ($notification) {
});
}
public function test_password_can_be_reset_with_valid_token(): void
{
// 修正前
// Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
// 修正後
Notification::assertSentTo($user, CustomResetPassword::class, function ($notification) use ($user) {
});
}
}