I am creating a test for Laravel's built-in email verification and am unsure how to test this via PHPUnit. I'm able to receive the notification emails using mailtrap.io but am unable to make the PHPUnit test pass.
Here is my test:
namespace Tests\Feature;
use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Notification;
use Tests\TestCase;
class RegistrationTest extends TestCase
{
use RefreshDatabase;
function test_a_confirmation_email_is_sent_on_registration()
{
Notification::fake();
$user = create('App\User');
Notification::assertSentTo($user, VerifyEmail::class);
}
}
I'm looking to have the assertSentTo to pass.
Right now I am getting:
The expected [Illuminate\Auth\Notifications\VerifyEmail] notification was not sent. Failed asserting that false is true. /home/jhiggins/projects/forum/vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/NotificationFake.php:52 /home/jhiggins/projects/forum/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237 /home/jhiggins/projects/forum/tests/Feature/RegistrationTest.php:20