drakakisgeo / mailtester
Mail testing helper
Installs: 2 711
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ~7.2|~7.3|~7.4|~8.0|~8.1
- guzzlehttp/guzzle: ~6.0|~7.1
- illuminate/contracts: ^5.0|6.*|^7.0|^8.0
- illuminate/support: ^5.0|6.*|^7.0|^8.0
Requires (Dev)
- orchestra/testbench: ^5.0
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: ^3.0
- swiftmailer/swiftmailer: ^6.0
README
A package to help with acceptance Email testing. The goal is to add usefull PHPunit assertions in a Trait that you can include when there is a need to test emails that are fired from acceptance testing packages like Laravel Dusk.
Install
This package assumes that you've already installed Mailcatcher. You can check this tutorial on how to install it to your system.
Via Composer
$ composer require drakakisgeo/mailtester
Laravel 5.*
After updating composer, add the ServiceProvider to the providers array in config/app.php
Drakakisgeo\Mailtester\MailtesterServiceProvider::class,
Copy the package config to your local config with the publish command:
$ php artisan vendor:publish --provider="Drakakisgeo\Mailtester\MailtesterServiceProvider"
Instructions
Include the InteractsWithMailCatcher Trait in your test and make sure that your test extends the Laravel's Testcase class. Immediately you have access to the following methods:
Email was send
- assertEmailIsSent()
Email subject contains a $string
- assertEmailFirstSubjectContains()
- assertEmailLastSubjectContains()
- assertEmailNthSubjectContains()
Email subject equals a $string
- assertEmailFirstSubjectEquals()
- assertEmailLastSubjectEquals()
- assertEmailNthSubjectEquals()
- assertEmailSubjectEquals()
Email Html body contains a $string
- assertEmailFirstHtmlContains()
- assertEmailLastHtmlContains()
- assertEmailNthHtmlContains()
- assertEmailHtmlContains()
Email Text body contains a $string
- assertEmailFirstTextContains()
- assertEmailLastTextContains()
- assertEmailNthTextContains()
- assertEmailTextContains()
Email sender is the target $email
- assertEmailFirstSenderEquals()
- assertEmailLastSenderEquals()
- assertEmailNthSenderEquals()
- assertEmailSenderEquals()
Email recipient is the target $email
- assertEmailFirstRecipientsContain()
- assertEmailLastRecipientsContain()
- assertEmailNthRecipientsContain()
- assertEmailRecipientsContain()
Email Cc is the target $email
- assertEmailFirstCcContain()
- assertEmailLastCcContain()
- assertEmailNthCcContain()
- assertEmailCcContain()
Email Bcc is the target $email
- assertEmailFirstBccContain()
- assertEmailLastBccContain()
- assertEmailNthtBccContain()
- assertEmailBccContain()
Email Attachment is the target $file
- Soon!
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Credits
License
The MIT License (MIT). Please see License File for more information.