Package Data | |
---|---|
Maintainer Username: | TijmenWierenga |
Maintainer Contact: | tijmen@floown.com (Tijmen Wierenga) |
Package Create Date: | 2016-07-27 |
Package Last Update: | 2016-07-28 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-09 15:17:38 |
Package Statistics | |
---|---|
Total Downloads: | 193 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
An extension to Laravel's TestCase which allows you to run unit tests on emails.
composer require tijmen-wierenga/laravel-mail-tester
Next, add the trait to the TestCase
class located at tests/TestCase
:
use TijmenWierenga\LaravelMailTester\TestsEmail;
class TestCase extends Laravel\Lumen\Testing\TestCase
{
use TestsEmail;
...
}
LaravelMailTester adds an event listener as a plugin when in a testing environment. It tracks when an email is sent, and stores all data in the test case. You can then perform assertions against it.
class AuthenticationTest extends TestCase
{
/**
* @test
*/
public function it_sends_an_email() {
// Send an email
Mail::raw('Wow, awesome email testing!', function($mail) {
$mail->to('tijmen@floown.com');
$mail->from('no-reply@floown.com');
$mail->subject('Read this awesome email');
}
$this->assertEmailWasSent()
->assertEmailWasSentTo('tijmen@floown.com')
->assertEmailWasSentFrom('no-reply@floown.com')
->assertEmailBodyContains('awesome email testing')
}
}
More assertions to come.
The MIT License (MIT).