WordPress.org

Make WordPress Core

Opened 4 weeks ago

Last modified 4 weeks ago

#50639 new defect (bug)

[PHP 8] Add @requires annotations for PHPUnit tests that assert engine-enforced constraints

Reported by: ayeshrajans Owned by:
Milestone: 5.6 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: php8 has-patch
Focuses: Cc:

Description

PHP 8.0 throws errors when certain build-in functions encounter unexpected values.

Ref:

In current PHP 8 builds, there are few test failures on tests that are supposed to test how functions behave when they encounter unexpected values. In PHP 8, it is not necessary to have these tests because they are validated internally by the engine now.

We still need to keep these assertions for older PHP 8 versions.

  • Adds @requires PHP < 8 annotation to prevent PHPUnit from running the test on PHP 8 and higher.
  • Adds @requires extension gd to mark that the test requires gd extension. This is to prevent "jpeg support required" test failures on current PHP nightly builds. I think failing a test when the test environment does not support the extension is not appropriate and we should ideally skip that test instead. Fixing test-failures to mark tests skipped is out of this ticket.

Note that PHPUnit 7.5 will be used for PHP 8 builds. @required annotations are not supported in earlier versions such as 5.x and 6.x, which WordPress still uses for older PHP versions. For PHP 8, PHPUnit 7.5 will be used, so using @required annotations is a progressive update.

It is also acknowledged that this is an early ticket for PHP 8. Practically speaking, we are looking to target WordPress 5.6 for this ticket.

With this ticket, we change the tests from:

Tests: 10860, Assertions: 52721, Errors: 37, Failures: 20, Skipped: 97, Risky: 3.

(https://travis-ci.com/github/Ayesh/wordpress-develop/jobs/360267882#L3836)

To:

Tests: 10860, Assertions: 52679, Errors: 30, Failures: 10, Skipped: 121, Risky: 3

(https://travis-ci.com/github/Ayesh/wordpress-develop/jobs/360274089#L3808)

Attachments (1)

50639-1.patch (4.7 KB) - added by ayeshrajans 4 weeks ago.

Download all attachments as: .zip

Change History (3)

@ayeshrajans
4 weeks ago

#1 @ayeshrajans
4 weeks ago

  • Keywords has-patch added

#2 @SergeyBiryukov
4 weeks ago

  • Milestone changed from Awaiting Review to 5.6
Note: See TracTickets for help on using tickets.