Make WordPress Core

Ticket #29278: ticket29278.patch

File ticket29278.patch, 1.5 KB (added by djm1119, 10 years ago)
  • src/wp-includes/taxonomy.php

     
    29442944        $parsed_args['name'] = $name;
    29452945        $parsed_args['description'] = $description;
    29462946
     2947        if ( array_key_exists('term_group', $args) ) {
     2948                $term_group = wp_unslash( $args[ 'term_group' ] );
     2949                $parsed_args[ 'term_group' ] = $term_group;
     2950        }
     2951
    29472952        if ( '' == trim($name) )
    29482953                return new WP_Error('empty_term_name', __('A name is required for this term'));
    29492954
  • tests/phpunit/tests/taxonomy.php

     
    296296                $term20 = $this->factory->tag->create( array( 'name' => 'A--' ) );
    297297                $this->assertFalse( is_wp_error( $term20 ) );
    298298        }
     299
     300        /**
     301         * @ticket 29278
     302         */
     303        function test_update_term_updates_term_group() {
     304                $term = wp_insert_term( 'Test Term Group', 'category', array( 'term_group' => 1 ) );
     305                $this->assertFalse( is_wp_error( $term ) );
     306                $term_with_term_group = get_term_by( 'id', $term[ 'term_id' ], 'category' );
     307                $this->assertEquals( 0, $term_with_term_group->term_group );
     308                $term_with_new_term_group = wp_update_term( $term_with_term_group->term_id, 'category', array( 'term_group' => 1 ) );
     309                $updated_term = get_term_by( 'id', $term_with_new_term_group[ 'term_id' ], 'category' );
     310                $this->assertEquals( 1, $updated_term->term_group );
     311        }
    299312}