|
16 | 16 | use PHPUnit\Runner;
|
17 | 17 | use PHPUnit\TextUI;
|
18 | 18 |
|
19 |
| -final class Extension implements Runner\Extension\Extension |
20 |
| -{ |
21 |
| - public function bootstrap( |
22 |
| - TextUI\Configuration\Configuration $configuration, |
23 |
| - Runner\Extension\Facade $facade, |
24 |
| - Runner\Extension\ParameterCollection $parameters, |
25 |
| - ): void { |
26 |
| - if ($configuration->noOutput()) { |
27 |
| - return; |
28 |
| - } |
| 19 | +if (1 !== \preg_match('/(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/', Runner\Version::id(), $matches)) { |
| 20 | + throw new \RuntimeException(\sprintf( |
| 21 | + 'Unable to determine PHPUnit version from version identifier "%s".', |
| 22 | + Runner\Version::id(), |
| 23 | + )); |
| 24 | +} |
29 | 25 |
|
30 |
| - $maximumCount = Count::fromInt(10); |
| 26 | +$major = (int) $matches['major']; |
31 | 27 |
|
32 |
| - if ($parameters->has('maximum-count')) { |
33 |
| - $maximumCount = Count::fromInt((int) $parameters->get('maximum-count')); |
34 |
| - } |
| 28 | +if (10 <= $major) { |
| 29 | + /** |
| 30 | + * @internal |
| 31 | + */ |
| 32 | + final class Extension implements Runner\Extension\Extension |
| 33 | + { |
| 34 | + public function bootstrap( |
| 35 | + TextUI\Configuration\Configuration $configuration, |
| 36 | + Runner\Extension\Facade $facade, |
| 37 | + Runner\Extension\ParameterCollection $parameters, |
| 38 | + ): void { |
| 39 | + if ($configuration->noOutput()) { |
| 40 | + return; |
| 41 | + } |
35 | 42 |
|
36 |
| - $maximumDuration = Duration::fromMilliseconds(500); |
| 43 | + $maximumCount = Count::fromInt(10); |
37 | 44 |
|
38 |
| - if ($parameters->has('maximum-duration')) { |
39 |
| - $maximumDuration = Duration::fromMilliseconds((int) $parameters->get('maximum-duration')); |
40 |
| - } |
| 45 | + if ($parameters->has('maximum-count')) { |
| 46 | + $maximumCount = Count::fromInt((int) $parameters->get('maximum-count')); |
| 47 | + } |
41 | 48 |
|
42 |
| - $collector = new Collector\DefaultCollector(); |
| 49 | + $maximumDuration = Duration::fromMilliseconds(500); |
43 | 50 |
|
44 |
| - $reporter = new Reporter\DefaultReporter( |
45 |
| - new Formatter\DefaultDurationFormatter(), |
46 |
| - $maximumDuration, |
47 |
| - $maximumCount, |
48 |
| - ); |
| 51 | + if ($parameters->has('maximum-duration')) { |
| 52 | + $maximumDuration = Duration::fromMilliseconds((int) $parameters->get('maximum-duration')); |
| 53 | + } |
49 | 54 |
|
50 |
| - $timeKeeper = new TimeKeeper(); |
| 55 | + $collector = new Collector\DefaultCollector(); |
51 | 56 |
|
52 |
| - $facade->registerSubscribers( |
53 |
| - new Subscriber\TestPreparedSubscriber($timeKeeper), |
54 |
| - new Subscriber\TestPassedSubscriber( |
| 57 | + $reporter = new Reporter\DefaultReporter( |
| 58 | + new Formatter\DefaultDurationFormatter(), |
55 | 59 | $maximumDuration,
|
56 |
| - $timeKeeper, |
57 |
| - $collector, |
58 |
| - ), |
59 |
| - new Subscriber\TestRunnerExecutionFinishedSubscriber( |
60 |
| - $collector, |
61 |
| - $reporter, |
62 |
| - ), |
63 |
| - ); |
| 60 | + $maximumCount, |
| 61 | + ); |
| 62 | + |
| 63 | + $timeKeeper = new TimeKeeper(); |
| 64 | + |
| 65 | + $facade->registerSubscribers( |
| 66 | + new Subscriber\TestPreparedSubscriber($timeKeeper), |
| 67 | + new Subscriber\TestPassedSubscriber( |
| 68 | + $maximumDuration, |
| 69 | + $timeKeeper, |
| 70 | + $collector, |
| 71 | + ), |
| 72 | + new Subscriber\TestRunnerExecutionFinishedSubscriber( |
| 73 | + $collector, |
| 74 | + $reporter, |
| 75 | + ), |
| 76 | + ); |
| 77 | + } |
64 | 78 | }
|
| 79 | +} else { |
| 80 | + throw new \RuntimeException(\sprintf( |
| 81 | + 'Unable to select extension for PHPUnit version with version identifier "%s".', |
| 82 | + Runner\Version::id(), |
| 83 | + )); |
65 | 84 | }
|
0 commit comments