【发布时间】:2020-07-10 07:19:33
【问题描述】:
在我的 Laravel 5.6 应用程序中重置密码电子邮件的功能测试中,我一直在努力获取 Notification::assertSentTo() 方法,但仍然收到以下代码的持续失败:
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()
期待任何有助于成功测试的提示。 问候并保重!
【问题讨论】:
标签: laravel testing notifications phpunit