- Timestamp:
- 04/03/2024 03:09:38 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/wpRestTemplatesController.php
r57790 r57919 15 15 */ 16 16 protected static $admin_id; 17 private static $post; 17 private static $template_post; 18 private static $template_part_post; 18 19 19 20 /** … … 30 31 31 32 // Set up template post. 32 $args = array(33 $args = array( 33 34 'post_type' => 'wp_template', 34 35 'post_name' => 'my_template', … … 42 43 ), 43 44 ); 44 self::$post = self::factory()->post->create_and_get( $args ); 45 wp_set_post_terms( self::$post->ID, get_stylesheet(), 'wp_theme' ); 45 self::$template_post = self::factory()->post->create_and_get( $args ); 46 wp_set_post_terms( self::$template_post->ID, get_stylesheet(), 'wp_theme' ); 47 48 // Set up template part post. 49 $args = array( 50 'post_type' => 'wp_template_part', 51 'post_name' => 'my_template_part', 52 'post_title' => 'My Template Part', 53 'post_content' => 'Content', 54 'post_excerpt' => 'Description of my template part.', 55 'tax_input' => array( 56 'wp_theme' => array( 57 get_stylesheet(), 58 ), 59 'wp_template_part_area' => array( 60 WP_TEMPLATE_PART_AREA_HEADER, 61 ), 62 ), 63 ); 64 self::$template_part_post = self::factory()->post->create_and_get( $args ); 65 wp_set_post_terms( self::$template_part_post->ID, get_stylesheet(), 'wp_theme' ); 66 wp_set_post_terms( self::$template_part_post->ID, WP_TEMPLATE_PART_AREA_HEADER, 'wp_template_part_area' ); 46 67 } 47 68 48 69 public static function wpTearDownAfterClass() { 49 wp_delete_post( self::$ post->ID );70 wp_delete_post( self::$template_post->ID ); 50 71 } 51 72 … … 57 78 public function tear_down() { 58 79 if ( has_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes' ) ) { 59 remove_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes' , 10);80 remove_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes' ); 60 81 } 61 82 if ( WP_Block_Type_Registry::get_instance()->is_registered( 'tests/block' ) ) { … … 131 152 ), 132 153 'status' => 'publish', 133 'wp_id' => self::$ post->ID,154 'wp_id' => self::$template_post->ID, 134 155 'has_theme_file' => false, 135 156 'is_custom' => true, 136 157 'author' => 0, 137 'modified' => mysql_to_rfc3339( self::$ post->post_modified ),158 'modified' => mysql_to_rfc3339( self::$template_post->post_modified ), 138 159 'author_text' => 'Test Blog', 139 160 'original_source' => 'site', … … 178 199 ), 179 200 'status' => 'publish', 180 'wp_id' => self::$ post->ID,201 'wp_id' => self::$template_post->ID, 181 202 'has_theme_file' => false, 182 203 'is_custom' => true, 183 204 'author' => 0, 184 'modified' => mysql_to_rfc3339( self::$ post->post_modified ),205 'modified' => mysql_to_rfc3339( self::$template_post->post_modified ), 185 206 'author_text' => 'Test Blog', 186 207 'original_source' => 'site', … … 217 238 ), 218 239 'status' => 'publish', 219 'wp_id' => self::$ post->ID,240 'wp_id' => self::$template_post->ID, 220 241 'has_theme_file' => false, 221 242 'is_custom' => true, 222 243 'author' => 0, 223 'modified' => mysql_to_rfc3339( self::$ post->post_modified ),244 'modified' => mysql_to_rfc3339( self::$template_post->post_modified ), 224 245 'author_text' => 'Test Blog', 225 246 'original_source' => 'site', … … 945 966 ); 946 967 947 add_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes' , 10, 2);968 add_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes' ); 948 969 949 970 $endpoint = new WP_REST_Templates_Controller( 'wp_template_part' ); … … 952 973 $prepare_item_for_database->setAccessible( true ); 953 974 975 $id = get_stylesheet() . '//' . 'my_template_part'; 954 976 $body_params = array( 955 ' title' => 'Untitled Template Part',956 'slug' => ' untitled-template-part',977 'id' => $id, 978 'slug' => 'my_template_part', 957 979 'content' => '<!-- wp:tests/anchor-block -->Hello<!-- /wp:tests/anchor-block -->', 958 980 );
Note: See TracChangeset
for help on using the changeset viewer.