diff --git a/.github/settings.yml b/.github/settings.yml index a521a22a..44f8cc4d 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -83,6 +83,10 @@ branches: - context: "Tests (11.0.0, 8.3, lowest)" - context: "Tests (11.3.6, 8.4, highest)" - context: "Tests (11.3.6, 8.4, lowest)" + - context: "Tests (12.0.0, 8.3, highest)" + - context: "Tests (12.0.0, 8.3, lowest)" + - context: "Tests (12.0.0, 8.4, highest)" + - context: "Tests (12.0.0, 8.4, lowest)" strict: false restrictions: diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index 34059074..3e982b5c 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -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" @@ -772,6 +788,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/download-artifact@v4.1.8" with: @@ -809,3 +829,7 @@ 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" + + - 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" diff --git a/CHANGELOG.md b/CHANGELOG.md index aac4e693..9483f99c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.17.0...main`][2.17.0...main]. +### Added + +- Added support for `phpunit/phpunit:^12.0.0` ([#651]), by [@localheinz] + ## [`2.17.0`][2.17.0] For a full diff see [`2.16.1...2.17.0`][2.16.1...2.17.0]. @@ -380,6 +384,7 @@ For a full diff see [`7afa59c...1.0.0`][7afa59c...1.0.0]. [#598]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/598 [#604]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/604 [#635]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/635 +[#651]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/651 [@dantleech]: https://github.com/dantleech [@HypeMC]: https://github.com/HypeMC diff --git a/README.md b/README.md index 452557de..bb32596d 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ The extension is compatible with the following versions of `phpunit/phpunit`: - [`phpunit/phpunit:^9.0.0`](https://github.com/sebastianbergmann/phpunit/tree/9.0.0) - [`phpunit/phpunit:^10.0.0`](https://github.com/sebastianbergmann/phpunit/tree/10.0.0) - [`phpunit/phpunit:^11.0.0`](https://github.com/sebastianbergmann/phpunit/tree/11.0.0) +- [`phpunit/phpunit:^12.0.0`](https://github.com/sebastianbergmann/phpunit/tree/12.0.0) ## Installation @@ -104,11 +105,13 @@ To bootstrap the extension as a `composer` package when using - `phpunit/phpunit:^10.0.0` - `phpunit/phpunit:^11.0.0` +- `phpunit/phpunit:^12.0.0` adjust your `phpunit.xml` configuration file and configure the - [`extensions` element](https://docs.phpunit.de/en/10.5/configuration.html#the-extensions-element) on [`phpunit/phpunit:^10.0.0`](https://docs.phpunit.de/en/10.5/) - [`extensions` element](https://docs.phpunit.de/en/11.0/configuration.html#the-extensions-element) on [`phpunit/phpunit:^11.0.0`](https://docs.phpunit.de/en/11.0/) +- [`extensions` element](https://docs.phpunit.de/en/12.0/configuration.html#the-extensions-element) on [`phpunit/phpunit:^12.0.0`](https://docs.phpunit.de/en/12.0/) ```diff - + diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 3a37a7bf..a17670a7 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -380,6 +380,21 @@ parameters: count: 1 path: test/Unit/Version/MajorTest.php + - + message: "#^Method Ergebnis\\\\PHPUnit\\\\SlowTestDetector\\\\Test\\\\Unit\\\\Version\\\\MajorTest\\:\\:testIsLessThanReturnsFalseWhenValueIsGreater\\(\\) has no return type specified\\.$#" + count: 1 + path: test/Unit/Version/MajorTest.php + + - + message: "#^Method Ergebnis\\\\PHPUnit\\\\SlowTestDetector\\\\Test\\\\Unit\\\\Version\\\\MajorTest\\:\\:testIsLessThanReturnsFalseWhenValueIsSame\\(\\) has no return type specified\\.$#" + count: 1 + path: test/Unit/Version/MajorTest.php + + - + message: "#^Method Ergebnis\\\\PHPUnit\\\\SlowTestDetector\\\\Test\\\\Unit\\\\Version\\\\MajorTest\\:\\:testIsLessThanReturnsTrueWhenValueIsLess\\(\\) has no return type specified\\.$#" + count: 1 + path: test/Unit/Version/MajorTest.php + - message: "#^Method Ergebnis\\\\PHPUnit\\\\SlowTestDetector\\\\Test\\\\Unit\\\\Version\\\\MajorTest\\:\\:testIsOneOfReturnsFalseWhenAllValuesAreDifferent\\(\\) has no return type specified\\.$#" count: 1 diff --git a/src/Extension.php b/src/Extension.php index 8de41c31..26587324 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -13,6 +13,7 @@ namespace Ergebnis\PHPUnit\SlowTestDetector; +use Ergebnis\PHPUnit; use PHPUnit\Framework; use PHPUnit\Runner; use PHPUnit\TextUI; @@ -406,7 +407,7 @@ private function resolveMaximumDuration(string $test): Duration return; } -if ($phpUnitVersionSeries->major()->isOneOf(Version\Major::fromInt(10), Version\Major::fromInt(11))) { +if ($phpUnitVersionSeries->major()->isOneOf(Version\Major::fromInt(10), Version\Major::fromInt(11), Version\Major::fromInt(12))) { /** * @internal */ @@ -446,7 +447,8 @@ public function bootstrap( new Subscriber\Test\FinishedSubscriber( $maximumDuration, $timeKeeper, - $collector + $collector, + Version\Series::fromString(Runner\Version::series()) ), new Subscriber\TestRunner\ExecutionFinishedSubscriber( $collector, diff --git a/src/Subscriber/Test/FinishedSubscriber.php b/src/Subscriber/Test/FinishedSubscriber.php index d9a63d3e..63e8514b 100644 --- a/src/Subscriber/Test/FinishedSubscriber.php +++ b/src/Subscriber/Test/FinishedSubscriber.php @@ -22,6 +22,7 @@ use Ergebnis\PHPUnit\SlowTestDetector\TestIdentifier; use Ergebnis\PHPUnit\SlowTestDetector\Time; use Ergebnis\PHPUnit\SlowTestDetector\TimeKeeper; +use Ergebnis\PHPUnit\SlowTestDetector\Version; use PHPUnit\Event; use PHPUnit\Framework; use PHPUnit\Metadata; @@ -46,14 +47,21 @@ final class FinishedSubscriber implements Event\Test\FinishedSubscriber */ private $collector; + /** + * @var Version\Series + */ + private $versionSeries; + public function __construct( Duration $maximumDuration, TimeKeeper $timeKeeper, - Collector\Collector $collector + Collector\Collector $collector, + Version\Series $versionSeries ) { $this->maximumDuration = $maximumDuration; $this->timeKeeper = $timeKeeper; $this->collector = $collector; + $this->versionSeries = $versionSeries; } /** @@ -152,10 +160,12 @@ private function resolveMaximumDuration(Event\Code\Test $test): Duration return $maximumDurationFromAttribute; } - $maximumDurationFromAnnotation = self::resolveMaximumDurationFromAnnotation($test); + if ($this->versionSeries->major()->isLessThan(Version\Major::fromInt(12))) { + $maximumDurationFromAnnotation = self::resolveMaximumDurationFromAnnotation($test); - if ($maximumDurationFromAnnotation instanceof Duration) { - return $maximumDurationFromAnnotation; + if ($maximumDurationFromAnnotation instanceof Duration) { + return $maximumDurationFromAnnotation; + } } return $this->maximumDuration; diff --git a/src/Version/Major.php b/src/Version/Major.php index 9a2e71fb..fc32423d 100644 --- a/src/Version/Major.php +++ b/src/Version/Major.php @@ -53,6 +53,11 @@ public function equals(self $other): bool return $this->value === $other->value; } + public function isLessThan(self $other): bool + { + return $this->value < $other->value; + } + public function isOneOf(self ...$others): bool { foreach ($others as $other) { diff --git a/test/EndToEnd/Version12/Configuration/Defaults/SleeperTest.php b/test/EndToEnd/Version12/Configuration/Defaults/SleeperTest.php new file mode 100644 index 00000000..9bd80e82 --- /dev/null +++ b/test/EndToEnd/Version12/Configuration/Defaults/SleeperTest.php @@ -0,0 +1,60 @@ +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 + */ + public static function provideMillisecondsGreaterThanDefaultMaximumDuration(): iterable + { + $values = \range( + 600, + 1600, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/Configuration/Defaults/phpunit.xml b/test/EndToEnd/Version12/Configuration/Defaults/phpunit.xml new file mode 100644 index 00000000..e296d314 --- /dev/null +++ b/test/EndToEnd/Version12/Configuration/Defaults/phpunit.xml @@ -0,0 +1,32 @@ + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/Configuration/Defaults/test.phpt b/test/EndToEnd/Version12/Configuration/Defaults/test.phpt new file mode 100644 index 00000000..b3b6abc2 --- /dev/null +++ b/test/EndToEnd/Version12/Configuration/Defaults/test.phpt @@ -0,0 +1,42 @@ +--TEST-- +With default configuration +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +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) diff --git a/test/EndToEnd/Version12/Configuration/MaximumCount/SleeperTest.php b/test/EndToEnd/Version12/Configuration/MaximumCount/SleeperTest.php new file mode 100644 index 00000000..8c9ccdbb --- /dev/null +++ b/test/EndToEnd/Version12/Configuration/MaximumCount/SleeperTest.php @@ -0,0 +1,60 @@ +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 + */ + public static function provideMillisecondsGreaterThanDefaultMaximumDuration(): iterable + { + $values = \range( + 600, + 1000, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/Configuration/MaximumCount/phpunit.xml b/test/EndToEnd/Version12/Configuration/MaximumCount/phpunit.xml new file mode 100644 index 00000000..5979d782 --- /dev/null +++ b/test/EndToEnd/Version12/Configuration/MaximumCount/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/Configuration/MaximumCount/test.phpt b/test/EndToEnd/Version12/Configuration/MaximumCount/test.phpt new file mode 100644 index 00000000..a1d3f6b1 --- /dev/null +++ b/test/EndToEnd/Version12/Configuration/MaximumCount/test.phpt @@ -0,0 +1,35 @@ +--TEST-- +With custom configuration setting the "maximum-count" parameter in the XML configuration file +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/Configuration/MaximumCount/phpunit.xml + +...... 6 / 6 (100%) + +Detected 5 tests where the duration exceeded the maximum duration. + +1. 1.0%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\MaximumCount\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #4 (1000) +2. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\MaximumCount\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #3 (900) +3. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\MaximumCount\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #2 (800) + +There are 2 additional slow tests that are not listed here. + +Time: %s, Memory: %s + +OK (6 tests, 6 assertions) diff --git a/test/EndToEnd/Version12/Configuration/MaximumDuration/SleeperTest.php b/test/EndToEnd/Version12/Configuration/MaximumDuration/SleeperTest.php new file mode 100644 index 00000000..266a2bef --- /dev/null +++ b/test/EndToEnd/Version12/Configuration/MaximumDuration/SleeperTest.php @@ -0,0 +1,60 @@ +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 1200, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/Configuration/MaximumDuration/phpunit.xml b/test/EndToEnd/Version12/Configuration/MaximumDuration/phpunit.xml new file mode 100644 index 00000000..b42542b3 --- /dev/null +++ b/test/EndToEnd/Version12/Configuration/MaximumDuration/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/Configuration/MaximumDuration/test.phpt b/test/EndToEnd/Version12/Configuration/MaximumDuration/test.phpt new file mode 100644 index 00000000..51abd93c --- /dev/null +++ b/test/EndToEnd/Version12/Configuration/MaximumDuration/test.phpt @@ -0,0 +1,42 @@ +--TEST-- +With custom configuration setting the "maximum-duration" parameter in the XML configuration file +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/Configuration/MaximumDuration/phpunit.xml + +............ 12 / 12 (100%) + +Detected 11 tests where the duration exceeded the maximum duration. + + 1. 1.2%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\MaximumDuration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #10 (1200) + 2. 1.1%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\MaximumDuration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #9 (1100) + 3. 1.0%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\MaximumDuration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #8 (1000) + 4. 0.9%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\MaximumDuration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #7 (900) + 5. 0.8%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\MaximumDuration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #6 (800) + 6. 0.7%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\MaximumDuration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #5 (700) + 7. 0.6%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\MaximumDuration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #4 (600) + 8. 0.5%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\MaximumDuration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #3 (500) + 9. 0.4%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\MaximumDuration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #2 (400) +10. 0.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\Configuration\MaximumDuration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) + +There is 1 additional slow test that is not listed here. + +Time: %s, Memory: %s + +OK (12 tests, 12 assertions) diff --git a/test/EndToEnd/Version12/Option/NoOutput/SleeperTest.php b/test/EndToEnd/Version12/Option/NoOutput/SleeperTest.php new file mode 100644 index 00000000..434f41e1 --- /dev/null +++ b/test/EndToEnd/Version12/Option/NoOutput/SleeperTest.php @@ -0,0 +1,32 @@ +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } +} diff --git a/test/EndToEnd/Version12/Option/NoOutput/phpunit.xml b/test/EndToEnd/Version12/Option/NoOutput/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/Option/NoOutput/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/Option/NoOutput/test.phpt b/test/EndToEnd/Version12/Option/NoOutput/test.phpt new file mode 100644 index 00000000..9aefa72a --- /dev/null +++ b/test/EndToEnd/Version12/Option/NoOutput/test.phpt @@ -0,0 +1,18 @@ +--TEST-- +With default configuration of extension +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- diff --git a/test/EndToEnd/Version12/TestCase/Bare/SleeperTest.php b/test/EndToEnd/Version12/TestCase/Bare/SleeperTest.php new file mode 100644 index 00000000..248f353e --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/Bare/SleeperTest.php @@ -0,0 +1,60 @@ +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 300, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/TestCase/Bare/phpunit.xml b/test/EndToEnd/Version12/TestCase/Bare/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/Bare/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestCase/Bare/test.phpt b/test/EndToEnd/Version12/TestCase/Bare/test.phpt new file mode 100644 index 00000000..385e6405 --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/Bare/test.phpt @@ -0,0 +1,32 @@ +--TEST-- +With a test case that does not sleep in methods that are not test methods +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestCase/Bare/phpunit.xml + +... 3 / 3 (100%) + +Detected 2 tests where the duration exceeded the maximum duration. + +1. 0.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\Bare\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) +2. 0.2%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\Bare\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #0 (200) + +Time: %s, Memory: %s + +OK (3 tests, 3 assertions) diff --git a/test/EndToEnd/Version12/TestCase/Combination/SleeperTest.php b/test/EndToEnd/Version12/TestCase/Combination/SleeperTest.php new file mode 100644 index 00000000..4957b4cc --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/Combination/SleeperTest.php @@ -0,0 +1,116 @@ +sleep(); + } + + public static function tearDownAfterClass(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + protected function setUp(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + protected function assertPreConditions(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + protected function assertPostConditions(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + protected function tearDown(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + #[Framework\Attributes\Before] + public function sleepWithBeforeAttribute(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + #[Framework\Attributes\BeforeClass] + public static function sleepWithBeforeClassAttribute(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + #[Framework\Attributes\After] + public function sleepWithAfterAttribute(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + #[Framework\Attributes\AfterClass] + public static function sleepWithAfterClassAttribute(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 300, + 100 + ); + + foreach ($values as $value) { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/TestCase/Combination/phpunit.xml b/test/EndToEnd/Version12/TestCase/Combination/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/Combination/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestCase/Combination/test.phpt b/test/EndToEnd/Version12/TestCase/Combination/test.phpt new file mode 100644 index 00000000..24a85009 --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/Combination/test.phpt @@ -0,0 +1,33 @@ +--TEST-- +With a test case that sleeps in data provider, hook, and test methods +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestCase/Combination/phpunit.xml + +... 3 / 3 (100%) + +Detected 3 tests where the duration exceeded the maximum duration. + +1. 0.9%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\Combination\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) +2. 0.8%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\Combination\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #0 (200) +3. 0.6%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\Combination\SleeperTest::testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration + +Time: %s, Memory: %s + +OK (3 tests, 3 assertions) diff --git a/test/EndToEnd/Version12/TestCase/WithAfterAttribute/SleeperTest.php b/test/EndToEnd/Version12/TestCase/WithAfterAttribute/SleeperTest.php new file mode 100644 index 00000000..50a00a67 --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithAfterAttribute/SleeperTest.php @@ -0,0 +1,66 @@ +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 300, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/TestCase/WithAfterAttribute/phpunit.xml b/test/EndToEnd/Version12/TestCase/WithAfterAttribute/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithAfterAttribute/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestCase/WithAfterAttribute/test.phpt b/test/EndToEnd/Version12/TestCase/WithAfterAttribute/test.phpt new file mode 100644 index 00000000..bfe50376 --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithAfterAttribute/test.phpt @@ -0,0 +1,33 @@ +--TEST-- +With a test case that sleeps in a method with After attribute +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestCase/WithAfterAttribute/phpunit.xml + +... 3 / 3 (100%) + +Detected 3 tests where the duration exceeded the maximum duration. + +1. 0.4%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithAfterAttribute\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) +2. 0.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithAfterAttribute\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #0 (200) +3. 0.1%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithAfterAttribute\SleeperTest::testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration + +Time: %s, Memory: %s + +OK (3 tests, 3 assertions) diff --git a/test/EndToEnd/Version12/TestCase/WithAfterClassAttribute/SleeperTest.php b/test/EndToEnd/Version12/TestCase/WithAfterClassAttribute/SleeperTest.php new file mode 100644 index 00000000..3e94a9ff --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithAfterClassAttribute/SleeperTest.php @@ -0,0 +1,66 @@ +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 300, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/TestCase/WithAfterClassAttribute/phpunit.xml b/test/EndToEnd/Version12/TestCase/WithAfterClassAttribute/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithAfterClassAttribute/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestCase/WithAfterClassAttribute/test.phpt b/test/EndToEnd/Version12/TestCase/WithAfterClassAttribute/test.phpt new file mode 100644 index 00000000..88376d22 --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithAfterClassAttribute/test.phpt @@ -0,0 +1,32 @@ +--TEST-- +With a test case that sleeps in a method with AfterClass attribute +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestCase/WithAfterClassAttribute/phpunit.xml + +... 3 / 3 (100%) + +Detected 2 tests where the duration exceeded the maximum duration. + +1. 0.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithAfterClassAttribute\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) +2. 0.2%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithAfterClassAttribute\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #0 (200) + +Time: %s, Memory: %s + +OK (3 tests, 3 assertions) diff --git a/test/EndToEnd/Version12/TestCase/WithAssertPostConditions/SleeperTest.php b/test/EndToEnd/Version12/TestCase/WithAssertPostConditions/SleeperTest.php new file mode 100644 index 00000000..fcfdd792 --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithAssertPostConditions/SleeperTest.php @@ -0,0 +1,65 @@ +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 300, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/TestCase/WithAssertPostConditions/phpunit.xml b/test/EndToEnd/Version12/TestCase/WithAssertPostConditions/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithAssertPostConditions/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestCase/WithAssertPostConditions/test.phpt b/test/EndToEnd/Version12/TestCase/WithAssertPostConditions/test.phpt new file mode 100644 index 00000000..294aea76 --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithAssertPostConditions/test.phpt @@ -0,0 +1,33 @@ +--TEST-- +With a test case that sleeps in assertPostConditions() method +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestCase/WithAssertPostConditions/phpunit.xml + +... 3 / 3 (100%) + +Detected 3 tests where the duration exceeded the maximum duration. + +1. 0.4%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithAssertPostConditions\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) +2. 0.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithAssertPostConditions\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #0 (200) +3. 0.1%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithAssertPostConditions\SleeperTest::testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration + +Time: %s, Memory: %s + +OK (3 tests, 3 assertions) diff --git a/test/EndToEnd/Version12/TestCase/WithAssertPreConditions/SleeperTest.php b/test/EndToEnd/Version12/TestCase/WithAssertPreConditions/SleeperTest.php new file mode 100644 index 00000000..633f752a --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithAssertPreConditions/SleeperTest.php @@ -0,0 +1,65 @@ +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 300, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/TestCase/WithAssertPreConditions/phpunit.xml b/test/EndToEnd/Version12/TestCase/WithAssertPreConditions/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithAssertPreConditions/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestCase/WithAssertPreConditions/test.phpt b/test/EndToEnd/Version12/TestCase/WithAssertPreConditions/test.phpt new file mode 100644 index 00000000..4e3f4d80 --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithAssertPreConditions/test.phpt @@ -0,0 +1,33 @@ +--TEST-- +With a test case that sleeps in assertPreConditions() method +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestCase/WithAssertPreConditions/phpunit.xml + +... 3 / 3 (100%) + +Detected 3 tests where the duration exceeded the maximum duration. + +1. 0.4%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithAssertPreConditions\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) +2. 0.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithAssertPreConditions\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #0 (200) +3. 0.1%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithAssertPreConditions\SleeperTest::testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration + +Time: %s, Memory: %s + +OK (3 tests, 3 assertions) diff --git a/test/EndToEnd/Version12/TestCase/WithBeforeAttribute/SleeperTest.php b/test/EndToEnd/Version12/TestCase/WithBeforeAttribute/SleeperTest.php new file mode 100644 index 00000000..828dbdfc --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithBeforeAttribute/SleeperTest.php @@ -0,0 +1,66 @@ +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 300, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/TestCase/WithBeforeAttribute/phpunit.xml b/test/EndToEnd/Version12/TestCase/WithBeforeAttribute/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithBeforeAttribute/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestCase/WithBeforeAttribute/test.phpt b/test/EndToEnd/Version12/TestCase/WithBeforeAttribute/test.phpt new file mode 100644 index 00000000..4d314864 --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithBeforeAttribute/test.phpt @@ -0,0 +1,33 @@ +--TEST-- +With a test case that sleeps in a method with Before attribute +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestCase/WithBeforeAttribute/phpunit.xml + +... 3 / 3 (100%) + +Detected 3 tests where the duration exceeded the maximum duration. + +1. 0.4%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithBeforeAttribute\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) +2. 0.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithBeforeAttribute\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #0 (200) +3. 0.1%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithBeforeAttribute\SleeperTest::testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration + +Time: %s, Memory: %s + +OK (3 tests, 3 assertions) diff --git a/test/EndToEnd/Version12/TestCase/WithBeforeClassAttribute/SleeperTest.php b/test/EndToEnd/Version12/TestCase/WithBeforeClassAttribute/SleeperTest.php new file mode 100644 index 00000000..48f786d0 --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithBeforeClassAttribute/SleeperTest.php @@ -0,0 +1,66 @@ +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 300, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/TestCase/WithBeforeClassAttribute/phpunit.xml b/test/EndToEnd/Version12/TestCase/WithBeforeClassAttribute/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithBeforeClassAttribute/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestCase/WithBeforeClassAttribute/test.phpt b/test/EndToEnd/Version12/TestCase/WithBeforeClassAttribute/test.phpt new file mode 100644 index 00000000..e3b1eace --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithBeforeClassAttribute/test.phpt @@ -0,0 +1,32 @@ +--TEST-- +With a test case that sleeps in a method with BeforeClass attribute +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestCase/WithBeforeClassAttribute/phpunit.xml + +... 3 / 3 (100%) + +Detected 2 tests where the duration exceeded the maximum duration. + +1. 0.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithBeforeClassAttribute\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) +2. 0.2%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithBeforeClassAttribute\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #0 (200) + +Time: %s, Memory: %s + +OK (3 tests, 3 assertions) diff --git a/test/EndToEnd/Version12/TestCase/WithDataProvider/SleeperTest.php b/test/EndToEnd/Version12/TestCase/WithDataProvider/SleeperTest.php new file mode 100644 index 00000000..97edb3af --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithDataProvider/SleeperTest.php @@ -0,0 +1,62 @@ +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 300, + 100 + ); + + foreach ($values as $value) { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/TestCase/WithDataProvider/phpunit.xml b/test/EndToEnd/Version12/TestCase/WithDataProvider/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithDataProvider/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestCase/WithDataProvider/test.phpt b/test/EndToEnd/Version12/TestCase/WithDataProvider/test.phpt new file mode 100644 index 00000000..33602fae --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithDataProvider/test.phpt @@ -0,0 +1,32 @@ +--TEST-- +With a test case that sleeps in a data provider +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestCase/WithDataProvider/phpunit.xml + +... 3 / 3 (100%) + +Detected 2 tests where the duration exceeded the maximum duration. + +1. 0.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithDataProvider\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) +2. 0.2%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithDataProvider\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #0 (200) + +Time: %s, Memory: %s + +OK (3 tests, 3 assertions) diff --git a/test/EndToEnd/Version12/TestCase/WithSetUp/SleeperTest.php b/test/EndToEnd/Version12/TestCase/WithSetUp/SleeperTest.php new file mode 100644 index 00000000..8b818e7d --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithSetUp/SleeperTest.php @@ -0,0 +1,65 @@ +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 300, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/TestCase/WithSetUp/phpunit.xml b/test/EndToEnd/Version12/TestCase/WithSetUp/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithSetUp/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestCase/WithSetUp/test.phpt b/test/EndToEnd/Version12/TestCase/WithSetUp/test.phpt new file mode 100644 index 00000000..ff62a8fa --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithSetUp/test.phpt @@ -0,0 +1,33 @@ +--TEST-- +With a test case that sleeps in a setUp() method +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestCase/WithSetUp/phpunit.xml + +... 3 / 3 (100%) + +Detected 3 tests where the duration exceeded the maximum duration. + +1. 0.4%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithSetUp\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) +2. 0.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithSetUp\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #0 (200) +3. 0.1%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithSetUp\SleeperTest::testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration + +Time: %s, Memory: %s + +OK (3 tests, 3 assertions) diff --git a/test/EndToEnd/Version12/TestCase/WithSetUpBeforeClass/SleeperTest.php b/test/EndToEnd/Version12/TestCase/WithSetUpBeforeClass/SleeperTest.php new file mode 100644 index 00000000..d8688f9c --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithSetUpBeforeClass/SleeperTest.php @@ -0,0 +1,65 @@ +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 300, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/TestCase/WithSetUpBeforeClass/phpunit.xml b/test/EndToEnd/Version12/TestCase/WithSetUpBeforeClass/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithSetUpBeforeClass/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestCase/WithSetUpBeforeClass/test.phpt b/test/EndToEnd/Version12/TestCase/WithSetUpBeforeClass/test.phpt new file mode 100644 index 00000000..e79eff2a --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithSetUpBeforeClass/test.phpt @@ -0,0 +1,32 @@ +--TEST-- +With a test case that sleeps in a setUpBeforeClass() method +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestCase/WithSetUpBeforeClass/phpunit.xml + +... 3 / 3 (100%) + +Detected 2 tests where the duration exceeded the maximum duration. + +1. 0.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithSetUpBeforeClass\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) +2. 0.2%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithSetUpBeforeClass\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #0 (200) + +Time: %s, Memory: %s + +OK (3 tests, 3 assertions) diff --git a/test/EndToEnd/Version12/TestCase/WithTearDown/SleeperTest.php b/test/EndToEnd/Version12/TestCase/WithTearDown/SleeperTest.php new file mode 100644 index 00000000..7c86c66e --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithTearDown/SleeperTest.php @@ -0,0 +1,65 @@ +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 300, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/TestCase/WithTearDown/phpunit.xml b/test/EndToEnd/Version12/TestCase/WithTearDown/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithTearDown/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestCase/WithTearDown/test.phpt b/test/EndToEnd/Version12/TestCase/WithTearDown/test.phpt new file mode 100644 index 00000000..70f32a4d --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithTearDown/test.phpt @@ -0,0 +1,33 @@ +--TEST-- +With a test case that sleeps in a tearDown() method +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestCase/WithTearDown/phpunit.xml + +... 3 / 3 (100%) + +Detected 3 tests where the duration exceeded the maximum duration. + +1. 0.4%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithTearDown\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) +2. 0.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithTearDown\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #0 (200) +3. 0.1%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithTearDown\SleeperTest::testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration + +Time: %s, Memory: %s + +OK (3 tests, 3 assertions) diff --git a/test/EndToEnd/Version12/TestCase/WithTearDownAfterClass/SleeperTest.php b/test/EndToEnd/Version12/TestCase/WithTearDownAfterClass/SleeperTest.php new file mode 100644 index 00000000..50a3e0e8 --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithTearDownAfterClass/SleeperTest.php @@ -0,0 +1,65 @@ +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[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 + */ + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable + { + $values = \range( + 200, + 300, + 100 + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/Version12/TestCase/WithTearDownAfterClass/phpunit.xml b/test/EndToEnd/Version12/TestCase/WithTearDownAfterClass/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithTearDownAfterClass/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestCase/WithTearDownAfterClass/test.phpt b/test/EndToEnd/Version12/TestCase/WithTearDownAfterClass/test.phpt new file mode 100644 index 00000000..117d0192 --- /dev/null +++ b/test/EndToEnd/Version12/TestCase/WithTearDownAfterClass/test.phpt @@ -0,0 +1,32 @@ +--TEST-- +With a test case that sleeps in a tearDownAfterClass() method +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestCase/WithTearDownAfterClass/phpunit.xml + +... 3 / 3 (100%) + +Detected 2 tests where the duration exceeded the maximum duration. + +1. 0.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithTearDownAfterClass\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #1 (300) +2. 0.2%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestCase\WithTearDownAfterClass\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider with data set #0 (200) + +Time: %s, Memory: %s + +OK (3 tests, 3 assertions) diff --git a/test/EndToEnd/Version12/TestMethod/WithMaximumDurationAttribute/SleeperTest.php b/test/EndToEnd/Version12/TestMethod/WithMaximumDurationAttribute/SleeperTest.php new file mode 100644 index 00000000..072b2904 --- /dev/null +++ b/test/EndToEnd/Version12/TestMethod/WithMaximumDurationAttribute/SleeperTest.php @@ -0,0 +1,46 @@ +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[Attribute\MaximumDuration(200)] + public function testSleeperSleepsLongerThanMaximumDurationFromAttributeWhenTestMethodHasValidMaximumDurationAttribute(): void + { + $milliseconds = 300; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } +} diff --git a/test/EndToEnd/Version12/TestMethod/WithMaximumDurationAttribute/phpunit.xml b/test/EndToEnd/Version12/TestMethod/WithMaximumDurationAttribute/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestMethod/WithMaximumDurationAttribute/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestMethod/WithMaximumDurationAttribute/test.phpt b/test/EndToEnd/Version12/TestMethod/WithMaximumDurationAttribute/test.phpt new file mode 100644 index 00000000..75be2ba4 --- /dev/null +++ b/test/EndToEnd/Version12/TestMethod/WithMaximumDurationAttribute/test.phpt @@ -0,0 +1,31 @@ +--TEST-- +With test methods with @maximumDuration Attributes +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestMethod/WithMaximumDurationAttribute/phpunit.xml + +.. 2 / 2 (100%) + +Detected 1 test where the duration exceeded the maximum duration. + +1. 0.3%s (0.200) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestMethod\WithMaximumDurationAttribute\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromAttributeWhenTestMethodHasValidMaximumDurationAttribute + +Time: %s, Memory: %s + +OK (2 tests, 2 assertions) diff --git a/test/EndToEnd/Version12/TestMethod/WithRunInSeparateProcessAttribute/SleeperTest.php b/test/EndToEnd/Version12/TestMethod/WithRunInSeparateProcessAttribute/SleeperTest.php new file mode 100644 index 00000000..6fc95328 --- /dev/null +++ b/test/EndToEnd/Version12/TestMethod/WithRunInSeparateProcessAttribute/SleeperTest.php @@ -0,0 +1,121 @@ +sleep(); + } + + public static function tearDownAfterClass(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + protected function setUp(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + protected function assertPreConditions(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + protected function assertPostConditions(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + protected function tearDown(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + #[Framework\Attributes\Before] + public function sleepWithBeforeAttribute(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + #[Framework\Attributes\BeforeClass] + public static function sleepWithBeforeClassAttribute(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + #[Framework\Attributes\After] + public function sleepWithAfterAttribute(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + #[Framework\Attributes\AfterClass] + public static function sleepWithAfterClassAttribute(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + public function testSleeperSleepsShorterThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[Framework\Attributes\RunInSeparateProcess] + public function testSleeperSleepsShorterThanMaximumDurationFromXmlConfigurationWhenMethodHasRunInSeparateProcessAttribute(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + public function testSleeperSleepsLongerThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 200; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[Framework\Attributes\RunInSeparateProcess] + public function testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWhenMethodHasRunInSeparateProcessAttribute(): void + { + $milliseconds = 300; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } +} diff --git a/test/EndToEnd/Version12/TestMethod/WithRunInSeparateProcessAttribute/phpunit.xml b/test/EndToEnd/Version12/TestMethod/WithRunInSeparateProcessAttribute/phpunit.xml new file mode 100644 index 00000000..f3c8d23f --- /dev/null +++ b/test/EndToEnd/Version12/TestMethod/WithRunInSeparateProcessAttribute/phpunit.xml @@ -0,0 +1,33 @@ + + + + + + + + + . + + + diff --git a/test/EndToEnd/Version12/TestMethod/WithRunInSeparateProcessAttribute/test.phpt b/test/EndToEnd/Version12/TestMethod/WithRunInSeparateProcessAttribute/test.phpt new file mode 100644 index 00000000..b6fd30e6 --- /dev/null +++ b/test/EndToEnd/Version12/TestMethod/WithRunInSeparateProcessAttribute/test.phpt @@ -0,0 +1,39 @@ +--TEST-- +With a test case that sleeps in data provider, hook, and test methods and has test methods with RunInSeparateProcess attribute +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s + +Runtime: %s +Configuration: %s/EndToEnd/Version12/TestMethod/WithRunInSeparateProcessAttribute/phpunit.xml + +.... 4 / 4 (100%) + +Detected 4 tests where the duration exceeded the maximum duration. + +1. 1.3%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestMethod\WithRunInSeparateProcessAttribute\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWhenMethodHasRunInSeparateProcessAttribute +2. 1.0%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestMethod\WithRunInSeparateProcessAttribute\SleeperTest::testSleeperSleepsShorterThanMaximumDurationFromXmlConfigurationWhenMethodHasRunInSeparateProcessAttribute +3. 0.8%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestMethod\WithRunInSeparateProcessAttribute\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromXmlConfiguration +4. 0.6%s (0.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version12\TestMethod\WithRunInSeparateProcessAttribute\SleeperTest::testSleeperSleepsShorterThanMaximumDurationFromXmlConfiguration + +Time: %s, Memory: %s + +OK (4 tests, 4 assertions) diff --git a/test/EndToEnd/Version12/phpunit.xml b/test/EndToEnd/Version12/phpunit.xml new file mode 100644 index 00000000..9516ae18 --- /dev/null +++ b/test/EndToEnd/Version12/phpunit.xml @@ -0,0 +1,30 @@ + + + + . + + + diff --git a/test/Phar/Version12/SleeperTest.php b/test/Phar/Version12/SleeperTest.php new file mode 100644 index 00000000..843f2180 --- /dev/null +++ b/test/Phar/Version12/SleeperTest.php @@ -0,0 +1,43 @@ +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + public function testSleeperSleepsJustAboveDefaultMaximumDuration(): void + { + $milliseconds = 600; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } +} diff --git a/test/Phar/Version12/bootstrap.php b/test/Phar/Version12/bootstrap.php new file mode 100644 index 00000000..c80df3ff --- /dev/null +++ b/test/Phar/Version12/bootstrap.php @@ -0,0 +1,14 @@ + + + + + + + . + + + diff --git a/test/Unit/Version/MajorTest.php b/test/Unit/Version/MajorTest.php index 37612846..a14890eb 100644 --- a/test/Unit/Version/MajorTest.php +++ b/test/Unit/Version/MajorTest.php @@ -69,6 +69,36 @@ public function testEqualsReturnsTrueWhenValueIsSame() self::assertTrue($one->equals($two)); } + public function testIsLessThanReturnsFalseWhenValueIsSame() + { + $value = self::faker()->numberBetween(0); + + $one = Version\Major::fromInt($value); + $two = Version\Major::fromInt($value); + + self::assertFalse($one->isLessThan($two)); + } + + public function testIsLessThanReturnsFalseWhenValueIsGreater() + { + $value = self::faker()->numberBetween(0); + + $one = Version\Major::fromInt($value + 1); + $two = Version\Major::fromInt($value); + + self::assertFalse($one->isLessThan($two)); + } + + public function testIsLessThanReturnsTrueWhenValueIsLess() + { + $value = self::faker()->numberBetween(0); + + $one = Version\Major::fromInt($value); + $two = Version\Major::fromInt($value + 1); + + self::assertTrue($one->isLessThan($two)); + } + public function testIsOneOfReturnsFalseWhenAllValuesAreDifferent() { $faker = self::faker()->unique();