rogervila / laravel-email-failer
Helper class for testing Laravel Mail Failures
Installs: 3 189
Dependents: 0
Suggesters: 0
Security: 0
Stars: 31
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- laravel/framework: ^11.0
Requires (Dev)
- laravel/pint: ^1.16
- orchestra/testbench: ^9.0
- phpunit/phpunit: ^10.0
README
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