Changeset 42578
- Timestamp:
- 01/23/2018 08:21:46 PM (6 years ago)
- Location:
- branches/4.9
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
branches/4.9/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
r41760 r42578 416 416 $existing_term = get_term( $term_id, $this->taxonomy ); 417 417 $term->add_data( $existing_term->term_id, 'term_exists' ); 418 $term->add_data( array( 'status' => 409 ) );418 $term->add_data( array( 'status' => 409, 'term_id' => $term_id ) ); 419 419 } 420 420 -
branches/4.9/tests/phpunit/tests/rest-api/rest-categories-controller.php
r41760 r42578 624 624 public function test_create_item_term_already_exists() { 625 625 wp_set_current_user( self::$administrator ); 626 $existing_id = $this->factory->category->create( array( 'name' => 'Existing' ) ); 627 626 628 $request = new WP_REST_Request( 'POST', '/wp/v2/categories' ); 627 $request->set_param( 'name', 'test' ); 628 $response = $this->server->dispatch( $request ); 629 $this->assertEquals( 201, $response->get_status() ); 629 $request->set_param( 'name', 'Existing' ); 630 630 631 $response = $this->server->dispatch( $request ); 631 632 $this->assertEquals( 409, $response->get_status() ); 632 633 $data = $response->get_data(); 633 634 $this->assertEquals( 'term_exists', $data['code'] ); 635 $this->assertEquals( $existing_id, (int) $data['data']['term_id'] ); 636 637 wp_delete_term( $existing_id, 'category' ); 634 638 } 635 639
Note: See TracChangeset
for help on using the changeset viewer.