2017 © Pedro Peláez
 

library mailgrasp

A package for Laravel applications (5.1) to add support for email testing in your test classes.

image

cyber-duck/mailgrasp

A package for Laravel applications (5.1) to add support for email testing in your test classes.

  • Thursday, February 2, 2017
  • by cyber-duck
  • Repository
  • 5 Watchers
  • 5 Stars
  • 5,818 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 8 Versions
  • 5 % Grown

The README.md

🚨 Discontinued 🚨

This functionality is redily available in later releases of Laravel., (*1)

MailGrasp

Build Status Latest Stable Version Total Downloads License, (*2)

MailGrasp is a package for Laravel applications (5.1+) to add support for email testing in your test classes., (*3)

Author: Simone Todaro, (*4)

Made with :heart: by Cyber-Duck Ltd, (*5)

Installation

composer require cyber-duck/mailgrasp --dev

Usage

Add the InteractsWithEmails to your test class. That's it!, (*6)

use \Cyberduck\MailGrasp\Testing\InteractsWithEmails;

The custom mailer will be initialised as soon as the visit() method is called., (*7)

seeEmails

It checks if exactly $count emails have been sent or enqueued., (*8)

$this->visit('/route/which/sends/2/emails')
    ->seeEmails(2);

seeEmailsInQueue

It checks if exactly $count emails have been enqueued., (*9)

$this->visit('/route/which/enqueues/2/emails')
    ->seeEmailsInQueue(2);

dontSeeEmails / notSeeEmails

It checks that no email has been sent or enqueued., (*10)

$this->visit('/route/with/no/emails')
    ->dontSeeEmails();

// OR

$this->visit('/route/with/no/emails')
    ->notSeeEmails();

dontSeeEmailsInQueue / notSeeEmailsInQueue

It checks that no email has been enqueued., (*11)

$this->visit('/route/with/no/emails')
    ->dontSeeEmailsInQueue();

// OR

$this->visit('/route/with/no/emails')
    ->notSeeEmailsInQueue();

seeEmail

It checks that an email matching given critaria has been sent or enqueued., (*12)

$this->visit('/route/which/sends/emails')
    ->seeEmail(function($m) {
        $m->from('from@test.com');
        $m->to('to@test.com');
        $m->subject('Subject');
    });

// OR

$this->visit('/route/which/sends/emails')
    ->seeEmail($this->message()
        ->from('from@test.com')
        ->to('to@test.com')
        ->subject('Subject');
    });

dontSeeEmail

Complete opposite of seeEmail., (*13)

$this->visit('/route/which/sends/emails')
    ->dontSeeEmail(function($m) {
        $m->from('from@test.com');
        $m->to('to@test.com');
        $m->subject('Subject');
    });

// OR

$this->visit('/route/which/sends/emails')
    ->dontSeeEmail($this->message()
        ->from('from@test.com')
        ->to('to@test.com')
        ->subject('Subject');
    });

seeEmailInQueue

It checks that an email matching given critaria has been enqueued., (*14)

$this->visit('/route/which/enqueues/emails')
    ->seeEmailInQueue(function($m) {
        $m->from('from@test.com');
        $m->to('to@test.com');
        $m->subject('Subject');
    });

// OR

$this->visit('/route/which/enqueues/emails')
    ->seeEmailInQueue($this->message()
        ->from('from@test.com')
        ->to('to@test.com')
        ->subject('Subject');
    });

seeInEmail

It checks that an email matching the given critaria contains the given string., (*15)

$this->visit('/route/which/sends/emails')
    ->seeInEmail(function($m) {
        $m->from('from@test.com');
        $m->to('to@test.com');
        $m->subject('Subject');
    }, 'Lorem ipsum dolor sit amet');

// OR

$this->visit('/route/which/sends/emails')
    ->seeInEmail($this->message()
        ->from('from@test.com')
        ->to('to@test.com')
        ->subject('Subject');
    }, 'Lorem ipsum dolor sit amet);

clickInEmail

Visit the page in the email link. Useful to test activation links., (*16)

$this->visit('/route/which/enqueues/emails')
    ->clickInEmail(function($m) {
        $m->from('from@test.com');
        $m->to('to@test.com');
        $m->subject('Subject');
    });

// OR

$this->visit('/route/which/enqueues/emails')
    ->clickInEmail($this->message()
        ->from('from@test.com')
        ->to('to@test.com')
        ->subject('Subject');
    });

If there is more than one link in the email, it's possible to select the link passing a css selector as second parameter., (*17)

$this->visit('/route/which/enqueues/emails')
    ->clickInEmail(function($m) {
        $m->from('from@test.com');
        $m->to('to@test.com');
        $m->subject('Subject');
    }, 'a.activation-link');

// OR

$this->visit('/route/which/enqueues/emails')
    ->clickInEmail($this->message()
        ->from('from@test.com')
        ->to('to@test.com')
        ->subject('Subject');
    }, 'a.activation-link');

The Versions

02/02 2017

dev-master

9999999-dev https://github.com/Cyber-Duck/Mail-Grasp

A package for Laravel applications (5.1) to add support for email testing in your test classes.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel testing emails

02/02 2017
04/01 2017
28/09 2016
28/09 2016
28/09 2016
25/09 2016
25/09 2016

1.0.1

1.0.1.0 https://www.cyberduck.co.uk

A package for Laravel applications (5.1) to add support for email testing in your test classes.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel testing emails