File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -1121,6 +1121,37 @@ a specific address, instead of the *real* address:
11211121 ],
11221122 ]);
11231123
1124+ Write a Functional Test
1125+ ~~~~~~~~~~~~~~~~~~~~~~~
1126+
1127+ To functionally test that an email was sent, and even assert the email content or headers,
1128+ you can use the built in assertions::
1129+
1130+ // tests/Controller/MailControllerTest.php
1131+ namespace App\Tests\Controller;
1132+
1133+ use Symfony\Bundle\FrameworkBundle\Test\MailerAssertionsTrait;
1134+ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
1135+
1136+ class MailControllerTest extends WebTestCase
1137+ {
1138+ use MailerAssertionsTrait;
1139+
1140+ public function testMailIsSentAndContentIsOk()
1141+ {
1142+ $client = $this->createClient();
1143+ $client->request('GET', '/mail/send');
1144+ $this->assertResponseIsSuccessful();
1145+
1146+ $this->assertEmailCount(1);
1147+
1148+ $email = $this->getMailerMessage();
1149+
1150+ $this->assertEmailHtmlBodyContains($email, 'Welcome');
1151+ $this->assertEmailTextBodyContains($email, 'Welcome');
1152+ }
1153+ }
1154+
11241155.. _`high availability` : https://en.wikipedia.org/wiki/High_availability
11251156.. _`load balancing` : https://en.wikipedia.org/wiki/Load_balancing_(computing)
11261157.. _`download the foundation-emails.css file` : https://github.com/foundation/foundation-emails/blob/develop/dist/foundation-emails.css
You can’t perform that action at this time.
0 commit comments