diff --git a/src/wp-includes/rest-api/class-wp-rest-server.php b/src/wp-includes/rest-api/class-wp-rest-server.php
index efda2321b7..12de6c55f0 100644
a
|
b
|
class WP_REST_Server { |
1288 | 1288 | // For non-variable routes, generate links. |
1289 | 1289 | if ( strpos( $route, '{' ) === false ) { |
1290 | 1290 | $data['_links'] = array( |
1291 | | 'self' => rest_url( $route ), |
| 1291 | 'self' => array( |
| 1292 | array( |
| 1293 | 'href' => rest_url( $route ), |
| 1294 | ), |
| 1295 | ), |
1292 | 1296 | ); |
1293 | 1297 | } |
1294 | 1298 | } |
diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php
index 755f0296ea..afcd1c52b6 100644
a
|
b
|
|
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** |
10 | | * @group restapi |
| 10 | * @group restapi22 |
11 | 11 | */ |
12 | 12 | class Tests_REST_Server extends WP_Test_REST_TestCase { |
13 | 13 | public function setUp() { |
… |
… |
class Tests_REST_Server extends WP_Test_REST_TestCase { |
1020 | 1020 | $this->assertContains( 'test/another', $namespaces ); |
1021 | 1021 | } |
1022 | 1022 | |
| 1023 | /** |
| 1024 | * Tests that the schema _links array is correctly formatted in non-variable REST routes. |
| 1025 | * |
| 1026 | * @ticket 49147 |
| 1027 | */ |
| 1028 | public function test_links_array_in_non_variable_routes() { |
| 1029 | $this->set_permalink_structure( '/%postname%' ); |
| 1030 | |
| 1031 | $server = new WP_REST_Server(); |
| 1032 | |
| 1033 | $links = array( |
| 1034 | 'self' => array( |
| 1035 | array( 'href' => 'http://example.org/wp-json/wp/v2/posts' ), |
| 1036 | ), |
| 1037 | ); |
| 1038 | |
| 1039 | $result = $server->get_data_for_route( |
| 1040 | '/wp/v2/posts', |
| 1041 | array( |
| 1042 | array( |
| 1043 | 'methods' => array( 'OPTIONS' => 1 ), |
| 1044 | 'show_in_index' => true, |
| 1045 | ), |
| 1046 | ) |
| 1047 | ); |
| 1048 | |
| 1049 | $this->assertEquals( |
| 1050 | $result['_links'], |
| 1051 | $links |
| 1052 | ); |
| 1053 | } |
| 1054 | |
1023 | 1055 | public function test_x_robot_tag_header_on_requests() { |
1024 | 1056 | $request = new WP_REST_Request( 'GET', '/', array() ); |
1025 | 1057 | |