Skip to content
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

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Dec 15, 2024

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:

Color legend:
- patch or minor release available - update recommended
- major release available - update possible

Direct dependencies required in composer.json:
Everything up to date

Transitive dependencies not required in composer.json:
phpstan/phpdoc-parser 1.33.0 2.0.0 PHPDoc parser with support for nullable, intersection and generic types

@greg0ire greg0ire added the test suite Improvements to the test suite label Dec 15, 2024
We never call these methods since 5653e3f.
composer.json Outdated Show resolved Hide resolved
@@ -99,6 +80,7 @@ public function testDeprecation(): void
);

$this->assertEquals(2, Deprecation::getUniqueTriggeredDeprecationsCount());
restore_error_handler();
Copy link
Member

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();
Copy link
Member

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?

Copy link
Member Author

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.

@greg0ire greg0ire dismissed derrabus’s stale review December 20, 2024 07:18

The review has been addressed.

@greg0ire greg0ire merged commit 7014f6c into doctrine:1.1.x Dec 20, 2024
3 checks passed
@greg0ire greg0ire deleted the phpunit-11 branch December 20, 2024 07:18
@greg0ire greg0ire added this to the 1.1.5 milestone Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test suite Improvements to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants