Ticket #42600: 42600.diff
File 42600.diff, 1.8 KB (added by , 7 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
415 415 if ( $term_id = $term->get_error_data( 'term_exists' ) ) { 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 421 421 return $term; -
tests/phpunit/tests/rest-api/rest-categories-controller.php
620 620 621 621 /** 622 622 * @ticket 41370 623 * @ticket 42600 623 624 */ 624 625 public function test_create_item_term_already_exists() { 625 626 wp_set_current_user( self::$administrator ); … … 627 628 $request->set_param( 'name', 'test' ); 628 629 $response = $this->server->dispatch( $request ); 629 630 $this->assertEquals( 201, $response->get_status() ); 631 632 $data = $response->get_data(); 633 $term_id = $data['id']; 634 $this->assertTrue( (int) $term_id > 0 ); 635 630 636 $response = $this->server->dispatch( $request ); 631 637 $this->assertEquals( 409, $response->get_status() ); 632 638 $data = $response->get_data(); 633 639 $this->assertEquals( 'term_exists', $data['code'] ); 640 641 $data = $response->get_data(); 642 $this->assertEquals( (int) $data['data']['term_id'], $term_id ); 643 634 644 } 635 645 636 646 public function test_create_item_invalid_taxonomy() {