| | 90 | |
| | 91 | /** |
| | 92 | * @ticket 26627 |
| | 93 | */ |
| | 94 | function test_tag_queried_object() { |
| | 95 | $slug = 'tag-slug-26627'; |
| | 96 | $this->factory->tag->create( array( 'slug' => $slug ) ); |
| | 97 | $tag = get_term_by( 'slug', $slug, 'post_tag' ); |
| | 98 | |
| | 99 | add_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 ); |
| | 100 | |
| | 101 | $this->go_to( get_term_link( $tag ) ); |
| | 102 | |
| | 103 | $this->assertQueryTrue( 'is_tag', 'is_archive' ); |
| | 104 | $this->assertNotEmpty( get_query_var( 'tag_id' ) ); |
| | 105 | $this->assertNotEmpty( get_query_var( 'tag' ) ); |
| | 106 | $this->assertEmpty( get_query_var( 'tax_query' ) ); |
| | 107 | $this->assertCount( 1, get_query_var( 'tag_slug__in' ) ); |
| | 108 | $this->assertEquals( get_queried_object(), $tag ); |
| | 109 | |
| | 110 | remove_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 ); |
| | 111 | } |
| | 112 | |
| | 113 | function _tag_queried_object( &$query ) { |
| | 114 | $tag = get_term_by( 'slug', 'tag-slug-26627', 'post_tag' ); |
| | 115 | $this->assertTrue( $query->is_tag() ); |
| | 116 | $this->assertTrue( $query->is_archive() ); |
| | 117 | $this->assertNotEmpty( $query->get( 'tag' ) ); |
| | 118 | $this->assertCount( 1, $query->get( 'tag_slug__in' ) ); |
| | 119 | $this->assertEquals( $query->get_queried_object(), $tag ); |
| | 120 | } |