vielhuber/comparehelper
Composer 安装命令:
composer require vielhuber/comparehelper
包简介
small php helper for comparing api responses in your tests.
README 文档
README
📑 comparehelper 📑
comparehelper is a small php helper for comparing api responses in your tests.
installation
install once with composer:
composer require vielhuber/comparehelper
then add this to your files:
require __DIR__ . '/vendor/autoload.php'; use vielhuber\comparehelper\comparehelper;
usage
comparehelper::compare($var1, $var2); // true|false
you can use the following placeholders:
*: any datatype#STR#: any string#INT#: any numeric value
examples
comparehelper::compare('foo', 'foo'); // true comparehelper::compare(42, 42); // true comparehelper::compare( [ 'foo' => 'bar' ], [ 'foo' => 'bar', 'foo2' => 'bar' ] ); // false comparehelper::compare( [ 'foo' => 'bar', 'bar' => ['baz', 42] ], [ '#STR' => '*', 'bar' => ['#STR#', '#INT#'] ] ); // true // ordering is lazy comparehelper::compare(['foo', 'bar'], ['bar', 'foo']); // true comparehelper::compare(['#INT#', '#STR#'], [42, 'foo']); // true comparehelper::compare(['#INT#', '#STR#'], ['foo', 42]); // false comparehelper::compare(['foo' => 7, 'bar' => 42], ['bar' => 42, 'foo' => 7]); // true comparehelper::compare(['#INT#' => 7, '#STR#' => 42], [7 => 7, 'foo' => 42]); // true comparehelper::compare(['#INT#' => 7, '#STR#' => 42], ['foo' => 42, 7 => 7]); // false // datatypes are strict comparehelper::compare(42, '42'); // false
phpunit integration
for better diff output in tests, use assertEquals() instead of compare():
// instead of: $this->assertTrue(comparehelper::compare($expected, $actual)); // use this for better diffs: comparehelper::assertEquals($expected, $actual); // example: comparehelper::assertEquals(['id' => '#INT#', 'name' => '#STR#', 'status' => 'active'], $apiResponse);
vielhuber/comparehelper 适用场景与选型建议
vielhuber/comparehelper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 768 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 07 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 vielhuber/comparehelper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vielhuber/comparehelper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 768
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-25