jtproductions/mailtrap-assertions
Composer 安装命令:
composer require jtproductions/mailtrap-assertions
包简介
Assertions for PHPUnit to use with Mailtrap mailbox
README 文档
README
The mailtrap assertiosn is to TDD your Laravel Application to check if mails has been send to mailtrap.
Installation
You can install the package using
composer require --dev jtproductions/mailtrap-assertions
.env file
You need to add a few variables into your .env file. You need to firstly login to your mailtrap.io account.
MAILTRAP_API_KEY =>
In the left navigation bar you click on API. There you see your API Token which you copy and paste in your .env file
MAILTRAP_INBOX_ID => In the left navigation bar you click on inboxes and then click on the name of your inbox. Now you
see in the address bar something like https://mailtrap.io/inboxes/123456789/messages. The number between inboxes and
messages is your inbox ID. In this case it is 123456789.
tests/TestCase.php
In your tests directory you open up TestCase.php and add make sure you have the following code
protected function setUpTraits() { $uses = parent::setUpTraits(); // TODO: Change the autogenerated stub if (isset($uses[RefreshMailtrap::class])) { $this->refreshMailtrap(); } if (isset($uses[MailtrapAssertions::class])) { $this->mailtrapSetup(); } }
phpunit.xml
Open up your phpunit.xml file. Change MAIL_MAILER from array to smtp
Usage
Adding traits
The trait RefreshMailtrap will empty you mailbox on each
class ExampleTest extends TestCase { use RefreshMailtrap; }
All the assertions are in the MailtrapAssertions Trait
class ExampleTest extends TestCase { use MailtrapAssertions; }
Assert empty mailbox
To check if the mailbox is empty
$this->assertMailboxEmpty();
Assert mailbox has $count messages
This asserts that there are 3 messages in the mailbox
$this->assertMailboxCount(3);
Manual clean mailbox
If you don't want to use the RefreshMailtrap trait or during a test clean your mailbox
$this->emptyMailbox();
jtproductions/mailtrap-assertions 适用场景与选型建议
jtproductions/mailtrap-assertions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 26 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「phpunit」 「mailtrap」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jtproductions/mailtrap-assertions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jtproductions/mailtrap-assertions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jtproductions/mailtrap-assertions 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Mailtrap module for Codeception
HiDev plugin for PHPUnit
Testing Suite For Lumen like Laravel does.
A cli tool which generates unit tests.
A Laravel package to catch outbound mail (similar to Mailtrap) that also provides a UI to view them.
A local mail inbox for Laravel
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-01-04