diff --git a/.github/settings.yml b/.github/settings.yml index b1c20ecd..2cd5c7ad 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -14,13 +14,23 @@ branches: required_approving_review_count: 1 required_status_checks: checks: - - context: "Code Coverage (8.5.19, 7.4, highest)" + - context: "Code Coverage (7.2.0, 7.4, highest)" - context: "Coding Standards (7.4, locked)" - context: "Compile Phar (8.1, locked)" - context: "Dependency Analysis (7.4, locked)" - context: "Refactoring (7.4, locked)" - context: "Security Analysis (7.4, locked)" - context: "Static Code Analysis (7.4, locked)" + - context: "Tests (7.2.0, 7.4, highest)" + - context: "Tests (7.2.0, 7.4, lowest)" + - context: "Tests (7.2.0, 8.0, highest)" + - context: "Tests (7.2.0, 8.0, lowest)" + - context: "Tests (7.2.0, 8.1, highest)" + - context: "Tests (7.2.0, 8.1, lowest)" + - context: "Tests (7.2.0, 8.2, highest)" + - context: "Tests (7.2.0, 8.2, lowest)" + - context: "Tests (7.2.0, 8.3, highest)" + - context: "Tests (7.2.0, 8.3, lowest)" - context: "Tests (8.5.19, 7.4, highest)" - context: "Tests (8.5.19, 7.4, lowest)" - context: "Tests (8.5.19, 8.0, highest)" diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index fe88a5d7..c57b1c61 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -19,7 +19,7 @@ jobs: strategy: matrix: phpunit-version: - - "8.5.19" + - "7.2.0" php-version: - "7.4" @@ -458,6 +458,7 @@ jobs: fail-fast: false matrix: phpunit-version: + - "7.2.0" - "8.5.19" - "9.0.0" @@ -556,8 +557,8 @@ jobs: with: dependencies: "${{ matrix.dependencies }}" - - name: "Run unit tests with phpunit/phpunit:8.5.19" - if: "matrix.phpunit-version == '8.5.19'" + - name: "Run unit tests with phpunit/phpunit:7.2.0" + if: "matrix.phpunit-version == '7.2.0'" run: "vendor/bin/phpunit --colors=always --configuration=test/Unit/phpunit.xml" - name: "Apply patch from https://github.com/sebastianbergmann/phpunit/pull/4486 for phpunit/phpunit:9.0.0" @@ -567,6 +568,10 @@ jobs: wget -O gh-4486.patch https://github.com/sebastianbergmann/phpunit/commit/0a488f22925b3c8732338ef0fbfe7f13cb4cf1d2.patch patch -p1 < gh-4486.patch + - name: "Run end-to-end tests with phpunit/phpunit:7.2.0" + if: "matrix.phpunit-version == '7.2.0'" + run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version07/phpunit.xml" + - name: "Run end-to-end tests with phpunit/phpunit:8.5.19" if: "matrix.phpunit-version == '8.5.19'" run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/Version08/phpunit.xml" diff --git a/CHANGELOG.md b/CHANGELOG.md index e499c2f1..6798f477 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.7.0...main`][2.7.0...main]. +### Added + +- Added support for `phpunit/phpunit:^7.2.0` ([#447]), by [@localheinz] + ## [`2.7.0`][2.7.0] For a full diff see [`2.6.0...2.7.0`][2.6.0...2.7.0]. @@ -237,6 +241,7 @@ For a full diff see [`7afa59c...1.0.0`][7afa59c...1.0.0]. [#393]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/393 [#394]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/394 [#396]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/396 +[#447]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/447 [@HypeMC]: https://github.com/HypeMC [@localheinz]: https://github.com/localheinz diff --git a/Makefile b/Makefile index 4cca86de..157f2deb 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,8 @@ static-code-analysis-baseline: vendor ## Generates a baseline for static code an .PHONY: tests tests: ## Runs unit and end-to-end tests with phpunit/phpunit mkdir -p .build/phpunit/ - composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^8.5.19 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/Unit/phpunit.xml; git checkout HEAD -- composer.json composer.lock + composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^7.2.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/Unit/phpunit.xml; git checkout HEAD -- composer.json composer.lock + composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^7.2.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version07/phpunit.xml; git checkout HEAD -- composer.json composer.lock composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^8.5.19 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version08/phpunit.xml; git checkout HEAD -- composer.json composer.lock composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^9.0.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version09/phpunit.xml; git checkout HEAD -- composer.json composer.lock composer config platform.php --unset; composer remove ergebnis/php-cs-fixer-config psalm/plugin-phpunit vimeo/psalm --dev --no-interaction --no-progress; composer require phpunit/phpunit:^10.0.0 --no-interaction --quiet --update-with-all-dependencies; vendor/bin/phpunit --configuration=test/EndToEnd/Version10/phpunit.xml; git checkout HEAD -- composer.json composer.lock diff --git a/README.md b/README.md index 4999d2f2..77f09305 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ This project provides a [`composer`](https://getcomposer.org) package and a [Pha The extension is compatible with the following versions of `phpunit/phpunit`: +- [`phpunit/phpunit:^7.2.0`](https://github.com/sebastianbergmann/phpunit/tree/7.2.0) - [`phpunit/phpunit:^8.5.19`](https://github.com/sebastianbergmann/phpunit/tree/8.5.19) - [`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) @@ -30,7 +31,7 @@ Run composer require --dev ergebnis/phpunit-slow-test-detector ``` -to install `ergebnis/phpunit-slow-test-detector` as a `composer` package when using `phpunit/phpunit:^8.5.19`, `phpunit/phpunit:^9.0.0`, or `phpunit/phpunit:^10.0.0`. +to install `ergebnis/phpunit-slow-test-detector` as a `composer` package when using `phpunit/phpunit:^7.2.0`, `phpunit/phpunit:^8.5.19`, `phpunit/phpunit:^9.0.0`, or `phpunit/phpunit:^10.0.0`. ### Installation as Phar @@ -42,6 +43,27 @@ Download `phpunit-slow-test-detector.phar` from the [latest release](https://git Before the extension can detect slow tests in `phpunit/phpunit`, you need to bootstrap it. The bootstrapping mechanism depends on the version of `phpunit/phpunit` you are using. +### Bootstrapping the extension as a `composer` package when using `phpunit/phpunit:^7.2.0` + +To bootstrap the extension as a `composer` package when using `phpunit/phpunit:^7.2.0`, adjust your `phpunit.xml` configuration file and configure the [`extensions` element](https://docs.phpunit.de/en/7.5/configuration.html#the-extensions-element): + +```diff + ++ ++ ++ + + + test/Unit/ + + + +``` + ### Bootstrapping the extension as a `composer` package when using `phpunit/phpunit:^8.5.19` To bootstrap the extension as a `composer` package when using `phpunit/phpunit:^8.5.19`, adjust your `phpunit.xml` configuration file and configure the [`extensions` element](https://docs.phpunit.de/en/8.5/configuration.html#the-extensions-element): @@ -136,6 +158,38 @@ You can configure the extension with the following options in your `phpunit.xml` The configuration mechanism depends on the version of `phpunit/phpunit` you are using. +### Configuring the extension when using `phpunit/phpunit:^7.2.0` + +The following example configures the maximum count of slow tests to three, and the maximum duration for all tests to 250 milliseconds when using `phpunit/phpunit:^7.2.0`: + +```diff + + +- ++ ++ ++ ++ ++ 3 ++ ++ ++ 250 ++ ++ ++ ++ + + + + test/Unit/ + + + +``` ### Configuring the extension when using `phpunit/phpunit:^8.5.19` The following example configures the maximum count of slow tests to three, and the maximum duration for all tests to 250 milliseconds when using `phpunit/phpunit:^8.5.19`: @@ -232,8 +286,8 @@ The following example configures the maximum count of slow tests to three, and t You can configure the maximum duration for a single test case with - an `Attribute\MaximumDuration` attribute when using `phpunit/phpunit:^10.0.0` -- a `@maximumDuration` annotation in the DocBlock when using `phpunit/phpunit:^8.5.19` or `phpunit/phpunit:^9.0.0` -- a `@slowThreshold` annotation in the DocBlock when using `phpunit/phpunit:^8.5.19` or `phpunit/phpunit:^9.0.0` +- a `@maximumDuration` annotation in the DocBlock when using `phpunit/phpunit:^7.2.0`, `phpunit/phpunit:^8.5.19`, or `phpunit/phpunit:^9.0.0` +- a `@slowThreshold` annotation in the DocBlock when using `phpunit/phpunit:^7.0.0`, `phpunit/phpunit:^8.5.19`, or `phpunit/phpunit:^9.0.0` The following example configures the maximum durations for single test cases to 5.000 ms, 4.000 ms, and 3.000 ms: @@ -316,9 +370,9 @@ Time: 00:12.601, Memory: 8.00 MB OK (13 tests, 13 assertions) ``` -### Understanding measured test durations when using `phpunit/phpunit:^8.5.19` or `phpunit/phpunit:^9.0.0` +### Understanding measured test durations when using `phpunit/phpunit:^7.0.0`, `phpunit/phpunit:^8.5.19`, or `phpunit/phpunit:^9.0.0` -When using `phpunit/phpunit:^8.5.19` or `phpunit/phpunit:^9.0.0`, the extension uses the hooks event system of `phpunit/phpunit`. +When using `phpunit/phpunit:^7.0.0`, `phpunit/phpunit:^8.5.19`, or `phpunit/phpunit:^9.0.0` the extension uses the hooks event system of `phpunit/phpunit`. The hooks event system supports eleven hook methods that `phpunit/phpunit` invokes during the execution of tests. diff --git a/composer.json b/composer.json index e527b493..fde745cd 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ }, "require": { "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", - "phpunit/phpunit": "^8.5.19 || ^9.0.0 || ^10.0.0" + "phpunit/phpunit": "^7.1.0 || ^8.5.19 || ^9.0.0 || ^10.0.0" }, "require-dev": { "ergebnis/composer-normalize": "^2.28.3", diff --git a/composer.lock b/composer.lock index b743b8b6..3599fe8f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ecd1e1b4246d58c9fde54da4f69e851b", + "content-hash": "7ae35d24f59881423272692cbb83acd9", "packages": [ { "name": "doctrine/instantiator", diff --git a/psalm-baseline.xml b/psalm-baseline.xml index b506c59b..f169533c 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -60,6 +60,42 @@ $reporter + + + sleepWithAfterAnnotation + sleepWithAfterClassAnnotation + sleepWithBeforeAnnotation + sleepWithBeforeClassAnnotation + + + + + sleepWithAfterAnnotation + + + + + sleepWithAfterClassAnnotation + + + + + sleepWithBeforeAnnotation + + + + + sleepWithBeforeClassAnnotation + + + + + sleepWithAfterAnnotation + sleepWithAfterClassAnnotation + sleepWithBeforeAnnotation + sleepWithBeforeClassAnnotation + + sleepWithAfterAnnotation diff --git a/src/Extension.php b/src/Extension.php index 5a763cf5..c2c69ce6 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -26,7 +26,7 @@ )); } -if ($phpUnitVersionSeries->major()->isOneOf(Version\Major::fromInt(8), Version\Major::fromInt(9))) { +if ($phpUnitVersionSeries->major()->isOneOf(Version\Major::fromInt(7), Version\Major::fromInt(8), Version\Major::fromInt(9))) { /** * @internal */ diff --git a/test/EndToEnd/Version07/Configuration/Defaults/SleeperTest.php b/test/EndToEnd/Version07/Configuration/Defaults/SleeperTest.php new file mode 100644 index 00000000..77292c2e --- /dev/null +++ b/test/EndToEnd/Version07/Configuration/Defaults/SleeperTest.php @@ -0,0 +1,64 @@ +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/Configuration/Defaults/phpunit.xml b/test/EndToEnd/Version07/Configuration/Defaults/phpunit.xml new file mode 100644 index 00000000..575fee6a --- /dev/null +++ b/test/EndToEnd/Version07/Configuration/Defaults/phpunit.xml @@ -0,0 +1,26 @@ + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/Configuration/Defaults/test.phpt b/test/EndToEnd/Version07/Configuration/Defaults/test.phpt new file mode 100644 index 00000000..05b0cfd6 --- /dev/null +++ b/test/EndToEnd/Version07/Configuration/Defaults/test.phpt @@ -0,0 +1,40 @@ +--TEST-- +With default configuration +--FILE-- +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/Configuration/MaximumCount/phpunit.xml b/test/EndToEnd/Version07/Configuration/MaximumCount/phpunit.xml new file mode 100644 index 00000000..0d6704ed --- /dev/null +++ b/test/EndToEnd/Version07/Configuration/MaximumCount/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 3 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/Configuration/MaximumCount/test.phpt b/test/EndToEnd/Version07/Configuration/MaximumCount/test.phpt new file mode 100644 index 00000000..9b18abcd --- /dev/null +++ b/test/EndToEnd/Version07/Configuration/MaximumCount/test.phpt @@ -0,0 +1,33 @@ +--TEST-- +With custom configuration setting the "maximum-count" parameter in the XML configuration file +--FILE-- +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/Configuration/MaximumDuration/phpunit.xml b/test/EndToEnd/Version07/Configuration/MaximumDuration/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/Configuration/MaximumDuration/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/Configuration/MaximumDuration/test.phpt b/test/EndToEnd/Version07/Configuration/MaximumDuration/test.phpt new file mode 100644 index 00000000..527b3b6b --- /dev/null +++ b/test/EndToEnd/Version07/Configuration/MaximumDuration/test.phpt @@ -0,0 +1,40 @@ +--TEST-- +With custom configuration setting the "maximum-duration" parameter in the XML configuration file +--FILE-- +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/TestCase/Bare/phpunit.xml b/test/EndToEnd/Version07/TestCase/Bare/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/Bare/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestCase/Bare/test.phpt b/test/EndToEnd/Version07/TestCase/Bare/test.phpt new file mode 100644 index 00000000..1c45bc90 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/Bare/test.phpt @@ -0,0 +1,30 @@ +--TEST-- +With a test case that does not sleep in methods that are not test methods +--FILE-- +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(); + } + + /** + * @before + */ + public function sleepWithBeforeAnnotation(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + /** + * @beforeClass + */ + public function sleepWithBeforeClassAnnotation(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + /** + * @after + */ + public function sleepWithAfterAnnotation(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + /** + * @afterClass + */ + public static function sleepWithAfterClassAnnotation(): 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()); + } + + /** + * @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/Version07/TestCase/Combination/phpunit.xml b/test/EndToEnd/Version07/TestCase/Combination/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/Combination/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestCase/Combination/test.phpt b/test/EndToEnd/Version07/TestCase/Combination/test.phpt new file mode 100644 index 00000000..19d359e1 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/Combination/test.phpt @@ -0,0 +1,31 @@ +--TEST-- +With a test case that sleeps in data provider, hook, and test methods +--FILE-- +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/TestCase/WithAfterAnnotation/phpunit.xml b/test/EndToEnd/Version07/TestCase/WithAfterAnnotation/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithAfterAnnotation/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestCase/WithAfterAnnotation/test.phpt b/test/EndToEnd/Version07/TestCase/WithAfterAnnotation/test.phpt new file mode 100644 index 00000000..951bbc65 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithAfterAnnotation/test.phpt @@ -0,0 +1,31 @@ +--TEST-- +With a test case that sleeps in a method with @after annotation +--FILE-- +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/TestCase/WithAfterClassAnnotation/phpunit.xml b/test/EndToEnd/Version07/TestCase/WithAfterClassAnnotation/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithAfterClassAnnotation/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestCase/WithAfterClassAnnotation/test.phpt b/test/EndToEnd/Version07/TestCase/WithAfterClassAnnotation/test.phpt new file mode 100644 index 00000000..e6769e81 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithAfterClassAnnotation/test.phpt @@ -0,0 +1,30 @@ +--TEST-- +With a test case that sleeps in a method with @afterClass annotation +--FILE-- +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/TestCase/WithAssertPostConditions/phpunit.xml b/test/EndToEnd/Version07/TestCase/WithAssertPostConditions/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithAssertPostConditions/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestCase/WithAssertPostConditions/test.phpt b/test/EndToEnd/Version07/TestCase/WithAssertPostConditions/test.phpt new file mode 100644 index 00000000..62c76aed --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithAssertPostConditions/test.phpt @@ -0,0 +1,31 @@ +--TEST-- +With a test case that sleeps in assertPostConditions() method +--FILE-- +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/TestCase/WithAssertPreConditions/phpunit.xml b/test/EndToEnd/Version07/TestCase/WithAssertPreConditions/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithAssertPreConditions/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestCase/WithAssertPreConditions/test.phpt b/test/EndToEnd/Version07/TestCase/WithAssertPreConditions/test.phpt new file mode 100644 index 00000000..536bd4c2 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithAssertPreConditions/test.phpt @@ -0,0 +1,31 @@ +--TEST-- +With a test case that sleeps in assertPreConditions() method +--FILE-- +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/TestCase/WithBeforeAnnotation/phpunit.xml b/test/EndToEnd/Version07/TestCase/WithBeforeAnnotation/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithBeforeAnnotation/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestCase/WithBeforeAnnotation/test.phpt b/test/EndToEnd/Version07/TestCase/WithBeforeAnnotation/test.phpt new file mode 100644 index 00000000..d9f93ec3 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithBeforeAnnotation/test.phpt @@ -0,0 +1,31 @@ +--TEST-- +With a test case that sleeps in a method with @before annotation +--FILE-- +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/TestCase/WithBeforeClassAnnotation/phpunit.xml b/test/EndToEnd/Version07/TestCase/WithBeforeClassAnnotation/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithBeforeClassAnnotation/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestCase/WithBeforeClassAnnotation/test.phpt b/test/EndToEnd/Version07/TestCase/WithBeforeClassAnnotation/test.phpt new file mode 100644 index 00000000..7f3c16c1 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithBeforeClassAnnotation/test.phpt @@ -0,0 +1,30 @@ +--TEST-- +With a test case that sleeps in a method with @beforeClass annotation +--FILE-- +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/TestCase/WithDataProvider/phpunit.xml b/test/EndToEnd/Version07/TestCase/WithDataProvider/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithDataProvider/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestCase/WithDataProvider/test.phpt b/test/EndToEnd/Version07/TestCase/WithDataProvider/test.phpt new file mode 100644 index 00000000..6180d970 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithDataProvider/test.phpt @@ -0,0 +1,30 @@ +--TEST-- +With a test case that sleeps in a data provider +--FILE-- +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/TestCase/WithSetUp/phpunit.xml b/test/EndToEnd/Version07/TestCase/WithSetUp/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithSetUp/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestCase/WithSetUp/test.phpt b/test/EndToEnd/Version07/TestCase/WithSetUp/test.phpt new file mode 100644 index 00000000..83f86c5c --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithSetUp/test.phpt @@ -0,0 +1,31 @@ +--TEST-- +With a test case that sleeps in a setUp() method +--FILE-- +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/TestCase/WithSetUpBeforeClass/phpunit.xml b/test/EndToEnd/Version07/TestCase/WithSetUpBeforeClass/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithSetUpBeforeClass/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestCase/WithSetUpBeforeClass/test.phpt b/test/EndToEnd/Version07/TestCase/WithSetUpBeforeClass/test.phpt new file mode 100644 index 00000000..b82c25cb --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithSetUpBeforeClass/test.phpt @@ -0,0 +1,30 @@ +--TEST-- +With a test case that sleeps in a setUpBeforeClass() method +--FILE-- +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/TestCase/WithTearDown/phpunit.xml b/test/EndToEnd/Version07/TestCase/WithTearDown/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithTearDown/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestCase/WithTearDown/test.phpt b/test/EndToEnd/Version07/TestCase/WithTearDown/test.phpt new file mode 100644 index 00000000..df67379a --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithTearDown/test.phpt @@ -0,0 +1,31 @@ +--TEST-- +With a test case that sleeps in a tearDown() method +--FILE-- +sleep(); + } + + public function testSleeperSleepsLessThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @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/Version07/TestCase/WithTearDownAfterClass/phpunit.xml b/test/EndToEnd/Version07/TestCase/WithTearDownAfterClass/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithTearDownAfterClass/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestCase/WithTearDownAfterClass/test.phpt b/test/EndToEnd/Version07/TestCase/WithTearDownAfterClass/test.phpt new file mode 100644 index 00000000..0784c639 --- /dev/null +++ b/test/EndToEnd/Version07/TestCase/WithTearDownAfterClass/test.phpt @@ -0,0 +1,30 @@ +--TEST-- +With a test case that sleeps in a tearDownAfterClass() method +--FILE-- +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 200 + * + * @slowThreshold 400 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromAnnotationWhenTestMethodHasMaximumDurationAndSlowThresholdAnnotations(): void + { + $milliseconds = 300; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } +} diff --git a/test/EndToEnd/Version07/TestMethod/WithMaximumDurationAndSlowThresholdAnnotations/phpunit.xml b/test/EndToEnd/Version07/TestMethod/WithMaximumDurationAndSlowThresholdAnnotations/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestMethod/WithMaximumDurationAndSlowThresholdAnnotations/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestMethod/WithMaximumDurationAndSlowThresholdAnnotations/test.phpt b/test/EndToEnd/Version07/TestMethod/WithMaximumDurationAndSlowThresholdAnnotations/test.phpt new file mode 100644 index 00000000..c3c74a0c --- /dev/null +++ b/test/EndToEnd/Version07/TestMethod/WithMaximumDurationAndSlowThresholdAnnotations/test.phpt @@ -0,0 +1,29 @@ +--TEST-- +With @maximumDuration and @slowThreshold annotations +--FILE-- +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 3.14 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWhenTestMethodHasInvalidMaximumDurationAnnotation(): void + { + $milliseconds = 200; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 200 + */ + public function testSleeperSleepsShorterThanMaximumDurationFromAnnotationWhenTestMethodHasValidMaximumDurationAnnotation(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 200 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromAnnotationWhenTestMethodHasValidMaximumDurationAnnotation(): void + { + $milliseconds = 300; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } +} diff --git a/test/EndToEnd/Version07/TestMethod/WithMaximumDurationAnnotation/phpunit.xml b/test/EndToEnd/Version07/TestMethod/WithMaximumDurationAnnotation/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestMethod/WithMaximumDurationAnnotation/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestMethod/WithMaximumDurationAnnotation/test.phpt b/test/EndToEnd/Version07/TestMethod/WithMaximumDurationAnnotation/test.phpt new file mode 100644 index 00000000..7edeb90c --- /dev/null +++ b/test/EndToEnd/Version07/TestMethod/WithMaximumDurationAnnotation/test.phpt @@ -0,0 +1,30 @@ +--TEST-- +With test methods with @maximumDuration annotations +--FILE-- +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(); + } + + /** + * @before + */ + public function sleepWithBeforeAnnotation(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + /** + * @beforeClass + */ + public static function sleepWithBeforeClassAnnotation(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + /** + * @after + */ + public function sleepWithAfterAnnotation(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + /** + * @afterClass + */ + public static function sleepWithAfterClassAnnotation(): void + { + Test\Fixture\Sleeper::fromMilliseconds(100)->sleep(); + } + + public function testSleeperSleepsShorterThanMaximumDurationFromXmlConfiguration(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @runInSeparateProcess + */ + public function testSleeperSleepsShorterThanMaximumDurationFromXmlConfigurationWhenMethodHasRunInSeparateProcessAnnotation(): void + { + $milliseconds = 50; + + $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()); + } + + /** + * @runInSeparateProcess + */ + public function testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWhenMethodHasRunInSeparateProcessAnnotation(): void + { + $milliseconds = 300; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } +} diff --git a/test/EndToEnd/Version07/TestMethod/WithRunInSeparateProcessAnnotation/phpunit.xml b/test/EndToEnd/Version07/TestMethod/WithRunInSeparateProcessAnnotation/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestMethod/WithRunInSeparateProcessAnnotation/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestMethod/WithRunInSeparateProcessAnnotation/test.phpt b/test/EndToEnd/Version07/TestMethod/WithRunInSeparateProcessAnnotation/test.phpt new file mode 100644 index 00000000..c713af46 --- /dev/null +++ b/test/EndToEnd/Version07/TestMethod/WithRunInSeparateProcessAnnotation/test.phpt @@ -0,0 +1,37 @@ +--TEST-- +With a test case that sleeps in data provider, hook, and test methods and has test methods with @runInSeparateProcess annotation +--FILE-- +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @slowThreshold 400 + * + * @maximumDuration 200 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromAnnotationWhenTestMethodHasMaximumDurationAndSlowThresholdAnnotations(): void + { + $milliseconds = 300; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } +} diff --git a/test/EndToEnd/Version07/TestMethod/WithSlowThresholdAndMaximumDurationAnnotations/phpunit.xml b/test/EndToEnd/Version07/TestMethod/WithSlowThresholdAndMaximumDurationAnnotations/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestMethod/WithSlowThresholdAndMaximumDurationAnnotations/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestMethod/WithSlowThresholdAndMaximumDurationAnnotations/test.phpt b/test/EndToEnd/Version07/TestMethod/WithSlowThresholdAndMaximumDurationAnnotations/test.phpt new file mode 100644 index 00000000..ab876c85 --- /dev/null +++ b/test/EndToEnd/Version07/TestMethod/WithSlowThresholdAndMaximumDurationAnnotations/test.phpt @@ -0,0 +1,29 @@ +--TEST-- +With @maximumDuration and @slowThreshold annotations +--FILE-- +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @slowThreshold 3.14 + * + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWhenTestMethodHasInvalidSlowThresholdAnnotation(): void + { + $milliseconds = 200; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @slowThreshold 200 + * + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + */ + public function testSleeperSleepsShorterThanSlowThresholdFromAnnotationWhenTestMethodHasValidSlowThresholdAnnotation(): void + { + $milliseconds = 10; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @slowThreshold 200 + * + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + */ + public function testSleeperSleepsLongerThanSlowThresholdFromAnnotationWhenTestMethodHasValidSlowThresholdAnnotation(): void + { + $milliseconds = 300; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } +} diff --git a/test/EndToEnd/Version07/TestMethod/WithSlowThresholdAnnotation/phpunit.xml b/test/EndToEnd/Version07/TestMethod/WithSlowThresholdAnnotation/phpunit.xml new file mode 100644 index 00000000..7a5abee6 --- /dev/null +++ b/test/EndToEnd/Version07/TestMethod/WithSlowThresholdAnnotation/phpunit.xml @@ -0,0 +1,34 @@ + + + + + + + 100 + + + + + + + + . + + + diff --git a/test/EndToEnd/Version07/TestMethod/WithSlowThresholdAnnotation/test.phpt b/test/EndToEnd/Version07/TestMethod/WithSlowThresholdAnnotation/test.phpt new file mode 100644 index 00000000..b2c0277b --- /dev/null +++ b/test/EndToEnd/Version07/TestMethod/WithSlowThresholdAnnotation/test.phpt @@ -0,0 +1,30 @@ +--TEST-- +With test methods with @slowThreshold annotations +--FILE-- + + + + . + + + diff --git a/test/Unit/phpunit.xml b/test/Unit/phpunit.xml index 1a0d4085..cdff234b 100644 --- a/test/Unit/phpunit.xml +++ b/test/Unit/phpunit.xml @@ -1,6 +1,6 @@