Make WordPress Core

Opened 6 months ago

Closed 6 months ago

#65203 closed enhancement (fixed)

Tests: Add unit tests for wp_check_php_version()

Reported by: pbearne Owned by: SergeyBiryukov
Priority: normal Milestone: 7.1
Component: Administration Version:
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses: tests

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 months 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 months ago

  • Milestone Awaiting Review → 7.1

#3 @SergeyBiryukov
6 months ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → 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.