Skip to content

Commit

Permalink
Merge pull request #485 from ergebnis/feature/phpunit-11
Browse files Browse the repository at this point in the history
Enhancement: Add support for `phpunit/phpunit:^11.0.0`
  • Loading branch information
localheinz committed Feb 5, 2024
2 parents 06ab797 + aa65403 commit c5bc65e
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 20 deletions.
6 changes: 4 additions & 2 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ branches:
- context: "Tests (10.0.0, 8.2, lowest)"
- context: "Tests (10.0.0, 8.3, highest)"
- context: "Tests (10.0.0, 8.3, lowest)"
- context: "Tests (11.0.x-dev, 8.2, highest)"
- context: "Tests (11.0.x-dev, 8.3, highest)"
- context: "Tests (11.0.0, 8.2, lowest)"
- context: "Tests (11.0.0, 8.2, highest)"
- context: "Tests (11.0.0, 8.3, highest)"
- context: "Tests (11.0.0, 8.3, lowest)"
strict: false
restrictions:

Expand Down
26 changes: 17 additions & 9 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,19 @@ jobs:
php-version: "8.3"
dependencies: "highest"

- phpunit-version: "11.0.x-dev"
- phpunit-version: "11.0.0"
php-version: "8.2"
dependencies: "lowest"

- phpunit-version: "11.0.0"
php-version: "8.2"
dependencies: "highest"

- phpunit-version: "11.0.x-dev"
- phpunit-version: "11.0.0"
php-version: "8.3"
dependencies: "lowest"

- phpunit-version: "11.0.0"
php-version: "8.3"
dependencies: "highest"

Expand Down Expand Up @@ -554,13 +562,9 @@ jobs:
run: "composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --ansi --dev --no-interaction --no-progress"

- name: "Require phpunit/phpunit:^${{ matrix.phpunit-version }}"
if: "matrix.dependencies != 'locked' && matrix.phpunit-version != '11.0.x-dev'"
if: "matrix.dependencies != 'locked'"
run: "composer require phpunit/phpunit:^${{ matrix.phpunit-version }} --ansi --no-interaction --no-progress --update-with-all-dependencies"

- name: "Require phpunit/phpunit:${{ matrix.phpunit-version }}"
if: "matrix.dependencies != 'locked' && matrix.phpunit-version == '11.0.x-dev'"
run: "composer require phpunit/phpunit:${{ matrix.phpunit-version }} --ansi --no-interaction --no-progress --update-with-all-dependencies"

- name: "Install ${{ matrix.dependencies }} dependencies with composer"
uses: "ergebnis/.github/actions/composer/install@1.9.0"
with:
Expand Down Expand Up @@ -593,8 +597,8 @@ jobs:
if: "matrix.phpunit-version == '10.0.0'"
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version10/phpunit.xml"

- name: "Run end-to-end tests with phpunit/phpunit:11.0.x-dev"
if: "matrix.phpunit-version == '11.0.x-dev'"
- name: "Run end-to-end tests with phpunit/phpunit:11.0.0"
if: "matrix.phpunit-version == '11.0.0'"
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version11/phpunit.xml"

- name: "Download Phar"
Expand All @@ -621,3 +625,7 @@ jobs:
- name: "Run phar tests with phpunit/phpunit:10.0.0"
if: "matrix.phpunit-version == '10.0.0'"
run: "vendor/bin/phpunit --colors=always --configuration=test/Phar/Version10/phpunit.xml"

- name: "Run phar tests with phpunit/phpunit:11.0.0"
if: "matrix.phpunit-version == '11.0.0'"
run: "vendor/bin/phpunit --colors=always --configuration=test/Phar/Version11/phpunit.xml"
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ For a full diff see [`2.9.0...main`][2.9.0...main].

### Changed

- Added support for `phpunit/phpunit:^11.0.0` ([#485]), by [@localheinz]
- Added support for using `phpunit-slow-test-detector.phar` with `phpunit/phpunit:^9.0.0` ([#491]), by [@localheinz]
- Added support for using `phpunit-slow-test-detector.phar` with `phpunit/phpunit:^8.5.19` ([#494]), by [@localheinz]
- Added support for using `phpunit-slow-test-detector.phar` with `phpunit/phpunit:^7.5.0` ([#495]), by [@localheinz]
Expand Down Expand Up @@ -269,6 +270,7 @@ For a full diff see [`7afa59c...1.0.0`][7afa59c...1.0.0].
[#396]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/396
[#447]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/447
[#448]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/448
[#485]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/485
[#491]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/491
[#494]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/494
[#495]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/495
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The extension is compatible with the following versions of `phpunit/phpunit`:
- [`phpunit/phpunit:^8.5.19`](https://github.com/sebastianbergmann/phpunit/tree/8.5.19)
- [`phpunit/phpunit:^9.0.0`](https://github.com/sebastianbergmann/phpunit/tree/9.0.0)
- [`phpunit/phpunit:^10.0.0`](https://github.com/sebastianbergmann/phpunit/tree/10.0.0)
- [`phpunit/phpunit:^11.0.0`](https://github.com/sebastianbergmann/phpunit/tree/11.0.0)

## Installation

Expand Down Expand Up @@ -214,10 +215,12 @@ The following example configures the maximum count of slow tests to three, and t
To configure the extension when using

- `phpunit/phpunit:^10.0.0`
- `phpunit/phpunit:^11.0.0`

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

- [`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/)
- [`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/)

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

Expand Down Expand Up @@ -248,6 +251,7 @@ You can configure the maximum duration for a single test case with

- an `Attribute\MaximumDuration` attribute when using
- `phpunit/phpunit:^10.0.0`
- `phpunit/phpunit:^11.0.0`
- a `@maximumDuration` annotation in the DocBlock when using
- `phpunit/phpunit:^7.5.0`
- `phpunit/phpunit:^8.5.19`
Expand Down Expand Up @@ -376,6 +380,7 @@ When phpunit/phpunit invokes `PHPUnit\Framework\TestCase::runBare()`, it will in
When using

- `phpunit/phpunit:^10.0.0`
- `phpunit/phpunit:^11.0.0`

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

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"require": {
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0",
"phpunit/phpunit": "^7.5.0 || ^8.5.19 || ^9.0.0 || ^10.0.0"
"phpunit/phpunit": "^7.5.0 || ^8.5.19 || ^9.0.0 || ^10.0.0 || ^11.0.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.42.0",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<phar xmlns="https://phar.io/xml/manifest/1.0">
<contains name="ergebnis/phpunit-slow-test-detector" version="2.9.0" type="extension">
<extension for="phpunit/phpunit" compatible="^7.5 || 8.5 || ^9.0 || ^10.0"/>
<extension for="phpunit/phpunit" compatible="^7.5 || 8.5 || ^9.0 || ^10.0 || ^11.0"/>
</contains>

<copyright>
Expand Down
43 changes: 43 additions & 0 deletions test/Phar/Version11/SleeperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2021-2024 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/phpunit-slow-test-detector
*/

namespace Ergebnis\PHPUnit\SlowTestDetector\Test\Phar\Version11;

use Ergebnis\PHPUnit\SlowTestDetector\Test;
use PHPUnit\Framework;

#[Framework\Attributes\CoversClass(Test\Fixture\Sleeper::class)]
final class SleeperTest extends Framework\TestCase
{
public function testSleeperDoesNotSleepAtAll(): void
{
$milliseconds = 0;

$sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds);

$sleeper->sleep();

self::assertSame($milliseconds, $sleeper->milliseconds());
}

public function testSleeperSleepsJustAboveDefaultMaximumDuration(): void
{
$milliseconds = 600;

$sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds);

$sleeper->sleep();

self::assertSame($milliseconds, $sleeper->milliseconds());
}
}
14 changes: 14 additions & 0 deletions test/Phar/Version11/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2021-2024 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/phpunit-slow-test-detector
*/

require_once __DIR__ . '/../../Fixture/Sleeper.php';
33 changes: 33 additions & 0 deletions test/Phar/Version11/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
bootstrap="bootstrap.php"
cacheResult="false"
colors="true"
columns="max"
displayDetailsOnIncompleteTests="true"
displayDetailsOnSkippedTests="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
executionOrder="random"
extensionsDirectory="../../../.build/phar/"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
>
<extensions>
<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension"/>
</extensions>
<testsuites>
<testsuite name="Unit Tests">
<directory>.</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit c5bc65e

Please sign in to comment.