PHP code example of rogervila / laravel-email-failer

1. Go to this page and download the library: Download rogervila/laravel-email-failer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rogervila / laravel-email-failer example snippets


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
}