Skip to content

Commit

Permalink
Merge pull request #533 from ergebnis/feature/phpunit-6
Browse files Browse the repository at this point in the history
Enhancement: Add support for `phpunit/phpunit:^6.5.0`
  • Loading branch information
localheinz committed Apr 7, 2024
2 parents f192ad8 + 517ec34 commit ee3009d
Show file tree
Hide file tree
Showing 71 changed files with 3,313 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/settings.yml
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
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
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Expand Up @@ -30,6 +30,7 @@
->withHeader($license->header())
->withRules(PhpCsFixer\Config\Rules::fromArray([
'mb_str_functions' => false,
'void_return' => false,
]));

$config = PhpCsFixer\Config\Factory::fromRuleSet($ruleSet);
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
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:^6.5.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
68 changes: 68 additions & 0 deletions README.md
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,6 +49,31 @@ 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`

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

- [`listeners` element](https://phpunit.de/manual/6.5/en/appendixes.configuration.html#appendixes.configuration.test-listeners) on [`phpunit/phpunit:^6.5.0`](https://phpunit.de/manual/6.5/en/)

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

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

- `phpunit/phpunit:^7.5.0`
- `phpunit/phpunit:^8.5.19`
- `phpunit/phpunit:^9.0.0`
Expand Down Expand Up @@ -175,6 +201,45 @@ The configuration mechanism depends on the version of `phpunit/phpunit` you are

To configure the extension when using

- `phpunit/phpunit:^6.5.0`

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

- [`arguments` element](https://phpunit.de/manual/6.5/en/appendixes.configuration.html#appendixes.configuration.test-listeners) on [`phpunit/phpunit:^6.5.0`](https://phpunit.de/manual/6.5/en/)

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

```diff
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
>
<listeners>
- <listener class="Ergebnis\PHPUnit\SlowTestDetector\Extension"/>
+ <listener class="Ergebnis\PHPUnit\SlowTestDetector\Extension">
+ <arguments>
+ <array>
+ <element key="maximum-count">
+ <integer>3</integer>
+ </element>
+ <element key="maximum-duration">
+ <integer>250</integer>
+ </element>
+ </array>
+ </arguments>
+ </listener>
</listeners>
<testsuites>
<testsuite name="unit">
<directory>test/Unit/</directory>
</testsuite>
</testsuites>
</phpunit>
```

To configure the extension when using

- `phpunit/phpunit:^7.5.0`
- `phpunit/phpunit:^8.5.19`
- `phpunit/phpunit:^9.0.0`
Expand Down Expand Up @@ -257,10 +322,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 +417,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
37 changes: 37 additions & 0 deletions psalm-baseline.xml
Expand Up @@ -3,6 +3,7 @@
<file src="src/Extension.php">
<DuplicateClass>
<code><![CDATA[Extension]]></code>
<code><![CDATA[Extension]]></code>
</DuplicateClass>
<UnusedClass>
<code><![CDATA[Extension]]></code>
Expand Down Expand Up @@ -105,6 +106,42 @@
<code><![CDATA[withWhitespace]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/EndToEnd/Version06/TestCase/Combination/SleeperTest.php">
<PossiblyUnusedMethod>
<code><![CDATA[sleepWithAfterAnnotation]]></code>
<code><![CDATA[sleepWithAfterClassAnnotation]]></code>
<code><![CDATA[sleepWithBeforeAnnotation]]></code>
<code><![CDATA[sleepWithBeforeClassAnnotation]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/EndToEnd/Version06/TestCase/WithAfterAnnotation/SleeperTest.php">
<PossiblyUnusedMethod>
<code><![CDATA[sleepWithAfterAnnotation]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/EndToEnd/Version06/TestCase/WithAfterClassAnnotation/SleeperTest.php">
<PossiblyUnusedMethod>
<code><![CDATA[sleepWithAfterClassAnnotation]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/EndToEnd/Version06/TestCase/WithBeforeAnnotation/SleeperTest.php">
<PossiblyUnusedMethod>
<code><![CDATA[sleepWithBeforeAnnotation]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/EndToEnd/Version06/TestCase/WithBeforeClassAnnotation/SleeperTest.php">
<PossiblyUnusedMethod>
<code><![CDATA[sleepWithBeforeClassAnnotation]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/EndToEnd/Version06/TestMethod/WithRunInSeparateProcessAnnotation/SleeperTest.php">
<PossiblyUnusedMethod>
<code><![CDATA[sleepWithAfterAnnotation]]></code>
<code><![CDATA[sleepWithAfterClassAnnotation]]></code>
<code><![CDATA[sleepWithBeforeAnnotation]]></code>
<code><![CDATA[sleepWithBeforeClassAnnotation]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/EndToEnd/Version07/TestCase/Combination/SleeperTest.php">
<PossiblyUnusedMethod>
<code><![CDATA[sleepWithAfterAnnotation]]></code>
Expand Down

0 comments on commit ee3009d

Please sign in to comment.