Make WordPress Core

Ticket #47684: 47684.2.diff

File 47684.2.diff, 2.5 KB (added by TimothyBlynJacobs, 5 years ago)
  • src/wp-includes/rest-api/class-wp-rest-server.php

    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 { 
    564564                $embedded = array();
    565565
    566566                foreach ( $data['_links'] as $rel => $links ) {
    567                         // Ignore links to self, for obvious reasons.
    568                         if ( 'self' === $rel ) {
    569                                 continue;
    570                         }
    571 
    572567                        $embeds = array();
    573568
    574569                        foreach ( $links as $item ) {
  • tests/phpunit/tests/rest-api/rest-search-controller.php

    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 { 
    500500                $this->assertEqualSets( array( 'test_first_type', 'test_second_type', WP_REST_Search_Controller::TYPE_ANY ), $params[ WP_REST_Search_Controller::PROP_SUBTYPE ]['items']['enum'] );
    501501        }
    502502
     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
    503517        /**
    504518         * Perform a REST request to our search endpoint with given parameters.
    505519         */
  • tests/phpunit/tests/rest-api/rest-server.php

    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 { 
    569569
    570570        /**
    571571         * @depends test_link_embedding
     572         * @ticket 47684
    572573         */
    573574        public function test_link_embedding_self() {
    574575                // Register our testing route.
    class Tests_REST_Server extends WP_Test_REST_TestCase { 
    587588
    588589                $data = rest_get_server()->response_to_data( $response, true );
    589590
    590                 $this->assertArrayNotHasKey( '_embedded', $data );
     591                $this->assertArrayHasKey( '_embedded', $data );
    591592        }
    592593
    593594        /**