Download the PHP package jtproductions/mailtrap-assertions without Composer
On this page you can find all versions of the php package jtproductions/mailtrap-assertions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jtproductions/mailtrap-assertions
More information about jtproductions/mailtrap-assertions
Files in jtproductions/mailtrap-assertions
Package mailtrap-assertions
Short Description Assertions for PHPUnit to use with Mailtrap mailbox
License MIT
Informations about the package mailtrap-assertions
Mailtrap assertsions to use in phpunit tests
The mailtrap assertiosn is to TDD your Laravel Application to check if mails has been send to mailtrap.
Installation
You can install the package using
.env file
You need to add a few variables into your .env
file. You need to firstly login to your mailtrap.io account.
MAILTRAP_API_KEY
=>
In the left navigation bar you click on API. There you see your API Token which you copy and paste in your .env file
MAILTRAP_INBOX_ID
=> In the left navigation bar you click on inboxes and then click on the name of your inbox. Now you
see in the address bar something like https://mailtrap.io/inboxes/123456789/messages. The number between inboxes and
messages is your inbox ID. In this case it is 123456789
.
tests/TestCase.php
In your tests directory you open up TestCase.php and add make sure you have the following code
phpunit.xml
Open up your phpunit.xml
file. Change MAIL_MAILER
from array
to smtp
Usage
Adding traits
The trait RefreshMailtrap will empty you mailbox on each
All the assertions are in the MailtrapAssertions Trait
Assert empty mailbox
To check if the mailbox is empty
Assert mailbox has $count messages
This asserts that there are 3 messages in the mailbox
Manual clean mailbox
If you don't want to use the RefreshMailtrap trait or during a test clean your mailbox