2017 © Pedro Peláez
 

library codeception-email

Provides test helpers for Codeception when testing email functionality

image

ericmartel/codeception-email

Provides test helpers for Codeception when testing email functionality

  • Tuesday, September 5, 2017
  • by ericmartel
  • Repository
  • 1 Watchers
  • 4 Stars
  • 39,610 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 5 Forks
  • 2 Open issues
  • 4 Versions
  • 20 % Grown

The README.md

Codeception Email Testing Framework

This framework defines a testing Trait (interface) which allows standardized email testing across various email testing services, such as, (*1)

Available Test Methods

All testing methods are defined in \Codeception\Email\TestsEmails., (*2)

haveEmails()

Checks if there are any emails in the inbox, (*3)

haveNumberOfEmails($expected)

Checks that the amount of emails in the inbox is exactly $expected, (*4)

dontHaveEmails()

Checks that there are no emails in the inbox, (*5)

haveUnreadEmails()

Checks that there is at least one unread email, (*6)

haveNumberOfUnreadEmails($expected)

Checks that the amount of emails in the unread inbox is exactly $expected, (*7)

dontHaveUnreadEmails()

Checks that there are no unread emails in the inbox, (*8)

seeInOpenedEmailBody($expected)

Validates that $expected can be found in the opened email body, (*9)

seeInOpenedEmailSubject($expected)

Validates that $expected can be found in the opened email subject, (*10)

dontSeeInOpenedEmailBody($expected)

Checks that $expected cannot be found in the opened email body, (*11)

dontSeeInOpenedEmailSubject($expected)

Checks that $expected cannot be found in the opened email subject, (*12)

seeInEmailBody($email, $expected)

Checks that the body of $email contains $expected, (*13)

dontSeeInEmailBody($email, $expected)

Checks that the body of $email does not contain $expected, (*14)

seeInEmailSubject($email, $expected)

Checks that the subject of $email contains $expected, (*15)

dontSeeInEmailSubject($email, $expected)

Checks that the subject of $email does not contain $expected, (*16)

seeInOpenedEmailSender($expected)

Checks if the sender of the opened email contains $expected, (*17)

dontSeeInOpenedEmailSender($expected)

Checks if the sender of the opened email does not contain $expected, (*18)

seeInEmailSender($email, $expected)

Checks if the sender of $email contains $expected, (*19)

dontSeeInEmailSender($email, $expected)

Checks if the sender of $email does not contain $expected, (*20)

seeInOpenedEmailReplyTo($expected)

Checks if the ReplyTo of the opened email contains $expected, (*21)

dontSeeInOpenedEmailReplyTo($expected)

Checks if the ReplyTo of the opened email does not contain $expected, (*22)

seeInEmailSender($email, $expected)

Checks if the ReplyTo of $email contains $expected, (*23)

dontSeeInEmailReplyTo($email, $expected)

Checks if the ReplyTo of $email does not contain $expected, (*24)

seeInOpenedEmailRecipients($expected)

Checks that the recipients of the opened email contain $expected, (*25)

dontSeeInOpenedEmailRecipients($expected)

Checks that the recipients of the opened email do not contain $expected, (*26)

seeInEmailRecipients($email, $expected)

Checks that the recipients of $email contain $expected, (*27)

dontSeeInEmailRecipients($email, $expected)

Checks that the recipients of $email do not contain $expected, (*28)

seeInOpenedEmailToField($expected)

Checks the the To field of the opened email contains $expected, (*29)

dontSeeInOpenedEmailToField($expected)

Checks the the To field of the opened email does not contain $expected, (*30)

seeInEmailToField($email, $expected)

Checks the the To field of $email contains $expected, (*31)

dontSeeInEmailToField($email, $expected)

Checks the the To field of $email does not contain $expected, (*32)

seeInOpenedEmailCCField($expected)

Checks that the CC field of the opened email contains $expected, (*33)

dontSeeInOpenedEmailCCField($expected)

Checks that the CC field of the opened email does not contain $expected, (*34)

seeInEmailCCField($email, $expected)

Checks that the CC field of $email contains $expected, (*35)

dontSeeInEmailCCField($email, $expected)

Checks that the CC field of $email does not contain $expected, (*36)

seeInOpenedEmailBCCField($expected)

Checks that the BCC field of the opened email contains $expected, (*37)

Warning: it is possible for an email to have its BCC field empty, it doesn't mean that another instance of the same email doesn't exist., (*38)

dontSeeInOpenedEmailBCCField($expected)

Checks that the BCC field of the opened email does not contain $expected, (*39)

Warning: it is possible for an email to have its BCC field empty, it doesn't mean that another instance of the same email doesn't exist., (*40)

seeInEmailBCCField($email, $expected)

Checks that the BCC field of $email contains $expected, (*41)

Warning: it is possible for an email to have its BCC field empty, it doesn't mean that another instance of the same email doesn't exist., (*42)

dontSeeInEmailBCCField($email, $expected)

Checks that the BCC field of $email does not contain $expected, (*43)

Warning: it is possible for an email to have its BCC field empty, it doesn't mean that another instance of the same email doesn't exist., (*44)

seeInOpenedEmailPriority($expected)

Checks that the priority of the opened email is $expected, (*45)

dontSeeInOpenedEmailPriority($expected)

Checks that the priority of the opened email is not $expected, (*46)

seeInEmailPriority($email, $expected)

Checks that the priority of $email is $expected, (*47)

dontSeeInEmailPriority($email, $expected)

Checks that the priority of $email is not $expected, (*48)

Developing For New Testing Services

A base trait defining the interface the test methods require is available in \Codeception\Email\EmailServiceProvider. All of these methods need to be overloaded in a new Service Provider. They are protected as they are only used by the testing layer, not by the user himself., (*49)

getCurrentInbox()

Returns the complete current inbox, (*50)

getUnreadInbox()

Returns the inbox containing unread emails, (*51)

getOpenedEmail($fetchNextUnread = FALSE)

Main method called by the tests, providing either the currently open email or the next unread one, (*52)

getEmailBody($email)

Returns the body of an email, (*53)

getEmailSubject($email)

Returns the subject of an email, (*54)

getSender($email)

Returns the string containing the sender of the email, (*55)

getEmailTo($email)

Returns the string containing the persons included in the To field, (*56)

getEmailCC($email)

Returns the string containing the persons included in the CC field, (*57)

getEmailBCC($email)

Returns the string containing the persons included in the BCC field, (*58)

getEmailRecipients($email)

Returns the string containing all of the recipients, such as To, CC and if provided BCC, (*59)

grabBodyFromEmail

Returns the email body as string, (*60)

$email_body = $I->grabBodyFromEmail('text/html');
$doc = new DOMDocument();
$doc->loadHTML($email_body);
$login = $doc->getElementById('login')->textContent;
$password = $doc->getElementById('password')->textContent;

Fetch login & password from 'text/html' email MIME-part., (*61)

To Do

While this framework should be sufficient for most email testing scenarios, the remaining features need to be implemented * HTML and Plain Text content * Attachments * Priority, (*62)

License

Copyright (c) 2015-2016 Eric Martel, http://github.com/ericmartel emartel@gmail.com, (*63)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*64)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*65)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*66)

The Versions

05/09 2017

dev-master

9999999-dev

Provides test helpers for Codeception when testing email functionality

  Sources   Download

MIT

by Eric Martel

05/09 2017

1.0.2

1.0.2.0

Provides test helpers for Codeception when testing email functionality

  Sources   Download

MIT

by Eric Martel

27/01 2016

1.0.1

1.0.1.0

Provides test helpers for Codeception when testing email functionality

  Sources   Download

MIT

by Eric Martel

30/12 2015

1.0.0

1.0.0.0

Provides test helpers for Codeception when testing email functionality

  Sources   Download

MIT

by Eric Martel