0
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?

PasswordResetTest をカスタムしている場合のテストの注意点

Last updated at Posted at 2025-08-20

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) {

        });
    }
}
0
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
0
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?