sophie-spec/versus
Composer 安装命令:
composer require sophie-spec/versus
包简介
A proof-of-concept unit tester for callables
README 文档
README
Like Ensure, Versus 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. Versus enlarges Ensure tool so we can verify several inputs/ouputs with ease.
Install
composer require --dev sophie-spec/versus
Requires PHP >= 7.4.
Use
To test a method with several inputs/outputs, we simply pass the callable and yield values from a generator:
use function Sophie\Versus\versus; $add = function ($a, $b) { return $a + $b; }; versus($add, function () { yield [1, 2] => 3; yield [-2, -3] => -5; yield [10, -20] => -10; });
If the assertion fails, a Sophie\Ensure\FailedAssertionException error is thrown with a detailed message:
versus($add, function () { yield [1, 2] => 100; }); /* Both values are not equal. Provided value: 3 Expected value: 100 */
License
MIT.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-12-28