sophie-spec/ensure
Composer 安装命令:
composer require sophie-spec/ensure
包简介
Ensure that both arguments are equal
README 文档
README
Ensure is born with the thought that an ideal unit test should be a strict equality between the output of a function and its expected result. Then, Ensure is that base tool for anything to test.
Install
composer require --dev sophie-spec/ensure
Requires PHP >= 7.4.
Use
use function Sophie\Ensure\ensure; $add = function ($a, $b) { return $a + $b; }; ensure($add(1, 2), 3);
If the assertion fails, a Sophie\Ensure\FailedAssertionException error is thrown with a detailed message:
ensure($add(1, 2), 10); /* Both values are not equal. Provided value: 3 Expected value: 10 */
More complex values are also well printed:
ensure( [ 'strawberry', 'orange', 'lime', ], [ 'orange', 'lime', 'strawberry', ], ); /* Both values are not equal. Provided value: array:3 [ 0 => (10) "strawberry" 1 => (6) "orange" 2 => (4) "lime" ] Expected value: array:3 [ 0 => (6) "orange" 1 => (4) "lime" 2 => (10) "strawberry" ] */
License
MIT.
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-12-24