loophp / phpspec-time
此包已被放弃且不再维护。未建议替代包。
一个提供测试中时间测量匹配器的PHPSpec扩展。
1.1.1
2021-03-21 20:46 UTC
Requires
- php: >= 7.4
- loophp/nanobench: ^1
Requires (Dev)
- drupol/php-conventions: ^3.0.2
- friends-of-phpspec/phpspec-code-coverage: ^5
- infection/infection: ^0.21
- infection/phpspec-adapter: ^0.1.2
- phpspec/phpspec: ^7
- phpstan/phpstan-strict-rules: ^0.12
- vimeo/psalm: ^4
This package is auto-updated.
Last update: 2022-03-21 10:52:37 UTC
README
PHPSpec 时间
一个提供测试中时间测量匹配器的PHPSpec扩展。
新匹配器
shouldTakeLessThan(float $timeUnit)
shouldTakeMoreThan(float $timeUnit)
shouldTakeInBetween(float $fromTimeUnit, float $toTimeUnit)
安装
composer require loophp/phpspec-time
使用
将扩展添加到phpspec配置文件中
extensions: loophp\phpspectime\Extension: ~
默认情况下,时间单位为秒
,但其他单位也可用
纳秒
微秒
毫秒
秒
分钟
小时
天
周
如果您想更改时间单位,请按如下方式编辑扩展配置
extensions: loophp\phpspectime\Extension: timeunit: nanosecond
在您的测试中,您现在可以访问以下新匹配器
$this ->shouldTakeMoreThan(10) ->during('method'); $this ->shouldNotTakeMoreThan(10) ->during('method'); $this ->shouldTakeLessThan(10) ->during('method'); $this ->shouldNotTakeLessThan(10) ->during('method'); $this ->shouldTakeInBetween(3.0, 3.2) ->during('method'); $this ->shouldNotTakeInBetween(3.0, 3.2) ->during('method');
代码质量、测试和基准
每次向库中引入更改时,Github 都会运行测试。
库的测试是用 PHPSpec 编写的。您可以在 spec
目录中自由查看它们。运行 composer phpspec
触发测试。
在每次提交之前,使用 GrumPHP 执行一些检查,运行 composer grumphp
手动检查。
测试质量使用 Infection 进行测试,这是一个PHP突变测试框架,运行 composer infection
尝试。
静态分析器也控制着代码。启用了PHPStan 和 PSalm 的最大级别。
贡献
您可以通过发送Github拉取请求来自由贡献。我非常积极 :-)
如果您不能对代码做出贡献,您也可以在Github 或 Paypal 上赞助我。
变更日志
请参阅CHANGELOG.md,以查看基于git提交的变更日志。
有关更详细的变更日志,请检查发布变更日志。