@@ -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