From 55a6d67a48369253afbe7e90693fb4adb2169f76 Mon Sep 17 00:00:00 2001 From: Sven Date: Thu, 15 Oct 2026 14:49:28 +0200 Subject: [PATCH] Give the PHP time limit back after every test (#89) A streaming controller's set_time_limit() outlived its test in the single PHPUnit process and killed slower runs part-way. A PHPUnit extension resets it after every test. Co-authored-by: pmdevelopment <4947485+pmdevelopment@users.noreply.github.com> --- phpunit.dist.xml | 3 ++ .../PhpUnit/ResetTimeLimitExtension.php | 47 +++++++++++++++++++ .../PhpUnit/ResetTimeLimitExtensionTest.php | 32 +++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 tests/Support/PhpUnit/ResetTimeLimitExtension.php create mode 100644 tests/Support/PhpUnit/ResetTimeLimitExtensionTest.php diff --git a/phpunit.dist.xml b/phpunit.dist.xml index f2d10a77..131df433 100644 --- a/phpunit.dist.xml +++ b/phpunit.dist.xml @@ -53,5 +53,8 @@ + + diff --git a/tests/Support/PhpUnit/ResetTimeLimitExtension.php b/tests/Support/PhpUnit/ResetTimeLimitExtension.php new file mode 100644 index 00000000..b7f308b1 --- /dev/null +++ b/tests/Support/PhpUnit/ResetTimeLimitExtension.php @@ -0,0 +1,47 @@ +registerSubscriber(new class implements FinishedSubscriber { + public function notify(Finished $event): void + { + // 0 is the CLI default: no limit. set_time_limit() also + // restarts the clock, which is what a limit somebody else set + // needs. + set_time_limit(0); + } + }); + } +} diff --git a/tests/Support/PhpUnit/ResetTimeLimitExtensionTest.php b/tests/Support/PhpUnit/ResetTimeLimitExtensionTest.php new file mode 100644 index 00000000..82243b7a --- /dev/null +++ b/tests/Support/PhpUnit/ResetTimeLimitExtensionTest.php @@ -0,0 +1,32 @@ +