定制 rpkamp/mailhog-mink-behat-context 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rpkamp/mailhog-mink-behat-context

Composer 安装命令:

composer require rpkamp/mailhog-mink-behat-context

包简介

Mailhog Extension for Behat

README 文档

README

A PHP (7.4+) Behat context for Mailhog with Mink integration.

Allows to simulate link clicks in emails and continue from the links URL in Mink. Suitable in browser-email-browser flows such as forgotten password resets.

This context is based on the MailhogAwareContext from rpkamp/mailhog-behat-extension.

Installation

This package does not require any specific HTTP client implementation, but it requires rpkamp/mailhog-client, which is based on HTTPlug, so you can inject your own HTTP client of choice. So you when you install this extension make sure you either already have an HTTP client installed, or install one at the same time as installing this context, otherwise installation will fail.

composer require rpkamp/mailhog-mink-behat-context <your-http-client-of-choice>

For more information please refer to the HTTPlug documentation for Library Users.

Usage

Register extension in Behat

This context require rpkamp/mailhog-behat-extension to be enabled in your behat configuration.

If you have not already done so, add the MailhogExtension extension to your behat.yml like so:

default:
  suites:
    # your suite configuration here
  extensions:
    rpkamp\Behat\MailhogExtension:
      base_url: http://localhost:8025

The base_url is the URL where the Mailhog Web UI is listening to (by default this is http://localhost:8025).

And also include the \rpkamp\Behat\MailhogExtension\Context\MinkAwareMailogContext in your contexts for behat:

default:
  suites:
    contexts:
      - rpkamp\Behat\Context\MinkAwareMailhogContext

Note that this context does not extend rpkamp\Behat\MailhogExtension\Context\MailhogContext from rpkamp/mailhog-behat-extension, so if you need functionality from both contexts you need to include both contexts in your behat configuration.

Gherkin steps

This context contains the following gherkin steps:

When I click the link "link-description" in the last received email
When I click the link "link-description" in the opened email 

This first step will fetch the last received email from Mailhog and search for a link with "link-description" as (in order):

  • id attribute (<a id="link-description"></a>)
  • link text (<a>link-description</a>)
  • title attribute (<a title="link-description"></a>)
  • alt attribute (<a alt="link-description"></a>)
  • partial link text (<a>some link-description</a>)

It will stop when it finds any of the above criteria fits and that tell Mink to follow that link, so from there on you can continue in Mink. This enables scenarios like password reset where you receive an email, click a link in that email and then do something in a browser.

The second step fetches the email that was opened using rpkamp/mailhog-behat-extension and open the link with "link-description" in that, using the same procedure as outline above.

Run tests

Make sure you have Mailhog running and run:

make test

Running Mailhog for tests

You can either run your own instance of Mailhog or use the provided docker-compose file to run one for you. To run Mailhog with Docker make sure you have Docker and docker-compose installed and run:

docker-compose up -d

Mailhog ports for tests

To prevent port collisions with any other Mailhog instances while testing the tests expect Mailhog to listen to SMTP on port 4025 (instead of the default 1025) and to HTTP traffic on port 11025 (instead of the default 8025).

rpkamp/mailhog-mink-behat-context 适用场景与选型建议

rpkamp/mailhog-mink-behat-context 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 58.21k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2017 年 12 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 rpkamp/mailhog-mink-behat-context 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 rpkamp/mailhog-mink-behat-context 我们能提供哪些服务?
定制开发 / 二次开发

基于 rpkamp/mailhog-mink-behat-context 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 58.21k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-17