Make WordPress Core

Changeset 54723


Ignore:
Timestamp:
10/30/2022 02:52:04 AM (20 months ago)
Author:
SergeyBiryukov
Message:

Tests: Correctly restore the wp_installing() status in Ajax tests.

In the tests for updating a plugin or theme via Ajax, wp_installing( true ) was called to prevent wp_update_plugins() or wp_update_themes() from running.

Since the subsequent wp_installing( false ) call was in the same try { ... } block, it could not be executed if an exception was thrown, affecting other tests.

In this case, after rearranging the Ajax tests in [54722], this started affecting the get_site_option() calls in the tests for wp_ajax_wp_compression_test().

By moving both wp_installing() calls out of the try/catch block, we can ensure the status is correctly restored.

Follow-up to [734/tests], [37150], [38168], [38710], [54722].

See #56793.

Location:
trunk/tests/phpunit/tests/ajax
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ajax/wpAjaxUpdatePlugin.php

    r54722 r54723  
    142142        $_POST['slug']        = 'hello-dolly';
    143143
     144        // Prevent wp_update_plugins() from running.
     145        wp_installing( true );
     146
    144147        // Make the request.
    145148        try {
    146             // Prevent wp_update_plugins() from running.
    147             wp_installing( true );
    148149            $this->_handleAjax( 'update-plugin' );
    149             wp_installing( false );
    150150        } catch ( WPAjaxDieContinueException $e ) {
    151151            unset( $e );
    152152        }
     153
     154        wp_installing( false );
    153155
    154156        // Get the response.
  • trunk/tests/phpunit/tests/ajax/wpAjaxUpdateTheme.php

    r54722 r54723  
    113113        $_POST['slug']        = 'twentyten';
    114114
     115        // Prevent wp_update_themes() from running.
     116        wp_installing( true );
     117
    115118        // Make the request.
    116119        try {
    117 
    118             // Prevent wp_update_themes() from running.
    119             wp_installing( true );
    120120            $this->_handleAjax( 'update-theme' );
    121             wp_installing( false );
    122 
    123121        } catch ( WPAjaxDieContinueException $e ) {
    124122            unset( $e );
    125123        }
     124
     125        wp_installing( false );
    126126
    127127        // Get the response.
Note: See TracChangeset for help on using the changeset viewer.