ericmartel/codeception-email-mailtrap
Composer 安装命令:
composer require ericmartel/codeception-email-mailtrap
包简介
Provides test helpers for Codeception when testing email functionality with Mailtrap
README 文档
README
This Codeception Module implements the required methods to test emails using the Codeception Email Testing Framework with Mailtrap
Installation
Through composer, require the package:
"require-dev": {
"ericmartel/codeception-email-mailtrap": "^1.0"
}
Then turn it on in your Codeception suite yaml file
class_name: FunctionalTester
modules:
enabled:
- Mailtrap
config:
Mailtrap:
api_token: 'your token'
inbox_id: 'the inbox id you're using'
The api_token can be found by visiting your Mailtrap's API Page. Clicking on one of your mailboxes will give you it's id in the URL, for example, https://mailtrap.io/inboxes/12345/settings would mean that the inbox_id is 12345.
Additional parameters can be fed directly to the Guzzle connection using the guzzleRequestOptions variable.
The variable deleteEmailsAfterScenario can be set to true to ensure that all emails are deleted at the end of each scenario, but it is turned off by default.
Added Methods
This Module adds a few public methods for the user, such as:
deleteAllEmails()
Deletes all emails in Mailtrap
fetchEmails()
Fetches all email headers from Mailtrap, sorts them by timestamp and assigns them to the current and unread inboxes
accessInboxFor($address)
Filters emails to only keep those that are received by the provided address
openNextUnreadEmail()
Pops the most recent unread email and assigns it as the email to conduct tests on
Example Test
Here is a simple scenario where we test the content of an email. For a detailed list of all available test methods, please refer to the Codeception Email Testing Framework.
<?php
$I = new FunctionalTester($scenario);
$I->am('a member');
$I->wantTo('request a reset password link');
// First, remove all existing emails in the Mailtrap inbox
$I->deleteAllEmails();
// Implementation is up to the user, use this as an example
$I->requestAPasswordResetLink();
// Query Mailtrap and fetch all available emails
$I->fetchEmails();
// This is optional, but will filter the emails in case you're sending multiple emails or use the BCC field
$I->accessInboxFor('testuser@example.com');
// A new email should be available and it should be unread
$I->haveEmails();
$I->haveUnreadEmails();
// Set the next unread email as the email to perform operations on
$I->openNextUnreadEmail();
// After opening the only available email, the unread inbox should be empty
$I->dontHaveUnreadEmails();
// Validate the content of the opened email, all of these operations are performed on the same email
$I->seeInOpenedEmailSubject('Your Password Reset Link');
$I->seeInOpenedEmailBody('Follow this link to reset your password');
$I->seeInOpenedEmailRecipients('testuser@example.com');
License
Copyright (c) 2015-2016 Eric Martel, http://github.com/ericmartel emartel@gmail.com
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.
ericmartel/codeception-email-mailtrap 适用场景与选型建议
ericmartel/codeception-email-mailtrap 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15.74k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ericmartel/codeception-email-mailtrap 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ericmartel/codeception-email-mailtrap 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 15.74k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-01-04