Skip to content

Commit a55e345

Browse files
committed
Enhancement: Add support for phpunit/phpunit:^9.6.13
1 parent 9774914 commit a55e345

File tree

5 files changed

+74
-39
lines changed

5 files changed

+74
-39
lines changed

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ static-code-analysis-baseline: vendor ## Generates a baseline for static code an
5959
.PHONY: tests
6060
tests: vendor ## Runs unit and end-to-end tests with phpunit/phpunit
6161
mkdir -p .build/phpunit
62+
composer require phpunit/phpunit:10.4.2 --no-interaction --no-progress
6263
vendor/bin/phpunit --configuration=test/Unit/phpunit.xml
63-
vendor/bin/phpunit --configuration=test/EndToEnd/phpunit.xml
64+
composer require phpunit/phpunit:10.4.2 --no-interaction --no-progress
65+
vendor/bin/phpunit --configuration=test/EndToEnd/Version10/phpunit.xml
66+
git checkout HEAD -- composer.json composer.lock
6467

6568
vendor: composer.json composer.lock
6669
composer validate --strict

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"require": {
2727
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
28-
"phpunit/phpunit": "^10.4.2"
28+
"phpunit/phpunit": "^9.6.13 || ^10.4.2"
2929
},
3030
"require-dev": {
3131
"ergebnis/composer-normalize": "^2.39.0",

composer.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

psalm-baseline.xml

+13
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
<MixedAssignment>
3131
<code>$maximumDuration</code>
3232
</MixedAssignment>
33+
<UnusedClass>
34+
<code>TestPassedSubscriber</code>
35+
</UnusedClass>
36+
</file>
37+
<file src="src/Subscriber/TestPreparedSubscriber.php">
38+
<UnusedClass>
39+
<code>TestPreparedSubscriber</code>
40+
</UnusedClass>
41+
</file>
42+
<file src="src/Subscriber/TestRunnerExecutionFinishedSubscriber.php">
43+
<UnusedClass>
44+
<code>TestRunnerExecutionFinishedSubscriber</code>
45+
</UnusedClass>
3346
</file>
3447
<file src="test/Double/Collector/AppendingCollector.php">
3548
<UnusedClass>

src/Extension.php

+55-36
Original file line numberDiff line numberDiff line change
@@ -16,50 +16,69 @@
1616
use PHPUnit\Runner;
1717
use PHPUnit\TextUI;
1818

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+
}
2925

30-
$maximumCount = Count::fromInt(10);
26+
$major = (int) $matches['major'];
3127

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+
}
3542

36-
$maximumDuration = Duration::fromMilliseconds(500);
43+
$maximumCount = Count::fromInt(10);
3744

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+
}
4148

42-
$collector = new Collector\DefaultCollector();
49+
$maximumDuration = Duration::fromMilliseconds(500);
4350

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+
}
4954

50-
$timeKeeper = new TimeKeeper();
55+
$collector = new Collector\DefaultCollector();
5156

52-
$facade->registerSubscribers(
53-
new Subscriber\TestPreparedSubscriber($timeKeeper),
54-
new Subscriber\TestPassedSubscriber(
57+
$reporter = new Reporter\DefaultReporter(
58+
new Formatter\DefaultDurationFormatter(),
5559
$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+
}
6478
}
79+
} else {
80+
throw new \RuntimeException(\sprintf(
81+
'Unable to select extension for PHPUnit version with version identifier "%s".',
82+
Runner\Version::id(),
83+
));
6584
}

0 commit comments

Comments
 (0)