Changeset 47122 for trunk/tests/phpunit/tests/http/base.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/http/base.php
r46682 r47122 33 33 // Disable all transports aside from this one. 34 34 foreach ( array( 'curl', 'streams', 'fsockopen' ) as $t ) { 35 remove_filter( "use_{$t}_transport", '__return_false' ); // Just strip them all35 remove_filter( "use_{$t}_transport", '__return_false' ); // Just strip them all... 36 36 if ( $t !== $this->transport ) { 37 add_filter( "use_{$t}_transport", '__return_false' ); // and add it back if need be..37 add_filter( "use_{$t}_transport", '__return_false' ); // ...and add it back if need be. 38 38 } 39 39 } … … 53 53 54 54 function test_redirect_on_301() { 55 // 5 : 5 & 301 55 // 5 : 5 & 301. 56 56 $res = wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 5 ) ); 57 57 … … 62 62 63 63 function test_redirect_on_302() { 64 // 5 : 5 & 302 64 // 5 : 5 & 302. 65 65 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 5 ) ); 66 66 … … 74 74 */ 75 75 function test_redirect_on_301_no_redirect() { 76 // 5 > 0 & 301 76 // 5 > 0 & 301. 77 77 $res = wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 0 ) ); 78 78 … … 86 86 */ 87 87 function test_redirect_on_302_no_redirect() { 88 // 5 > 0 & 302 88 // 5 > 0 & 302. 89 89 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) ); 90 90 … … 95 95 96 96 function test_redirections_equal() { 97 // 5 - 5 97 // 5 - 5. 98 98 $res = wp_remote_request( $this->redirection_script . '?rt=' . 5, array( 'redirection' => 5 ) ); 99 99 … … 104 104 105 105 function test_no_head_redirections() { 106 // No redirections on HEAD request :106 // No redirections on HEAD request. 107 107 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 1, array( 'method' => 'HEAD' ) ); 108 108 … … 116 116 */ 117 117 function test_redirect_on_head() { 118 // Redirections on HEAD request when Requested 118 // Redirections on HEAD request when Requested. 119 119 $res = wp_remote_request( 120 120 $this->redirection_script . '?rt=' . 5, … … 131 131 132 132 function test_redirections_greater() { 133 // 10 > 5 133 // 10 > 5. 134 134 $res = wp_remote_request( $this->redirection_script . '?rt=' . 10, array( 'redirection' => 5 ) ); 135 135 … … 139 139 140 140 function test_redirections_greater_edgecase() { 141 // 6 > 5 (close edge case)141 // 6 > 5 (close edge case). 142 142 $res = wp_remote_request( $this->redirection_script . '?rt=' . 6, array( 'redirection' => 5 ) ); 143 143 … … 147 147 148 148 function test_redirections_less_edgecase() { 149 // 4 < 5 (close edge case)149 // 4 < 5 (close edge case). 150 150 $res = wp_remote_request( $this->redirection_script . '?rt=' . 4, array( 'redirection' => 5 ) ); 151 151 … … 158 158 */ 159 159 function test_redirections_zero_redirections_specified() { 160 // 0 redirections asked for, Should return the document?160 // 0 redirections asked for, should return the document? 161 161 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) ); 162 162 … … 167 167 168 168 /** 169 * Do not redirect on non 3xx status codes 169 * Do not redirect on non 3xx status codes. 170 170 * 171 171 * @ticket 16889 172 172 */ 173 173 function test_location_header_on_201() { 174 // Prints PASS on initial load, FAIL if the client follows the specified redirection 174 // Prints PASS on initial load, FAIL if the client follows the specified redirection. 175 175 $res = wp_remote_request( $this->redirection_script . '?201-location=true' ); 176 176 … … 181 181 182 182 /** 183 * Test handling of PUT requests on redirects 183 * Test handling of PUT requests on redirects. 184 184 * 185 185 * @ticket 16889 … … 188 188 $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?201-location=1'; 189 189 190 // Test 301 - POST to POST 190 // Test 301 - POST to POST. 191 191 $res = wp_remote_request( 192 192 $url, … … 206 206 */ 207 207 function test_send_headers() { 208 // Test that the headers sent are received by the server 208 // Test that the headers sent are received by the server. 209 209 $headers = array( 210 210 'test1' => 'test', … … 231 231 // cURL/HTTP Extension Note: Will never pass, cURL does not pass headers with an empty value. 232 232 // Should it be that empty headers with empty values are NOT sent? 233 // $this->assertTrue( isset($headers['test3']) && '' === $headers['test3'] );233 // $this->assertTrue( isset( $headers['test3'] ) && '' === $headers['test3'] ); 234 234 } 235 235 … … 243 243 'timeout' => 30, 244 244 ) 245 ); // Auto generate the filename.245 ); // Auto generate the filename. 246 246 247 247 // Cleanup before we assert, as it'll return early. … … 254 254 $this->assertNotWPError( $res ); 255 255 $this->assertEquals( '', $res['body'] ); // The body should be empty. 256 $this->assertEquals( $size, $res['headers']['content-length'] ); // Check the headers are returned (and the size is the same..)257 $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters 258 $this->assertStringStartsWith( get_temp_dir(), $res['filename'] ); // Check it's saving within the temp dir 256 $this->assertEquals( $size, $res['headers']['content-length'] ); // Check the headers are returned (and the size is the same). 257 $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters. 258 $this->assertStringStartsWith( get_temp_dir(), $res['filename'] ); // Check it's saving within the temp directory. 259 259 } 260 260 … … 272 272 'limit_response_size' => $size, 273 273 ) 274 ); // Auto generate the filename.274 ); // Auto generate the filename. 275 275 276 276 // Cleanup before we assert, as it'll return early. … … 282 282 $this->skipTestOnTimeout( $res ); 283 283 $this->assertNotWPError( $res ); 284 $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters 285 286 } 287 288 /** 289 * Tests Limiting the response size when returning strings284 $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters. 285 286 } 287 288 /** 289 * Tests limiting the response size when returning strings. 290 290 * 291 291 * @ticket 31172 … … 309 309 310 310 /** 311 * Test POST redirection methods 311 * Test POST redirection methods. 312 312 * 313 313 * @dataProvider data_post_redirect_to_method_300 … … 326 326 public function data_post_redirect_to_method_300() { 327 327 return array( 328 // Test 300 - POST to POST 328 // Test 300 - POST to POST. 329 329 array( 330 330 300, 331 331 'POST', 332 332 ), 333 // Test 301 - POST to POST 333 // Test 301 - POST to POST. 334 334 array( 335 335 301, 336 336 'POST', 337 337 ), 338 // Test 302 - POST to GET 338 // Test 302 - POST to GET. 339 339 array( 340 340 302, 341 341 'GET', 342 342 ), 343 // Test 303 - POST to GET 343 // Test 303 - POST to GET. 344 344 array( 345 345 303, … … 350 350 351 351 /** 352 * Test HTTP Requests using an IP url, with a HOST header specified352 * Test HTTP Requests using an IP URL, with a HOST header specified. 353 353 * 354 354 * @ticket 24182 … … 373 373 374 374 /** 375 * Test HTTP requests where SSL verification is disabled but the CA bundle is still populated 375 * Test HTTP requests where SSL verification is disabled but the CA bundle is still populated. 376 376 * 377 377 * @ticket 33978 … … 395 395 396 396 /** 397 * Test HTTP Redirects with multiple Location headers specified 397 * Test HTTP Redirects with multiple Location headers specified. 398 398 * 399 399 * @ticket 16890 … … 415 415 416 416 /** 417 * Test HTTP Cookie handling 417 * Test HTTP Cookie handling. 418 418 * 419 419 * @ticket 21182 … … 429 429 430 430 /** 431 * Test if HTTPS support works 431 * Test if HTTPS support works. 432 432 * 433 433 * @group ssl
Note: See TracChangeset
for help on using the changeset viewer.