Changeset 64828
- Timestamp:
- 10/27/2026 07:40:58 PM (4 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/wpRestTemplatesController.php
r64390 r64828 945 945 946 946 /** 947 * @doesNotPerformAssertions 947 * @ticket 40538 948 * 949 * @covers WP_REST_Templates_Controller::prepare_item_for_response 948 950 */ 949 951 public function test_prepare_item() { 950 // Controller does not implement prepare_item(). 952 wp_set_current_user( self::$admin_id ); 953 954 $endpoint = new WP_REST_Templates_Controller( 'wp_template' ); 955 $request = new WP_REST_Request( 'GET', '/wp/v2/templates/default//my_template' ); 956 $request->set_param( 'context', 'edit' ); 957 $template = get_block_template( 'default//my_template', 'wp_template' ); 958 $response = $endpoint->prepare_item_for_response( $template, $request ); 959 960 $this->assertInstanceOf( WP_REST_Response::class, $response ); 961 $this->assertSame( 200, $response->get_status() ); 962 963 $data = $response->get_data(); 964 $this->assertSame( 'default//my_template', $data['id'] ); 965 $this->assertSame( 'default', $data['theme'] ); 966 $this->assertSame( 'my_template', $data['slug'] ); 967 $this->assertSame( 'wp_template', $data['type'] ); 968 $this->assertSame( 'custom', $data['source'] ); 969 $this->assertSame( 'Description of my template.', $data['description'] ); 970 $this->assertSame( 'My Template', $data['title']['raw'] ); 971 $this->assertSame( 'publish', $data['status'] ); 972 $this->assertSame( self::$template_post->ID, $data['wp_id'] ); 973 974 $links = test_rest_expand_compact_links( $response->get_links() ); 975 $this->assertSame( rest_url( 'wp/v2/templates/default//my_template' ), $links['self'][0]['href'] ); 976 $this->assertSame( rest_url( 'wp/v2/templates' ), $links['collection'][0]['href'] ); 977 $this->assertSame( rest_url( 'wp/v2/types/wp_template' ), $links['about'][0]['href'] ); 951 978 } 952 979
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)