Make WordPress Core


Ignore:
Timestamp:
01/30/2021 03:26:00 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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

Follow-up to [50088].

Merges [50097] to the 4.6 branch.
See #51669.

File:
1 edited

Legend:

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

    r50089 r50098  
    184184
    185185    /**
     186     * Allow tests to be skipped if the HTTP request times out.
     187     *
     188     * @param array|WP_Error $response HTTP response.
     189     */
     190    public function skipTestOnTimeout( $response ) {
     191        if ( ! is_wp_error( $response ) ) {
     192            return;
     193        }
     194        if ( 'connect() timed out!' === $response->get_error_message() ) {
     195            $this->markTestSkipped( 'HTTP timeout' );
     196        }
     197
     198        if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
     199            $this->markTestSkipped( 'HTTP timeout' );
     200        }
     201
     202        if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
     203            $this->markTestSkipped( 'HTTP timeout' );
     204        }
     205
     206    }
     207
     208    /**
    186209     * Unregister existing post types and register defaults.
    187210     *
     
    218241            _unregister_post_status( $post_status );
    219242        }
    220     }
    221 
    222     /**
    223      * Allow tests to be skipped if the HTTP request times out.
    224      *
    225      * @param array|WP_Error $response HTTP response.
    226      */
    227     public function skipTestOnTimeout( $response ) {
    228         if ( ! is_wp_error( $response ) ) {
    229             return;
    230         }
    231         if ( 'connect() timed out!' === $response->get_error_message() ) {
    232             $this->markTestSkipped( 'HTTP timeout' );
    233         }
    234 
    235         if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
    236             $this->markTestSkipped( 'HTTP timeout' );
    237         }
    238 
    239         if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
    240             $this->markTestSkipped( 'HTTP timeout' );
    241         }
    242 
    243243    }
    244244
Note: See TracChangeset for help on using the changeset viewer.