Opened 6 weeks ago
Last modified 5 weeks ago
#65180 new feature request
Tests: Add unit tests for wp_reset_vars()
| Reported by: |
|
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 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 (3)
This ticket was mentioned in PR #11737 on WordPress/wordpress-develop by @pbearne.
6 weeks ago
#1
- Keywords has-patch has-unit-tests added
#2
@
5 weeks ago
Tested the patch locally and confirmed the new wp_reset_vars() tests are passing successfully.
Environment:
- WordPress: trunk
- PHP: 8.2.29
- Database: MySQL
- PHPUnit: latest Core test suite
The added coverage looks solid overall, especially around documenting the current empty() behavior for values like '0' and ''.
A few additional edge cases may be worth considering, either in this patch or a potential follow-up:
false0(integer)null- array values
Additionally, in tear_down(), previously unset globals could potentially be restored using unset() instead of assigning null, which may help preserve the original global state more accurately.
Patch tests successfully.
Description:
This PR adds unit tests for the
wp_reset_vars()function inwp-admin/includes/misc.php. These tests ensure that the function correctly resets global variables based on the values in$_POSTand$_GET, or defaults them to an empty string.The tests cover:
$_POSTwhen they are not empty.$_GETwhen they are empty in$_POST(including cases like'0'or'').$_POSTand$_GET.Trac ticket: https://core.trac.wordpress.org/ticket/65180
AI Disclosure: