Skip to content

Commit c0f53ac

Browse files
Tests: Move skipTestOnTimeout() to a more appropriate location, for consistency with other branches.
Follow-up to [50088]. See #51669. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@50097 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8259505 commit c0f53ac

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

tests/phpunit/includes/testcase.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,29 @@ public function skipOnAutomatedBranches() {
197197
}
198198
}
199199

200+
/**
201+
* Allow tests to be skipped if the HTTP request times out.
202+
*
203+
* @param array|WP_Error $response HTTP response.
204+
*/
205+
public function skipTestOnTimeout( $response ) {
206+
if ( ! is_wp_error( $response ) ) {
207+
return;
208+
}
209+
if ( 'connect() timed out!' === $response->get_error_message() ) {
210+
$this->markTestSkipped( 'HTTP timeout' );
211+
}
212+
213+
if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
214+
$this->markTestSkipped( 'HTTP timeout' );
215+
}
216+
217+
if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
218+
$this->markTestSkipped( 'HTTP timeout' );
219+
}
220+
221+
}
222+
200223
/**
201224
* Unregister existing post types and register defaults.
202225
*
@@ -233,29 +256,6 @@ protected function reset_post_statuses() {
233256
_unregister_post_status( $post_status );
234257
}
235258
}
236-
237-
/**
238-
* Allow tests to be skipped if the HTTP request times out.
239-
*
240-
* @param array|WP_Error $response HTTP response.
241-
*/
242-
public function skipTestOnTimeout( $response ) {
243-
if ( ! is_wp_error( $response ) ) {
244-
return;
245-
}
246-
if ( 'connect() timed out!' === $response->get_error_message() ) {
247-
$this->markTestSkipped( 'HTTP timeout' );
248-
}
249-
250-
if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {
251-
$this->markTestSkipped( 'HTTP timeout' );
252-
}
253-
254-
if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {
255-
$this->markTestSkipped( 'HTTP timeout' );
256-
}
257-
258-
}
259259

260260
/**
261261
* Reset `$_SERVER` variables

0 commit comments

Comments
 (0)