ascii-soup / hamcrest-callback-matcher
Hamcrest 匹配器,用于与提供的回调进行匹配。
1.1
2016-03-16 15:42 UTC
Requires
- hamcrest/hamcrest-php: 1.2.*|2.*
Requires (Dev)
- phpunit/phpunit: 5.2.*
This package is auto-updated.
Last update: 2024-09-12 03:41:40 UTC
README
用法
assertThat("hello", matchesUsing(function($value) { return $value === "hello"; }));
创建新的自定义匹配器
使用回调匹配器可以简化创建新的自定义匹配器。
您可以使用 describedAs()
提供更好的期望描述。
function myCustomMatcher() { return describedAs('a custom value', new CallbackMatcher( function($value) { return $value === 'my custom value'; } ) }