Make WordPress Core

Opened 6 weeks ago

Closed 6 weeks ago

#65203 closed enhancement (fixed)

Tests: Add unit tests for wp_check_php_version()

Reported by: pbearne's profile pbearne Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 7.1 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 (3)

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


6 weeks 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.

#2 @SergeyBiryukov
6 weeks ago

  • Milestone changed from Awaiting Review to 7.1

#3 @SergeyBiryukov
6 weeks ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 62343:

Tests: Add unit tests for wp_check_php_version().

Follow-up to [44735].

Props pbearne.
Fixes #65203.

Note: See TracTickets for help on using tickets.