WordPress.org

Make WordPress Core

Changeset 50097


Ignore:
Timestamp:
01/30/2021 03:21:27 PM (8 months ago)
Author:
SergeyBiryukov
Message:

Tests: Move skipTestOnTimeout() to a more appropriate location, for consistency with other branches.

Follow-up to [50088].

See #51669.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7/tests/phpunit/includes/testcase.php

    r50088 r50097  
    199199
    200200    /**
     201     * Allow tests to be skipped if the HTTP request times out.
     202     *
     203     * @param array|WP_Error $response HTTP response.
     204     */
     205    public function skipTestOnTimeout( $response ) {
     206        if ( ! is_wp_error( $response ) ) {
     207            return;
     208        }
     209        if ( 'connect() timed out!' === $response->get_error_message() ) {
     210            $this->markTestSkipped( 'HTTP timeout' );
     211        }
     212
     213        if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
     214            $this->markTestSkipped( 'HTTP timeout' );
     215        }
     216
     217        if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
     218            $this->markTestSkipped( 'HTTP timeout' );
     219        }
     220
     221    }
     222
     223    /**
    201224     * Unregister existing post types and register defaults.
    202225     *
     
    233256            _unregister_post_status( $post_status );
    234257        }
    235     }
    236 
    237     /**
    238      * Allow tests to be skipped if the HTTP request times out.
    239      *
    240      * @param array|WP_Error $response HTTP response.
    241      */
    242     public function skipTestOnTimeout( $response ) {
    243         if ( ! is_wp_error( $response ) ) {
    244             return;
    245         }
    246         if ( 'connect() timed out!' === $response->get_error_message() ) {
    247             $this->markTestSkipped( 'HTTP timeout' );
    248         }
    249 
    250         if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
    251             $this->markTestSkipped( 'HTTP timeout' );
    252         }
    253 
    254         if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
    255             $this->markTestSkipped( 'HTTP timeout' );
    256         }
    257 
    258258    }
    259259
Note: See TracChangeset for help on using the changeset viewer.