Make WordPress Core


Ignore:
Timestamp:
01/05/2023 10:21:19 AM (22 months 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/http/wpGetHttpHeaders.php

    r52382 r55029  
    4545     * Mock the HTTP request response
    4646     *
    47      * @param bool   $false     False.
    48      * @param array  $arguments Request arguments.
    49      * @param string $url       Request URL.
    50      * @return array|bool
     47     * @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.
    5151     */
    52     public function mock_http_request( $false, $arguments, $url ) {
     52    public function mock_http_request( $response, $parsed_args, $url ) {
    5353        if ( 'http://example.com' === $url ) {
    5454            return array( 'headers' => true );
    5555        }
    5656
    57         return false;
     57        return $response;
    5858    }
    5959}
Note: See TracChangeset for help on using the changeset viewer.