-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow running tests with PHPUnit 10 and 11 #74
Conversation
We never call these methods since 5653e3f.
tests/DeprecationTest.php
Outdated
@@ -99,6 +80,7 @@ public function testDeprecation(): void | |||
); | |||
|
|||
$this->assertEquals(2, Deprecation::getUniqueTriggeredDeprecationsCount()); | |||
restore_error_handler(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't restore the error handler if the test fails. We should wrap everything that runs with a custom error handler into a try/finally block.
PHPUnit 11 emits complaints about the error handlers not being removed, which is risky, so I had to add a few calls to restore_error_handler(). This leaves us with PHPUnit deprecations about using @before and @after rather than the corresponding attributes. I do not think those can be addressed without a breaking change (adding the attributes is not enough, you have to remove the annotations).
$this->assertEquals(1, Deprecation::getUniqueTriggeredDeprecationsCount()); | ||
$this->assertEquals(1, Deprecation::getUniqueTriggeredDeprecationsCount()); | ||
} finally { | ||
restore_error_handler(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't tearDown()
be used in this test class just like in tests/VerifyDeprecationsTest.php
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could, but this is safer: if for some reason something fails before we get to set the error handler, it's better not to restore it.
PHPUnit 11 emits complaints about the error handlers not being removed, which is risky, so I had to add a few calls to
restore_error_handler()
.This leaves us with PHPUnit deprecations about using @before and @after rather than the corresponding attributes. I do not think those can be addressed without a breaking change (adding the attributes is not enough, you have to remove the annotations).
After this MR is merged,
composer outdated
is almost empty: