WordPress.org

Make WordPress Core

Opened 16 months ago

Last modified 3 weeks ago

#46149 assigned task (blessed)

PHPUnit 8.x support

Reported by: SergeyBiryukov Owned by: netweb
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-patch
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Background: #43218

PHPUnit 8.0.0 is scheduled for February 2019. The changelog includes some backwards compatibility breaks.

From the PHPUnit 7 announcement (February 2, 2018):

Looking Forward

The following methods do not have a return value and should therefore have a void return type declaration:

  • PHPUnit\Framework\TestCase::setUpBeforeClass()
  • PHPUnit\Framework\TestCase::setUp()
  • PHPUnit\Framework\TestCase::assertPreConditions()
  • PHPUnit\Framework\TestCase::assertPostConditions()
  • PHPUnit\Framework\TestCase::tearDown()
  • PHPUnit\Framework\TestCase::tearDownAfterClass()
  • PHPUnit\Framework\TestCase::onNotSuccessfulTest()

These methods will have a void return type declaration in PHPUnit 8. Please declare your methods that overwrite the above mentioned methods void now so you are not affected by this backward compatibility break.

This is now implemented in PHPUnit 8, so our method signatures are no longer compatible and cause fatal errors:

Fatal error: Declaration of WP_UnitTestCase_Base::setUpBeforeClass() must be compatible with PHPUnit\Framework\TestCase::setUpBeforeClass(): void in tests/phpunit/includes/abstract-testcase.php on line 1110

We could look into using different signatures for different PHPUnit versions in the same way as in [44701]. However, given the large number of tests extending the ::setUp() and ::tearDown() methods, it's probably easier to address this when we bump the required PHP version to 7.1.

Change History (15)

#1 @desrosj
16 months ago

  • Milestone changed from Awaiting Review to Future Release
  • Type changed from defect (bug) to task (blessed)

#2 @SergeyBiryukov
16 months ago

We could also look into displaying a friendly message instead of a fatal error. Something like:

Looks like you're using PHPUnit 8.x, WordPress currently is only compatible with PHPUnit 7.x. Please use the latest PHPUnit version from the 7.x branch.

#3 @SergeyBiryukov
16 months ago

In 44723:

Build/Test Tools: Display a message about currently supported PHPUnit branch to avoid fatal errors on later versions.

See #46149.

#4 @desrosj
16 months ago

PHPUnit 8.0 and 8.0.1 have officially been released.

#5 @desrosj
16 months ago

Noticed today that the PHP nightly build is now failing from the changes in #43218. This should be fixed when the needed changes are made for this ticket.

https://travis-ci.org/WordPress/wordpress-develop/jobs/490350822

#6 @pento
16 months ago

Nightly switched from PHP 7.4 to PHP 8.0. #46235 is for adding PHP 7.4 back to the test matrix.

#7 @conner_bw
13 months ago

Please consider upgrading. I ran into this issue today trying to setup pcov:

https://github.com/krakjoe/pcov

Requires phpunit v8. Improves code coverage performance significantly.

#8 @ZanderZ
6 months ago

In February, PHPUnit 7 support will end and only PHPUnit 8 and 9 (to be released on February 7) will be supported.

The tickets says "it's probably easier to address this when we bump the required PHP version to 7."
Is there any news related to that?

#9 @davidshq
5 months ago

Also interested to hear a status update on this.

#10 @johnbillion
5 months ago

  • Keywords needs-patch added

There isn't one. If someone wants to work on this, that would be great.

#11 follow-ups: @SergeyBiryukov
5 months ago

Note that this still depends on bumping the required PHP version to 7.

As of this time, the decision has not been made yet.

#12 @netweb
5 months ago

  • Owner set to netweb
  • Status changed from new to assigned

I've partially implemented this for a client, will work on bringing those changes here

#13 in reply to: ↑ 11 @ZanderZ
3 months ago

Replying to SergeyBiryukov:

Note that this still depends on bumping the required PHP version to 7.

As of this time, the decision has not been made yet.

There has been 0 news on this front since the initial announcement. That announcement said "Depending upon feedback and effectiveness, we can follow up by bumping the required PHP version to 7 as early as December 2019." but that timeframe has clearly passed.

Can the WP team please share some news on this?

This ticket was mentioned in Slack in #core by sergey. View the logs.


4 weeks ago

#15 in reply to: ↑ 11 @SergeyBiryukov
3 weeks ago

  • Description modified (diff)

Replying to SergeyBiryukov:

Note that this still depends on bumping the required PHP version to 7.

Just to clarify, bumping the required version to PHP 7.0 is apparently not enough, as the void return type declarations only appeared in PHP 7.1. So to support PHPUnit 8.x, we'd need PHP 7.1 as the minimum required version.

Updating the ticket description accordingly.

Note: See TracTickets for help on using tickets.