Make WordPress Core


Ignore:
Timestamp:
09/06/2013 05:26:04 PM (13 years ago)
Author:
wonderboymusic
Message:

Allow is_tag() to accept term_id, slug, 'term_name or array of any. Many other is_*()` funcs already do this. Adds unit tests.

Props ramiy.
Fixes #18746.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/conditionals.php

    r25280 r25287  
    429429        // 'tag/(.+?)/?$' => 'index.php?tag=$matches[1]',
    430430        function test_tag() {
    431                 $this->factory->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) );
     431                $term_id = $this->factory->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) );
    432432                $this->go_to('/tag/tag-a/');
    433433                $this->assertQueryTrue('is_archive', 'is_tag');
     434
     435                $tag = get_term( $term_id, 'post_tag' );
     436
     437                $this->assertTrue( is_tag() );
     438                $this->assertTrue( is_tag( $tag->name ) );
     439                $this->assertTrue( is_tag( $tag->slug ) );
     440                $this->assertTrue( is_tag( $tag->term_id ) );
     441                $this->assertTrue( is_tag( array() ) );
     442                $this->assertTrue( is_tag( array( $tag->name ) ) );
     443                $this->assertTrue( is_tag( array( $tag->slug ) ) );
     444                $this->assertTrue( is_tag( array( $tag->term_id ) ) );
    434445        }
    435446
Note: See TracChangeset for help on using the changeset viewer.