diff --git a/CHANGELOG.md b/CHANGELOG.md index b7f42a79..a0d84708 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.1.0...main`][2.1.0...main]. +### Fixed + +- Stopped registering extension when running `phpunit` with the `--no-output` option ([#243]), by [@localheinz] + ## [`2.1.0`][2.1.0] For a full diff see [`2.0.0...2.1.0`][2.0.0...2.1.0]. @@ -107,5 +111,6 @@ For a full diff see [`7afa59c...1.0.0`][7afa59c...1.0.0]. [#221]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/221 [#222]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/222 [#224]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/224 +[#243]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/243 [@localheinz]: https://github.com/localheinz diff --git a/src/Extension.php b/src/Extension.php index 3dce51e4..9e125929 100644 --- a/src/Extension.php +++ b/src/Extension.php @@ -23,6 +23,10 @@ public function bootstrap( Runner\Extension\Facade $facade, Runner\Extension\ParameterCollection $parameters, ): void { + if ($configuration->noOutput()) { + return; + } + $maximumCount = MaximumCount::fromInt(10); if ($parameters->has('maximum-count')) { diff --git a/test/EndToEnd/NoOutput/SleeperTest.php b/test/EndToEnd/NoOutput/SleeperTest.php new file mode 100644 index 00000000..b0fa3ad9 --- /dev/null +++ b/test/EndToEnd/NoOutput/SleeperTest.php @@ -0,0 +1,90 @@ +sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + public function testSleeperSleepsJustBelowDefaultMaximumDuration(): void + { + $milliseconds = 400; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->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()); + } + + /** + * @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(): \Generator + { + $values = \range( + 700, + 1600, + 100, + ); + + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } + } +} diff --git a/test/EndToEnd/NoOutput/phpunit.xml b/test/EndToEnd/NoOutput/phpunit.xml new file mode 100644 index 00000000..d4aee73a --- /dev/null +++ b/test/EndToEnd/NoOutput/phpunit.xml @@ -0,0 +1,32 @@ + + + + + + + . + + + diff --git a/test/EndToEnd/NoOutput/test.phpt b/test/EndToEnd/NoOutput/test.phpt new file mode 100644 index 00000000..80e87a04 --- /dev/null +++ b/test/EndToEnd/NoOutput/test.phpt @@ -0,0 +1,18 @@ +--TEST-- +With default configuration of extension +--FILE-- +run($_SERVER['argv']); +--EXPECTF--