Skip to content

Commit

Permalink
Enhancement: Add support for phpunit/phpunit:^6.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Apr 7, 2024
1 parent f192ad8 commit 210e1fb
Show file tree
Hide file tree
Showing 68 changed files with 3,016 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ branches:
- context: "Refactoring (7.4, locked)"
- context: "Security Analysis (7.4, locked)"
- context: "Static Code Analysis (7.4, locked)"
- context: "Tests (6.5.0, 7.1, highest)"
- context: "Tests (6.5.0, 7.1, lowest)"
- context: "Tests (6.5.0, 7.2, highest)"
- context: "Tests (6.5.0, 7.2, lowest)"
- context: "Tests (6.5.0, 7.3, highest)"
- context: "Tests (6.5.0, 7.3, lowest)"
- context: "Tests (6.5.0, 7.4, highest)"
- context: "Tests (6.5.0, 7.4, lowest)"
- context: "Tests (7.5.0, 7.1, highest)"
- context: "Tests (7.5.0, 7.1, lowest)"
- context: "Tests (7.5.0, 7.2, highest)"
Expand Down
38 changes: 37 additions & 1 deletion .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ jobs:
fail-fast: false
matrix:
phpunit-version:
- "7.5.0"
- "6.5.0"

php-version:
- "7.1"
Expand All @@ -470,6 +470,38 @@ jobs:
- "highest"

include:
- phpunit-version: "7.5.0"
php-version: "7.1"
dependencies: "lowest"

- phpunit-version: "7.5.0"
php-version: "7.1"
dependencies: "highest"

- phpunit-version: "7.5.0"
php-version: "7.2"
dependencies: "lowest"

- phpunit-version: "7.5.0"
php-version: "7.2"
dependencies: "highest"

- phpunit-version: "7.5.0"
php-version: "7.3"
dependencies: "lowest"

- phpunit-version: "7.5.0"
php-version: "7.3"
dependencies: "highest"

- phpunit-version: "7.5.0"
php-version: "7.4"
dependencies: "lowest"

- phpunit-version: "7.5.0"
php-version: "7.4"
dependencies: "highest"

- phpunit-version: "8.5.19"
php-version: "7.2"
dependencies: "lowest"
Expand Down Expand Up @@ -675,6 +707,10 @@ jobs:
wget -O gh-4486.patch https://github.com/sebastianbergmann/phpunit/commit/0a488f22925b3c8732338ef0fbfe7f13cb4cf1d2.patch
patch -p1 < gh-4486.patch
- name: "Run end-to-end tests with phpunit/phpunit:6.5.0"
if: "matrix.phpunit-version == '6.5.0'"
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version06/phpunit.xml"

- name: "Run end-to-end tests with phpunit/phpunit:7.5.0"
if: "matrix.phpunit-version == '7.5.0'"
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version07/phpunit.xml"
Expand Down
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.13.0...main`][2.13.0...main].

### Changed

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

## [`2.13.0`][2.13.0]

For a full diff see [`2.12.0...2.13.0`][2.12.0...2.13.0].
Expand Down Expand Up @@ -313,6 +317,7 @@ For a full diff see [`7afa59c...1.0.0`][7afa59c...1.0.0].
[#495]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/495
[#531]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/531
[#532]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/532
[#533]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/533

[@HypeMC]: https://github.com/HypeMC
[@localheinz]: https://github.com/localheinz
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This project provides a [`composer`](https://getcomposer.org) package and a [Pha

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

- [`phpunit/phpunit:^6.5.0`](https://github.com/sebastianbergmann/phpunit/tree/6.5.0)
- [`phpunit/phpunit:^7.5.0`](https://github.com/sebastianbergmann/phpunit/tree/7.5.0)
- [`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)
Expand Down Expand Up @@ -48,12 +49,14 @@ Before the extension can detect slow tests in `phpunit/phpunit`, you need to boo

To bootstrap the extension as a `composer` package when using

- `phpunit/phpunit:^6.5.0`
- `phpunit/phpunit:^7.5.0`
- `phpunit/phpunit:^8.5.19`
- `phpunit/phpunit:^9.0.0`

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

- [`extensions` element](https://docs.phpunit.de/en/6.5/configuration.html#the-extensions-element) on [`phpunit/phpunit:^6.5.0`](https://docs.phpunit.de/en/6.5/)
- [`extensions` element](https://docs.phpunit.de/en/7.5/configuration.html#the-extensions-element) on [`phpunit/phpunit:^7.5.0`](https://docs.phpunit.de/en/7.5/)
- [`extensions` element](https://docs.phpunit.de/en/8.5/configuration.html#the-extensions-element) on [`phpunit/phpunit:^8.5.19`](https://docs.phpunit.de/en/8.5/)
- [`extensions` element](https://docs.phpunit.de/en/9.6/configuration.html#the-extensions-element) on [`phpunit/phpunit:^9.0.0`](https://docs.phpunit.de/en/9.6/)
Expand Down Expand Up @@ -175,12 +178,14 @@ The configuration mechanism depends on the version of `phpunit/phpunit` you are

To configure the extension when using

- `phpunit/phpunit:^6.5.0`
- `phpunit/phpunit:^7.5.0`
- `phpunit/phpunit:^8.5.19`
- `phpunit/phpunit:^9.0.0`

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

- [`arguments` element](https://docs.phpunit.de/en/6.5/configuration.html#the-arguments-element) on [`phpunit/phpunit:^6.5.0`](https://docs.phpunit.de/en/6.5/)
- [`arguments` element](https://docs.phpunit.de/en/7.5/configuration.html#the-arguments-element) on [`phpunit/phpunit:^7.5.0`](https://docs.phpunit.de/en/7.5/)
- [`arguments` element](https://docs.phpunit.de/en/8.5/configuration.html#the-arguments-element) on [`phpunit/phpunit:^8.5.19`](https://docs.phpunit.de/en/8.5/)
- [`arguments` element](https://docs.phpunit.de/en/9.6/configuration.html#the-arguments-element) on [`phpunit/phpunit:^9.0.0`](https://docs.phpunit.de/en/9.6/)
Expand Down Expand Up @@ -257,10 +262,12 @@ You can configure the maximum duration for a single test case with
- `phpunit/phpunit:^10.0.0`
- `phpunit/phpunit:^11.0.0`
- a `@maximumDuration` annotation in the DocBlock when using
- `phpunit/phpunit:^6.5.0`
- `phpunit/phpunit:^7.5.0`
- `phpunit/phpunit:^8.5.19`
- `phpunit/phpunit:^9.0.0`
- a `@slowThreshold` annotation in the DocBlock when using
- `phpunit/phpunit:^6.5.0`
- `phpunit/phpunit:^7.5.0`
- `phpunit/phpunit:^8.5.19`
- `phpunit/phpunit:^9.0.0`
Expand Down Expand Up @@ -350,6 +357,7 @@ OK (13 tests, 13 assertions)

When using

- `phpunit/phpunit:^6.5.0`
- `phpunit/phpunit:^7.5.0`
- `phpunit/phpunit:^8.5.19`
- `phpunit/phpunit:^9.0.0`
Expand Down
64 changes: 64 additions & 0 deletions test/EndToEnd/Version06/Configuration/Defaults/SleeperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?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\EndToEnd\Version06\Configuration\Defaults;

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

/**
* @covers \Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Sleeper
*/
final class SleeperTest extends Framework\TestCase
{
public function testSleeperSleepsLessThanDefaultMaximumDuration(): void
{
$milliseconds = 10;

$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(
600,
1600,
100
);

foreach ($values as $value) {
yield $value => [
$value,
];
}
}
}
26 changes: 26 additions & 0 deletions test/EndToEnd/Version06/Configuration/Defaults/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
bootstrap="../../../../../vendor/autoload.php"
colors="true"
columns="max"
forceCoversAnnotation="true"
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>
40 changes: 40 additions & 0 deletions test/EndToEnd/Version06/Configuration/Defaults/test.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--TEST--
With default configuration
--FILE--
<?php

declare(strict_types=1);

use PHPUnit\TextUI;

$_SERVER['argv'][] = '--configuration=test/EndToEnd/Version06/Configuration/Defaults/phpunit.xml';

require_once __DIR__ . '/../../../../../vendor/autoload.php';

PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s

Runtime: %s
Configuration: %s/EndToEnd/Version06/Configuration/Defaults/phpunit.xml

............ 12 / 12 (100%)

Detected 11 tests where the duration exceeded the maximum duration.

1. 1.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version06\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #10 (1600)
2. 1.5%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version07\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #9 (1500)
3. 1.4%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version07\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #8 (1400)
4. 1.3%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version07\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #7 (1300)
5. 1.2%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version07\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #6 (1200)
6. 1.1%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version07\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #5 (1100)
7. 1.0%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version07\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #4 (1000)
8. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version07\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #3 (900)
9. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version07\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #2 (800)
10. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version07\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #1 (700)

There is 1 additional slow test that is not listed here.

Time: %s, Memory: %s

OK (12 tests, 12 assertions)
64 changes: 64 additions & 0 deletions test/EndToEnd/Version06/Configuration/MaximumCount/SleeperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?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\EndToEnd\Version06\Configuration\MaximumCount;

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

/**
* @covers \Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Sleeper
*/
final class SleeperTest extends Framework\TestCase
{
public function testSleeperSleepsLessThanDefaultMaximumDuration(): void
{
$milliseconds = 10;

$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(
600,
1000,
100
);

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

0 comments on commit 210e1fb

Please sign in to comment.