Make WordPress Core

Opened 13 hours ago

Last modified 13 hours ago

#65180 new feature request

Tests: Add unit tests for wp_reset_vars()

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: Cc:

Description

This ticket adds unit tests for the wp_reset_vars() function in wp-admin/includes/misc.php. This function resets global variables based on $_GET and $_POST values.

Change History (1)

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


13 hours ago
#1

  • Keywords has-patch has-unit-tests added

Description:
This PR adds unit tests for the wp_reset_vars() function in wp-admin/includes/misc.php. These tests ensure that the function correctly resets global variables based on the values in $_POST and $_GET, or defaults them to an empty string.

The tests cover:

  • Resetting variables from $_POST when they are not empty.
  • Resetting variables from $_GET when they are empty in $_POST (including cases like '0' or '').
  • Defaulting variables to an empty string when they are missing from both $_POST and $_GET.
  • Handling multiple variables simultaneously.

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

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.