REST API: Fix links format in OPTIONS requests for non-variable routes.

Props nsundberg, johnwatkins0, birgire.
Fixes #49149.


git-svn-id: https://develop.svn.wordpress.org/trunk@47326 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Timothy Jacobs
2020-02-20 00:53:43 +00:00
parent 727faabe98
commit be371a7431
2 changed files with 28 additions and 1 deletions
@@ -1020,6 +1020,29 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
$this->assertContains( 'test/another', $namespaces );
}
/**
* @ticket 49147
*/
public function test_get_data_for_non_variable_route_includes_links() {
$expected = array(
'self' => array(
array( 'href' => rest_url( 'wp/v2/posts' ) ),
),
);
$actual = rest_get_server()->get_data_for_route(
'/wp/v2/posts',
array(
array(
'methods' => array( 'OPTIONS' => 1 ),
'show_in_index' => true,
),
)
);
$this->assertEquals( $expected, $actual['_links'] );
}
public function test_x_robot_tag_header_on_requests() {
$request = new WP_REST_Request( 'GET', '/', array() );