Build/Test Tools: Fix comments odd/even instabilities (test leaks).

The odd / even class attribute global variables are causing issues in comments tests when a new test is added or an existing test is modified. To stabilize the odd / even comment tests, the comment global variables are added to the base test class' `tear_down()` using the same patterns as the other global resets. This change ensures each comment test starts at the same state. In doing so, the expected odd / even class attributes are no longer affected by previous tests, i.e. test leaks.

Follow-up to [53172].

Props hellofromTonya, zieladam, peterwilsoncc.
See #54725.

git-svn-id: https://develop.svn.wordpress.org/trunk@53430 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork
2022-05-23 11:54:28 +00:00
parent 2c06c9afd5
commit edf3f48e04
2 changed files with 47 additions and 12 deletions
@@ -174,6 +174,12 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
$GLOBALS[ $global ] = null;
}
// Reset comment globals.
$comment_globals = array( 'comment_alt', 'comment_depth', 'comment_thread_alt' );
foreach ( $comment_globals as $global ) {
$GLOBALS[ $global ] = null;
}
/*
* Reset $wp_sitemap global so that sitemap-related dynamic $wp->public_query_vars
* are added when the next test runs.