Make WordPress Core


Ignore:
Timestamp:
01/30/2021 12:55:05 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.3 branch.
See #51669.

Location:
branches/5.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.3

  • branches/5.3/tests/phpunit/includes/abstract-testcase.php

    r47125 r50092  
    181181
    182182    /**
    183      * Allow tests to be skipped on some automated runs
     183     * Allow tests to be skipped on some automated runs.
    184184     *
    185185     * For test runs on Travis for something other than trunk/master
     
    220220            $this->markTestSkipped( 'Test does not run on Multisite' );
    221221        }
     222    }
     223
     224    /**
     225     * Allow tests to be skipped if the HTTP request times out.
     226     *
     227     * @param array|WP_Error $response HTTP response.
     228     */
     229    public function skipTestOnTimeout( $response ) {
     230        if ( ! is_wp_error( $response ) ) {
     231            return;
     232        }
     233        if ( 'connect() timed out!' === $response->get_error_message() ) {
     234            $this->markTestSkipped( 'HTTP timeout' );
     235        }
     236
     237        if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
     238            $this->markTestSkipped( 'HTTP timeout' );
     239        }
     240
     241        if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
     242            $this->markTestSkipped( 'HTTP timeout' );
     243        }
     244
    222245    }
    223246
Note: See TracChangeset for help on using the changeset viewer.