Skip to content

Commit c062ec6

Browse files
laylatichygitbutler-client
authored andcommitted
test(mailer): add test asserting EmailWasSent event dispatch
1 parent 51cd70e commit c062ec6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/Integration/Mailer/MailerTesterTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use PHPUnit\Framework\AssertionFailedError;
77
use Tempest\Mail\Attachment;
88
use Tempest\Mail\Email;
9+
use Tempest\Mail\EmailWasSent;
910
use Tempest\Mail\GenericEmail;
1011
use Tests\Tempest\Integration\FrameworkIntegrationTestCase;
1112
use Tests\Tempest\Integration\Mailer\Fixtures\SendWelcomeEmail;
@@ -79,4 +80,22 @@ public function test_assertions(): void
7980
$this->assertSame('hello!', ($email->attachments[0]->resolve)());
8081
});
8182
}
83+
84+
public function test_email_was_sent_event_was_dispatched(): void
85+
{
86+
$this->eventBus->preventEventHandling();
87+
88+
$this->mailer
89+
->send(email: new GenericEmail(
90+
subject: 'Hello',
91+
92+
html: 'Hello Jon',
93+
94+
attachments: [
95+
Attachment::fromClosure(callable: fn () => 'hello!'),
96+
],
97+
));
98+
99+
$this->eventBus->assertDispatched(event: EmailWasSent::class);
100+
}
82101
}

0 commit comments

Comments
 (0)