Make WordPress Core


Ignore:
Timestamp:
01/30/2021 01:05:57 PM (3 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.1 branch.
See #51669.

Location:
branches/5.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.1

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

    r44719 r50094  
    173173
    174174    /**
    175      * Allow tests to be skipped on some automated runs
     175     * Allow tests to be skipped on some automated runs.
    176176     *
    177177     * For test runs on Travis for something other than trunk/master
     
    213213            $this->markTestSkipped( 'Test does not run on Multisite' );
    214214        }
     215    }
     216
     217    /**
     218     * Allow tests to be skipped if the HTTP request times out.
     219     *
     220     * @param array|WP_Error $response HTTP response.
     221     */
     222    public function skipTestOnTimeout( $response ) {
     223        if ( ! is_wp_error( $response ) ) {
     224            return;
     225        }
     226        if ( 'connect() timed out!' === $response->get_error_message() ) {
     227            $this->markTestSkipped( 'HTTP timeout' );
     228        }
     229
     230        if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
     231            $this->markTestSkipped( 'HTTP timeout' );
     232        }
     233
     234        if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
     235            $this->markTestSkipped( 'HTTP timeout' );
     236        }
     237
    215238    }
    216239
Note: See TracChangeset for help on using the changeset viewer.