From d8e0be7bed198ea56770d6bfad7568ac3d351e05 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sat, 10 Aug 2024 07:29:03 +0200 Subject: [PATCH 1/2] Suppress deprecation (using trigger_error() with E_USER_ERROR is deprecated in PHP 8.4) --- tests/unit/Framework/TestCaseTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Framework/TestCaseTest.php b/tests/unit/Framework/TestCaseTest.php index 615096aace1..26f626103f2 100644 --- a/tests/unit/Framework/TestCaseTest.php +++ b/tests/unit/Framework/TestCaseTest.php @@ -1253,7 +1253,7 @@ public function testErrorCanBeExpected(): void $this->expectErrorMessage('foo'); $this->expectErrorMessageMatches('/foo/'); - trigger_error('foo', E_USER_ERROR); + @trigger_error('foo', E_USER_ERROR); } /** From 131d7f4ad5301b970b80fc830dccee834ca14198 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sat, 10 Aug 2024 07:41:07 +0200 Subject: [PATCH 2/2] Split test into one version for PHP < 8.4 and one version for PHP >= 8.4 (using trigger_error() with E_USER_ERROR is deprecated in PHP 8.4) --- tests/end-to-end/event/user-error-php-84.phpt | 57 +++++++++++++++++++ tests/end-to-end/event/user-error.phpt | 5 ++ 2 files changed, 62 insertions(+) create mode 100644 tests/end-to-end/event/user-error-php-84.phpt diff --git a/tests/end-to-end/event/user-error-php-84.phpt b/tests/end-to-end/event/user-error-php-84.phpt new file mode 100644 index 00000000000..46ca61c9b1f --- /dev/null +++ b/tests/end-to-end/event/user-error-php-84.phpt @@ -0,0 +1,57 @@ +--TEST-- +The right events are emitted in the right order for a test that runs code which triggers E_USER_ERROR +--SKIPIF-- +run($_SERVER['argv']); + +print file_get_contents($traceFile); + +unlink($traceFile); +--EXPECTF-- +PHPUnit Started (PHPUnit %s using %s) +Test Runner Configured +Test Suite Loaded (2 tests) +Event Facade Sealed +Test Runner Started +Test Suite Sorted +Test Runner Execution Started (2 tests) +Test Suite Started (PHPUnit\TestFixture\Event\UserErrorTest, 2 tests) +Test Preparation Started (PHPUnit\TestFixture\Event\UserErrorTest::testUserError) +Test Prepared (PHPUnit\TestFixture\Event\UserErrorTest::testUserError) +Assertion Succeeded (Constraint: is true, Value: true) +Test Triggered PHP Deprecation (PHPUnit\TestFixture\Event\UserErrorTest::testUserError) +Passing E_USER_ERROR to trigger_error() is deprecated since 8.4, throw an exception or call exit with a string message instead +Test Triggered Error (PHPUnit\TestFixture\Event\UserErrorTest::testUserError) +message +Test Errored (PHPUnit\TestFixture\Event\UserErrorTest::testUserError) +E_USER_ERROR was triggered +Test Finished (PHPUnit\TestFixture\Event\UserErrorTest::testUserError) +Test Preparation Started (PHPUnit\TestFixture\Event\UserErrorTest::testUserErrorMustAbortExecution) +Test Prepared (PHPUnit\TestFixture\Event\UserErrorTest::testUserErrorMustAbortExecution) +Test Triggered PHP Deprecation (PHPUnit\TestFixture\Event\UserErrorTest::testUserErrorMustAbortExecution) +Passing E_USER_ERROR to trigger_error() is deprecated since 8.4, throw an exception or call exit with a string message instead +Test Triggered Error (PHPUnit\TestFixture\Event\UserErrorTest::testUserErrorMustAbortExecution) +message +Test Errored (PHPUnit\TestFixture\Event\UserErrorTest::testUserErrorMustAbortExecution) +E_USER_ERROR was triggered +Test Finished (PHPUnit\TestFixture\Event\UserErrorTest::testUserErrorMustAbortExecution) +Test Suite Finished (PHPUnit\TestFixture\Event\UserErrorTest, 2 tests) +Test Runner Execution Finished +Test Runner Finished +PHPUnit Finished (Shell Exit Code: 2) diff --git a/tests/end-to-end/event/user-error.phpt b/tests/end-to-end/event/user-error.phpt index b379ae7678d..01f65fffd94 100644 --- a/tests/end-to-end/event/user-error.phpt +++ b/tests/end-to-end/event/user-error.phpt @@ -1,5 +1,10 @@ --TEST-- The right events are emitted in the right order for a test that runs code which triggers E_USER_ERROR +--SKIPIF-- +