Changeset 55029
- Timestamp:
- 01/05/2023 10:21:19 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-http.php
r54997 r55029 252 252 * @since 2.9.0 253 253 * 254 * @param false|array|WP_Error $ preemptA preemptive return value of an HTTP request. Default false.254 * @param false|array|WP_Error $response A preemptive return value of an HTTP request. Default false. 255 255 * @param array $parsed_args HTTP request arguments. 256 256 * @param string $url The request URL. -
trunk/tests/phpunit/tests/admin/includesFile.php
r52760 r55029 69 69 } 70 70 71 public function _fake_download_url_non_200_response_code( $response, $ args, $url ) {71 public function _fake_download_url_non_200_response_code( $response, $parsed_args, $url ) { 72 72 file_put_contents( $args['filename'], 'This is an unexpected error message from your favorite server.' ); 73 73 return array( … … 151 151 * @return array 152 152 */ 153 public function filter_content_disposition_header_with_filename( $response, $ args, $url ) {153 public function filter_content_disposition_header_with_filename( $response, $parsed_args, $url ) { 154 154 return array( 155 155 'response' => array( … … 169 169 * @return array 170 170 */ 171 public function filter_content_disposition_header_with_filename_with_path_traversal( $response, $ args, $url ) {171 public function filter_content_disposition_header_with_filename_with_path_traversal( $response, $parsed_args, $url ) { 172 172 return array( 173 173 'response' => array( … … 187 187 * @return array 188 188 */ 189 public function filter_content_disposition_header_with_filename_without_quotes( $response, $ args, $url ) {189 public function filter_content_disposition_header_with_filename_without_quotes( $response, $parsed_args, $url ) { 190 190 return array( 191 191 'response' => array( … … 236 236 * @return array 237 237 */ 238 public function filter_content_disposition_header_with_filename_without_context( $response, $ args, $url ) {238 public function filter_content_disposition_header_with_filename_without_context( $response, $parsed_args, $url ) { 239 239 return array( 240 240 'response' => array( … … 254 254 * @return array 255 255 */ 256 public function filter_content_disposition_header_with_filename_with_inline_context( $response, $ args, $url ) {256 public function filter_content_disposition_header_with_filename_with_inline_context( $response, $parsed_args, $url ) { 257 257 return array( 258 258 'response' => array( … … 272 272 * @return array 273 273 */ 274 public function filter_content_disposition_header_with_filename_with_form_data_context( $response, $ args, $url ) {274 public function filter_content_disposition_header_with_filename_with_form_data_context( $response, $parsed_args, $url ) { 275 275 return array( 276 276 'response' => array( … … 366 366 * Mock the HTTP request response. 367 367 * 368 * @param bool $false False.369 * @param array $arguments Request arguments.370 * @param string $url Request URL.371 * @return array|bool372 */ 373 public function mock_http_request( $ false, $arguments, $url ) {368 * @param false|array|WP_Error $response A preemptive return value of an HTTP request. Default false. 369 * @param array $parsed_args HTTP request arguments. 370 * @param string $url The request URL. 371 * @return false|array|WP_Error Response data. 372 */ 373 public function mock_http_request( $response, $parsed_args, $url ) { 374 374 if ( 'https://example.com' === $url ) { 375 375 return array( … … 380 380 } 381 381 382 return $ false;382 return $response; 383 383 } 384 384 } -
trunk/tests/phpunit/tests/admin/wpSiteHealth.php
r54076 r55029 203 203 add_filter( 204 204 'pre_http_request', 205 function ( $r , $parsed_args ) use ( &$responses, &$is_unauthorized, $good_basic_auth, $delay_the_response, $threshold ) {205 function ( $response, $parsed_args ) use ( &$responses, &$is_unauthorized, $good_basic_auth, $delay_the_response, $threshold ) { 206 206 207 207 $expected_response = array_shift( $responses ); -
trunk/tests/phpunit/tests/functions/doEnclose.php
r52780 r55029 255 255 * @since 5.3.0 256 256 * 257 * @param bool $false False.258 * @param array $arguments Request arguments.259 * @param string $url Request URL.260 * @return array Header.261 */ 262 public function mock_http_request( $ false, $arguments, $url ) {257 * @param false|array|WP_Error $response A preemptive return value of an HTTP request. Default false. 258 * @param array $parsed_args HTTP request arguments. 259 * @param string $url The request URL. 260 * @return array Response data. 261 */ 262 public function mock_http_request( $response, $parsed_args, $url ) { 263 263 264 264 // Video and audio headers. -
trunk/tests/phpunit/tests/http/http.php
r54997 r55029 585 585 add_filter( 586 586 'pre_http_request', 587 function( $response, $ args, $url ) use ( &$pre_http_request_filter_has_run ) {587 function( $response, $parsed_args, $url ) use ( &$pre_http_request_filter_has_run ) { 588 588 $pre_http_request_filter_has_run = true; 589 589 -
trunk/tests/phpunit/tests/http/wpGetHttpHeaders.php
r52382 r55029 45 45 * Mock the HTTP request response 46 46 * 47 * @param bool $false False.48 * @param array $arguments Request arguments.49 * @param string $url Request URL.50 * @return array|bool47 * @param false|array|WP_Error $response A preemptive return value of an HTTP request. Default false. 48 * @param array $parsed_args HTTP request arguments. 49 * @param string $url The request URL. 50 * @return false|array|WP_Error Response data. 51 51 */ 52 public function mock_http_request( $ false, $arguments, $url ) {52 public function mock_http_request( $response, $parsed_args, $url ) { 53 53 if ( 'http://example.com' === $url ) { 54 54 return array( 'headers' => true ); 55 55 } 56 56 57 return false;57 return $response; 58 58 } 59 59 } -
trunk/tests/phpunit/tests/https-detection.php
r51657 r55029 265 265 } 266 266 267 public function record_request_url( $ preempt, $parsed_args, $url ) {267 public function record_request_url( $response, $parsed_args, $url ) { 268 268 $this->last_request_url = $url; 269 return $ preempt;270 } 271 272 public function mock_success_with_sslverify( $ preempt, $parsed_args ) {269 return $response; 270 } 271 272 public function mock_success_with_sslverify( $response, $parsed_args ) { 273 273 if ( ! empty( $parsed_args['sslverify'] ) ) { 274 274 return $this->mock_success(); 275 275 } 276 return $ preempt;277 } 278 279 public function mock_error_with_sslverify( $ preempt, $parsed_args ) {276 return $response; 277 } 278 279 public function mock_error_with_sslverify( $response, $parsed_args ) { 280 280 if ( ! empty( $parsed_args['sslverify'] ) ) { 281 281 return $this->mock_error(); 282 282 } 283 return $ preempt;284 } 285 286 public function mock_success_without_sslverify( $ preempt, $parsed_args ) {283 return $response; 284 } 285 286 public function mock_success_without_sslverify( $response, $parsed_args ) { 287 287 if ( empty( $parsed_args['sslverify'] ) ) { 288 288 return $this->mock_success(); 289 289 } 290 return $ preempt;291 } 292 293 public function mock_error_without_sslverify( $ preempt, $parsed_args ) {290 return $response; 291 } 292 293 public function mock_error_without_sslverify( $response, $parsed_args ) { 294 294 if ( empty( $parsed_args['sslverify'] ) ) { 295 295 return $this->mock_error(); 296 296 } 297 return $ preempt;297 return $response; 298 298 } 299 299 -
trunk/tests/phpunit/tests/oembed/controller.php
r54891 r55029 85 85 * Intercept oEmbed requests and mock responses. 86 86 * 87 * @param mixed $preempt Whether to preempt an HTTP request's return value. Default false.88 * @param mixed $rHTTP request arguments.89 * @param string $urlThe request URL.87 * @param false|array|WP_Error $response A preemptive return value of an HTTP request. Default false. 88 * @param array $parsed_args HTTP request arguments. 89 * @param string $url The request URL. 90 90 * @return array Response data. 91 91 */ 92 public function mock_embed_request( $ preempt, $r, $url ) {93 unset( $ preempt, $r);92 public function mock_embed_request( $response, $parsed_args, $url ) { 93 unset( $response, $parsed_args ); 94 94 95 95 $parsed_url = wp_parse_url( $url ); -
trunk/tests/phpunit/tests/rest-api/rest-block-directory-controller.php
r54058 r55029 275 275 add_filter( 276 276 'pre_http_request', 277 static function ( $re turn, $args, $url ) use ( $blocked_host ) {277 static function ( $response, $parsed_args, $url ) use ( $blocked_host ) { 278 278 if ( @parse_url( $url, PHP_URL_HOST ) === $blocked_host ) { 279 279 return new WP_Error( 'plugins_api_failed', "An expected error occurred connecting to $blocked_host because of a unit test", "cURL error 7: Failed to connect to $blocked_host port 80: Connection refused" ); … … 281 281 } 282 282 283 return $re turn;283 return $response; 284 284 }, 285 285 10, -
trunk/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php
r54058 r55029 523 523 add_filter( 524 524 'pre_http_request', 525 static function ( $ preempt, $args, $url ) use ( $action, $expects_results ) {525 static function ( $response, $parsed_args, $url ) use ( $action, $expects_results ) { 526 526 527 527 if ( 'api.wordpress.org' !== wp_parse_url( $url, PHP_URL_HOST ) ) { 528 return $ preempt;528 return $response; 529 529 } 530 530 … … 557 557 add_filter( 558 558 'pre_http_request', 559 static function ( $re turn, $args, $url ) use ( $blocked_host ) {559 static function ( $response, $parsed_args, $url ) use ( $blocked_host ) { 560 560 561 561 if ( wp_parse_url( $url, PHP_URL_HOST ) === $blocked_host ) { … … 568 568 } 569 569 570 return $re turn;570 return $response; 571 571 }, 572 572 10, -
trunk/tests/phpunit/tests/rest-api/rest-plugins-controller.php
r54304 r55029 1140 1140 add_filter( 1141 1141 'pre_http_request', 1142 static function ( $re turn, $args, $url ) use ( $blocked_host ) {1142 static function ( $response, $parsed_args, $url ) use ( $blocked_host ) { 1143 1143 if ( @parse_url( $url, PHP_URL_HOST ) === $blocked_host ) { 1144 1144 return new WP_Error( 'plugins_api_failed', "An expected error occurred connecting to $blocked_host because of a unit test", "cURL error 7: Failed to connect to $blocked_host port 80: Connection refused" ); … … 1146 1146 } 1147 1147 1148 return $re turn;1148 return $response; 1149 1149 }, 1150 1150 10, -
trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php
r54891 r55029 35 35 } 36 36 37 public function mock_embed_request( $ preempt, $r, $url ) {38 unset( $ preempt, $r);37 public function mock_embed_request( $response, $parsed_args, $url ) { 38 unset( $response, $parsed_args ); 39 39 40 40 // Mock request to YouTube Embed. -
trunk/tests/phpunit/tests/rest-api/wpRestUrlDetailsController.php
r54059 r55029 1097 1097 * @return array faux/mocked response. 1098 1098 */ 1099 public function mock_success_request_to_remote_url( $response, $ args ) {1100 return $this->mock_request_to_remote_url( 'success', $ args );1101 } 1102 1103 public function mock_failed_request_to_remote_url( $response, $ args ) {1104 return $this->mock_request_to_remote_url( 'failure', $ args );1105 } 1106 1107 public function mock_request_to_remote_url_with_empty_body_response( $response, $ args ) {1108 return $this->mock_request_to_remote_url( 'empty_body', $ args );1109 } 1110 1111 private function mock_request_to_remote_url( $result_type, $ args ) {1112 $this->request_args = $ args;1099 public function mock_success_request_to_remote_url( $response, $parsed_args ) { 1100 return $this->mock_request_to_remote_url( 'success', $parsed_args ); 1101 } 1102 1103 public function mock_failed_request_to_remote_url( $response, $parsed_args ) { 1104 return $this->mock_request_to_remote_url( 'failure', $parsed_args ); 1105 } 1106 1107 public function mock_request_to_remote_url_with_empty_body_response( $response, $parsed_args ) { 1108 return $this->mock_request_to_remote_url( 'empty_body', $parsed_args ); 1109 } 1110 1111 private function mock_request_to_remote_url( $result_type, $parsed_args ) { 1112 $this->request_args = $parsed_args; 1113 1113 1114 1114 $types = array(
Note: See TracChangeset
for help on using the changeset viewer.