Make WordPress Core

Opened 19 hours ago

Last modified 19 hours ago

#65203 new enhancement

Tests: Add unit tests for wp_check_php_version()

Reported by: pbearne's profile pbearne Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch has-unit-tests
Focuses: tests Cc:

Description

This ticket adds comprehensive unit tests for the wp_check_php_version() function in wp-admin/includes/misc.php. The tests will cover API response handling, transient caching, the wp_is_php_version_acceptable filter, and future minimum version logic (e.g., forcing warnings for PHP < 8.0).

Change History (1)

This ticket was mentioned in PR #11764 on WordPress/wordpress-develop by @pbearne.


19 hours ago
#1

  • Keywords has-patch has-unit-tests added

Description:
This PR adds unit tests for the wp_check_php_version() function in wp-admin/includes/misc.php. These tests ensure that WordPress correctly checks the active PHP version against the Serve Happy API, handles API failures gracefully, manages caching via site transients, and correctly enforces minimum version requirements.

The tests cover:

  • Handling of API failures (returning false).
  • Verification of the response structure and data on API success.
  • Verification that API results are correctly cached in site transients.
  • Verification that cached results are used in subsequent calls.
  • Verification of the wp_is_php_version_acceptable filter.
  • Verification of future minimum version logic (ensuring PHP versions below 8.0 are marked as unacceptable).

Trac ticket: https://core.trac.wordpress.org/ticket/65203

AI Disclosure:

  • AI assistance: Yes
  • Tool(s): Junie (JetBrains)
  • Model(s): gemini-3-flash-preview
  • Used for: Code analysis, test implementation, and workflow management.
Note: See TracTickets for help on using tickets.