diff options
-rw-r--r-- | tests/phpunit/includes/testcase.php | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index b2ad19df9a..1bee6b168c 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -183,6 +183,29 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { } /** + * Allow tests to be skipped if the HTTP request times out. + * + * @param array|WP_Error $response HTTP response. + */ + public function skipTestOnTimeout( $response ) { + if ( ! is_wp_error( $response ) ) { + return; + } + if ( 'connect() timed out!' === $response->get_error_message() ) { + $this->markTestSkipped( 'HTTP timeout' ); + } + + if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) { + $this->markTestSkipped( 'HTTP timeout' ); + } + + if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) { + $this->markTestSkipped( 'HTTP timeout' ); + } + + } + + /** * Unregister existing post types and register defaults. * * Run before each test in order to clean up the global scope, in case @@ -219,29 +242,6 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase { }
}
- /**
- * Allow tests to be skipped if the HTTP request times out.
- *
- * @param array|WP_Error $response HTTP response.
- */
- public function skipTestOnTimeout( $response ) {
- if ( ! is_wp_error( $response ) ) {
- return;
- }
- if ( 'connect() timed out!' === $response->get_error_message() ) {
- $this->markTestSkipped( 'HTTP timeout' );
- }
-
- if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
- $this->markTestSkipped( 'HTTP timeout' );
- }
-
- if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
- $this->markTestSkipped( 'HTTP timeout' );
- }
-
- }
-
/** * Reset `$_SERVER` variables */ |