Make WordPress Core


Ignore:
Timestamp:
01/05/2023 10:21:19 AM (18 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/https-detection.php

    r51657 r55029  
    265265    }
    266266
    267     public function record_request_url( $preempt, $parsed_args, $url ) {
     267    public function record_request_url( $response, $parsed_args, $url ) {
    268268        $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 ) {
    273273        if ( ! empty( $parsed_args['sslverify'] ) ) {
    274274            return $this->mock_success();
    275275        }
    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 ) {
    280280        if ( ! empty( $parsed_args['sslverify'] ) ) {
    281281            return $this->mock_error();
    282282        }
    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 ) {
    287287        if ( empty( $parsed_args['sslverify'] ) ) {
    288288            return $this->mock_success();
    289289        }
    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 ) {
    294294        if ( empty( $parsed_args['sslverify'] ) ) {
    295295            return $this->mock_error();
    296296        }
    297         return $preempt;
     297        return $response;
    298298    }
    299299
Note: See TracChangeset for help on using the changeset viewer.