Make WordPress Core


Ignore:
Timestamp:
01/30/2021 01:02:18 PM (6 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.2 branch.
See #51669.

Location:
branches/5.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.2

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

    r44966 r50093  
    190190
    191191        /**
    192          * Allow tests to be skipped on some automated runs
     192         * Allow tests to be skipped on some automated runs.
    193193         *
    194194         * For test runs on Travis for something other than trunk/master
    … …  
    230230                        $this->markTestSkipped( 'Test does not run on Multisite' );
    231231                }
     232        }
     233
     234        /**
     235         * Allow tests to be skipped if the HTTP request times out.
     236         *
     237         * @param array|WP_Error $response HTTP response.
     238         */
     239        public function skipTestOnTimeout( $response ) {
     240                if ( ! is_wp_error( $response ) ) {
     241                        return;
     242                }
     243                if ( 'connect() timed out!' === $response->get_error_message() ) {
     244                        $this->markTestSkipped( 'HTTP timeout' );
     245                }
     246
     247                if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
     248                        $this->markTestSkipped( 'HTTP timeout' );
     249                }
     250
     251                if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
     252                        $this->markTestSkipped( 'HTTP timeout' );
     253                }
     254
    232255        }
    233256
Note: See TracChangeset for help on using the changeset viewer.