tumtum/mock-extern-service
Composer 安装命令:
composer require tumtum/mock-extern-service
包简介
To mock service like mail or UDP socket for functional Tests. TDD, PHPUnit
README 文档
README
To mock service like mail or UDP socket for functional Tests. The result will be saved in a file and that can you assert.
Installation
composer require --dev "tumtum/mock-extern-service"
Booting
At first to you must booting this system, that can you do in the bootstrap file see.
\tm\MockExternService\Service::boot();
Than you must start PHPUnit with PHP interpreter option -d sendmail_path=[vendor/]bin/smtp-mock-server.php
This script will mock the Mail System.
Assert
Mock Mails System
with tm\MockExternService\Result::MailInbox() get you the mail Content.
The PHP ini "sendmail_path" must be set to smtp-mock-server.php script. That get the Mail and save it. This config can only set befor starts the script. Like in php.ini or as command option (php -d)
Sample:
public function testMockMailSystem()
{
$msg = "Content " . time();
mail('root@@127.0.0.1', "subject", $msg);
$this->assertContains($msg, MockExternService\Result::MailInbox());
}
Mock UDP Socket
with tm\MockExternService\Result::UdpSockArrived() get you 2048 Bit of Content.
Socket will be listen on:
| host | port |
|---|---|
| 127.0.0.1 | 13010 |
Sample:
public function testGrayLogServer()
{
$data = "graylog_data " . time();
$socket = fsockopen('udp://127.0.0.1:13010');
fputs($socket, $data);
$this->assertEquals($data, MockExternService\Result::UdpSockArrived());
}
Sample:
See PHPUnitTest command: php -d sendmail_path=mock-service/smtp-mock-server.php ./vendor/bin/phpunit.
Chanelog
- v0.1 First Idea
tumtum/mock-extern-service 适用场景与选型建议
tumtum/mock-extern-service 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 576 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 tumtum/mock-extern-service 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tumtum/mock-extern-service 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 576
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-06-09