Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a54fdf
commit 1ee71b5
Showing
4 changed files
with
79 additions
and
35 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Spatie\MailableTest\Test; | ||
|
||
use Exception; | ||
use Mail; | ||
use Artisan; | ||
|
||
class SendTestMailTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_can_send_a_mail() | ||
{ | ||
Mail::fake(); | ||
|
||
TestModel::create(['name' => 'my name']); | ||
|
||
Artisan::call('mail:send-test', [ | ||
'mailableClass' => TestMailable::class, | ||
'recipient' => 'recepient@mail.com' | ||
]); | ||
|
||
Mail::assertSent(TestMailable::class, function (TestMailable $mail) { | ||
$this->assertCount(1, $mail->to); | ||
$this->assertEquals('recepient@mail.com', $mail->to[0]['address']); | ||
$this->assertCount(0, $mail->cc); | ||
$this->assertCount(0, $mail->bcc); | ||
|
||
return true; | ||
}); | ||
} | ||
|
||
/** @test */ | ||
public function it_will_throw_an_exception_when_passing_an_invalid_mail_address() | ||
{ | ||
$this->expectException(Exception::class); | ||
|
||
Artisan::call('mail:send-test', [ | ||
'mailableClass' => TestMailable::class, | ||
'recipient' => 'invalid-mail-address' | ||
]); | ||
} | ||
} |
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