1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace loophp\phpspectime; |
6
|
|
|
|
7
|
|
|
use PhpSpec\Exception\Example\MatcherException; |
8
|
|
|
use PhpSpec\Formatter\Presenter\Presenter; |
9
|
|
|
|
10
|
|
|
final class TimeMatcherException |
11
|
|
|
{ |
12
|
2 |
|
public static function notInRangeMatcherException(Presenter $presenter, $result, $from, $to): MatcherException |
13
|
|
|
{ |
14
|
2 |
|
return new MatcherException( |
15
|
2 |
|
sprintf( |
16
|
|
|
"Method call not in the expected timespan.\n" . |
17
|
|
|
"From %s to %s second(s) expected,\n" . |
18
|
2 |
|
'Got %s.', |
19
|
2 |
|
$presenter->presentValue($from), |
20
|
2 |
|
$presenter->presentValue($to), |
21
|
2 |
|
$presenter->presentValue($result) |
22
|
|
|
) |
23
|
|
|
); |
24
|
|
|
} |
25
|
|
|
|
26
|
2 |
|
public static function tooFastMatcherException(Presenter $presenter, $result, float $expected): MatcherException |
27
|
|
|
{ |
28
|
2 |
|
return new MatcherException( |
29
|
2 |
|
sprintf( |
30
|
|
|
"Method call too fast to complete.\n" . |
31
|
|
|
"%s second(s) expected,\n" . |
32
|
2 |
|
'Got %s.', |
33
|
2 |
|
$presenter->presentValue($expected), |
34
|
2 |
|
$presenter->presentValue($result) |
35
|
|
|
) |
36
|
|
|
); |
37
|
|
|
} |
38
|
|
|
|
39
|
2 |
|
public static function tooSlowMatcherException(Presenter $presenter, $result, float $expected): MatcherException |
40
|
|
|
{ |
41
|
2 |
|
return new MatcherException( |
42
|
2 |
|
sprintf( |
43
|
|
|
"Method call too slow to complete.\n" . |
44
|
|
|
"%s second(s) expected,\n" . |
45
|
2 |
|
'Got %s.', |
46
|
2 |
|
$presenter->presentValue($expected), |
47
|
2 |
|
$presenter->presentValue($result) |
48
|
|
|
) |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|