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 05cc240c02..8b09076da0 100644
a
|
b
|
class WP_REST_Server { |
564 | 564 | $embedded = array(); |
565 | 565 | |
566 | 566 | foreach ( $data['_links'] as $rel => $links ) { |
567 | | // Ignore links to self, for obvious reasons. |
568 | | if ( 'self' === $rel ) { |
569 | | continue; |
570 | | } |
571 | | |
572 | 567 | $embeds = array(); |
573 | 568 | |
574 | 569 | foreach ( $links as $item ) { |
diff --git a/tests/phpunit/tests/rest-api/rest-search-controller.php b/tests/phpunit/tests/rest-api/rest-search-controller.php
index 60d1ef0bfb..9a3982a701 100644
a
|
b
|
class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { |
500 | 500 | $this->assertEqualSets( array( 'test_first_type', 'test_second_type', WP_REST_Search_Controller::TYPE_ANY ), $params[ WP_REST_Search_Controller::PROP_SUBTYPE ]['items']['enum'] ); |
501 | 501 | } |
502 | 502 | |
| 503 | /** |
| 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 | |
503 | 517 | /** |
504 | 518 | * Perform a REST request to our search endpoint with given parameters. |
505 | 519 | */ |
diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php
index efb656ed4e..d2dc693334 100644
a
|
b
|
class Tests_REST_Server extends WP_Test_REST_TestCase { |
569 | 569 | |
570 | 570 | /** |
571 | 571 | * @depends test_link_embedding |
| 572 | * @ticket 47684 |
572 | 573 | */ |
573 | 574 | public function test_link_embedding_self() { |
574 | 575 | // Register our testing route. |
… |
… |
class Tests_REST_Server extends WP_Test_REST_TestCase { |
587 | 588 | |
588 | 589 | $data = rest_get_server()->response_to_data( $response, true ); |
589 | 590 | |
590 | | $this->assertArrayNotHasKey( '_embedded', $data ); |
| 591 | $this->assertArrayHasKey( '_embedded', $data ); |
591 | 592 | } |
592 | 593 | |
593 | 594 | /** |