Make WordPress Core

Ticket #40614: 40614.4.diff

File 40614.4.diff, 1.4 KB (added by kadamwhite, 5 years ago)

Change redundant test docbloc to a @ticket annotation

  • src/wp-includes/rest-api.php

    diff --git src/wp-includes/rest-api.php src/wp-includes/rest-api.php
    index 1e4e23617b..89c4e6bb3a 100644
    function rest_get_server() { 
    482482 * Ensures request arguments are a request object (for consistency).
    483483 *
    484484 * @since 4.4.0
     485 * @since 5.3.0 Accept string argument for the request path.
    485486 *
    486  * @param array|WP_REST_Request $request Request to check.
     487 * @param array|string|WP_REST_Request $request Request to check.
    487488 * @return WP_REST_Request REST request instance.
    488489 */
    489490function rest_ensure_request( $request ) {
    function rest_ensure_request( $request ) { 
    491492                return $request;
    492493        }
    493494
     495        if ( is_string( $request ) ) {
     496                return new WP_REST_Request( 'GET', $request );
     497        }
     498
    494499        return new WP_REST_Request( 'GET', '', $request );
    495500}
    496501
  • tests/phpunit/tests/rest-api.php

    diff --git tests/phpunit/tests/rest-api.php tests/phpunit/tests/rest-api.php
    index 237fd71ee4..802c57a8f8 100644
    class Tests_REST_API extends WP_UnitTestCase { 
    744744
    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}