Make WordPress Core

Ticket #31135: 31135.3.patch

File 31135.3.patch, 1.4 KB (added by tyxla, 9 years ago)

Updating unit tests as per @DrewAPicture's suggestions.

  • src/wp-includes/taxonomy.php

     
    341341        );
    342342        $args = wp_parse_args( $args, $defaults );
    343343
    344         if ( strlen( $taxonomy ) > 32 ) {
    345                 _doing_it_wrong( __FUNCTION__, __( 'Taxonomies cannot exceed 32 characters in length' ), '4.0' );
    346                 return new WP_Error( 'taxonomy_too_long', __( 'Taxonomies cannot exceed 32 characters in length' ) );
     344        $taxonomy_length = strlen( $taxonomy );
     345        if ( $taxonomy_length < 1 || $taxonomy_length > 32 ) {
     346                _doing_it_wrong( __FUNCTION__, __( 'Taxonomies must be between 1 and 32 characters in length.' ), '4.2' );
     347                return new WP_Error( 'taxonomy_length_invalid', __( 'Taxonomies must be between 1 and 32 characters in length.' ) );
    347348        }
    348349
    349350        if ( false !== $args['query_var'] && ! empty( $wp ) ) {
  • tests/phpunit/tests/taxonomy.php

     
    154154        }
    155155
    156156        /**
     157         * @ticket 31135
     158         *
     159         * @expectedIncorrectUsage register_taxonomy
     160         */
     161        function test_register_short_taxonomy() {
     162                $this->assertInstanceOf( 'WP_Error', register_taxonomy( '', 'post', array() ) );
     163        }
     164
     165        /**
    157166         * @ticket 21593
    158167         *
    159168         * @expectedIncorrectUsage register_taxonomy