2017 © Pedro Peláez
 

library mahana-mailinator-test

A PHPUnit extension for testing emails via the Mailinator API

image

jrmadsen67/mahana-mailinator-test

A PHPUnit extension for testing emails via the Mailinator API

  • Friday, October 16, 2015
  • by jrmadsen67
  • Repository
  • 1 Watchers
  • 4 Stars
  • 2,938 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 20 % Grown

The README.md

MahanaMailinatorTest

Software License, (*1)

A PHPUnit extension for testing emails via the Mailinator API, (*2)

Requirements

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)

Installation

composer require jrmadsen67/mahana-mailinator-test, (*5)

Usage

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)

The Versions

16/10 2015

dev-master

9999999-dev

A PHPUnit extension for testing emails via the Mailinator API

  Sources   Download

MIT

The Requires

 

by Jeffrey R. Madsen