Changeset 39055
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
r39049 r39055 1197 1197 } 1198 1198 1199 $terms = array_map( 'absint', $request[ $base ] ); 1200 $result = wp_set_object_terms( $post_id, $terms, $taxonomy->name ); 1199 $result = wp_set_object_terms( $post_id, $request[ $base ], $taxonomy->name ); 1201 1200 1202 1201 if ( is_wp_error( $result ) ) { … … 1966 1965 'type' => 'integer', 1967 1966 ), 1967 'arg_options' => array( 1968 'sanitize_callback' => 'wp_parse_id_list', 1969 ), 1968 1970 'context' => array( 'view', 'edit' ), 1969 1971 ); … … 1971 1973 'description' => sprintf( __( 'The terms in the %s taxonomy that should not be assigned to the object.' ), $taxonomy->name ), 1972 1974 'type' => 'array', 1975 'items' => array( 1976 'type' => 'integer', 1977 ), 1978 'arg_options' => array( 1979 'sanitize_callback' => 'wp_parse_id_list', 1980 ), 1973 1981 'context' => array( 'view', 'edit' ), 1974 1982 ); -
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r39047 r39055 200 200 $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) ); 201 201 $this->assertTrue( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) ); 202 202 203 $request->set_param( 'exclude', array( $id2 ) ); 204 $response = $this->server->dispatch( $request ); 205 $data = $response->get_data(); 206 $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) ); 207 $this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) ); 208 209 $request->set_param( 'exclude', "$id2" ); 203 210 $response = $this->server->dispatch( $request ); 204 211 $data = $response->get_data(); … … 1303 1310 $data = $response->get_data(); 1304 1311 $this->assertEquals( array( $category['term_id'] ), $data['categories'] ); 1312 } 1313 1314 public function test_create_post_with_categories_as_csv() { 1315 wp_set_current_user( self::$editor_id ); 1316 $category = wp_insert_term( 'Chicken', 'category' ); 1317 $category2 = wp_insert_term( 'Ribs', 'category' ); 1318 $request = new WP_REST_Request( 'POST', '/wp/v2/posts' ); 1319 $params = $this->set_post_data( array( 1320 'categories' => $category['term_id'] . ',' . $category2['term_id'], 1321 ) ); 1322 $request->set_body_params( $params ); 1323 $response = $this->server->dispatch( $request ); 1324 1325 $data = $response->get_data(); 1326 $this->assertEquals( array( $category['term_id'], $category2['term_id'] ), $data['categories'] ); 1305 1327 } 1306 1328
Note: See TracChangeset
for help on using the changeset viewer.