Make WordPress Core


Ignore:
Timestamp:
05/23/2022 11:54:28 AM (3 years ago)
Author:
hellofromTonya
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r53349 r53430  
    172172        $current_screen_globals = array( 'current_screen', 'taxnow', 'typenow' );
    173173        foreach ( $current_screen_globals as $global ) {
     174            $GLOBALS[ $global ] = null;
     175        }
     176
     177        // Reset comment globals.
     178        $comment_globals = array( 'comment_alt', 'comment_depth', 'comment_thread_alt' );
     179        foreach ( $comment_globals as $global ) {
    174180            $GLOBALS[ $global ] = null;
    175181        }
Note: See TracChangeset for help on using the changeset viewer.