Laravel 5.6 测试 Notification::assertSentTo() 未找到

Laravel 5.6 testing Notification::assertSentTo() not found

为了让 Notification::assertSentTo() 方法在我的 Laravel 5.6 应用程序中的重置密码电子邮件功能测试中工作多日而苦苦挣扎,但收到以下代码的持续失败:

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Support\Facades\Notification;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;

class UserPasswordResetTest extends TestCase
{
   public function test_submit_password_reset_request()
   {
      $user = factory("App\User")->create();

      $this->followingRedirects()
         ->from(route('password.request'))
         ->post(route('password.email'), [ "email" => $user->email ]);

      Notification::assertSentTo($user, ResetPassword::class);
   }

}

我尝试了几种想法,包括直接在使用列表中使用 Illuminate\Support\Testing\Fakes\NotificationFake。 在任何尝试中,测试都会失败

Error: Call to undefined method Illuminate\Notifications\Channels\MailChannel::assertSentTo()

期待任何有助于成功测试的提示。 问候并保重!

你好像少了一个 Notification::fake();为了使用正确的假通知驱动程序。

Notification::fake();

$this->followingRedirects()
...