Skip to content

Commit

Permalink
Enhancement: Add support for phpunit/phpunit:^8.5.36
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Dec 3, 2023
1 parent fa9cc29 commit 68ad1fc
Show file tree
Hide file tree
Showing 19 changed files with 631 additions and 41 deletions.
29 changes: 22 additions & 7 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,49 @@ branches:
required_approving_review_count: 1
required_status_checks:
checks:
- context: "Code Coverage (7.4, 9.6.0, locked)"
- context: "Code Coverage (7.4, 8.5.36, locked)"
- context: "Coding Standards (7.4, locked)"
- context: "Compile Phar (8.1, locked)"
- context: "Dependency Analysis (7.4, locked)"
- context: "Refactoring (7.4, locked)"
- context: "Security Analysis (7.4, locked)"
- context: "Static Code Analysis (7.4, locked)"
- context: "Tests (7.4, 9.6.0, highest)"
- context: "Tests (7.4, 9.6.0, locked)"
- context: "Tests (7.4, 9.6.0, lowest)"
- context: "Tests (8.0, 9.6.0, highest)"
- context: "Tests (8.0, 9.6.0, locked)"
- context: "Tests (8.0, 9.6.0, lowest)"
- context: "Tests (7.4, 8.5.36, highest)"
- context: "Tests (7.4, 8.5.36, highest)"
- context: "Tests (7.4, 8.5.36, locked)"
- context: "Tests (7.4, 8.5.36, locked)"
- context: "Tests (7.4, 8.5.36, lowest)"
- context: "Tests (7.4, 8.5.36, lowest)"
- context: "Tests (8.0, 8.5.36, highest)"
- context: "Tests (8.0, 8.5.36, highest)"
- context: "Tests (8.0, 8.5.36, locked)"
- context: "Tests (8.0, 8.5.36, locked)"
- context: "Tests (8.0, 8.5.36, lowest)"
- context: "Tests (8.0, 8.5.36, lowest)"
- context: "Tests (8.1, 10.4.0, highest)"
- context: "Tests (8.1, 10.4.0, locked)"
- context: "Tests (8.1, 10.4.0, lowest)"
- context: "Tests (8.1, 8.5.36, highest)"
- context: "Tests (8.1, 8.5.36, locked)"
- context: "Tests (8.1, 8.5.36, lowest)"
- context: "Tests (8.1, 9.6.0, highest)"
- context: "Tests (8.1, 9.6.0, locked)"
- context: "Tests (8.1, 9.6.0, lowest)"
- context: "Tests (8.2, 10.4.0, highest)"
- context: "Tests (8.2, 10.4.0, locked)"
- context: "Tests (8.2, 10.4.0, lowest)"
- context: "Tests (8.2, 8.5.36, highest)"
- context: "Tests (8.2, 8.5.36, locked)"
- context: "Tests (8.2, 8.5.36, lowest)"
- context: "Tests (8.2, 9.6.0, highest)"
- context: "Tests (8.2, 9.6.0, locked)"
- context: "Tests (8.2, 9.6.0, lowest)"
- context: "Tests (8.3, 10.4.0, highest)"
- context: "Tests (8.3, 10.4.0, locked)"
- context: "Tests (8.3, 10.4.0, lowest)"
- context: "Tests (8.3, 8.5.36, highest)"
- context: "Tests (8.3, 8.5.36, locked)"
- context: "Tests (8.3, 8.5.36, lowest)"
- context: "Tests (8.3, 9.6.0, highest)"
- context: "Tests (8.3, 9.6.0, locked)"
- context: "Tests (8.3, 9.6.0, lowest)"
Expand Down
49 changes: 35 additions & 14 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- "7.4"

phpunit-version:
- "9.6.0"
- "8.5.36"

dependencies:
- "locked"
Expand Down Expand Up @@ -57,6 +57,9 @@ jobs:
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Remove incompatible dependencies with composer"
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 }}"
run: "composer require phpunit/phpunit:^${{ matrix.phpunit-version }} --ansi --no-interaction --no-progress --update-with-all-dependencies"

Expand Down Expand Up @@ -454,42 +457,56 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"

phpunit-version:
- "8.5.36"
- "9.6.0"
- "10.4.0"

dependencies:
- "lowest"
- "locked"
- "highest"

include:
- php-version: "7.4"
phpunit-version: "9.6.0"
- php-version: "8.1"
phpunit-version: "10.4.0"
dependencies: "lowest"

- php-version: "8.1"
phpunit-version: "10.4.0"
dependencies: "locked"

- php-version: "8.1"
phpunit-version: "10.4.0"
dependencies: "highest"

- php-version: "8.2"
phpunit-version: "10.4.0"
dependencies: "lowest"

- php-version: "7.4"
phpunit-version: "9.6.0"
- php-version: "8.2"
phpunit-version: "10.4.0"
dependencies: "locked"

- php-version: "7.4"
phpunit-version: "9.6.0"
- php-version: "8.2"
phpunit-version: "10.4.0"
dependencies: "highest"

- php-version: "8.0"
phpunit-version: "9.6.0"
- php-version: "8.3"
phpunit-version: "10.4.0"
dependencies: "lowest"

- php-version: "8.0"
phpunit-version: "9.6.0"
- php-version: "8.3"
phpunit-version: "10.4.0"
dependencies: "locked"

- php-version: "8.0"
phpunit-version: "9.6.0"
- php-version: "8.3"
phpunit-version: "10.4.0"
dependencies: "highest"

steps:
Expand Down Expand Up @@ -537,6 +554,10 @@ jobs:
if: "matrix.phpunit-version == '9.6.0'"
run: "vendor/bin/phpunit --colors=always --configuration=test/Unit/phpunit.xml"

- name: "Run end-to-end tests with phpunit/phpunit:8.5.36"
if: "matrix.phpunit-version == '8.5.36'"
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version8/phpunit.xml"

- name: "Run end-to-end tests with phpunit/phpunit:9.6.0"
if: "matrix.phpunit-version == '9.6.0'"
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version9/phpunit.xml"
Expand Down
4 changes: 4 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.5.0...main`][2.5.0...main].

### Added

- Added support for `phpunit/phpunit:^8.5.36` ([#394]), by [@localheinz]

## [`2.5.0`][2.5.0]

For a full diff see [`2.4.0...2.5.0`][2.4.0...2.5.0].
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ it: refactoring coding-standards security-analysis static-code-analysis tests ##
.PHONY: code-coverage
code-coverage: ## Collects coverage from running unit tests with phpunit/phpunit
mkdir -p .build/phpunit/
composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^9.6.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-text; git checkout HEAD -- composer.json composer.lock
composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^8.5.36 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-text; git checkout HEAD -- composer.json composer.lock

.PHONY: coding-standards
coding-standards: vendor ## Lints YAML files with yamllint, normalizes composer.json with ergebnis/composer-normalize, and fixes code style issues with friendsofphp/php-cs-fixer
Expand Down Expand Up @@ -60,7 +60,8 @@ static-code-analysis-baseline: vendor ## Generates a baseline for static code an
.PHONY: tests
tests: ## Runs unit and end-to-end tests with phpunit/phpunit
mkdir -p .build/phpunit
composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^9.6.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/Unit/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^8.5.36 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/Unit/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^8.5.36 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version8/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^9.6.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version9/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^10.4.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version10/phpunit.xml; git checkout HEAD -- composer.json composer.lock

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

This package provides an extension for detecting slow tests in [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit).

The extension is compatible with the following versions of `phpunit/phpunit`:

- [`phpunit/phpunit:^8.5.36`](https://github.com/sebastianbergmann/phpunit/tree/8.5.36)
- [`phpunit/phpunit:^9.6.0`](https://github.com/sebastianbergmann/phpunit/tree/9.6.0)
- [`phpunit/phpunit:^10.4.0`](https://github.com/sebastianbergmann/phpunit/tree/10.4.0)

## Installation

### Composer
Expand Down Expand Up @@ -124,7 +130,7 @@ The following example configures the maximum count of slow tests to three, and t
</phpunit>
```

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`:
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:^8.5.0` or `phpunit/phpunit:^9.6.0`:

```diff
<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": "^9.6.0 || ^10.4.0"
"phpunit/phpunit": "^8.5.36 || ^9.6.0 || ^10.4.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.28.3",
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.

5 changes: 4 additions & 1 deletion src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
));
}

if ($phpUnitVersionSeries->major()->equals(Version\Major::fromInt(9))) {
if (
$phpUnitVersionSeries->major()->equals(Version\Major::fromInt(8))
|| $phpUnitVersionSeries->major()->equals(Version\Major::fromInt(9))
) {

Check warning on line 32 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L29-L32

Added lines #L29 - L32 were not covered by tests
/**
* @internal
*/
Expand Down
66 changes: 66 additions & 0 deletions test/EndToEnd/Version8/DefaultConfiguration/SleeperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

declare(strict_types=1);

/**
* Copyright (c) 2021-2023 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\EndToEnd\Version8\DefaultConfiguration;

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

/**
* @covers \Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Sleeper
*/
final class SleeperTest extends Framework\TestCase
{
use Test\Util\Helper;

public function testSleeperDoesNotSleepAtAll(): void
{
$milliseconds = 0;

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

$sleeper->sleep();

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

/**
* @dataProvider provideMillisecondsGreaterThanDefaultMaximumDuration
*/
public function testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider(int $milliseconds): void
{
$sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds);

$sleeper->sleep();

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

/**
* @return \Generator<int, array{0: int}>
*/
public static function provideMillisecondsGreaterThanDefaultMaximumDuration(): iterable
{
$values = \range(
550,
1050,
50,
);

foreach ($values as $value) {
yield $value => [
$value,
];
}
}
}
28 changes: 28 additions & 0 deletions test/EndToEnd/Version8/DefaultConfiguration/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
bootstrap="../../../../vendor/autoload.php"
cacheResult="false"
colors="true"
columns="max"
forceCoversAnnotation="true"
executionOrder="random"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="true"
>
<extensions>
<extension class="Ergebnis\PHPUnit\SlowTestDetector\Extension"/>
</extensions>
<testsuites>
<testsuite name="Unit Tests">
<directory>.</directory>
</testsuite>
</testsuites>
</phpunit>
Loading

0 comments on commit 68ad1fc

Please sign in to comment.