Changeset 59729 for trunk/tests/phpunit/tests/http/base.php
- Timestamp:
- 01/29/2025 06:17:34 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/http/base.php
r58108 r59729 45 45 public function test_redirect_on_301() { 46 46 // 5 : 5 & 301. 47 $res = wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 5 ) ); 48 49 $this->skipTestOnTimeout( $res ); 47 $res = $this->wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 5 ) ); 48 50 49 $this->assertNotWPError( $res ); 51 50 $this->assertSame( 200, (int) $res['response']['code'] ); … … 57 56 public function test_redirect_on_302() { 58 57 // 5 : 5 & 302. 59 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 5 ) ); 60 61 $this->skipTestOnTimeout( $res ); 58 $res = $this->wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 5 ) ); 59 62 60 $this->assertNotWPError( $res ); 63 61 $this->assertSame( 200, (int) $res['response']['code'] ); … … 71 69 public function test_redirect_on_301_no_redirect() { 72 70 // 5 > 0 & 301. 73 $res = wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 0 ) ); 74 75 $this->skipTestOnTimeout( $res ); 71 $res = $this->wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 0 ) ); 72 76 73 $this->assertNotWPError( $res ); 77 74 $this->assertSame( 301, (int) $res['response']['code'] ); … … 85 82 public function test_redirect_on_302_no_redirect() { 86 83 // 5 > 0 & 302. 87 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) ); 88 89 $this->skipTestOnTimeout( $res ); 84 $res = $this->wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) ); 85 90 86 $this->assertNotWPError( $res ); 91 87 $this->assertSame( 302, (int) $res['response']['code'] ); … … 97 93 public function test_redirections_equal() { 98 94 // 5 - 5. 99 $res = wp_remote_request( $this->redirection_script . '?rt=' . 5, array( 'redirection' => 5 ) ); 100 101 $this->skipTestOnTimeout( $res ); 95 $res = $this->wp_remote_request( $this->redirection_script . '?rt=' . 5, array( 'redirection' => 5 ) ); 96 102 97 $this->assertNotWPError( $res ); 103 98 $this->assertSame( 200, (int) $res['response']['code'] ); … … 109 104 public function test_no_head_redirections() { 110 105 // No redirections on HEAD request. 111 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 1, array( 'method' => 'HEAD' ) ); 112 113 $this->skipTestOnTimeout( $res ); 106 $res = $this->wp_remote_request( $this->redirection_script . '?code=302&rt=' . 1, array( 'method' => 'HEAD' ) ); 107 114 108 $this->assertNotWPError( $res ); 115 109 $this->assertSame( 302, (int) $res['response']['code'] ); … … 123 117 public function test_redirect_on_head() { 124 118 // Redirections on HEAD request when Requested. 125 $res = wp_remote_request(119 $res = $this->wp_remote_request( 126 120 $this->redirection_script . '?rt=' . 5, 127 121 array( … … 131 125 ); 132 126 133 $this->skipTestOnTimeout( $res );134 127 $this->assertNotWPError( $res ); 135 128 $this->assertSame( 200, (int) $res['response']['code'] ); … … 141 134 public function test_redirections_greater() { 142 135 // 10 > 5. 143 $res = wp_remote_request( $this->redirection_script . '?rt=' . 10, array( 'redirection' => 5 ) ); 144 145 $this->skipTestOnTimeout( $res ); 136 $res = $this->wp_remote_request( $this->redirection_script . '?rt=' . 10, array( 'redirection' => 5 ) ); 137 146 138 $this->assertWPError( $res ); 147 139 } … … 152 144 public function test_redirections_greater_edgecase() { 153 145 // 6 > 5 (close edge case). 154 $res = wp_remote_request( $this->redirection_script . '?rt=' . 6, array( 'redirection' => 5 ) ); 155 156 $this->skipTestOnTimeout( $res ); 146 $res = $this->wp_remote_request( $this->redirection_script . '?rt=' . 6, array( 'redirection' => 5 ) ); 147 157 148 $this->assertWPError( $res ); 158 149 } … … 163 154 public function test_redirections_less_edgecase() { 164 155 // 4 < 5 (close edge case). 165 $res = wp_remote_request( $this->redirection_script . '?rt=' . 4, array( 'redirection' => 5 ) ); 166 167 $this->skipTestOnTimeout( $res ); 156 $res = $this->wp_remote_request( $this->redirection_script . '?rt=' . 4, array( 'redirection' => 5 ) ); 157 168 158 $this->assertNotWPError( $res ); 169 159 } … … 176 166 public function test_redirections_zero_redirections_specified() { 177 167 // 0 redirections asked for, should return the document? 178 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) ); 179 180 $this->skipTestOnTimeout( $res ); 168 $res = $this->wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) ); 169 181 170 $this->assertNotWPError( $res ); 182 171 $this->assertSame( 302, (int) $res['response']['code'] ); … … 192 181 public function test_location_header_on_201() { 193 182 // Prints PASS on initial load, FAIL if the client follows the specified redirection. 194 $res = wp_remote_request( $this->redirection_script . '?201-location=true' ); 195 196 $this->skipTestOnTimeout( $res ); 183 $res = $this->wp_remote_request( $this->redirection_script . '?201-location=true' ); 184 197 185 $this->assertNotWPError( $res ); 198 186 $this->assertSame( 'PASS', $res['body'] ); … … 211 199 212 200 // Test 301 - POST to POST. 213 $res = wp_remote_request(201 $res = $this->wp_remote_request( 214 202 $url, 215 203 array( … … 219 207 ); 220 208 221 $this->skipTestOnTimeout( $res );222 209 $this->assertNotWPError( $res ); 223 210 $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) ); … … 237 224 'test3' => '', 238 225 ); 239 $res = wp_remote_request( $this->redirection_script . '?header-check', array( 'headers' => $headers ) ); 240 241 $this->skipTestOnTimeout( $res ); 226 $res = $this->wp_remote_request( $this->redirection_script . '?header-check', array( 'headers' => $headers ) ); 227 242 228 $this->assertNotWPError( $res ); 243 229 … … 268 254 $url = $this->file_stream_url; 269 255 $size = 153204; 270 $res = wp_remote_request(256 $res = $this->wp_remote_request( 271 257 $url, 272 258 array( … … 282 268 } 283 269 284 $this->skipTestOnTimeout( $res );285 270 $this->assertNotWPError( $res ); 286 271 $this->assertSame( '', $res['body'] ); // The body should be empty. … … 298 283 $url = $this->file_stream_url; 299 284 $size = 10000; 300 $res = wp_remote_request(285 $res = $this->wp_remote_request( 301 286 $url, 302 287 array( … … 313 298 } 314 299 315 $this->skipTestOnTimeout( $res );316 300 $this->assertNotWPError( $res ); 317 301 $this->assertSame( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters. … … 329 313 $size = 10000; 330 314 331 $res = wp_remote_request(315 $res = $this->wp_remote_request( 332 316 $url, 333 317 array( … … 337 321 ); 338 322 339 $this->skipTestOnTimeout( $res );340 323 $this->assertNotWPError( $res ); 341 324 $this->assertSame( $size, strlen( $res['body'] ) ); … … 355 338 $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?post-redirect-to-method=1'; 356 339 357 $res = wp_remote_post( add_query_arg( 'response_code', $response_code, $url ), array( 'timeout' => 30 ) ); 358 359 $this->skipTestOnTimeout( $res ); 340 $res = $this->wp_remote_post( add_query_arg( 'response_code', $response_code, $url ), array( 'timeout' => 30 ) ); 341 360 342 $this->assertNotWPError( $res ); 361 343 $this->assertSame( $method, wp_remote_retrieve_body( $res ) ); … … 406 388 ); 407 389 408 $res = wp_remote_get( $url, $args ); 409 410 $this->skipTestOnTimeout( $res ); 390 $res = $this->wp_remote_get( $url, $args ); 391 411 392 $this->assertNotWPError( $res ); 412 393 $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) ); … … 428 409 add_filter( 'http_request_args', array( $this, 'filter_http_request_args' ) ); 429 410 430 $res = wp_remote_head( $url, $args );411 $res = $this->wp_remote_head( $url, $args ); 431 412 432 413 remove_filter( 'http_request_args', array( $this, 'filter_http_request_args' ) ); 433 414 434 $this->skipTestOnTimeout( $res );435 415 $this->assertNotEmpty( $this->http_request_args['sslcertificates'] ); 436 416 $this->assertNotWPError( $res ); … … 448 428 $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?cookie-test=1'; 449 429 450 $res = wp_remote_get( $url ); 451 452 $this->skipTestOnTimeout( $res ); 430 $res = $this->wp_remote_get( $url ); 431 453 432 $this->assertNotWPError( $res ); 454 433 $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) ); … … 468 447 } 469 448 470 $res = wp_remote_get( 'https://wordpress.org/' ); 471 472 $this->skipTestOnTimeout( $res ); 449 $res = $this->wp_remote_get( 'https://wordpress.org/' ); 450 473 451 $this->assertNotWPError( $res ); 474 452 } … … 485 463 $url = str_replace( $path, '/' . $path, $url ); 486 464 487 $res = wp_remote_request( $url ); 488 489 $this->skipTestOnTimeout( $res ); 465 $res = $this->wp_remote_request( $url ); 466 490 467 $this->assertNotWPError( $res ); 491 468 }
Note: See TracChangeset
for help on using the changeset viewer.