@@ -28,7 +28,7 @@ function skipTestOnTimeout( $response ) {
2828 $ this ->markTestSkipped ( 'HTTP timeout ' );
2929 }
3030
31- if ( 0 === strpos ( $ response ->get_error_message (), 'Operation timed out after ' ) ){
31+ if ( false !== strpos ( $ response ->get_error_message (), 'timed out after ' ) ) {
3232 $ this ->markTestSkipped ( 'HTTP timeout ' );
3333 }
3434
@@ -73,13 +73,17 @@ function filter_http_request_args( array $args ) {
7373 function test_redirect_on_301 () {
7474 // 5 : 5 & 301
7575 $ res = wp_remote_request ($ this ->redirection_script . '?code=301&rt= ' . 5 , array ('redirection ' => 5 ) );
76+
77+ $ this ->skipTestOnTimeout ( $ res );
7678 $ this ->assertNotWPError ( $ res );
7779 $ this ->assertEquals (200 , (int )$ res ['response ' ]['code ' ] );
7880 }
7981
8082 function test_redirect_on_302 () {
8183 // 5 : 5 & 302
8284 $ res = wp_remote_request ($ this ->redirection_script . '?code=302&rt= ' . 5 , array ('redirection ' => 5 ) );
85+
86+ $ this ->skipTestOnTimeout ( $ res );
8387 $ this ->assertNotWPError ( $ res );
8488 $ this ->assertEquals (200 , (int )$ res ['response ' ]['code ' ] );
8589 }
@@ -90,6 +94,8 @@ function test_redirect_on_302() {
9094 function test_redirect_on_301_no_redirect () {
9195 // 5 > 0 & 301
9296 $ res = wp_remote_request ($ this ->redirection_script . '?code=301&rt= ' . 5 , array ('redirection ' => 0 ) );
97+
98+ $ this ->skipTestOnTimeout ( $ res );
9399 $ this ->assertNotWPError ( $ res );
94100 $ this ->assertEquals (301 , (int )$ res ['response ' ]['code ' ] );
95101 }
@@ -100,20 +106,26 @@ function test_redirect_on_301_no_redirect() {
100106 function test_redirect_on_302_no_redirect () {
101107 // 5 > 0 & 302
102108 $ res = wp_remote_request ($ this ->redirection_script . '?code=302&rt= ' . 5 , array ('redirection ' => 0 ) );
109+
110+ $ this ->skipTestOnTimeout ( $ res );
103111 $ this ->assertNotWPError ( $ res );
104112 $ this ->assertEquals (302 , (int )$ res ['response ' ]['code ' ] );
105113 }
106114
107115 function test_redirections_equal () {
108116 // 5 - 5
109117 $ res = wp_remote_request ($ this ->redirection_script . '?rt= ' . 5 , array ('redirection ' => 5 ) );
118+
119+ $ this ->skipTestOnTimeout ( $ res );
110120 $ this ->assertNotWPError ( $ res );
111121 $ this ->assertEquals (200 , (int )$ res ['response ' ]['code ' ] );
112122 }
113123
114124 function test_no_head_redirections () {
115125 // No redirections on HEAD request:
116126 $ res = wp_remote_request ($ this ->redirection_script . '?code=302&rt= ' . 1 , array ('method ' => 'HEAD ' ) );
127+
128+ $ this ->skipTestOnTimeout ( $ res );
117129 $ this ->assertNotWPError ( $ res );
118130 $ this ->assertEquals ( 302 , (int )$ res ['response ' ]['code ' ] );
119131 }
@@ -124,25 +136,33 @@ function test_no_head_redirections() {
124136 function test_redirect_on_head () {
125137 // Redirections on HEAD request when Requested
126138 $ res = wp_remote_request ($ this ->redirection_script . '?rt= ' . 5 , array ('redirection ' => 5 , 'method ' => 'HEAD ' ) );
139+
140+ $ this ->skipTestOnTimeout ( $ res );
127141 $ this ->assertNotWPError ( $ res );
128142 $ this ->assertEquals ( 200 , (int )$ res ['response ' ]['code ' ] );
129143 }
130144
131145 function test_redirections_greater () {
132146 // 10 > 5
133147 $ res = wp_remote_request ($ this ->redirection_script . '?rt= ' . 10 , array ('redirection ' => 5 ) );
148+
149+ $ this ->skipTestOnTimeout ( $ res );
134150 $ this ->assertWPError ( $ res );
135151 }
136152
137153 function test_redirections_greater_edgecase () {
138154 // 6 > 5 (close edgecase)
139155 $ res = wp_remote_request ($ this ->redirection_script . '?rt= ' . 6 , array ('redirection ' => 5 ) );
156+
157+ $ this ->skipTestOnTimeout ( $ res );
140158 $ this ->assertWPError ( $ res );
141159 }
142160
143161 function test_redirections_less_edgecase () {
144162 // 4 < 5 (close edgecase)
145163 $ res = wp_remote_request ($ this ->redirection_script . '?rt= ' . 4 , array ('redirection ' => 5 ) );
164+
165+ $ this ->skipTestOnTimeout ( $ res );
146166 $ this ->assertNotWPError ( $ res );
147167 }
148168
@@ -152,6 +172,8 @@ function test_redirections_less_edgecase() {
152172 function test_redirections_zero_redirections_specified () {
153173 // 0 redirections asked for, Should return the document?
154174 $ res = wp_remote_request ($ this ->redirection_script . '?code=302&rt= ' . 5 , array ('redirection ' => 0 ) );
175+
176+ $ this ->skipTestOnTimeout ( $ res );
155177 $ this ->assertNotWPError ( $ res );
156178 $ this ->assertEquals ( 302 , (int )$ res ['response ' ]['code ' ] );
157179 }
@@ -164,6 +186,8 @@ function test_redirections_zero_redirections_specified() {
164186 function test_location_header_on_201 () {
165187 // Prints PASS on initial load, FAIL if the client follows the specified redirection
166188 $ res = wp_remote_request ( $ this ->redirection_script . '?201-location=true ' );
189+
190+ $ this ->skipTestOnTimeout ( $ res );
167191 $ this ->assertNotWPError ( $ res );
168192 $ this ->assertEquals ( 'PASS ' , $ res ['body ' ]);
169193 }
@@ -178,6 +202,8 @@ function test_no_redirection_on_PUT() {
178202
179203 // Test 301 - POST to POST
180204 $ res = wp_remote_request ( $ url , array ( 'method ' => 'PUT ' , 'timeout ' => 30 ) );
205+
206+ $ this ->skipTestOnTimeout ( $ res );
181207 $ this ->assertEquals ( 'PASS ' , wp_remote_retrieve_body ( $ res ) );
182208 $ this ->assertTrue ( !empty ( $ res ['headers ' ]['location ' ] ) );
183209 }
@@ -190,6 +216,7 @@ function test_send_headers() {
190216 $ headers = array ('test1 ' => 'test ' , 'test2 ' => 0 , 'test3 ' => '' );
191217 $ res = wp_remote_request ( $ this ->redirection_script . '?header-check ' , array ('headers ' => $ headers ) );
192218
219+ $ this ->skipTestOnTimeout ( $ res );
193220 $ this ->assertNotWPError ( $ res );
194221
195222 $ headers = array ();
@@ -220,7 +247,6 @@ function test_file_stream() {
220247 }
221248
222249 $ this ->skipTestOnTimeout ( $ res );
223-
224250 $ this ->assertNotWPError ( $ res );
225251 $ this ->assertEquals ( '' , $ res ['body ' ] ); // The body should be empty.
226252 $ this ->assertEquals ( $ size , $ res ['headers ' ]['content-length ' ] ); // Check the headers are returned (and the size is the same..)
@@ -243,7 +269,6 @@ function test_file_stream_limited_size() {
243269 }
244270
245271 $ this ->skipTestOnTimeout ( $ res );
246-
247272 $ this ->assertNotWPError ( $ res );
248273 $ this ->assertEquals ( $ size , $ filesize ); // Check that the file is written to disk correctly without any extra characters
249274
@@ -261,7 +286,6 @@ function test_request_limited_size() {
261286 $ res = wp_remote_request ( $ url , array ( 'timeout ' => 30 , 'limit_response_size ' => $ size ) );
262287
263288 $ this ->skipTestOnTimeout ( $ res );
264-
265289 $ this ->assertNotWPError ( $ res );
266290 $ this ->assertEquals ( $ size , strlen ( $ res ['body ' ] ) );
267291 }
@@ -277,6 +301,8 @@ function test_post_redirect_to_method_300( $response_code, $method ) {
277301 $ url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?post-redirect-to-method=1 ' ;
278302
279303 $ res = wp_remote_post ( add_query_arg ( 'response_code ' , $ response_code , $ url ), array ( 'timeout ' => 30 ) );
304+
305+ $ this ->skipTestOnTimeout ( $ res );
280306 $ this ->assertEquals ( $ method , wp_remote_retrieve_body ( $ res ) );
281307 }
282308
@@ -322,6 +348,8 @@ function test_ip_url_with_host_header() {
322348 );
323349
324350 $ res = wp_remote_get ( $ url , $ args );
351+
352+ $ this ->skipTestOnTimeout ( $ res );
325353 $ this ->assertEquals ( 'PASS ' , wp_remote_retrieve_body ( $ res ) );
326354
327355 }
@@ -343,6 +371,7 @@ function test_https_url_without_ssl_verification() {
343371
344372 remove_filter ( 'http_request_args ' , array ( $ this , 'filter_http_request_args ' ) );
345373
374+ $ this ->skipTestOnTimeout ( $ res );
346375 $ this ->assertNotEmpty ( $ this ->http_request_args ['sslcertificates ' ] );
347376 $ this ->assertNotWPError ( $ res );
348377 }
@@ -356,10 +385,13 @@ function test_multiple_location_headers() {
356385 $ url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?multiple-location-headers=1 ' ;
357386 $ res = wp_remote_head ( $ url , array ( 'timeout ' => 30 ) );
358387
388+ $ this ->skipTestOnTimeout ( $ res );
359389 $ this ->assertInternalType ( 'array ' , wp_remote_retrieve_header ( $ res , 'location ' ) );
360390 $ this ->assertCount ( 2 , wp_remote_retrieve_header ( $ res , 'location ' ) );
361391
362392 $ res = wp_remote_get ( $ url , array ( 'timeout ' => 30 ) );
393+
394+ $ this ->skipTestOnTimeout ( $ res );
363395 $ this ->assertEquals ( 'PASS ' , wp_remote_retrieve_body ( $ res ) );
364396
365397 }
@@ -373,6 +405,8 @@ function test_cookie_handling() {
373405 $ url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?cookie-test=1 ' ;
374406
375407 $ res = wp_remote_get ( $ url );
408+
409+ $ this ->skipTestOnTimeout ( $ res );
376410 $ this ->assertEquals ( 'PASS ' , wp_remote_retrieve_body ( $ res ) );
377411 }
378412
@@ -387,6 +421,8 @@ function test_ssl() {
387421 $ this ->fail ( 'This installation of PHP does not support SSL ' );
388422
389423 $ res = wp_remote_get ( 'https://wordpress.org/ ' );
424+
425+ $ this ->skipTestOnTimeout ( $ res );
390426 $ this ->assertNotWPError ( $ res );
391427 }
392428
@@ -400,6 +436,8 @@ function test_url_with_double_slashes_path() {
400436 $ url = str_replace ( $ path , '/ ' . $ path , $ url );
401437
402438 $ res = wp_remote_request ( $ url );
439+
440+ $ this ->skipTestOnTimeout ( $ res );
403441 $ this ->assertNotWPError ( $ res );
404442 }
405443
0 commit comments