WordPress.org

Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.8/tests/phpunit/tests/query.php

    r25601 r27647  
    7979
    8080    }
     81
     82    /**
     83     * @ticket 26627
     84     */
     85    function test_tag_queried_object() {
     86        $slug = 'tag-slug-26627';
     87        $this->factory->tag->create( array( 'slug' => $slug ) );
     88        $tag = get_term_by( 'slug', $slug, 'post_tag' );
     89
     90        add_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 );
     91
     92        $this->go_to( get_term_link( $tag ) );
     93
     94        $this->assertQueryTrue( 'is_tag', 'is_archive' );
     95        $this->assertNotEmpty( get_query_var( 'tag_id' ) );
     96        $this->assertNotEmpty( get_query_var( 'tag' ) );
     97        $this->assertEmpty( get_query_var( 'tax_query' ) );
     98        $this->assertCount( 1, get_query_var( 'tag_slug__in' ) );
     99        $this->assertEquals( get_queried_object(), $tag );
     100
     101        remove_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 );
     102    }
     103
     104    function _tag_queried_object( &$query ) {
     105        $tag = get_term_by( 'slug', 'tag-slug-26627', 'post_tag' );
     106        $this->assertTrue( $query->is_tag() );
     107        $this->assertTrue( $query->is_archive() );
     108        $this->assertNotEmpty( $query->get( 'tag' ) );
     109        $this->assertCount( 1, $query->get( 'tag_slug__in' ) );
     110        $this->assertEquals( $query->get_queried_object(), $tag );
     111    }
    81112}
Note: See TracChangeset for help on using the changeset viewer.