Skip to content

Commit

Permalink
Enhancement: Add support for phpunit/phpunit:^11.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Feb 4, 2024
1 parent eb449d3 commit 4c84ae6
Show file tree
Hide file tree
Showing 13 changed files with 174 additions and 27 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
24 changes: 14 additions & 10 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ jobs:
run: ".phive/box info ${{ env.PHPUNIT_SLOW_TEST_DETECTOR_PHAR }} --ansi --list"

- name: "Run phar tests with phpunit/phpunit"
run: ".phive/phpunit --colors=always --configuration=test/Phar/phpunit.xml"
run: ".phive/phpunit --colors=always --configuration=test/Phar/Version10/phpunit.xml"

dependency-analysis:
name: "Dependency Analysis"
Expand Down Expand Up @@ -496,11 +496,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 @@ -543,13 +551,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/[email protected]"
with:
Expand Down Expand Up @@ -582,6 +586,6 @@ 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"
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

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]

## [`2.9.0`][2.9.0]

For a full diff see [`2.8.0...2.9.0`][2.8.0...2.9.0].
Expand Down Expand Up @@ -263,6 +267,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

[@HypeMC]: https://github.com/HypeMC
[@localheinz]: https://github.com/localheinz
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ phar: phive ## Builds a phar with humbug/box
.phive/box compile --config=box.json
git checkout HEAD -- composer.json composer.lock
.phive/box info .build/phar/phpunit-slow-test-detector.phar --list
.phive/phpunit --configuration=test/Phar/phpunit.xml
.phive/phpunit --configuration=test/Phar/Version10/phpunit.xml
.phive/phpunit --configuration=test/Phar/Version11/phpunit.xml

.PHONY: phive
phive: .phive ## Installs dependencies with phive
Expand Down Expand Up @@ -58,7 +59,7 @@ tests: ## Runs unit and end-to-end tests with phpunit/phpunit
composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^8.5.19 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version08/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^9.0.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version09/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^10.0.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version10/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:11.0.x-dev --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version11/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^11.0.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version11/phpunit.xml; git checkout HEAD -- composer.json composer.lock

vendor: composer.json composer.lock
composer validate --strict
Expand Down
47 changes: 45 additions & 2 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 All @@ -31,11 +32,11 @@ Run
composer require --dev ergebnis/phpunit-slow-test-detector
```

to install `ergebnis/phpunit-slow-test-detector` as a `composer` package when using `phpunit/phpunit:^7.5.0`, `phpunit/phpunit:^8.5.19`, `phpunit/phpunit:^9.0.0`, or `phpunit/phpunit:^10.0.0`.
to install `ergebnis/phpunit-slow-test-detector` as a `composer` package when using `phpunit/phpunit:^7.5.0`, `phpunit/phpunit:^8.5.19`, `phpunit/phpunit:^9.0.0`, `phpunit/phpunit:^10.0.0`, or `phpunit/phpunit:^11.0.0`.

### Installation as Phar

Download `phpunit-slow-test-detector.phar` from the [latest release](https://github.com/ergebnis/phpunit-slow-test-detector/releases/latest) when using `phpunit/phpunit:^10.0.0`.
Download `phpunit-slow-test-detector.phar` from the [latest release](https://github.com/ergebnis/phpunit-slow-test-detector/releases/latest) when using `phpunit/phpunit:^10.0.0` or `phpunit/phpunit:^11.0.0`.

## Usage

Expand Down Expand Up @@ -110,6 +111,26 @@ To bootstrap the extension as a `composer` package when using `phpunit/phpunit:^

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

```diff
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
>
+ <extensions>
+ <bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension"/>
+ </extensions>
<testsuites>
<testsuite name="unit">
<directory>test/Unit/</directory>
</testsuite>
</testsuites>
</phpunit>
```
### Bootstrapping the extension as a `composer` package when using `phpunit/phpunit:^11.0.0`

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

```diff
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down Expand Up @@ -149,6 +170,28 @@ To bootstrap the extension as a PHAR when using `phpunit/phpunit:^10.0.0`, adjus
</phpunit>
```

### Bootstrapping the extension as a PHAR when using `phpunit/phpunit:^11.0.0`

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

```diff
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
+ extensionsDirectory="directory/where/you/saved/the/extension/phars"
>
+ <extensions>
+ <bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension"/>
+ </extensions>
<testsuites>
<testsuite name="unit">
<directory>test/Unit/</directory>
</testsuite>
</testsuites>
</phpunit>
```

### Configuring the extension

You can configure the extension with the following options in your `phpunit.xml` configuration file:
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.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @see https://github.com/ergebnis/phpunit-slow-test-detector
*/

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

use Ergebnis\PHPUnit\SlowTestDetector\Test;
use PHPUnit\Framework;
Expand Down
4 changes: 2 additions & 2 deletions test/Phar/bootstrap.php → test/Phar/Version10/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
* @see https://github.com/ergebnis/phpunit-slow-test-detector
*/

require_once __DIR__ . '/../Fixture/Sleeper.php';
require_once __DIR__ . '/../../Fixture/Sleeper.php';

require_once __DIR__ . '/../Util/Helper.php';
require_once __DIR__ . '/../../Util/Helper.php';
File renamed without changes.
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());
}
}
16 changes: 16 additions & 0 deletions test/Phar/Version11/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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';

require_once __DIR__ . '/../../Util/Helper.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 4c84ae6

Please sign in to comment.