Skip to content

Commit 3b8e095

Browse files
committed
Enhancement: Add support for phpunit/phpunit:^9.6.0
1 parent 0dc5417 commit 3b8e095

File tree

36 files changed

+964
-169
lines changed

36 files changed

+964
-169
lines changed

.github/settings.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,24 @@ branches:
2121
- context: "Refactoring (8.1, locked)"
2222
- context: "Security Analysis (8.1, locked)"
2323
- context: "Static Code Analysis (8.1, locked)"
24-
- context: "Tests (8.1, highest)"
25-
- context: "Tests (8.1, locked)"
26-
- context: "Tests (8.1, lowest)"
27-
- context: "Tests (8.2, highest)"
28-
- context: "Tests (8.2, locked)"
29-
- context: "Tests (8.2, lowest)"
30-
- context: "Tests (8.3, highest)"
31-
- context: "Tests (8.3, locked)"
32-
- context: "Tests (8.3, lowest)"
24+
- context: "Tests (8.1, 10.4.0, highest)"
25+
- context: "Tests (8.1, 10.4.0, locked)"
26+
- context: "Tests (8.1, 10.4.0, lowest)"
27+
- context: "Tests (8.1, 9.6.0, highest)"
28+
- context: "Tests (8.1, 9.6.0, locked)"
29+
- context: "Tests (8.1, 9.6.0, lowest)"
30+
- context: "Tests (8.2, 10.4.0, highest)"
31+
- context: "Tests (8.2, 10.4.0, locked)"
32+
- context: "Tests (8.2, 10.4.0, lowest)"
33+
- context: "Tests (8.2, 9.6.0, highest)"
34+
- context: "Tests (8.2, 9.6.0, locked)"
35+
- context: "Tests (8.2, 9.6.0, lowest)"
36+
- context: "Tests (8.3, 10.4.0, highest)"
37+
- context: "Tests (8.3, 10.4.0, locked)"
38+
- context: "Tests (8.3, 10.4.0, lowest)"
39+
- context: "Tests (8.3, 9.6.0, highest)"
40+
- context: "Tests (8.3, 9.6.0, locked)"
41+
- context: "Tests (8.3, 9.6.0, lowest)"
3342
strict: false
3443
restrictions:
3544

.github/workflows/integrate.yaml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,10 @@ jobs:
449449
- "8.2"
450450
- "8.3"
451451

452+
phpunit-version:
453+
- "9.6.0"
454+
- "10.4.0"
455+
452456
dependencies:
453457
- "lowest"
454458
- "locked"
@@ -481,16 +485,25 @@ jobs:
481485
uses: "actions/[email protected]"
482486
with:
483487
path: "${{ env.COMPOSER_CACHE_DIR }}"
484-
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
485-
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"
488+
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-phpunit-${{ matrix.phpunit-version }}-${{ hashFiles('composer.lock') }}"
489+
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-phpunit-${{ matrix.phpunit-version }}-"
490+
491+
- name: "Require phpunit/phpunit:^${{ matrix.phpunit-version }}"
492+
run: "composer require phpunit/phpunit:^${{ matrix.phpunit-version }} --ansi --no-interaction --no-progress --update-with-all-dependencies"
486493

487494
- name: "Install ${{ matrix.dependencies }} dependencies with composer"
488495
uses: "ergebnis/.github/actions/composer/[email protected]"
489496
with:
490497
dependencies: "${{ matrix.dependencies }}"
491498

492-
- name: "Run unit tests with phpunit/phpunit"
499+
- name: "Run unit tests with phpunit/phpunit:10.4.0"
500+
if: "matrix.phpunit-version == '10.4.0'"
493501
run: "vendor/bin/phpunit --colors=always --configuration=test/Unit/phpunit.xml"
494502

495-
- name: "Run end-to-end tests with phpunit/phpunit"
496-
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/phpunit.xml"
503+
- name: "Run end-to-end tests with phpunit/phpunit:10.4.0"
504+
if: "matrix.phpunit-version == '10.4.0'"
505+
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version10/phpunit.xml"
506+
507+
- name: "Run end-to-end tests with phpunit/phpunit:9.6.0"
508+
if: "matrix.phpunit-version == '9.6.0'"
509+
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version9/phpunit.xml"

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88

99
For a full diff see [`2.3.2...main`][2.3.2...main].
1010

11+
### Added
12+
13+
- Added support for `phpunit/phpunit:^9.6.0` ([#341]), by [@localheinz]
14+
1115
### Changed
1216

1317
- Extracted `Duration` ([#351]), by [@localheinz]
@@ -175,6 +179,7 @@ For a full diff see [`7afa59c...1.0.0`][7afa59c...1.0.0].
175179
[#272]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/272
176180
[#273]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/273
177181
[#340]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/340
182+
[#341]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/341
178183
[#342]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/342
179184
[#343]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/343
180185
[#350]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/350

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ 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-
vendor/bin/phpunit --configuration=test/Unit/phpunit.xml
63-
vendor/bin/phpunit --configuration=test/EndToEnd/phpunit.xml
62+
composer require phpunit/phpunit:10.4.0 --no-interaction --no-progress --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/Unit/phpunit.xml; git checkout HEAD -- composer.json composer.lock; composer install --no-interaction --no-progress
63+
composer require phpunit/phpunit:10.4.0 --no-interaction --no-progress --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version10/phpunit.xml; git checkout HEAD -- composer.json composer.lock; composer install --no-interaction --no-progress
64+
composer require phpunit/phpunit:9.6.0 --no-interaction --no-progress --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version9/phpunit.xml; git checkout HEAD -- composer.json composer.lock; composer install --no-interaction --no-progress
6465

6566
vendor: composer.json composer.lock
6667
composer validate --strict

README.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Download `phpunit-slow-test-detector.phar` from the [latest release](https://git
3434

3535
### Bootstrapping the extension as a `composer` package
3636

37-
To bootstrap the extension as a `composer` package, adjust your `phpunit.xml` configuration file and configure the [`<extensions>` element](https://docs.phpunit.de/en/10.4/configuration.html#the-extensions-element):
37+
To bootstrap the extension as a `composer` package when using `phpunit/phpunit:^10.4.0`, adjust your `phpunit.xml` configuration file and configure the [`extensions` element](https://docs.phpunit.de/en/10.4/configuration.html#the-extensions-element):
3838

3939
```diff
4040
<phpunit
@@ -53,9 +53,28 @@ To bootstrap the extension as a `composer` package, adjust your `phpunit.xml` co
5353
</phpunit>
5454
```
5555

56+
To bootstrap the extension as a `composer` package when using `phpunit/phpunit:^9.6.0`, adjust your `phpunit.xml` configuration file and configure the [`extensions` element](https://docs.phpunit.de/en/9.6/configuration.html#the-extensions-element):
57+
58+
```diff
59+
<phpunit
60+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
61+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
62+
bootstrap="vendor/autoload.php"
63+
>
64+
+ <extensions>
65+
+ <extension class="Ergebnis\PHPUnit\SlowTestDetector\Extension"/>
66+
+ </extensions>
67+
<testsuites>
68+
<testsuite name="unit">
69+
<directory>test/Unit/</directory>
70+
</testsuite>
71+
</testsuites>
72+
</phpunit>
73+
```
74+
5675
### Bootstrapping the extension as a PHAR
5776

58-
To bootstrap the extension as a PHAR, adjust your `phpunit.xml` configuration file and configure the [`extensionsDirectory` attribute](https://docs.phpunit.de/en/10.4/configuration.html#the-extensionsdirectory-attribute) of the [`<phpunit>` element](https://docs.phpunit.de/en/10.4/configuration.html#the-phpunit-element):
77+
To bootstrap the extension as a PHAR when using `phpunit/phpunit:^10.4.0`, adjust your `phpunit.xml` configuration file and configure the [`extensionsDirectory` attribute](https://docs.phpunit.de/en/10.4/configuration.html#the-extensionsdirectory-attribute) of the [`<phpunit>` element](https://docs.phpunit.de/en/10.4/configuration.html#the-phpunit-element):
5978

6079
```diff
6180
<phpunit
@@ -82,7 +101,7 @@ You can configure the extension with the following parameters in your `phpunit.x
82101
- `maximum-count`, an `int`, the maximum count of slow test that should be listed, defaults to `10`
83102
- `maximum-duration`, an `int`, the maximum duration in milliseconds for all tests, defaults to `500`
84103

85-
The following example configures the maximum count of slow tests to three, and the maximum duration for all tests to 250 milliseconds:
104+
The following example configures the maximum count of slow tests to three, and the maximum duration for all tests to 250 milliseconds when using `phpunit/phpunit:^10.4.0`:
86105

87106
```diff
88107
<phpunit
@@ -105,6 +124,37 @@ The following example configures the maximum count of slow tests to three, and t
105124
</phpunit>
106125
```
107126

127+
The following example configures the maximum count of slow tests to three, and the maximum duration for all tests to 250 milliseconds when using `phpunit/phpunit:^9.6.0`:
128+
129+
```diff
130+
<phpunit
131+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
132+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
133+
bootstrap="vendor/autoload.php"
134+
>
135+
<extensions>
136+
- <extension class="Ergebnis\PHPUnit\SlowTestDetector\Extension"/>
137+
+ <extension class="Ergebnis\PHPUnit\SlowTestDetector\Extension">
138+
+ <arguments>
139+
+ <array>
140+
+ <element key="maximum-count">
141+
+ <integer>3</integer>
142+
+ </element>
143+
+ <element key="maximum-duration">
144+
+ <integer>250</integer>
145+
+ </element>
146+
+ </array>
147+
+ </arguments>
148+
+ </extension>
149+
</extensions>
150+
<testsuites>
151+
<testsuite name="unit">
152+
<directory>test/Unit/</directory>
153+
</testsuite>
154+
</testsuites>
155+
</phpunit>
156+
```
157+
108158
#### Configuring the maximum duration per test case
109159

110160
You can configure the maximum duration for a single test with a `@maximumDuration` (or `@slowThreshold`) annotation in the DocBlock.

composer-require-checker.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{
2-
"symbol-whitelist": []
2+
"symbol-whitelist": [
3+
"PHPUnit\\Runner\\AfterLastTestHook",
4+
"PHPUnit\\Runner\\AfterSuccessfulTestHook",
5+
"PHPUnit\\Runner\\BeforeFirstTestHook"
6+
]
37
}

composer.json

Lines changed: 1 addition & 1 deletion
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.0"
28+
"phpunit/phpunit": "^9.6.0 || ^10.4.0"
2929
},
3030
"require-dev": {
3131
"ergebnis/composer-normalize": "^2.39.0",

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

psalm-baseline.xml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<files psalm-version="5.15.0@5c774aca4746caf3d239d9c8cadb9f882ca29352">
33
<file src="src/Extension.php">
4+
<DuplicateClass>
5+
<code>Extension</code>
6+
</DuplicateClass>
47
<UnusedClass>
58
<code>Extension</code>
69
</UnusedClass>
@@ -30,6 +33,19 @@
3033
<MixedAssignment>
3134
<code>$maximumDuration</code>
3235
</MixedAssignment>
36+
<UnusedClass>
37+
<code>TestPassedSubscriber</code>
38+
</UnusedClass>
39+
</file>
40+
<file src="src/Subscriber/TestPreparedSubscriber.php">
41+
<UnusedClass>
42+
<code>TestPreparedSubscriber</code>
43+
</UnusedClass>
44+
</file>
45+
<file src="src/Subscriber/TestRunnerExecutionFinishedSubscriber.php">
46+
<UnusedClass>
47+
<code>TestRunnerExecutionFinishedSubscriber</code>
48+
</UnusedClass>
3349
</file>
3450
<file src="test/Double/Collector/AppendingCollector.php">
3551
<UnusedClass>
@@ -46,12 +62,12 @@
4662
<code>NullReporter</code>
4763
</UnusedClass>
4864
</file>
49-
<file src="test/EndToEnd/Default/SleeperTest.php">
65+
<file src="test/EndToEnd/Version10/Default/SleeperTest.php">
5066
<PossiblyUnusedMethod>
5167
<code>provideMillisecondsGreaterThanDefaultMaximumDuration</code>
5268
</PossiblyUnusedMethod>
5369
</file>
54-
<file src="test/EndToEnd/MaximumCount/Three/SleeperTest.php">
70+
<file src="test/EndToEnd/Version10/MaximumCount/Three/SleeperTest.php">
5571
<PossiblyUnusedMethod>
5672
<code>provideMillisecondsGreaterThanDefaultMaximumDuration</code>
5773
</PossiblyUnusedMethod>

rector.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,4 @@
3131
$rectorConfig->rules([
3232
Php81\Rector\Property\ReadOnlyPropertyRector::class,
3333
]);
34-
35-
$rectorConfig->sets([
36-
PHPUnit\Set\PHPUnitSetList::PHPUNIT_100,
37-
]);
3834
};

0 commit comments

Comments
 (0)