Skip to content

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

Open
wants to merge 6 commits into
base: 3.5.x
Choose a base branch
from
Open

PHPUnit 11 #12146

wants to merge 6 commits into from

Conversation

greg0ire
Copy link
Member

This upgrades to PHPUnit 11 and addresses all newly emitted deprecations.

@greg0ire greg0ire marked this pull request as draft August 20, 2025 20:06
@greg0ire

This comment was marked as resolved.

@greg0ire

This comment was marked as resolved.

@greg0ire greg0ire force-pushed the upg-phpunit branch 2 times, most recently from bbd0ad5 to 9538859 Compare August 20, 2025 20:38
@greg0ire greg0ire marked this pull request as ready for review August 20, 2025 20:38
@@ -31,6 +31,15 @@ protected function setUp(): void
PersistentObject::setObjectManager($this->_em);
}

protected function tearDown(): void
{
if (! class_exists(PersistentObject::class)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really required?

// In case test is skipped, tearDown is called, but no setup may have run
if (! $conn) {
return;
}
does already handle this case gracefully, doesn't it?

Copy link
Member Author

@greg0ire greg0ire Aug 21, 2025

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, nice find!

greg0ire and others added 6 commits August 21, 2025 13:39
self::returnValue() and self::onConsecutiveCalls() 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants