-
Notifications
You must be signed in to change notification settings - Fork 2.5k
PHPUnit 11 #12146
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
base: 3.5.x
Are you sure you want to change the base?
PHPUnit 11 #12146
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
bbd0ad5
to
9538859
Compare
@@ -31,6 +31,15 @@ protected function setUp(): void | |||
PersistentObject::setObjectManager($this->_em); | |||
} | |||
|
|||
protected function tearDown(): void | |||
{ | |||
if (! class_exists(PersistentObject::class)) { |
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.
Is this really required?
orm/tests/Tests/OrmFunctionalTestCase.php
Lines 542 to 545 in 31e6a1d
// In case test is skipped, tearDown is called, but no setup may have run | |
if (! $conn) { | |
return; | |
} |
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.
Ah I didn't see this. But no, it no longer handles this gracefully when running the whole test suite, so maybe sharedConn now persists between tests.
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.
@xabbuh I debugged it, and sharedConn
is always set.
Moreover, using this code:
protected function tearDown(): void
{
try {
parent::tearDown();
} catch (\Throwable $e) {
var_dump($e->getMessage());
}
}
With PHPUnit 10
prints this:
string(41) "Call to a member function clear() on null"
So the same issue exists with both versions of PHPUnit, it's just that for some reason, PHPUnit 10 swallows the exception.
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.
I replaced the commit that introduce this change with another that acts at the OrmFunctionalTestCase
level, by also checking $this->_em
.
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.
Ah that explains it probably: sebastianbergmann/phpunit#6281
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.
Yes, nice find!
It has been deprecated.
self::returnValue() and self::onConsecutiveCalls() has been deprecated.
It has been deprecated.
It seems that this could happen with PHPUnit 10, then tearDown() would crash when calling `clear()` on null, but then PHPUnit 10 did not show that exception.
This upgrades to PHPUnit 11 and addresses all newly emitted deprecations.