Make WordPress Core


Ignore:
Timestamp:
01/30/2021 02:51:08 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Skip test_readme() if the HTTP request to secure.php.net or dev.mysql.com failed on timeout.

Move skipTestOnTimeout() to WP_UnitTestCase_Base to avoid duplication.

Merges [46682] and [46996] to the 5.0 branch.
See #51669.

Location:
branches/5.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0

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

    r41945 r50095  
    183183
    184184    /**
    185      * Allow tests to be skipped on some automated runs
     185     * Allow tests to be skipped on some automated runs.
    186186     *
    187187     * For test runs on Travis for something other than trunk/master
     
    223223            $this->markTestSkipped( 'Test does not run on Multisite' );
    224224        }
     225    }
     226
     227    /**
     228     * Allow tests to be skipped if the HTTP request times out.
     229     *
     230     * @param array|WP_Error $response HTTP response.
     231     */
     232    public function skipTestOnTimeout( $response ) {
     233        if ( ! is_wp_error( $response ) ) {
     234            return;
     235        }
     236        if ( 'connect() timed out!' === $response->get_error_message() ) {
     237            $this->markTestSkipped( 'HTTP timeout' );
     238        }
     239
     240        if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
     241            $this->markTestSkipped( 'HTTP timeout' );
     242        }
     243
     244        if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
     245            $this->markTestSkipped( 'HTTP timeout' );
     246        }
     247
    225248    }
    226249
Note: See TracChangeset for help on using the changeset viewer.