WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/08/2019 04:43:10 AM (6 months ago)
Author:
kadamwhite
Message:

REST API: Permit embedding of the 'self' link relation in the /search endpoint.

Removes a special-case prohibition against embedding 'self' which prevented ?_embed from being used with the /wp/v2/search endpoint.

Props TimothyBlynJacobs, chrisvanpatten, kadamwhite.
Fixes #47684.

File:
1 edited

Legend:

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

    r44107 r46434  
    502502
    503503    /**
     504     * @ticket 47684
     505     */
     506    public function test_search_result_links_are_embedded() {
     507        $response = $this->do_request_with_params( array( 'per_page' => 1 ) );
     508        $data     = rest_get_server()->response_to_data( $response, true )[0];
     509
     510        $this->assertArrayHasKey( '_embedded', $data );
     511        $this->assertArrayHasKey( 'self', $data['_embedded'] );
     512        $this->assertCount( 1, $data['_embedded']['self'] );
     513        $this->assertArrayHasKey( WP_REST_Search_Controller::PROP_ID, $data['_embedded']['self'][0] );
     514        $this->assertEquals( $data[ WP_REST_Search_Controller::PROP_ID ], $data['_embedded']['self'][0][ WP_REST_Search_Controller::PROP_ID ] );
     515    }
     516
     517    /**
    504518     * Perform a REST request to our search endpoint with given parameters.
    505519     */
Note: See TracChangeset for help on using the changeset viewer.