psyao / mailtester
在 Codeception 测试中测试电子邮件
1.1.0
2014-08-03 21:44 UTC
Requires
- php: >=5.4.0
- codeception/codeception: ~2.0
- guzzlehttp/guzzle: ~4.0
This package is auto-updated.
Last update: 2024-09-26 06:29:36 UTC
README
此包是 Codeception 模块,允许您测试电子邮件是否发送到真实的 SMTP 服务器。
安装
通过在 composer.json 中添加来安装 MailTester
"require": { "codeception/codeception": "~2.0", "psyao/mailtester": "~1.1" }
配置
首先在套件配置中启用该模块,例如,在 functional.suite.yml 中,并选择您想要使用的提供程序
class_name: FunctionalTester modules: enabled: [Filesystem, FunctionalHelper, MailTester] config: MailTester: provider: "MailCatcher"
目前支持两种提供程序。
MailCatcher
MailCatcher 运行一个超级简单的 SMTP 服务器,它捕获发送给它的任何消息并在 Web 界面中显示。您需要在您的开发服务器上安装它。
class_name: FunctionalTester modules: ... config: MailTester: provider: "MailCatcher" MailCatcher: url: 'http://192.168.10.10' port: '1080'
MailTrap
MailTrap 是一个在线的假 SMTP 服务器,用于开发团队测试、查看和分享从开发和预发布环境中发送的电子邮件。
class_name: FunctionalTester modules: ... config: MailTester: provider: "MailTrap" MailTrap: api_token: 'myw0nd3rfu7ap1t0k3n' inbox_id: '1337'
示例用法
<?php $I = new FunctionalTester($scenario); $I->wantTo('send an email'); $I->amOnPage('/contact'); $I->fillField("Your Email", 'john@example.com'); $I->click("Send Email"); $I->seeInLastEmail('Someone tried to get in touch with you!'); $I->seeLastEmailWasSentFrom('john@example.com'); $I->seeLastEmailWasSentTo('patrick@example.com'); $I->dontSeeInLastEmail('Foo'); $I->dontSeeLastEmailWasSentFrom('bar@example.com'); $I->dontSeeLastEmailWasSentTo('baz@example.com');
方法
有关可用方法,请参阅 MailTester.php。
变更日志
- 1.1 : 添加了新的提供程序 (mailtrap.io)
- 1.0 : 第一个版本
许可证
在与 Codeception 相同的许可证下发布:MIT