- Timestamp:
- 11/09/2016 07:12:01 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r39156 r39182 1024 1024 1025 1025 $this->check_create_post_response( $response ); 1026 } 1027 1028 /** 1029 * @ticket 38698 1030 */ 1031 public function test_create_item_with_template() { 1032 wp_set_current_user( self::$editor_id ); 1033 add_filter( 'theme_post_templates', array( $this, 'filter_theme_post_templates' ) ); 1034 1035 $request = new WP_REST_Request( 'POST', '/wp/v2/posts' ); 1036 $params = $this->set_post_data( array( 1037 'template' => 'post-my-test-template.php', 1038 ) ); 1039 $request->set_body_params( $params ); 1040 $response = $this->server->dispatch( $request ); 1041 1042 $data = $response->get_data(); 1043 $post_template = get_page_template_slug( get_post( $data['id'] ) ); 1044 1045 remove_filter( 'theme_post_templates', array( $this, 'filter_theme_post_templates' ) ); 1046 1047 $this->assertEquals( 'post-my-test-template.php', $data['template'] ); 1048 $this->assertEquals( 'post-my-test-template.php', $post_template ); 1049 } 1050 1051 /** 1052 * @ticket 38698 1053 */ 1054 public function test_create_item_with_template_none_available() { 1055 wp_set_current_user( self::$editor_id ); 1056 1057 $request = new WP_REST_Request( 'POST', '/wp/v2/posts' ); 1058 $params = $this->set_post_data( array( 1059 'template' => 'post-my-test-template.php', 1060 ) ); 1061 $request->set_body_params( $params ); 1062 $response = $this->server->dispatch( $request ); 1063 1064 $data = $response->get_data(); 1065 $post_template = get_page_template_slug( get_post( $data['id'] ) ); 1066 1067 $this->assertEquals( '', $data['template'] ); 1068 $this->assertEquals( '', $post_template ); 1026 1069 } 1027 1070 … … 2318 2361 $data = $response->get_data(); 2319 2362 $properties = $data['schema']['properties']; 2320 $this->assertEquals( 2 3, count( $properties ) );2363 $this->assertEquals( 24, count( $properties ) ); 2321 2364 $this->assertArrayHasKey( 'author', $properties ); 2322 2365 $this->assertArrayHasKey( 'comment_status', $properties ); … … 2338 2381 $this->assertArrayHasKey( 'status', $properties ); 2339 2382 $this->assertArrayHasKey( 'sticky', $properties ); 2383 $this->assertArrayHasKey( 'template', $properties ); 2340 2384 $this->assertArrayHasKey( 'title', $properties ); 2341 2385 $this->assertArrayHasKey( 'type', $properties ); … … 2470 2514 } 2471 2515 2516 public function filter_theme_post_templates( $post_templates ) { 2517 return array( 2518 'post-my-test-template.php' => 'My Test Template', 2519 ); 2520 } 2472 2521 }
Note: See TracChangeset
for help on using the changeset viewer.