rogervila/laravel-email-failer

Helper class for testing Laravel Mail Failures
3,190 32
Install
composer require rogervila/laravel-email-failer
Latest Version:1.0.0
License:MIT
Last Updated:Jul 7, 2024
Links: GitHub  ·  Packagist
Maintainer: rogervila

Build Status Build status StyleCI Latest Stable Version Total Downloads License MadeWithLaravel.com shield

Laravel Email Failer

composer require --dev rogervila/laravel-email-failer

About

Trigger email failures to assert what happens on your Laravel Application when an email fails to send

Usage

Once MailFailer instance is binded, all emails will fail. This helps to assert that your application Mail exceptions are handled correctly (ie: mark the email address as invalid)

class MyService
{
    public static function sendEmail()
    {
        \Illuminate\Support\Facades\Mail::send(...);
    }
}

public function test_happy_path()
{
    Mail::fake();

    MyService::sendEmail();

    Mail::assertSent(MyMailable::class);
}

public function test_email_failures()
{
    $this->expectException(TransportException::class);

    \LaravelEmailFailer\MailFailer::bind();

    MyService::sendEmail();

    Mail::assertNotSent(MyMailable::class);

    dump(Mail::failures());
    // Assert here what happens when the email has failed
}

License

Laravel Email Failer is open-sourced software licensed under the MIT license.

Icon made by Darius Dan from www.flaticon.com is licensed by CC 3.0 BY

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

637,827,751 9,703
laravel/framework

The Laravel Framework.

589,172,971 34,950
laravel/tinker

Powerful REPL for the Laravel framework.

498,216,183 7,442
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

413,412,504 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released Laravel License
1.0.0 ^11.0 MIT
0.4.0 5.8.*|^6.0|^7.0|^8.0 MIT
0.3.0 5.8.*|^6.0|^7.0 MIT
0.2.0 5.8.*|^6.0 MIT
0.1.0 5.8.x MIT