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.
- Loading branch information
1 parent
33c9e8a
commit 3b2df85
Showing
199 changed files
with
7,899 additions
and
1,813 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
60 changes: 60 additions & 0 deletions
60
test/EndToEnd/Version10/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-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\Version10\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 = 1; | ||
|
||
$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, | ||
]; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--TEST-- | ||
With default configuration | ||
--FILE-- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use PHPUnit\TextUI; | ||
|
||
$_SERVER['argv'][] = '--configuration=test/EndToEnd/Version10/Configuration/Defaults/phpunit.xml'; | ||
|
||
require_once __DIR__ . '/../../../../../vendor/autoload.php'; | ||
|
||
$application = new TextUI\Application(); | ||
|
||
$application->run($_SERVER['argv']); | ||
--EXPECTF-- | ||
PHPUnit %s | ||
|
||
Runtime: %s | ||
Configuration: %s/EndToEnd/Version10/Configuration/Defaults/phpunit.xml | ||
Random %seed: %s | ||
|
||
............ 12 / 12 (100%) | ||
|
||
Detected 11 tests that took longer than expected. | ||
|
||
1. 1.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#10 | ||
2. 1.5%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#9 | ||
3. 1.4%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#8 | ||
4. 1.3%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#7 | ||
5. 1.2%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#6 | ||
6. 1.1%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#5 | ||
7. 1.0%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#4 | ||
8. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#3 | ||
9. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#2 | ||
10. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\Configuration\Defaults\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#1 | ||
|
||
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/Version10/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-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\Version10\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 = 1; | ||
|
||
$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, | ||
]; | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
test/EndToEnd/Version10/Configuration/MaximumCount/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,35 @@ | ||
<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" | ||
displayDetailsOnIncompleteTests="true" | ||
displayDetailsOnSkippedTests="true" | ||
displayDetailsOnTestsThatTriggerDeprecations="true" | ||
displayDetailsOnTestsThatTriggerErrors="true" | ||
displayDetailsOnTestsThatTriggerNotices="true" | ||
displayDetailsOnTestsThatTriggerWarnings="true" | ||
executionOrder="random" | ||
requireCoverageMetadata="true" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
stopOnIncomplete="false" | ||
stopOnSkipped="false" | ||
> | ||
<extensions> | ||
<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension"> | ||
<parameter name="maximum-count" value="3"/> | ||
</bootstrap> | ||
</extensions> | ||
<testsuites> | ||
<testsuite name="Unit Tests"> | ||
<directory>.</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
36 changes: 36 additions & 0 deletions
36
test/EndToEnd/Version10/Configuration/MaximumCount/test.phpt
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-- | ||
With custom configuration setting the "maximum-count" parameter in the XML configuration file | ||
--FILE-- | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use PHPUnit\TextUI; | ||
|
||
$_SERVER['argv'][] = '--configuration=test/EndToEnd/Version10/Configuration/MaximumCount/phpunit.xml'; | ||
|
||
require_once __DIR__ . '/../../../../../vendor/autoload.php'; | ||
|
||
$application = new TextUI\Application(); | ||
|
||
$application->run($_SERVER['argv']); | ||
--EXPECTF-- | ||
PHPUnit %s | ||
|
||
Runtime: %s | ||
Configuration: %s/EndToEnd/Version10/Configuration/MaximumCount/phpunit.xml | ||
Random %seed: %s | ||
|
||
...... 6 / 6 (100%) | ||
|
||
Detected 5 tests that took longer than expected. | ||
|
||
1. 1.0%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\Configuration\MaximumCount\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#4 | ||
2. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\Configuration\MaximumCount\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#3 | ||
3. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\Configuration\MaximumCount\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#2 | ||
|
||
There are 2 additional slow tests that are not listed here. | ||
|
||
Time: %s, Memory: %s | ||
|
||
OK (6 tests, 6 assertions) |
Oops, something went wrong.