Skip to content

Commit 9a409cf

Browse files
authored
[10.x] Test mailable sent (#46181)
* test mail facade fakes and sends mailables * formatting * code style
1 parent 8f91965 commit 9a409cf

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/Support/SupportMailTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminate\Tests\Support;
44

5+
use Illuminate\Mail\Mailable;
56
use Illuminate\Support\Facades\Mail;
67
use Orchestra\Testbench\TestCase;
78

@@ -28,4 +29,27 @@ public function testItRegisterAndCallMacrosWhenFaked()
2829

2930
$this->assertEquals('it works!', Mail::test('foo'));
3031
}
32+
33+
public function testEmailSent()
34+
{
35+
Mail::fake();
36+
Mail::assertNothingSent();
37+
38+
Mail::to('[email protected]')->send(new TestMail());
39+
40+
Mail::assertSent(TestMail::class);
41+
}
42+
}
43+
44+
class TestMail extends Mailable
45+
{
46+
/**
47+
* Build the message.
48+
*
49+
* @return $this
50+
*/
51+
public function build()
52+
{
53+
return $this->view('view');
54+
}
3155
}

0 commit comments

Comments
 (0)