1

我试图为我的身份验证路线进行测试。对于密码重置路线,我试图在其中伪造 laravel 的通知模块并根据文档进行断言。这是我的测试文件

 public function testUserReceivesAnEmailWithAPasswordResetLink()
    {
        $this->withoutExceptionHandling();
        Notification::fake();

        $user = factory(User::class)->make();

        $response = $this->post($this->passwordEmailPostRoute(), [
            'email' => $user->email,
        ]);

        $this->assertNotNull($token = DB::table('password_resets')->where('email', $user->email));

        Notification::assertSentTo($user, PasswordReset::class);

    }

当我运行这个时,我得到了notification was not sent错误。

我的用户模型是这样的:

 use Notifiable, HasApiTokens, SoftDeletes, Uuidable, Switchable, ResourceMapper;

 public function role()
    {
        return $this->belongsTo('App\Models\Role');
    }

    public function company()
    {
        return $this->belongsTo('App\Models\Company');
    }

    public function AauthAccessToken()
    {
        return $this->hasMany('App\Models\OauthAccessToken');
    }

    public function isRole($role)
    {
        return $this->role->uuid == $role;
    }

    public function sendPasswordResetNotification($token)
    {
        $this->notify(new PasswordReset($token));
    }

    public function resource()
    {
        return $this->morphTo();
    }

我无法弄清楚确切的问题是什么。

4

0 回答 0