Created
November 19, 2021 10:36
-
-
Save RomikMakavana/587fc593db821ccffa177c679a408ee2 to your computer and use it in GitHub Desktop.
Laravel Mail Unit Testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Tests\Feature; | |
use App\Mail\OrderShipped; | |
use Illuminate\Foundation\Testing\RefreshDatabase; | |
use Illuminate\Foundation\Testing\WithoutMiddleware; | |
use Illuminate\Support\Facades\Mail; | |
use Tests\TestCase; | |
class UserRegisterTest extends TestCase | |
{ | |
public function test_user_register() | |
{ | |
Mail::fake(); | |
// Perform order shipping... | |
// Assert that no mailables were sent... | |
Mail::assertNothingSent(); | |
// Assert that a mailable was sent... | |
Mail::assertSent(EmailVerification::class); | |
// Assert a mailable was sent twice... | |
Mail::assertSent(EmailVerification::class, 2); | |
// Assert a mailable was not sent... | |
Mail::assertNotSent(AnotherMailable::class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment