Make WordPress Core


Ignore:
Timestamp:
03/25/2014 06:39:26 PM (10 years ago)
Author:
wonderboymusic
Message:

Popular tags' edit links should respect the current post type. Adds unit test.

Props mordauk, fahmiadib.
Fixes #25566.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post.php

    r27380 r27720  
    874874        $this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) );
    875875    }
     876
     877    /**
     878     * @ticket 25566
     879     */
     880    function test_wp_tag_cloud_link_with_post_type() {
     881        $post_type = 'new_post_type';
     882        $tax = 'new_tag';
     883        register_post_type( $post_type, array( 'taxonomies' => array( 'post_tag', $tax ) ) );
     884        register_taxonomy( $tax, $post_type );
     885
     886        $post = $this->factory->post->create( array( 'post_type' => $post_type ) );
     887        wp_set_object_terms( $post, rand_str(), $tax );
     888
     889        $wp_tag_cloud = wp_tag_cloud( array(
     890            'post_type' => $post_type,
     891            'taxonomy' => $tax,
     892            'echo' => false,
     893            'link' => 'edit'
     894        ) );
     895
     896        $terms = get_terms( $tax );
     897        $term = reset( $terms );
     898        $url = sprintf( '%s?action=edit&taxonomy=%s&tag_ID=%d&post_type=%s',
     899            admin_url( 'edit-tags.php' ),
     900            $tax,
     901            $term->term_id,
     902            $post_type
     903        );
     904        $expected_wp_tag_cloud = sprintf( "<a href='%s' class='tag-link-%d' title='1 topic' style='font-size: 8pt;'>%s</a>",
     905            $url,
     906            $term->term_id,
     907            $term->name
     908        );
     909        $this->assertEquals( $expected_wp_tag_cloud, $wp_tag_cloud );
     910
     911        _unregister_post_type( $post_type );
     912        _unregister_taxonomy( $tax );
     913    }
     914
    876915}
Note: See TracChangeset for help on using the changeset viewer.