[wp-trac] [WordPress Trac] #40142: WP Remote Remaining Methods

WordPress Trac noreply at wordpress.org
Tue Mar 28 16:23:31 UTC 2017


#40142: WP Remote Remaining Methods
-------------------------------------------------+-------------------------
 Reporter:  bhubbard                             |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
Component:  HTTP API                             |  Review
 Severity:  normal                               |     Version:  2.7
 Keywords:  has-patch 2nd-opinion needs-unit-    |  Resolution:
  tests                                          |     Focuses:
-------------------------------------------------+-------------------------

Comment (by johnbillion):

 It looks like there's no test coverage for the existing `wp_remote_get()`
 and `wp_remote_post()` functions with regard to the HTTP method they use.

 A test could look something like this, with `test_remote_methods()` using
 a dataProvider for each of the supported methods.

 {{{
 function test_remote_methods( $method, $expected_http_method ) {
         add_filter( 'pre_http_request', array( $this, 'http_catcher' ),
 10, 2 );

         call_user_func( "wp_remote_{$method}", 'http://example.com' );

         remove_filter( 'pre_http_request', array( $this, 'http_catcher' ),
 10, 2 );

         $this->assertSame( $this->http_args['method'],
 $expected_http_method );
 }

 function http_catcher( $preempt, $args ) {
         // log the args
         $this->http_args = $args;
         // short-circuit the request
         return true;
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40142#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list