biozshock/phpunit-consecutive
Composer 安装命令:
composer require --dev biozshock/phpunit-consecutive
包简介
Utility class to replace phpunit withConsecutive
关键字:
README 文档
README
Why?
In the issue of PHPUnit there are several
possibilities to replace missing functionality withConsecutive of PHPUnit.
Most of the comments use some sort of the callback:
$expectedArguments = [ ... ] ->withConsecutive(function ($arg1, $arg2) use (&$index) { if ($index === 0) { self::assertEquals('some', $arg1); ... } });
Eventually i've got sick of writing such code. Writing boilerplate and repeating yourself is no fun.
The class solve also the issue, where you need to operate with arguments <-> return value relation. Giving the developer an ability to define what's returned with each argument set.
Install
composer require --dev biozshock/phpunit-consecutive
Usage
When you need to mock the method which returns a value.
$mock->method('add') ->withConsecutive($a, $b) ->willReturn(1, 2);
Is replaced by
$mock->method('add') ->willRecturnCallback(Consecutive::consecutiveMap([ [$a, 1], [$b, 2] ]));
Or return callback, which accepts given arguments:
$mock->method('add') ->willRecturnCallback(Consecutive::consecutiveMap([ [$a, $b, static function (int $a, string $b): bool { return $a === (int) $b; }], [$c, $d, static function (int $c, string $d): bool { return str_starts_with($d, (string) $c); }] ]));
Also, you can test methods that return one of arguments. In this example the test expects zero-index argument $a to be returned:
$mock->method('add') ->willRecturnCallback(Consecutive::consecutiveMap([ [$a, $b], [$a, $d] ], 0));
Otherwise, when mocked method returns void.
$mock->method('add') ->withConsecutive($a, $b);
Is replaced by
$mock->method('add') ->willRecturnCallback(Consecutive::consecutiveCall([ [$a], [$b] ]));
biozshock/phpunit-consecutive 适用场景与选型建议
biozshock/phpunit-consecutive 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.02k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「phpunit」 「dev」 「consecutive」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 biozshock/phpunit-consecutive 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 biozshock/phpunit-consecutive 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 biozshock/phpunit-consecutive 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Drop-in Trait to use removed ConsecutiveParams from PhpUnit
HiDev plugin for PHPUnit
Testing Suite For Lumen like Laravel does.
A cli tool which generates unit tests.
Monolog bridge for PHP Debugbar
Laravel package to generate values in a unique and customizable series.
统计信息
- 总下载量: 1.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-05