generated from ergebnis/php-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Add support for phpunit/phpunit:^12.0.0
- Loading branch information
1 parent
10c7fab
commit 1b0c9ea
Showing
79 changed files
with
3,222 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -679,6 +679,22 @@ jobs: | |
php-version: "8.4" | ||
dependencies: "highest" | ||
|
||
- phpunit-version: "12.0.0" | ||
php-version: "8.3" | ||
dependencies: "lowest" | ||
|
||
- phpunit-version: "12.0.0" | ||
php-version: "8.3" | ||
dependencies: "highest" | ||
|
||
- phpunit-version: "12.0.0" | ||
php-version: "8.4" | ||
dependencies: "lowest" | ||
|
||
- phpunit-version: "12.0.0" | ||
php-version: "8.4" | ||
dependencies: "highest" | ||
|
||
env: | ||
PHPUNIT_SLOW_TEST_DETECTOR_PHAR: ".build/phar/phpunit-slow-test-detector.phar" | ||
|
||
|
@@ -768,6 +784,10 @@ jobs: | |
if: "matrix.phpunit-version == '11.0.0'" | ||
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version11/phpunit.xml" | ||
|
||
- name: "Run end-to-end tests with phpunit/phpunit:12.0.0" | ||
if: "matrix.phpunit-version == '12.0.0'" | ||
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version12/phpunit.xml" | ||
|
||
- name: "Download Phar" | ||
uses: "actions/[email protected]" | ||
with: | ||
|
@@ -800,4 +820,8 @@ jobs: | |
|
||
- name: "Run phar tests with phpunit/phpunit:11.0.0" | ||
if: "matrix.phpunit-version == '11.0.0'" | ||
run: "vendor/bin/phpunit --colors=always --configuration=test/Phar/Version11/phpunit.xml" | ||
run: "vendor/bin/phpunit --colors=always --configuration=test/Phar/Version12/phpunit.xml" | ||
|
||
- name: "Run phar tests with phpunit/phpunit:12.0.0" | ||
if: "matrix.phpunit-version == '12.0.0'" | ||
run: "vendor/bin/phpunit --colors=always --configuration=test/Phar/Version12/phpunit.xml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
test/EndToEnd/Version12/Configuration/Defaults/SleeperTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021-2025 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\Version12\Configuration\Defaults; | ||
|
||
use Ergebnis\PHPUnit\SlowTestDetector\Test; | ||
use PHPUnit\Framework; | ||
|
||
#[Framework\Attributes\CoversClass(Test\Fixture\Sleeper::class)] | ||
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()); | ||
} | ||
|
||
#[Framework\Attributes\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, | ||
]; | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
test/EndToEnd/Version12/Configuration/Defaults/phpunit.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.0/phpunit.xsd" | ||
beStrictAboutChangesToGlobalState="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTestsThatDoNotTestAnything="true" | ||
bootstrap="../../../../../vendor/autoload.php" | ||
cacheResult="false" | ||
colors="true" | ||
columns="max" | ||
displayDetailsOnIncompleteTests="true" | ||
displayDetailsOnSkippedTests="true" | ||
displayDetailsOnTestsThatTriggerDeprecations="true" | ||
displayDetailsOnTestsThatTriggerErrors="true" | ||
displayDetailsOnTestsThatTriggerNotices="true" | ||
displayDetailsOnTestsThatTriggerWarnings="true" | ||
executionOrder="default" | ||
requireCoverageMetadata="true" | ||
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--TEST-- | ||
With default configuration | ||
--FILE-- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use PHPUnit\TextUI; | ||
|
||
$_SERVER['argv'][] = '--configuration=test/EndToEnd/Version12/Configuration/Defaults/phpunit.xml'; | ||
|
||
require_once __DIR__ . '/../../../../../vendor/autoload.php'; | ||
|
||
$application = new TextUI\Application(); | ||
|
||
$application->run($_SERVER['argv']); | ||
--EXPECTF-- | ||
PHPUnit %s | ||
Check failure on line 18 in test/EndToEnd/Version12/Configuration/Defaults/test.phpt
|
||
|
||
Runtime: %s | ||
Configuration: %s/EndToEnd/Version12/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\Version12\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #10 (1600) | ||
2. 1.5%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #9 (1500) | ||
3. 1.4%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #8 (1400) | ||
4. 1.3%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #7 (1300) | ||
5. 1.2%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #6 (1200) | ||
6. 1.1%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #5 (1100) | ||
7. 1.0%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #4 (1000) | ||
8. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #3 (900) | ||
9. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #2 (800) | ||
10. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\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) |
60 changes: 60 additions & 0 deletions
60
test/EndToEnd/Version12/Configuration/MaximumCount/SleeperTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021-2025 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\Version12\Configuration\MaximumCount; | ||
|
||
use Ergebnis\PHPUnit\SlowTestDetector\Test; | ||
use PHPUnit\Framework; | ||
|
||
#[Framework\Attributes\CoversClass(Test\Fixture\Sleeper::class)] | ||
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()); | ||
} | ||
|
||
#[Framework\Attributes\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, | ||
]; | ||
} | ||
} | ||
} |
Oops, something went wrong.