dev-master
9999999-devA PHPUnit extension for testing emails via the Mailinator API
MIT
The Requires
- php >=5.2.1
- jrmadsen67/mahana-mailinator-api dev-master
by Jeffrey R. Madsen
Wallogit.com
2017 © Pedro Peláez
A PHPUnit extension for testing emails via the Mailinator API
A PHPUnit extension for testing emails via the Mailinator API, (*2)
You need to have the cURL-extension installed on your server. PHP 5.4 will suffice., (*3)
Mahana Mailinator Test depends on the Mahana Mailinator API library (will install with composer, or can be found here: https://github.com/jrmadsen67/MahanaMailinatorAPI), (*4)
composer require jrmadsen67/mahana-mailinator-test, (*5)
Mahana Mailinator Test is a PHPUnit extension used for functional email testing against the Mailintor API. You will need to get an api token at https://www.mailinator.com/settings.jsp., (*6)
In your tests, create a Mahana Mailinator API object with your token, then pass that object to your Mahana Mailinator Test object:, (*7)
use jrmadsen67\MahanaMailinatorAPI\MahanaMailinatorAPI; use jrmadsen67\MahanaMailinatorAPI\MahanaMailinatorTest; $mahanaMailinatorAPI = new MahanaMailinatorAPI($token); $mahanaMailinatorTest = new MahanaMailinatorTest($mahanaMailinatorAPI);
IMPORTANT! You need to send emails via your own mail library. This library will only retreive and test the contents., (*8)
Examples:, (*9)
// inbox value does not require "@mailinator.com" for the API to retrieve.
$inbox = 'mytestbox@mailinator.com';
//psuedo-code to send an email:
mail_send([
'to'=>$inbox,
'subject' => 'My test subject',
'from'=> 'me@test.com',
'body' => 'blah, blah, blah',
]);
// get the email you just sent. this is an array.
$email = $mahanaMailinatorTest->getLastMessage($inbox);
//start testing
$mahanaMailinatorTest->assertEmailSubjectContains('test', $email);
$mahanaMailinatorTest->assertEmailSubjectEquals('My test subject', $email);
$mahanaMailinatorTest->assertEmailTextContains('blah', $email);
Please read the library source for a full set of functions. (Better specs on the way, I promise!), (*10)
A PHPUnit extension for testing emails via the Mailinator API
MIT