FilamentF
Filament12mo ago
Sourabh

Test Filament Email Verification.

I want to test filament email verification by Pest, and I have created a separate MySQL testing database along with the .env.testing environment. When I run the test case, the email verification notification is not received on user email id.
Please find below code for your reference.
<?php 
test('sends the filament email verification notification after registering', function () {
    Notification::fake();
    $response = Livewire(Register::class)
        ->fillForm([
            'name' => 'App User',
            'company_name' => 'Company Name',
            'email' => 'appuser@yopmail.com',
            'password' => 'password',
            'passwordConfirmation' => 'password',
        ])

        ->call('register')
        ->assertHasNoFormErrors();

    $user = User::where('email', 'appuser@yopmail.com')->firstOrFail();

    Notification::assertSentTo([$user], VerifyEmail::class);
});

?>

//.env.testing
<?php 
APP_NAME="laravel"
APP_ENV=testing
APP_KEY=base64:UzY9zi19NQxvCu0j8aqCpsg2VK6jDrhynKGGEzPoHzY=
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000/


DB_CONNECTION=testing
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=riview_app_testing
DB_USERNAME=root
DB_PASSWORD=tops12345

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
SESSION_DRIVER=file
SESSION_LIFETIME=120

MAIL_MAILER=smtp
MAIL_HOST=smtp-relay.brevo.com
MAIL_PORT=465
MAIL_USERNAME=sourabh@gmail.com
MAIL_PASSWORD="password"
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="sourabh@gmail.com"
MAIL_FROM_NAME="${APP_NAME}"
?>
Was this page helpful?