generated from ergebnis/php-package-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #423 from ergebnis/feature/phpunit-11
Enhancement: Run end-to-end tests with `phpunit/phpunit:11.0.x-dev`
- Loading branch information
Showing
15 changed files
with
724 additions
and
2 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
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
49 changes: 49 additions & 0 deletions
49
test/EndToEnd/Version11/CustomConfiguration/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,49 @@ | ||
<?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\Version11\CustomConfiguration; | ||
|
||
use Ergebnis\PHPUnit\SlowTestDetector\Test; | ||
use PHPUnit\Framework; | ||
|
||
#[Framework\Attributes\CoversClass(Test\Fixture\Sleeper::class)] | ||
final class SleeperTest extends Framework\TestCase | ||
{ | ||
#[Framework\Attributes\DataProvider('provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration')] | ||
public function testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider(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 provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable | ||
{ | ||
$values = \range( | ||
300, | ||
500, | ||
50, | ||
); | ||
|
||
foreach ($values as $value) { | ||
yield $value => [ | ||
$value, | ||
]; | ||
} | ||
} | ||
} |
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,29 @@ | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" | ||
beStrictAboutChangesToGlobalState="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTestsThatDoNotTestAnything="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
bootstrap="../../../../vendor/autoload.php" | ||
cacheResult="false" | ||
colors="true" | ||
columns="max" | ||
executionOrder="random" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
stopOnIncomplete="false" | ||
stopOnSkipped="false" | ||
> | ||
<extensions> | ||
<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension"> | ||
<parameter name="maximum-count" value="3"/> | ||
<parameter name="maximum-duration" value="300"/> | ||
</bootstrap> | ||
</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,36 @@ | ||
--TEST-- | ||
Configuring "maximum-count" parameter to 3 and "maximum-duration" parameter to 300 milliseconds | ||
--FILE-- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use PHPUnit\TextUI; | ||
|
||
$_SERVER['argv'][] = '--configuration=test/EndToEnd/Version11/CustomConfiguration/phpunit.xml'; | ||
|
||
require_once __DIR__ . '/../../../../vendor/autoload.php'; | ||
|
||
$application = new TextUI\Application(); | ||
|
||
$application->run($_SERVER['argv']); | ||
--EXPECTF-- | ||
PHPUnit %s | ||
|
||
Runtime: %s | ||
Configuration: %Stest/EndToEnd/Version11/CustomConfiguration/phpunit.xml | ||
Random %seed: %s | ||
|
||
..... 5 / 5 (100%) | ||
|
||
Detected 5 tests that took longer than expected. | ||
|
||
1. 0.5%s (0.300) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version11\CustomConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider#4 | ||
2. 0.4%s (0.300) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version11\CustomConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider#3 | ||
3. 0.4%s (0.300) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version11\CustomConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider#2 | ||
|
||
There are 2 additional slow tests that are not listed here. | ||
|
||
Time: %s, Memory: %s | ||
|
||
OK (5 tests, 5 assertions) |
Oops, something went wrong.