Make WordPress Core


Ignore:
Timestamp:
11/09/2019 03:36:19 AM (5 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.

See #44613.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r46612 r46682  
    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
     
    221221            $this->markTestSkipped( 'Test does not run on Multisite' );
    222222        }
     223    }
     224
     225    /**
     226     * Allow tests to be skipped if the HTTP request times out.
     227     *
     228     * @param array|WP_Error $response HTTP response.
     229     */
     230    public function skipTestOnTimeout( $response ) {
     231        if ( ! is_wp_error( $response ) ) {
     232            return;
     233        }
     234        if ( 'connect() timed out!' === $response->get_error_message() ) {
     235            $this->markTestSkipped( 'HTTP timeout' );
     236        }
     237
     238        if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
     239            $this->markTestSkipped( 'HTTP timeout' );
     240        }
     241
     242        if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
     243            $this->markTestSkipped( 'HTTP timeout' );
     244        }
     245
    223246    }
    224247
Note: See TracChangeset for help on using the changeset viewer.