Make WordPress Core


Ignore:
Timestamp:
01/30/2021 03:26:59 PM (6 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.4 branch.
See #51669.

File:
1 edited

Legend:

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

    r50091 r50100  
    171171
    172172        /**
     173         * Allow tests to be skipped if the HTTP request times out.
     174         *
     175         * @param array|WP_Error $response HTTP response.
     176         */
     177        public function skipTestOnTimeout( $response ) {
     178                if ( ! is_wp_error( $response ) ) {
     179                        return;
     180                }
     181                if ( 'connect() timed out!' === $response->get_error_message() ) {
     182                        $this->markTestSkipped( 'HTTP timeout' );
     183                }
     184
     185                if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
     186                        $this->markTestSkipped( 'HTTP timeout' );
     187                }
     188
     189                if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
     190                        $this->markTestSkipped( 'HTTP timeout' );
     191                }
     192
     193        }
     194
     195        /**
    173196         * Unregister existing post types and register defaults.
    174197         *
     
    205228                        _unregister_post_status( $post_status );
    206229                }
    207         }
    208 
    209         /**
    210          * Allow tests to be skipped if the HTTP request times out.
    211          *
    212          * @param array|WP_Error $response HTTP response.
    213          */
    214         public function skipTestOnTimeout( $response ) {
    215                 if ( ! is_wp_error( $response ) ) {
    216                         return;
    217                 }
    218                 if ( 'connect() timed out!' === $response->get_error_message() ) {
    219                         $this->markTestSkipped( 'HTTP timeout' );
    220                 }
    221 
    222                 if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
    223                         $this->markTestSkipped( 'HTTP timeout' );
    224                 }
    225 
    226                 if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
    227                         $this->markTestSkipped( 'HTTP timeout' );
    228                 }
    229 
    230230        }
    231231
Note: See TracChangeset for help on using the changeset viewer.