Changeset 57380
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
r57312 r57380 185 185 if ( is_wp_error( $fields_update ) ) { 186 186 return $fields_update; 187 } 188 189 $terms_update = $this->handle_terms( $attachment_id, $request ); 190 191 if ( is_wp_error( $terms_update ) ) { 192 return $terms_update; 187 193 } 188 194 -
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r56549 r57380 1044 1044 $attachment = $response->get_data(); 1045 1045 $this->assertStringNotContainsString( ABSPATH, get_post_meta( $attachment['id'], '_wp_attached_file', true ) ); 1046 } 1047 1048 /** 1049 * @ticket 57897 1050 * 1051 * @requires function imagejpeg 1052 */ 1053 public function test_create_item_with_terms() { 1054 wp_set_current_user( self::$author_id ); 1055 register_taxonomy_for_object_type( 'category', 'attachment' ); 1056 $category = wp_insert_term( 'Media Category', 'category' ); 1057 $request = new WP_REST_Request( 'POST', '/wp/v2/media' ); 1058 $request->set_header( 'Content-Type', 'image/jpeg' ); 1059 $request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' ); 1060 1061 $request->set_body( file_get_contents( self::$test_file ) ); 1062 $request->set_param( 'categories', array( $category['term_id'] ) ); 1063 $response = rest_get_server()->dispatch( $request ); 1064 $attachment = $response->get_data(); 1065 1066 $term = wp_get_post_terms( $attachment['id'], 'category' ); 1067 $this->assertSame( $category['term_id'], $term[0]->term_id ); 1046 1068 } 1047 1069
Note: See TracChangeset
for help on using the changeset viewer.