Make WordPress Core


Ignore:
Timestamp:
05/23/2022 02:04:23 PM (4 years ago)
Author:
hellofromTonya
Message:

Build/Test Tools: Add tests and fix comments odd/even instabilities (test leaks).

[53353] Add unit test for Comment Template block.

[53353] 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.

Also moves the comment globals reset from the base test case to the test's tear_down(). Why? To avoid risks to extenders' tests as it's too late in the 6.0 cycle for a dev note.

Follow-up to [53298], [53172], [53138].

Props bernhard-reiter, darerodz, gziolo, hellofromTonya, zieladam, peterwilsoncc.
Merges [53353] and [53430] to the 6.0 branch.
Fixes #54725,#55643.

Location:
branches/6.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.0

  • branches/6.0/tests/phpunit/includes/abstract-testcase.php

    r53350 r53432  
    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.