From 92ee7e12d6d55605a3fa0628ed8cdfe0092a6a8c Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 30 Jan 2021 15:26:00 +0000 Subject: [PATCH] Tests: Move `skipTestOnTimeout()` to a more appropriate location, for consistency with other branches. Follow-up to [50088]. Merges [50097] to the 4.6 branch. See #51669. git-svn-id: https://develop.svn.wordpress.org/branches/4.6@50098 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/testcase.php | 46 ++++++++++++++--------------- 1 file 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 @@ -182,6 +182,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. * @@ -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 */