Changeset 57659
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-server.php
r57623 r57659 744 744 } 745 745 746 // Embedded resources get passed context=embed. 747 if ( empty( $request['context'] ) ) { 748 $request['context'] = 'embed'; 749 } 750 746 751 if ( empty( $request['per_page'] ) ) { 747 752 $matched = $this->match_request_to_handler( $request ); … … 749 754 $request['per_page'] = (int) $matched[1]['args']['per_page']['maximum']; 750 755 } 751 }752 753 // Embedded resources get passed context=embed.754 if ( empty( $request['context'] ) ) {755 $request['context'] = 'embed';756 756 } 757 757 -
trunk/tests/phpunit/tests/rest-api/rest-navigation-fallback-controller.php
r57656 r57659 161 161 $request = new WP_REST_Request( 'GET', '/wp-block-editor/v1/navigation-fallback' ); 162 162 $response = rest_get_server()->dispatch( $request ); 163 $links = $response->get_links(); 164 165 // Extract the navigation endpoint URL from the response. 166 $embedded_navigation_href = $links['self'][0]['href']; 167 preg_match( '/\?rest_route=(.*)/', $embedded_navigation_href, $matches ); 168 $navigation_endpoint = $matches[1]; 169 170 // Fetch the "linked" navigation post from the endpoint, with the context parameter set to 'embed' to simulate fetching embedded links. 171 $request = new WP_REST_Request( 'GET', $navigation_endpoint ); 172 $request->set_param( 'context', 'embed' ); 173 $response = rest_get_server()->dispatch( $request ); 174 $data = $response->get_data(); 163 $data = rest_get_server()->response_to_data( $response, true ); 164 $embedded = $data['_embedded']['self'][0]; 175 165 176 166 // Verify that the additional status field is present. 177 $this->assertArrayHasKey( 'status', $ data, 'Response title should contain a "status" field.' );167 $this->assertArrayHasKey( 'status', $embedded, 'Response title should contain a "status" field.' ); 178 168 179 169 // Verify that the additional content fields are present. 180 $this->assertArrayHasKey( 'content', $ data, 'Response should contain a "content" field.' );181 $this->assertArrayHasKey( 'raw', $ data['content'], 'Response content should contain a "raw" field.' );182 $this->assertArrayHasKey( 'rendered', $ data['content'], 'Response content should contain a "rendered" field.' );183 $this->assertArrayHasKey( 'block_version', $ data['content'], 'Response should contain a "block_version" field.' );170 $this->assertArrayHasKey( 'content', $embedded, 'Response should contain a "content" field.' ); 171 $this->assertArrayHasKey( 'raw', $embedded['content'], 'Response content should contain a "raw" field.' ); 172 $this->assertArrayHasKey( 'rendered', $embedded['content'], 'Response content should contain a "rendered" field.' ); 173 $this->assertArrayHasKey( 'block_version', $embedded['content'], 'Response should contain a "block_version" field.' ); 184 174 185 175 // Verify that the additional title.raw field is present. 186 $this->assertArrayHasKey( 'raw', $ data['title'], 'Response title should contain a "raw" key.' );176 $this->assertArrayHasKey( 'raw', $embedded['title'], 'Response title should contain a "raw" key.' ); 187 177 } 188 178
Note: See TracChangeset
for help on using the changeset viewer.