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/rest-api/rest-pattern-directory-controller.php

    r54058 r55029  
    523523        add_filter(
    524524            'pre_http_request',
    525             static function ( $preempt, $args, $url ) use ( $action, $expects_results ) {
     525            static function ( $response, $parsed_args, $url ) use ( $action, $expects_results ) {
    526526
    527527                if ( 'api.wordpress.org' !== wp_parse_url( $url, PHP_URL_HOST ) ) {
    528                     return $preempt;
     528                    return $response;
    529529                }
    530530
     
    557557        add_filter(
    558558            'pre_http_request',
    559             static function ( $return, $args, $url ) use ( $blocked_host ) {
     559            static function ( $response, $parsed_args, $url ) use ( $blocked_host ) {
    560560
    561561                if ( wp_parse_url( $url, PHP_URL_HOST ) === $blocked_host ) {
     
    568568                }
    569569
    570                 return $return;
     570                return $response;
    571571            },
    572572            10,
Note: See TracChangeset for help on using the changeset viewer.