Opened 4 months ago
Last modified 4 months ago
#65180 new feature request
Tests: Add unit tests for wp_reset_vars()
| Reported by: | pbearne | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Administration | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: | tests |
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.
4 months ago
#1
- Keywords has-patch has-unit-tests added
#2
@
4 months 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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: