WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/12/2019 09:46:41 PM (2 years ago)
Author:
kadamwhite
Message:

REST API: Accept string path in rest_ensure_request.

Update rest_ensure_request() to accept a string path, permitting a string path to be passed to rest_do_request() as is indicated (previously inaccurately) in that method's PHPDoc.

Props TimothyBlynJacobs, kadamwhite.
Fixes #40614.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api.php

    r45607 r46099  
    745745        $GLOBALS['wp_rest_server'] = $rest_server;
    746746    }
     747
     748    /**
     749     * @ticket 40614
     750     */
     751    function test_rest_ensure_response_accepts_path_string() {
     752        $request = rest_ensure_request( '/wp/v2/posts' );
     753        $this->assertInstanceOf( 'WP_REST_Request', $request );
     754        $this->assertEquals( '/wp/v2/posts', $request->get_route() );
     755        $this->assertEquals( 'GET', $request->get_method() );
     756    }
    747757}
Note: See TracChangeset for help on using the changeset viewer.