Make WordPress Core


Ignore:
Timestamp:
01/05/2023 10:21:19 AM (2 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/functions/doEnclose.php

    r52780 r55029  
    255255     * @since 5.3.0
    256256     *
    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 ) {
    263263
    264264        // Video and audio headers.
Note: See TracChangeset for help on using the changeset viewer.