Changeset 46434
- Timestamp:
- 10/08/2019 04:43:10 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-server.php
r46206 r46434 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 -
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r46280 r46434 1364 1364 $this->assertEquals( rest_url( '/wp/v2/posts/' . self::$post_id ), $links['self'][0]['href'] ); 1365 1365 $this->assertEquals( rest_url( '/wp/v2/posts' ), $links['collection'][0]['href'] ); 1366 $this->assertArrayNotHasKey( 'embeddable', $links['self'][0]['attributes'] ); 1366 1367 1367 1368 $this->assertEquals( rest_url( '/wp/v2/types/' . get_post_type( self::$post_id ) ), $links['about'][0]['href'] ); -
trunk/tests/phpunit/tests/rest-api/rest-search-controller.php
r44107 r46434 502 502 503 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 517 /** 504 518 * Perform a REST request to our search endpoint with given parameters. 505 519 */ -
trunk/tests/phpunit/tests/rest-api/rest-server.php
r45809 r46434 570 570 /** 571 571 * @depends test_link_embedding 572 * @ticket 47684 572 573 */ 573 574 public function test_link_embedding_self() { … … 583 584 $response = new WP_REST_Response(); 584 585 585 // 'self' should be ignored. 586 $response->add_link( 'self', rest_url( '/test/notembeddable' ), array( 'embeddable' => true ) ); 586 // 'self' should not be special-cased, and may be marked embeddable. 587 $response->add_link( 'self', rest_url( '/test/embeddable' ), array( 'embeddable' => true ) ); 588 589 $data = rest_get_server()->response_to_data( $response, true ); 590 591 $this->assertArrayHasKey( '_embedded', $data ); 592 } 593 594 /** 595 * @depends test_link_embedding 596 * @ticket 47684 597 */ 598 public function test_link_embedding_self_non_embeddable() { 599 // Register our testing route. 600 rest_get_server()->register_route( 601 'test', 602 '/test/embeddable', 603 array( 604 'methods' => 'GET', 605 'callback' => array( $this, 'embedded_response_callback' ), 606 ) 607 ); 608 $response = new WP_REST_Response(); 609 610 // 'self' should not be special-cased, and should be ignored if not marked embeddable. 611 $response->add_link( 'self', rest_url( '/test/notembeddable' ) ); 587 612 588 613 $data = rest_get_server()->response_to_data( $response, true );
Note: See TracChangeset
for help on using the changeset viewer.