Skip to content

Commit

Permalink
Enhancement: Add support for phpunit/phpunit:^9.6.13
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Nov 5, 2023
1 parent 9774914 commit b9334b9
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 102 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ jobs:
- "8.2"
- "8.3"

phpunit-version:
- "9.6.13"
- "10.4.2"

dependencies:
- "lowest"
- "locked"
Expand Down Expand Up @@ -481,16 +485,21 @@ jobs:
uses: "actions/[email protected]"
with:
path: "${{ env.COMPOSER_CACHE_DIR }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-phpunit-${{ matrix.phpunit-version }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-phpunit-${{ matrix.phpunit-version }}-"

- name: "Require phpunit/phpunit:^${{ matrix.phpunit-version }}"
run: "composer require phpunit/phpunit:^${{ matrix.phpunit-version }} --ansi --no-interaction --no-progress"

- name: "Install ${{ matrix.dependencies }} dependencies with composer"
uses: "ergebnis/.github/actions/composer/[email protected]"
with:
dependencies: "${{ matrix.dependencies }}"

- name: "Run unit tests with phpunit/phpunit"
if: "matrix.phpunit-version == '10.4.2'"
run: "vendor/bin/phpunit --colors=always --configuration=test/Unit/phpunit.xml"

- name: "Run end-to-end tests with phpunit/phpunit"
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/phpunit.xml"
if: "matrix.phpunit-version == '10.4.2'"
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version10/phpunit.xml"
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ static-code-analysis-baseline: vendor ## Generates a baseline for static code an
.PHONY: tests
tests: vendor ## Runs unit and end-to-end tests with phpunit/phpunit
mkdir -p .build/phpunit
vendor/bin/phpunit --configuration=test/Unit/phpunit.xml
vendor/bin/phpunit --configuration=test/EndToEnd/phpunit.xml
composer require phpunit/phpunit:10.4.2 --no-interaction --no-progress; vendor/bin/phpunit --configuration=test/Unit/phpunit.xml; git checkout HEAD -- composer.json composer.lock
composer require phpunit/phpunit:10.4.2 --no-interaction --no-progress; vendor/bin/phpunit --configuration=test/EndToEnd/Version10/phpunit.xml; git checkout HEAD -- composer.json composer.lock

vendor: composer.json composer.lock
composer validate --strict
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": "~8.1.0 || ~8.2.0 || ~8.3.0",
"phpunit/phpunit": "^10.4.2"
"phpunit/phpunit": "^9.6.13 || ^10.4.2"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.39.0",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

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

15 changes: 14 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
<MixedAssignment>
<code>$maximumDuration</code>
</MixedAssignment>
<UnusedClass>
<code>TestPassedSubscriber</code>
</UnusedClass>
</file>
<file src="src/Subscriber/TestPreparedSubscriber.php">
<UnusedClass>
<code>TestPreparedSubscriber</code>
</UnusedClass>
</file>
<file src="src/Subscriber/TestRunnerExecutionFinishedSubscriber.php">
<UnusedClass>
<code>TestRunnerExecutionFinishedSubscriber</code>
</UnusedClass>
</file>
<file src="test/Double/Collector/AppendingCollector.php">
<UnusedClass>
Expand All @@ -51,7 +64,7 @@
<code><![CDATA[$this->milliseconds * 1000]]></code>
</ArgumentTypeCoercion>
</file>
<file src="test/Fixture/SleeperTest.php">
<file src="test/Fixture/Version10/SleeperTest.php">
<PossiblyUnusedMethod>
<code>provideMillisecondsGreaterThanDefaultMaximumDuration</code>
</PossiblyUnusedMethod>
Expand Down
91 changes: 55 additions & 36 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,69 @@
use PHPUnit\Runner;
use PHPUnit\TextUI;

final class Extension implements Runner\Extension\Extension
{
public function bootstrap(
TextUI\Configuration\Configuration $configuration,
Runner\Extension\Facade $facade,
Runner\Extension\ParameterCollection $parameters,
): void {
if ($configuration->noOutput()) {
return;
}
if (1 !== \preg_match('/(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/', Runner\Version::id(), $matches)) {
throw new \RuntimeException(\sprintf(
'Unable to determine PHPUnit version from version identifier "%s".',
Runner\Version::id(),
));

Check warning on line 23 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L19-L23

Added lines #L19 - L23 were not covered by tests
}

$maximumCount = Count::fromInt(10);
$major = (int) $matches['major'];

Check warning on line 26 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L26

Added line #L26 was not covered by tests

if ($parameters->has('maximum-count')) {
$maximumCount = Count::fromInt((int) $parameters->get('maximum-count'));
}
if (10 <= $major) {

Check warning on line 28 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L28

Added line #L28 was not covered by tests
/**
* @internal
*/
final class Extension implements Runner\Extension\Extension
{
public function bootstrap(

Check warning on line 34 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L34

Added line #L34 was not covered by tests
TextUI\Configuration\Configuration $configuration,
Runner\Extension\Facade $facade,
Runner\Extension\ParameterCollection $parameters,
): void {
if ($configuration->noOutput()) {
return;

Check warning on line 40 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L39-L40

Added lines #L39 - L40 were not covered by tests
}

$maximumDuration = Duration::fromMilliseconds(500);
$maximumCount = Count::fromInt(10);

Check warning on line 43 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L43

Added line #L43 was not covered by tests

if ($parameters->has('maximum-duration')) {
$maximumDuration = Duration::fromMilliseconds((int) $parameters->get('maximum-duration'));
}
if ($parameters->has('maximum-count')) {
$maximumCount = Count::fromInt((int) $parameters->get('maximum-count'));

Check warning on line 46 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L45-L46

Added lines #L45 - L46 were not covered by tests
}

$collector = new Collector\DefaultCollector();
$maximumDuration = Duration::fromMilliseconds(500);

Check warning on line 49 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L49

Added line #L49 was not covered by tests

$reporter = new Reporter\DefaultReporter(
new Formatter\DefaultDurationFormatter(),
$maximumDuration,
$maximumCount,
);
if ($parameters->has('maximum-duration')) {
$maximumDuration = Duration::fromMilliseconds((int) $parameters->get('maximum-duration'));

Check warning on line 52 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L51-L52

Added lines #L51 - L52 were not covered by tests
}

$timeKeeper = new TimeKeeper();
$collector = new Collector\DefaultCollector();

Check warning on line 55 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L55

Added line #L55 was not covered by tests

$facade->registerSubscribers(
new Subscriber\TestPreparedSubscriber($timeKeeper),
new Subscriber\TestPassedSubscriber(
$reporter = new Reporter\DefaultReporter(
new Formatter\DefaultDurationFormatter(),

Check warning on line 58 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L57-L58

Added lines #L57 - L58 were not covered by tests
$maximumDuration,
$timeKeeper,
$collector,
),
new Subscriber\TestRunnerExecutionFinishedSubscriber(
$collector,
$reporter,
),
);
$maximumCount,
);

Check warning on line 61 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L60-L61

Added lines #L60 - L61 were not covered by tests

$timeKeeper = new TimeKeeper();

Check warning on line 63 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L63

Added line #L63 was not covered by tests

$facade->registerSubscribers(
new Subscriber\TestPreparedSubscriber($timeKeeper),
new Subscriber\TestPassedSubscriber(
$maximumDuration,
$timeKeeper,
$collector,
),
new Subscriber\TestRunnerExecutionFinishedSubscriber(
$collector,
$reporter,
),
);

Check warning on line 76 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L65-L76

Added lines #L65 - L76 were not covered by tests
}
}
} else {
throw new \RuntimeException(\sprintf(
'Unable to select extension for PHPUnit version with version identifier "%s".',
Runner\Version::id(),
));

Check warning on line 83 in src/Extension.php

View check run for this annotation

Codecov / codecov/patch

src/Extension.php#L80-L83

Added lines #L80 - L83 were not covered by tests
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="../../../../vendor/phpunit/phpunit/phpunit.xsd"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
bootstrap="../../../vendor/autoload.php"
bootstrap="../../../../vendor/autoload.php"
cacheResult="false"
colors="true"
columns="max"
Expand All @@ -26,7 +26,7 @@
</extensions>
<testsuites>
<testsuite name="Unit Tests">
<directory>../../Fixture/</directory>
<directory>../../../Fixture/</directory>
</testsuite>
</testsuites>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ declare(strict_types=1);

use PHPUnit\TextUI;

$_SERVER['argv'][] = '--configuration=test/EndToEnd/Default/phpunit.xml';
$_SERVER['argv'][] = '--configuration=test/EndToEnd/Version10/Default/phpunit.xml';

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

$application = new TextUI\Application();

Expand All @@ -18,23 +18,23 @@ $application->run($_SERVER['argv']);
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s
Configuration: %Stest/EndToEnd/Default/phpunit.xml
Configuration: %Stest/EndToEnd/Version10/Default/phpunit.xml
Random Seed: %s

............. 13 / 13 (100%)

Detected 11 tests that took longer than expected.

1. 1.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#9
2. 1.5%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#8
3. 1.4%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#7
4. 1.3%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#6
5. 1.2%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#5
6. 1.1%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#4
7. 1.0%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#3
8. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#2
9. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#1
10. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#0
1. 1.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#9
2. 1.5%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#8
3. 1.4%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#7
4. 1.3%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#6
5. 1.2%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#5
6. 1.1%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#4
7. 1.0%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#3
8. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#2
9. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#1
10. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#0

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="../../../../../vendor/phpunit/phpunit/phpunit.xsd"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
bootstrap="../../../../vendor/autoload.php"
bootstrap="../../../../../vendor/autoload.php"
cacheResult="false"
colors="true"
columns="max"
Expand All @@ -22,7 +22,7 @@
</extensions>
<testsuites>
<testsuite name="Unit Tests">
<directory>../../../Fixture/</directory>
<directory>../../../../Fixture/</directory>
</testsuite>
</testsuites>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ declare(strict_types=1);

use PHPUnit\TextUI;

$_SERVER['argv'][] = '--configuration=test/EndToEnd/MaximumCount/Five/phpunit.xml';
$_SERVER['argv'][] = '--configuration=test/EndToEnd/Version10/MaximumCount/Five/phpunit.xml';

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

$application = new TextUI\Application();

Expand All @@ -18,18 +18,18 @@ $application->run($_SERVER['argv']);
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s
Configuration: %Stest/EndToEnd/MaximumCount/Five/phpunit.xml
Configuration: %Stest/EndToEnd/Version10/MaximumCount/Five/phpunit.xml
Random Seed: %s

............. 13 / 13 (100%)

Detected 11 tests that took longer than expected.

1. 1.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#9
2. 1.5%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#8
3. 1.4%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#7
4. 1.3%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#6
5. 1.2%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#5
1. 1.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#9
2. 1.5%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#8
3. 1.4%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#7
4. 1.3%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#6
5. 1.2%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\Fixture\Version10\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#5

There are 6 additional slow tests that are not listed here.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="../../../../../vendor/phpunit/phpunit/phpunit.xsd"
beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
bootstrap="../../../../vendor/autoload.php"
bootstrap="../../../../../vendor/autoload.php"
cacheResult="false"
colors="true"
columns="max"
Expand All @@ -22,7 +22,7 @@
</extensions>
<testsuites>
<testsuite name="Unit Tests">
<directory>../../../Fixture/</directory>
<directory>../../../../Fixture/</directory>
</testsuite>
</testsuites>
</phpunit>
Loading

0 comments on commit b9334b9

Please sign in to comment.