Skip to content

Cyber-Duck/Mail-Grasp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚨 Discontinued 🚨

This functionality is redily available in later releases of Laravel.

MailGrasp

Build Status Latest Stable Version Total Downloads License

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

Author: Simone Todaro

Made with ❤️ by Cyber-Duck Ltd

Installation

composer require cyber-duck/mailgrasp --dev

Usage

Add the InteractsWithEmails to your test class. That's it!

use \Cyberduck\MailGrasp\Testing\InteractsWithEmails;

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

seeEmails

It checks if exactly $count emails have been sent or enqueued.

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

seeEmailsInQueue

It checks if exactly $count emails have been enqueued.

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

dontSeeEmails / notSeeEmails

It checks that no email has been sent or enqueued.

$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.

$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.

$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.

$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.

$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.

$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.

$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.

$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');

About

This package adds support for email testing in a Laravel application (>5.0)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy