Make WordPress Core


Ignore:
Timestamp:
01/05/2023 10:21:19 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Bring some consistency to mocking HTTP requests in unit tests.

Includes:

  • Renaming the $preempt parameter to $response in the pre_http_request filter to better match the context used in callbacks (returning the original value if the conditions are not met rather than preempting the request).
  • Synchronizing parameter names and types in various pre_http_request callbacks in unit tests.

Follow-up to [34509], [37907], [40628], [40629], [45667], [46175], [48242], [48462], [49904], [51021], [51973], [52146], [52382], [54043], [54968].

See #56793, #56792.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/wpRestUrlDetailsController.php

    r54059 r55029  
    10971097         * @return array faux/mocked response.
    10981098         */
    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;
    11131113
    11141114                $types = array(
Note: See TracChangeset for help on using the changeset viewer.