Make WordPress Core


Ignore:
Timestamp:
01/30/2021 12:08:49 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use skipTestOnTimeout() in more HTTP tests.

Adjust it to handle more types of timeouts, e.g. "Resolving timed out", "Connection timed out".

Merges [38757], [43511], [43512], [46682], [46996] to the 4.4 branch.
See #51669.

Location:
branches/4.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4

  • branches/4.4/tests/phpunit/includes/testcase.php

    r40243 r50091  
    150150
    151151        /**
    152          * Allow tests to be skipped on some automated runs
     152         * Allow tests to be skipped on some automated runs.
    153153         *
    154154         * For test runs on Travis for something other than trunk/master
     
    205205                        _unregister_post_status( $post_status );
    206206                }
     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
    207230        }
    208231
Note: See TracChangeset for help on using the changeset viewer.