Ticket #39265: h_folders.patch
File h_folders.patch, 29.1 KB (added by , 4 years ago) |
---|
-
hooks/addFilter.php
9 9 class Tests_WP_Hook_Add_Filter extends WP_UnitTestCase { 10 10 11 11 public $hook; 12 12 13 /* 14 * @covers WP_Hook::add_filter 15 */ 13 16 public function test_add_filter_with_function() { 14 17 $callback = '__return_null'; 15 18 $hook = new WP_Hook(); … … 23 26 $this->assertSame( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] ); 24 27 $this->assertSame( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] ); 25 28 } 26 29 30 /* 31 * @covers WP_Hook::add_filter 32 */ 27 33 public function test_add_filter_with_object() { 28 34 $a = new MockAction(); 29 35 $callback = array( $a, 'action' ); … … 38 44 $this->assertSame( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] ); 39 45 $this->assertSame( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] ); 40 46 } 41 47 48 /* 49 * @covers WP_Hook::add_filter 50 */ 42 51 public function test_add_filter_with_static_method() { 43 52 $callback = array( 'MockAction', 'action' ); 44 53 $hook = new WP_Hook(); … … 52 61 $this->assertSame( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] ); 53 62 $this->assertSame( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] ); 54 63 } 55 64 65 /* 66 * @covers WP_Hook::add_filter 67 */ 56 68 public function test_add_two_filters_with_same_priority() { 57 69 $callback_one = '__return_null'; 58 70 $callback_two = '__return_false'; … … 67 79 $hook->add_filter( $tag, $callback_two, $priority, $accepted_args ); 68 80 $this->assertCount( 2, $hook->callbacks[ $priority ] ); 69 81 } 70 82 83 /* 84 * @covers WP_Hook::add_filter 85 */ 71 86 public function test_add_two_filters_with_different_priority() { 72 87 $callback_one = '__return_null'; 73 88 $callback_two = '__return_false'; … … 83 98 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 84 99 $this->assertCount( 1, $hook->callbacks[ $priority + 1 ] ); 85 100 } 86 101 102 /* 103 * @covers WP_Hook::add_filter 104 */ 87 105 public function test_readd_filter() { 88 106 $callback = '__return_null'; 89 107 $hook = new WP_Hook(); … … 97 115 $hook->add_filter( $tag, $callback, $priority, $accepted_args ); 98 116 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 99 117 } 100 118 119 /* 120 * @covers WP_Hook::add_filter 121 */ 101 122 public function test_readd_filter_with_different_priority() { 102 123 $callback = '__return_null'; 103 124 $hook = new WP_Hook(); … … 112 133 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 113 134 $this->assertCount( 1, $hook->callbacks[ $priority + 1 ] ); 114 135 } 115 136 137 /* 138 * @covers WP_Hook::add_filter 139 */ 116 140 public function test_sort_after_add_filter() { 117 141 $a = new MockAction(); 118 142 $b = new MockAction(); … … 126 150 127 151 $this->assertSame( array( 5, 8, 10 ), array_keys( $hook->callbacks ) ); 128 152 } 129 153 154 /* 155 * @covers WP_Hook::add_filter 156 */ 130 157 public function test_remove_and_add() { 131 158 $this->hook = new Wp_Hook(); 132 159 … … 140 167 141 168 $this->assertSame( '24', $value ); 142 169 } 143 170 171 /* 172 * @covers WP_Hook::add_filter 173 */ 144 174 public function test_remove_and_add_last_filter() { 145 175 $this->hook = new Wp_Hook(); 146 176 … … 154 184 155 185 $this->assertSame( '12', $value ); 156 186 } 157 187 188 /* 189 * @covers WP_Hook::add_filter 190 */ 158 191 public function test_remove_and_recurse_and_add() { 159 192 $this->hook = new Wp_Hook(); 160 193 … … 199 232 public function _filter_remove_and_add4( $string ) { 200 233 return $string . '4'; 201 234 } 202 235 236 /* 237 * @covers WP_Hook::do_action 238 */ 203 239 public function test_remove_and_add_action() { 204 240 $this->hook = new Wp_Hook(); 205 241 $this->action_output = ''; … … 214 250 215 251 $this->assertSame( '24', $this->action_output ); 216 252 } 217 253 254 /* 255 * @covers WP_Hook::do_action 256 */ 218 257 public function test_remove_and_add_last_action() { 219 258 $this->hook = new Wp_Hook(); 220 259 $this->action_output = ''; … … 229 268 230 269 $this->assertSame( '12', $this->action_output ); 231 270 } 232 271 272 /* 273 * @covers WP_Hook::do_action 274 */ 233 275 public function test_remove_and_recurse_and_add_action() { 234 276 $this->hook = new Wp_Hook(); 235 277 $this->action_output = ''; -
hooks/applyFilters.php
23 23 $this->assertSame( $returned, $arg ); 24 24 $this->assertSame( 1, $a->get_call_count() ); 25 25 } 26 26 27 /* 28 * @covers WP_Hook::apply_filters 29 */ 27 30 public function test_apply_filters_with_multiple_calls() { 28 31 $a = new MockAction(); 29 32 $callback = array( $a, 'filter' ); -
hooks/doAction.php
14 14 parent::setUp(); 15 15 $this->events = array(); 16 16 } 17 17 18 /* 19 * @covers WP_Hook::do_action 20 */ 18 21 public function test_do_action_with_callback() { 19 22 $a = new MockAction(); 20 23 $callback = array( $a, 'action' ); … … 29 32 30 33 $this->assertSame( 1, $a->get_call_count() ); 31 34 } 32 35 36 /* 37 * @covers WP_Hook::do_action 38 */ 33 39 public function test_do_action_with_multiple_calls() { 34 40 $a = new MockAction(); 35 41 $callback = array( $a, 'filter' ); … … 45 51 46 52 $this->assertSame( 2, $a->get_call_count() ); 47 53 } 48 54 55 /* 56 * @covers WP_Hook::do_action 57 */ 49 58 public function test_do_action_with_multiple_callbacks_on_same_priority() { 50 59 $a = new MockAction(); 51 60 $b = new MockAction(); … … 64 73 $this->assertSame( 1, $a->get_call_count() ); 65 74 $this->assertSame( 1, $a->get_call_count() ); 66 75 } 67 76 77 /* 78 * @covers WP_Hook::do_action 79 */ 68 80 public function test_do_action_with_multiple_callbacks_on_different_priorities() { 69 81 $a = new MockAction(); 70 82 $b = new MockAction(); … … 83 95 $this->assertSame( 1, $a->get_call_count() ); 84 96 $this->assertSame( 1, $a->get_call_count() ); 85 97 } 86 98 99 /* 100 * @covers WP_Hook::do_action 101 */ 87 102 public function test_do_action_with_no_accepted_args() { 88 103 $callback = array( $this, '_action_callback' ); 89 104 $hook = new WP_Hook(); … … 97 112 98 113 $this->assertEmpty( $this->events[0]['args'] ); 99 114 } 100 115 116 /* 117 * @covers WP_Hook::do_action 118 */ 101 119 public function test_do_action_with_one_accepted_arg() { 102 120 $callback = array( $this, '_action_callback' ); 103 121 $hook = new WP_Hook(); … … 111 129 112 130 $this->assertCount( 1, $this->events[0]['args'] ); 113 131 } 114 132 133 /* 134 * @covers WP_Hook::do_action 135 */ 115 136 public function test_do_action_with_more_accepted_args() { 116 137 $callback = array( $this, '_action_callback' ); 117 138 $hook = new WP_Hook(); … … 125 146 126 147 $this->assertCount( 1, $this->events[0]['args'] ); 127 148 } 128 149 150 /* 151 * @covers WP_Hook::do_action 152 */ 129 153 public function test_do_action_doesnt_change_value() { 130 154 $this->hook = new WP_Hook(); 131 155 $this->action_output = ''; … … 138 162 139 163 $this->assertSame( 'a1-b1b3-a2a3', $this->action_output ); 140 164 } 141 165 142 166 public function _filter_do_action_doesnt_change_value1( $value ) { 143 167 $this->action_output .= $value . 1; 144 168 return 'x1'; -
hooks/doAllHook.php
6 6 * @group hooks 7 7 */ 8 8 class Tests_WP_Hook_Do_All_Hook extends WP_UnitTestCase { 9 9 10 /* 11 * @covers WP_Hook::do_all_hook 12 */ 10 13 public function test_do_all_hook_with_multiple_calls() { 11 14 $a = new MockAction(); 12 15 $callback = array( $a, 'action' ); -
hooks/hasFilter.php
6 6 * @group hooks 7 7 */ 8 8 class Tests_WP_Hook_Has_Filter extends WP_UnitTestCase { 9 9 10 /* 11 * @covers WP_Hook::has_filter 12 */ 10 13 public function test_has_filter_with_function() { 11 14 $callback = '__return_null'; 12 15 $hook = new WP_Hook(); … … 18 21 19 22 $this->assertSame( $priority, $hook->has_filter( $tag, $callback ) ); 20 23 } 21 24 25 /* 26 * @covers WP_Hook::has_filter 27 */ 22 28 public function test_has_filter_with_object() { 23 29 $a = new MockAction(); 24 30 $callback = array( $a, 'action' ); … … 31 37 32 38 $this->assertSame( $priority, $hook->has_filter( $tag, $callback ) ); 33 39 } 34 40 41 /* 42 * @covers WP_Hook::has_filter 43 */ 35 44 public function test_has_filter_with_static_method() { 36 45 $callback = array( 'MockAction', 'action' ); 37 46 $hook = new WP_Hook(); … … 43 52 44 53 $this->assertSame( $priority, $hook->has_filter( $tag, $callback ) ); 45 54 } 46 55 56 /* 57 * @covers WP_Hook::has_filter 58 */ 47 59 public function test_has_filter_without_callback() { 48 60 $callback = '__return_null'; 49 61 $hook = new WP_Hook(); … … 55 67 56 68 $this->assertTrue( $hook->has_filter() ); 57 69 } 58 70 71 /* 72 * @covers WP_Hook::has_filter 73 */ 59 74 public function test_not_has_filter_without_callback() { 60 75 $hook = new WP_Hook(); 61 76 $this->assertFalse( $hook->has_filter() ); 62 77 } 63 78 79 /* 80 * @covers WP_Hook::has_filter 81 */ 64 82 public function test_not_has_filter_with_callback() { 65 83 $callback = '__return_null'; 66 84 $hook = new WP_Hook(); … … 68 86 69 87 $this->assertFalse( $hook->has_filter( $tag, $callback ) ); 70 88 } 71 89 90 /* 91 * @covers WP_Hook::has_filter 92 */ 72 93 public function test_has_filter_with_wrong_callback() { 73 94 $callback = '__return_null'; 74 95 $hook = new WP_Hook(); -
hooks/hasFilters.php
6 6 * @group hooks 7 7 */ 8 8 class Tests_WP_Hook_Has_Filters extends WP_UnitTestCase { 9 9 10 /* 11 * @covers WP_Hook::has_filters 12 */ 10 13 public function test_has_filters_with_callback() { 11 14 $callback = '__return_null'; 12 15 $hook = new WP_Hook(); … … 18 21 19 22 $this->assertTrue( $hook->has_filters() ); 20 23 } 21 24 25 /* 26 * @covers WP_Hook::has_filters 27 */ 22 28 public function test_has_filters_without_callback() { 23 29 $hook = new WP_Hook(); 24 30 $this->assertFalse( $hook->has_filters() ); 25 31 } 26 32 33 /* 34 * @covers WP_Hook::has_filters 35 */ 27 36 public function test_not_has_filters_with_removed_callback() { 28 37 $callback = '__return_null'; 29 38 $hook = new WP_Hook(); … … 35 44 $hook->remove_filter( $tag, $callback, $priority ); 36 45 $this->assertFalse( $hook->has_filters() ); 37 46 } 38 47 48 /* 49 * @covers WP_Hook::has_filters 50 */ 39 51 public function test_not_has_filter_with_directly_removed_callback() { 40 52 $callback = '__return_null'; 41 53 $hook = new WP_Hook(); -
hooks/iterator.php
6 6 * @group hooks 7 7 */ 8 8 class Tests_WP_Hook_Iterator extends WP_UnitTestCase { 9 9 10 /* 11 * @covers WP_Hook::add_filter 12 */ 10 13 public function test_foreach() { 11 14 $callback_one = '__return_null'; 12 15 $callback_two = '__return_false'; -
hooks/preinitHooks.php
6 6 * @group hooks 7 7 */ 8 8 class Tests_WP_Hook_Preinit_Hooks extends WP_UnitTestCase { 9 9 10 /* 11 * @covers WP_Hook::build_preinitialized_hooks 12 */ 10 13 public function test_array_to_hooks() { 11 14 $tag1 = __FUNCTION__ . '_1'; 12 15 $priority1 = rand( 1, 100 ); -
hooks/removeAllFilters.php
6 6 * @group hooks 7 7 */ 8 8 class Tests_WP_Hook_Remove_All_Filters extends WP_UnitTestCase { 9 9 10 /* 11 * @covers WP_Hook::remove_all_filters 12 * @covers WP_Hook::has_filters 13 */ 10 14 public function test_remove_all_filters() { 11 15 $callback = '__return_null'; 12 16 $hook = new WP_Hook(); … … 20 24 21 25 $this->assertFalse( $hook->has_filters() ); 22 26 } 23 27 28 /* 29 * @covers WP_Hook::remove_all_filters 30 * @covers WP_Hook::has_filter 31 */ 24 32 public function test_remove_all_filters_with_priority() { 25 33 $callback_one = '__return_null'; 26 34 $callback_two = '__return_false'; -
hooks/removeFilter.php
6 6 * @group hooks 7 7 */ 8 8 class Tests_WP_Hook_Remove_Filter extends WP_UnitTestCase { 9 9 10 /* 11 * @covers WP_Hook::remove_filter 12 */ 10 13 public function test_remove_filter_with_function() { 11 14 $callback = '__return_null'; 12 15 $hook = new WP_Hook(); … … 19 22 20 23 $this->assertFalse( isset( $hook->callbacks[ $priority ] ) ); 21 24 } 22 25 26 /* 27 * @covers WP_Hook::remove_filter 28 */ 23 29 public function test_remove_filter_with_object() { 24 30 $a = new MockAction(); 25 31 $callback = array( $a, 'action' ); … … 33 39 34 40 $this->assertFalse( isset( $hook->callbacks[ $priority ] ) ); 35 41 } 36 42 43 /* 44 * @covers WP_Hook::remove_filter 45 */ 37 46 public function test_remove_filter_with_static_method() { 38 47 $callback = array( 'MockAction', 'action' ); 39 48 $hook = new WP_Hook(); … … 46 55 47 56 $this->assertFalse( isset( $hook->callbacks[ $priority ] ) ); 48 57 } 49 58 59 /* 60 * @covers WP_Hook::remove_filter 61 */ 50 62 public function test_remove_filters_with_another_at_same_priority() { 51 63 $callback_one = '__return_null'; 52 64 $callback_two = '__return_false'; … … 62 74 63 75 $this->assertCount( 1, $hook->callbacks[ $priority ] ); 64 76 } 65 77 78 /* 79 * @covers WP_Hook::remove_filter 80 */ 66 81 public function test_remove_filter_with_another_at_different_priority() { 67 82 $callback_one = '__return_null'; 68 83 $callback_two = '__return_false'; -
http/base.php
50 50 $this->http_request_args = $args; 51 51 return $args; 52 52 } 53 53 54 /* 55 * @covers ::wp_remote_request 56 */ 54 57 function test_redirect_on_301() { 55 58 // 5 : 5 & 301. 56 59 $res = wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 5 ) ); … … 59 62 $this->assertNotWPError( $res ); 60 63 $this->assertSame( 200, (int) $res['response']['code'] ); 61 64 } 62 65 66 /* 67 * @covers ::wp_remote_request 68 */ 63 69 function test_redirect_on_302() { 64 70 // 5 : 5 & 302. 65 71 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 5 ) ); … … 71 77 72 78 /** 73 79 * @ticket 16855 80 * 81 * @covers ::wp_remote_request 74 82 */ 75 83 function test_redirect_on_301_no_redirect() { 76 84 // 5 > 0 & 301. … … 83 91 84 92 /** 85 93 * @ticket 16855 94 * 95 * @covers ::wp_remote_request 86 96 */ 87 97 function test_redirect_on_302_no_redirect() { 88 98 // 5 > 0 & 302. … … 92 102 $this->assertNotWPError( $res ); 93 103 $this->assertSame( 302, (int) $res['response']['code'] ); 94 104 } 95 105 106 /** 107 * @covers ::wp_remote_request 108 */ 96 109 function test_redirections_equal() { 97 110 // 5 - 5. 98 111 $res = wp_remote_request( $this->redirection_script . '?rt=' . 5, array( 'redirection' => 5 ) ); … … 101 114 $this->assertNotWPError( $res ); 102 115 $this->assertSame( 200, (int) $res['response']['code'] ); 103 116 } 104 117 118 /** 119 * @covers ::wp_remote_request 120 */ 105 121 function test_no_head_redirections() { 106 122 // No redirections on HEAD request. 107 123 $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 1, array( 'method' => 'HEAD' ) ); … … 113 129 114 130 /** 115 131 * @ticket 16855 132 * 133 * @covers ::wp_remote_request 116 134 */ 117 135 function test_redirect_on_head() { 118 136 // Redirections on HEAD request when Requested. … … 128 146 $this->assertNotWPError( $res ); 129 147 $this->assertSame( 200, (int) $res['response']['code'] ); 130 148 } 131 149 150 /** 151 * @covers ::wp_remote_request 152 */ 132 153 function test_redirections_greater() { 133 154 // 10 > 5. 134 155 $res = wp_remote_request( $this->redirection_script . '?rt=' . 10, array( 'redirection' => 5 ) ); … … 136 157 $this->skipTestOnTimeout( $res ); 137 158 $this->assertWPError( $res ); 138 159 } 139 160 161 /** 162 * @covers ::wp_remote_request 163 */ 140 164 function test_redirections_greater_edgecase() { 141 165 // 6 > 5 (close edge case). 142 166 $res = wp_remote_request( $this->redirection_script . '?rt=' . 6, array( 'redirection' => 5 ) ); … … 144 168 $this->skipTestOnTimeout( $res ); 145 169 $this->assertWPError( $res ); 146 170 } 147 171 172 /** 173 * @covers ::wp_remote_request 174 */ 148 175 function test_redirections_less_edgecase() { 149 176 // 4 < 5 (close edge case). 150 177 $res = wp_remote_request( $this->redirection_script . '?rt=' . 4, array( 'redirection' => 5 ) ); … … 155 182 156 183 /** 157 184 * @ticket 16855 185 * 186 * @covers ::wp_remote_request 158 187 */ 159 188 function test_redirections_zero_redirections_specified() { 160 189 // 0 redirections asked for, should return the document? … … 169 198 * Do not redirect on non 3xx status codes. 170 199 * 171 200 * @ticket 16889 201 * 202 * @covers ::wp_remote_request 172 203 */ 173 204 function test_location_header_on_201() { 174 205 // Prints PASS on initial load, FAIL if the client follows the specified redirection. … … 183 214 * Test handling of PUT requests on redirects. 184 215 * 185 216 * @ticket 16889 217 * 218 * @covers ::wp_remote_request 219 * @covers ::wp_remote_retrieve_body 186 220 */ 187 221 function test_no_redirection_on_PUT() { 188 222 $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?201-location=1'; … … 203 237 204 238 /** 205 239 * @ticket 11888 240 * 241 * @covers ::wp_remote_request 206 242 */ 207 243 function test_send_headers() { 208 244 // Test that the headers sent are received by the server. … … 232 268 // Should it be that empty headers with empty values are NOT sent? 233 269 // $this->assertTrue( isset( $headers['test3'] ) && '' === $headers['test3'] ); 234 270 } 235 271 272 /** 273 * @ticket 11888 274 * 275 * @covers ::wp_remote_request 276 */ 236 277 function test_file_stream() { 237 278 $url = $this->file_stream_url; 238 279 $size = 153204; … … 260 301 261 302 /** 262 303 * @ticket 26726 304 * 305 * @covers ::wp_remote_request 263 306 */ 264 307 function test_file_stream_limited_size() { 265 308 $url = $this->file_stream_url; … … 289 332 * Tests limiting the response size when returning strings. 290 333 * 291 334 * @ticket 31172 335 * 336 * @covers ::wp_remote_request 292 337 */ 293 338 function test_request_limited_size() { 294 339 $url = $this->file_stream_url; … … 313 358 * @dataProvider data_post_redirect_to_method_300 314 359 * 315 360 * @ticket 17588 361 * 362 * @covers ::wp_remote_post 363 * @covers ::wp_remote_retrieve_body 316 364 */ 317 365 function test_post_redirect_to_method_300( $response_code, $method ) { 318 366 $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?post-redirect-to-method=1'; … … 322 370 $this->skipTestOnTimeout( $res ); 323 371 $this->assertSame( $method, wp_remote_retrieve_body( $res ) ); 324 372 } 325 373 326 374 public function data_post_redirect_to_method_300() { 327 375 return array( 328 376 // Test 300 - POST to POST. … … 352 400 * Test HTTP Requests using an IP URL, with a HOST header specified. 353 401 * 354 402 * @ticket 24182 403 * 404 * @covers ::wp_remote_get 405 * @covers ::wp_remote_retrieve_body 355 406 */ 356 407 function test_ip_url_with_host_header() { 357 408 $ip = gethostbyname( 'api.wordpress.org' ); … … 375 426 * Test HTTP requests where SSL verification is disabled but the CA bundle is still populated. 376 427 * 377 428 * @ticket 33978 429 * 430 * @covers ::wp_remote_head 378 431 */ 379 432 function test_https_url_without_ssl_verification() { 380 433 $url = 'https://wordpress.org/'; … … 397 450 * Test HTTP Redirects with multiple Location headers specified. 398 451 * 399 452 * @ticket 16890 453 * 454 * @covers ::wp_remote_head 455 * @covers ::wp_remote_retrieve_header 456 * @covers ::wp_remote_get 457 * @covers ::wp_remote_retrieve_body 400 458 */ 401 459 function test_multiple_location_headers() { 402 460 $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?multiple-location-headers=1'; … … 417 475 * Test HTTP Cookie handling. 418 476 * 419 477 * @ticket 21182 478 * 479 * @covers ::wp_remote_get 480 * @covers ::wp_remote_retrieve_body 420 481 */ 421 482 function test_cookie_handling() { 422 483 $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?cookie-test=1'; … … 432 493 * 433 494 * @group ssl 434 495 * @ticket 25007 496 * 497 * @covers ::wp_remote_get 435 498 */ 436 499 function test_ssl() { 437 500 if ( ! wp_http_supports( array( 'ssl' ) ) ) { … … 446 509 447 510 /** 448 511 * @ticket 37733 512 * 513 * @covers ::wp_remote_request 449 514 */ 450 515 function test_url_with_double_slashes_path() { 451 516 $url = $this->redirection_script . '?rt=' . 0; -
http/curl.php
11 11 12 12 /** 13 13 * @ticket 39783 14 * 15 * @covers ::wp_remote_request 14 16 */ 15 17 public function test_http_api_curl_stream_parameter_is_a_reference() { 16 18 add_action( 'http_api_curl', array( $this, '_action_test_http_api_curl_stream_parameter_is_a_reference' ), 10, 3 ); -
http/functions.php
13 13 14 14 parent::setUp(); 15 15 } 16 16 17 /* 18 * @covers ::wp_remote_head 19 */ 17 20 function test_head_request() { 18 21 // This URL gives a direct 200 response. 19 22 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; … … 29 32 $this->assertSame( '40148', $headers['content-length'] ); 30 33 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 31 34 } 32 35 36 /* 37 * @covers ::wp_remote_head 38 */ 33 39 function test_head_redirect() { 34 40 // This URL will 301 redirect. 35 41 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; … … 38 44 $this->skipTestOnTimeout( $response ); 39 45 $this->assertSame( 301, wp_remote_retrieve_response_code( $response ) ); 40 46 } 41 47 48 /* 49 * @covers ::wp_remote_head 50 */ 42 51 function test_head_404() { 43 52 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg'; 44 53 $response = wp_remote_head( $url ); … … 46 55 $this->skipTestOnTimeout( $response ); 47 56 $this->assertSame( 404, wp_remote_retrieve_response_code( $response ) ); 48 57 } 49 58 59 /* 60 * @covers ::wp_remote_get 61 */ 50 62 function test_get_request() { 51 63 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; 52 64 … … 63 75 $this->assertSame( '40148', $headers['content-length'] ); 64 76 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 65 77 } 66 78 79 /* 80 * @covers ::wp_remote_get 81 */ 67 82 function test_get_redirect() { 68 83 // This will redirect to asdftestblog1.files.wordpress.com. 69 84 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; … … 79 94 $this->assertSame( '40148', $headers['content-length'] ); 80 95 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 81 96 } 82 97 98 /* 99 * @covers ::wp_remote_get 100 */ 83 101 function test_get_redirect_limit_exceeded() { 84 102 // This will redirect to asdftestblog1.files.wordpress.com. 85 103 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; … … 93 111 94 112 /** 95 113 * @ticket 33711 114 * 115 * @covers ::wp_remote_retrieve_cookies 116 * @covers ::wp_remote_retrieve_cookie 117 * @covers ::wp_remote_retrieve_cookie_value 96 118 */ 97 119 function test_get_response_cookies() { 98 120 $url = 'https://login.wordpress.org/wp-login.php'; … … 122 144 123 145 /** 124 146 * @ticket 37437 147 * 148 * @covers ::wp_remote_get 149 * @covers ::wp_remote_retrieve_cookie 150 * @covers ::wp_remote_retrieve_cookies 125 151 */ 126 152 function test_get_response_cookies_with_wp_http_cookie_object() { 127 153 $url = 'http://example.org'; … … 154 180 155 181 /** 156 182 * @ticket 37437 183 * 184 * @covers ::wp_remote_retrieve_cookies 157 185 */ 158 186 function test_get_response_cookies_with_name_value_array() { 159 187 $url = 'http://example.org'; … … 181 209 182 210 /** 183 211 * @ticket 43231 212 * 213 * @covers ::wp_remote_retrieve_cookie 214 * @covers ::wp_remote_retrieve_cookies 215 * @covers WP_Http::normalize_cookies 184 216 */ 185 217 function test_get_cookie_host_only() { 186 218 // Emulate WP_Http::request() internals. -
http/getHttpHeaders.php
27 27 28 28 /** 29 29 * Test with a valid URL 30 * 31 * @covers ::wp_get_http_headers 30 32 */ 31 33 public function test_wp_get_http_headers_valid_url() { 32 34 $result = wp_get_http_headers( 'http://example.com' ); … … 35 37 36 38 /** 37 39 * Test with an invalid URL 40 * 41 * @covers ::wp_get_http_headers 38 42 */ 39 43 public function test_wp_get_http_headers_invalid_url() { 40 44 $result = wp_get_http_headers( 'not_an_url' ); … … 43 47 44 48 /** 45 49 * Test to see if the deprecated argument is working 50 * 51 * @covers ::wp_get_http_headers 46 52 */ 47 53 public function test_wp_get_http_headers_deprecated_argument() { 48 54 $this->setExpectedDeprecated( 'wp_get_http_headers' ); -
http/http.php
10 10 11 11 /** 12 12 * @dataProvider make_absolute_url_testcases 13 * 14 * @covers WP_Http::make_absolute_url 13 15 */ 14 16 function test_make_absolute_url( $relative_url, $absolute_url, $expected ) { 15 17 $actual = WP_Http::make_absolute_url( $relative_url, $absolute_url ); 16 18 $this->assertSame( $expected, $actual ); 17 19 } 18 20 19 21 function make_absolute_url_testcases() { 20 22 // 0: The Location header, 1: The current URL, 3: The expected URL. 21 23 return array( … … 69 71 70 72 /** 71 73 * @dataProvider parse_url_testcases 74 * 75 * @covers ::wp_parse_url 72 76 */ 73 77 function test_wp_parse_url( $url, $expected ) { 74 78 $actual = wp_parse_url( $url ); 75 79 $this->assertSame( $expected, $actual ); 76 80 } 77 81 78 82 function parse_url_testcases() { 79 83 // 0: The URL, 1: The expected resulting structure. 80 84 return array( … … 180 184 181 185 /** 182 186 * @ticket 36356 187 * 188 * @covers ::wp_parse_url 183 189 */ 184 190 function test_wp_parse_url_with_default_component() { 185 191 $actual = wp_parse_url( self::FULL_TEST_URL, -1 ); … … 202 208 * @ticket 36356 203 209 * 204 210 * @dataProvider parse_url_component_testcases 211 * 212 * @covers ::wp_parse_url 205 213 */ 206 214 function test_wp_parse_url_with_component( $url, $component, $expected ) { 207 215 $actual = wp_parse_url( $url, $component ); 208 216 $this->assertSame( $expected, $actual ); 209 217 } 210 218 219 211 220 function parse_url_component_testcases() { 212 221 // 0: The URL, 1: The requested component, 2: The expected resulting structure. 213 222 return array( … … 261 270 262 271 /** 263 272 * @ticket 35426 273 * 274 * @covers ReflectionClass::getConstants 264 275 */ 265 276 public function test_http_response_code_constants() { 266 277 global $wp_header_to_desc; … … 272 283 get_status_header_desc( 200 ); 273 284 274 285 $this->assertSame( array_keys( $wp_header_to_desc ), array_values( $constants ) ); 275 276 286 } 277 287 278 288 /** 279 289 * @ticket 37768 290 * 291 * @covers WP_Http::normalize_cookies 280 292 */ 281 293 public function test_normalize_cookies_scalar_values() { 282 294 $http = _wp_http_get_object(); … … 312 324 * @ticket 36356 313 325 * 314 326 * @dataProvider get_component_from_parsed_url_array_testcases 327 * 328 * @covers ::_get_component_from_parsed_url_array 315 329 */ 316 330 function test_get_component_from_parsed_url_array( $url, $component, $expected ) { 317 331 $parts = wp_parse_url( $url ); … … 318 332 $actual = _get_component_from_parsed_url_array( $parts, $component ); 319 333 $this->assertSame( $expected, $actual ); 320 334 } 321 335 322 336 function get_component_from_parsed_url_array_testcases() { 323 337 // 0: A URL, 1: PHP URL constant, 2: The expected result. 324 338 return array( … … 351 365 * @ticket 36356 352 366 * 353 367 * @dataProvider wp_translate_php_url_constant_to_key_testcases 368 * 369 * @covers ::_wp_translate_php_url_constant_to_key 354 370 */ 355 371 function test_wp_translate_php_url_constant_to_key( $input, $expected ) { 356 372 $actual = _wp_translate_php_url_constant_to_key( $input ); -
http/remoteRetrieveHeaders.php
7 7 8 8 /** 9 9 * Valid response 10 * 11 * @covers ::wp_remote_retrieve_headers 10 12 */ 11 13 function test_remote_retrieve_headers_valid_response() { 12 14 $headers = 'headers_data'; … … 18 20 19 21 /** 20 22 * Response is a WP_Error 23 * 24 * @covers ::wp_remote_retrieve_headers 21 25 */ 22 26 function test_remote_retrieve_headers_is_error() { 23 27 $response = new WP_Error( 'Some error' ); … … 28 32 29 33 /** 30 34 * Response does not contain 'headers' 35 * 36 * @covers ::wp_remote_retrieve_headers 31 37 */ 32 38 function test_remote_retrieve_headers_invalid_response() { 33 39 $response = array( 'no_headers' => 'set' );