Changeset 41737
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
r41731 r41737 406 406 $existing_term = get_term( $term_id, $this->taxonomy ); 407 407 $term->add_data( $existing_term->term_id, 'term_exists' ); 408 $term->add_data( array( 'status' => 409 ) ); 408 409 } 409 410 -
trunk/tests/phpunit/tests/rest-api/rest-categories-controller.php
r39896 r41737 603 603 } 604 604 605 /** 606 * @ticket 41370 607 */ 608 public function test_create_item_term_already_exists() { 609 wp_set_current_user( self::$administrator ); 610 $request = new WP_REST_Request( 'POST', '/wp/v2/categories' ); 611 $request->set_param( 'name', 'test' ); 612 $response = $this->server->dispatch( $request ); 613 $this->assertEquals( 201, $response->get_status() ); 614 $response = $this->server->dispatch( $request ); 615 $this->assertEquals( 409, $response->get_status() ); 616 $data = $response->get_data(); 617 $this->assertEquals( 'term_exists', $data['code'] ); 618 } 619 605 620 public function test_create_item_invalid_taxonomy() { 606 621 wp_set_current_user( self::$administrator );
Note: See TracChangeset
for help on using the changeset viewer.