Skip to content

Commit 4e747f2

Browse files
authored
Merge pull request #651 from ergebnis/feature/phpunit-12
Enhancement: Add support for `phpunit/phpunit:^12.0.0`
2 parents b226bff + a4041a1 commit 4e747f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2764
-12
lines changed

.github/settings.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ branches:
8383
- context: "Tests (11.0.0, 8.3, lowest)"
8484
- context: "Tests (11.3.6, 8.4, highest)"
8585
- context: "Tests (11.3.6, 8.4, lowest)"
86+
- context: "Tests (12.0.0, 8.3, highest)"
87+
- context: "Tests (12.0.0, 8.3, lowest)"
88+
- context: "Tests (12.0.0, 8.4, highest)"
89+
- context: "Tests (12.0.0, 8.4, lowest)"
8690
strict: false
8791
restrictions:
8892

.github/workflows/integrate.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,22 @@ jobs:
679679
php-version: "8.4"
680680
dependencies: "highest"
681681

682+
- phpunit-version: "12.0.0"
683+
php-version: "8.3"
684+
dependencies: "lowest"
685+
686+
- phpunit-version: "12.0.0"
687+
php-version: "8.3"
688+
dependencies: "highest"
689+
690+
- phpunit-version: "12.0.0"
691+
php-version: "8.4"
692+
dependencies: "lowest"
693+
694+
- phpunit-version: "12.0.0"
695+
php-version: "8.4"
696+
dependencies: "highest"
697+
682698
env:
683699
PHPUNIT_SLOW_TEST_DETECTOR_PHAR: ".build/phar/phpunit-slow-test-detector.phar"
684700

@@ -772,6 +788,10 @@ jobs:
772788
if: "matrix.phpunit-version == '11.0.0'"
773789
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version11/phpunit.xml"
774790

791+
- name: "Run end-to-end tests with phpunit/phpunit:12.0.0"
792+
if: "matrix.phpunit-version == '12.0.0'"
793+
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version12/phpunit.xml"
794+
775795
- name: "Download Phar"
776796
uses: "actions/[email protected]"
777797
with:
@@ -809,3 +829,7 @@ jobs:
809829
- name: "Run phar tests with phpunit/phpunit:11.0.0"
810830
if: "matrix.phpunit-version == '11.0.0'"
811831
run: "vendor/bin/phpunit --colors=always --configuration=test/Phar/Version11/phpunit.xml"
832+
833+
- name: "Run phar tests with phpunit/phpunit:12.0.0"
834+
if: "matrix.phpunit-version == '12.0.0'"
835+
run: "vendor/bin/phpunit --colors=always --configuration=test/Phar/Version12/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.17.0...main`][2.17.0...main].
1010

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

1317
For a full diff see [`2.16.1...2.17.0`][2.16.1...2.17.0].
@@ -380,6 +384,7 @@ For a full diff see [`7afa59c...1.0.0`][7afa59c...1.0.0].
380384
[#598]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/598
381385
[#604]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/604
382386
[#635]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/635
387+
[#651]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/651
383388

384389
[@dantleech]: https://github.com/dantleech
385390
[@HypeMC]: https://github.com/HypeMC

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The extension is compatible with the following versions of `phpunit/phpunit`:
2121
- [`phpunit/phpunit:^9.0.0`](https://github.com/sebastianbergmann/phpunit/tree/9.0.0)
2222
- [`phpunit/phpunit:^10.0.0`](https://github.com/sebastianbergmann/phpunit/tree/10.0.0)
2323
- [`phpunit/phpunit:^11.0.0`](https://github.com/sebastianbergmann/phpunit/tree/11.0.0)
24+
- [`phpunit/phpunit:^12.0.0`](https://github.com/sebastianbergmann/phpunit/tree/12.0.0)
2425

2526
## Installation
2627

@@ -104,11 +105,13 @@ To bootstrap the extension as a `composer` package when using
104105

105106
- `phpunit/phpunit:^10.0.0`
106107
- `phpunit/phpunit:^11.0.0`
108+
- `phpunit/phpunit:^12.0.0`
107109

108110
adjust your `phpunit.xml` configuration file and configure the
109111

110112
- [`extensions` element](https://docs.phpunit.de/en/10.5/configuration.html#the-extensions-element) on [`phpunit/phpunit:^10.0.0`](https://docs.phpunit.de/en/10.5/)
111113
- [`extensions` element](https://docs.phpunit.de/en/11.0/configuration.html#the-extensions-element) on [`phpunit/phpunit:^11.0.0`](https://docs.phpunit.de/en/11.0/)
114+
- [`extensions` element](https://docs.phpunit.de/en/12.0/configuration.html#the-extensions-element) on [`phpunit/phpunit:^12.0.0`](https://docs.phpunit.de/en/12.0/)
112115

113116
```diff
114117
<phpunit
@@ -163,11 +166,13 @@ To bootstrap the extension as a PHAR when using
163166

164167
- `phpunit/phpunit:^10.0.0`
165168
- `phpunit/phpunit:^11.0.0`
169+
- `phpunit/phpunit:^12.0.0`
166170

167171
adjust your `phpunit.xml` configuration file and configure the
168172

169173
- [`extensionsDirectory` attribute](https://docs.phpunit.de/en/10.5/configuration.html#the-extensionsdirectory-attribute) and the [`extensions` element](https://docs.phpunit.de/en/10.5/configuration.html#the-extensions-element) on [`phpunit/phpunit:^10.0.0`](https://docs.phpunit.de/en/10.5/)
170174
- [`extensionsDirectory` attribute](https://docs.phpunit.de/en/11.0/configuration.html#the-extensionsdirectory-attribute) and the [`extensions` element](https://docs.phpunit.de/en/11.0/configuration.html#the-extensions-element) on [`phpunit/phpunit:^11.0.0`](https://docs.phpunit.de/en/11.0/)
175+
- [`extensionsDirectory` attribute](https://docs.phpunit.de/en/12.0/configuration.html#the-extensionsdirectory-attribute) and the [`extensions` element](https://docs.phpunit.de/en/12.0/configuration.html#the-extensions-element) on [`phpunit/phpunit:^12.0.0`](https://docs.phpunit.de/en/12.0/)
171176

172177
```diff
173178
<phpunit
@@ -284,11 +289,13 @@ To configure the extension when using
284289

285290
- `phpunit/phpunit:^10.0.0`
286291
- `phpunit/phpunit:^11.0.0`
292+
- `phpunit/phpunit:^12.0.0`
287293

288294
adjust your `phpunit.xml` configuration file and configure one or more
289295

290296
- [`parameter` elements](https://docs.phpunit.de/en/10.5/configuration.html#the-parameter-element) on [`phpunit/phpunit:^10.0.0`](https://docs.phpunit.de/en/10.5/)
291297
- [`parameter` elements](https://docs.phpunit.de/en/11.0/configuration.html#the-parameter-element) on [`phpunit/phpunit:^11.0.0`](https://docs.phpunit.de/en/11.0/)
298+
- [`parameter` elements](https://docs.phpunit.de/en/12.0/configuration.html#the-parameter-element) on [`phpunit/phpunit:^12.0.0`](https://docs.phpunit.de/en/12.0/)
292299

293300
The following example configures the maximum count of slow tests to three, and the maximum duration for all tests to 250 milliseconds:
294301

@@ -320,6 +327,7 @@ You can configure the maximum duration for a single test case with
320327
- an `Attribute\MaximumDuration` attribute when using
321328
- `phpunit/phpunit:^10.0.0`
322329
- `phpunit/phpunit:^11.0.0`
330+
- `phpunit/phpunit:^12.0.0`
323331
- a `@maximumDuration` annotation in the DocBlock when using
324332
- `phpunit/phpunit:^6.5.0`
325333
- `phpunit/phpunit:^7.5.0`
@@ -450,6 +458,7 @@ When using
450458

451459
- `phpunit/phpunit:^10.0.0`
452460
- `phpunit/phpunit:^11.0.0`
461+
- `phpunit/phpunit:^12.0.0`
453462

454463
the extension uses the new event system of `phpunit/phpunit`.
455464

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": "~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
28-
"phpunit/phpunit": "^6.5.0 || ^7.5.0 || ^8.5.19 || ^9.0.0 || ^10.0.0 || ^11.0.0"
28+
"phpunit/phpunit": "^6.5.0 || ^7.5.0 || ^8.5.19 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0"
2929
},
3030
"require-dev": {
3131
"ergebnis/composer-normalize": "^2.45.0",

composer.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<phar xmlns="https://phar.io/xml/manifest/1.0">
33
<contains name="ergebnis/phpunit-slow-test-detector" version="2.17.0" type="extension">
4-
<extension for="phpunit/phpunit" compatible="^7.5 || 8.5 || ^9.0 || ^10.0 || ^11.0"/>
4+
<extension for="phpunit/phpunit" compatible="^7.5 || 8.5 || ^9.0 || ^10.0 || ^11.0 || ^12.0"/>
55
</contains>
66

77
<copyright>

phpstan-baseline.neon

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,21 @@ parameters:
380380
count: 1
381381
path: test/Unit/Version/MajorTest.php
382382

383+
-
384+
message: "#^Method Ergebnis\\\\PHPUnit\\\\SlowTestDetector\\\\Test\\\\Unit\\\\Version\\\\MajorTest\\:\\:testIsLessThanReturnsFalseWhenValueIsGreater\\(\\) has no return type specified\\.$#"
385+
count: 1
386+
path: test/Unit/Version/MajorTest.php
387+
388+
-
389+
message: "#^Method Ergebnis\\\\PHPUnit\\\\SlowTestDetector\\\\Test\\\\Unit\\\\Version\\\\MajorTest\\:\\:testIsLessThanReturnsFalseWhenValueIsSame\\(\\) has no return type specified\\.$#"
390+
count: 1
391+
path: test/Unit/Version/MajorTest.php
392+
393+
-
394+
message: "#^Method Ergebnis\\\\PHPUnit\\\\SlowTestDetector\\\\Test\\\\Unit\\\\Version\\\\MajorTest\\:\\:testIsLessThanReturnsTrueWhenValueIsLess\\(\\) has no return type specified\\.$#"
395+
count: 1
396+
path: test/Unit/Version/MajorTest.php
397+
383398
-
384399
message: "#^Method Ergebnis\\\\PHPUnit\\\\SlowTestDetector\\\\Test\\\\Unit\\\\Version\\\\MajorTest\\:\\:testIsOneOfReturnsFalseWhenAllValuesAreDifferent\\(\\) has no return type specified\\.$#"
385400
count: 1

src/Extension.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Ergebnis\PHPUnit\SlowTestDetector;
1515

16+
use Ergebnis\PHPUnit;
1617
use PHPUnit\Framework;
1718
use PHPUnit\Runner;
1819
use PHPUnit\TextUI;
@@ -406,7 +407,7 @@ private function resolveMaximumDuration(string $test): Duration
406407
return;
407408
}
408409

409-
if ($phpUnitVersionSeries->major()->isOneOf(Version\Major::fromInt(10), Version\Major::fromInt(11))) {
410+
if ($phpUnitVersionSeries->major()->isOneOf(Version\Major::fromInt(10), Version\Major::fromInt(11), Version\Major::fromInt(12))) {
410411
/**
411412
* @internal
412413
*/
@@ -446,7 +447,8 @@ public function bootstrap(
446447
new Subscriber\Test\FinishedSubscriber(
447448
$maximumDuration,
448449
$timeKeeper,
449-
$collector
450+
$collector,
451+
Version\Series::fromString(Runner\Version::series())
450452
),
451453
new Subscriber\TestRunner\ExecutionFinishedSubscriber(
452454
$collector,

src/Subscriber/Test/FinishedSubscriber.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Ergebnis\PHPUnit\SlowTestDetector\TestIdentifier;
2323
use Ergebnis\PHPUnit\SlowTestDetector\Time;
2424
use Ergebnis\PHPUnit\SlowTestDetector\TimeKeeper;
25+
use Ergebnis\PHPUnit\SlowTestDetector\Version;
2526
use PHPUnit\Event;
2627
use PHPUnit\Framework;
2728
use PHPUnit\Metadata;
@@ -46,14 +47,21 @@ final class FinishedSubscriber implements Event\Test\FinishedSubscriber
4647
*/
4748
private $collector;
4849

50+
/**
51+
* @var Version\Series
52+
*/
53+
private $versionSeries;
54+
4955
public function __construct(
5056
Duration $maximumDuration,
5157
TimeKeeper $timeKeeper,
52-
Collector\Collector $collector
58+
Collector\Collector $collector,
59+
Version\Series $versionSeries
5360
) {
5461
$this->maximumDuration = $maximumDuration;
5562
$this->timeKeeper = $timeKeeper;
5663
$this->collector = $collector;
64+
$this->versionSeries = $versionSeries;
5765
}
5866

5967
/**
@@ -152,10 +160,12 @@ private function resolveMaximumDuration(Event\Code\Test $test): Duration
152160
return $maximumDurationFromAttribute;
153161
}
154162

155-
$maximumDurationFromAnnotation = self::resolveMaximumDurationFromAnnotation($test);
163+
if ($this->versionSeries->major()->isLessThan(Version\Major::fromInt(12))) {
164+
$maximumDurationFromAnnotation = self::resolveMaximumDurationFromAnnotation($test);
156165

157-
if ($maximumDurationFromAnnotation instanceof Duration) {
158-
return $maximumDurationFromAnnotation;
166+
if ($maximumDurationFromAnnotation instanceof Duration) {
167+
return $maximumDurationFromAnnotation;
168+
}
159169
}
160170

161171
return $this->maximumDuration;

0 commit comments

Comments
 (0)