Changeset 42343 for trunk/tests/phpunit/tests/query/isTerm.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/query/isTerm.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query/isTerm.php
r37954 r42343 29 29 30 30 $GLOBALS['wp_the_query'] = new WP_Query(); 31 $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];31 $GLOBALS['wp_query'] = $GLOBALS['wp_the_query']; 32 32 33 33 $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); … … 38 38 flush_rewrite_rules(); 39 39 40 $this->tag_id = self::factory()->tag->create( array( 'slug' => 'tag-slug' ) ); 41 $this->cat_id = self::factory()->category->create( array( 'slug' => 'cat-slug' ) ); 42 $this->tax_id = self::factory()->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug' ) ); 43 $this->tax_id2 = self::factory()->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug2' ) ); 40 $this->tag_id = self::factory()->tag->create( array( 'slug' => 'tag-slug' ) ); 41 $this->cat_id = self::factory()->category->create( array( 'slug' => 'cat-slug' ) ); 42 $this->tax_id = self::factory()->term->create( 43 array( 44 'taxonomy' => 'testtax', 45 'slug' => 'tax-slug', 46 ) 47 ); 48 $this->tax_id2 = self::factory()->term->create( 49 array( 50 'taxonomy' => 'testtax', 51 'slug' => 'tax-slug2', 52 ) 53 ); 44 54 $this->post_id = self::factory()->post->create(); 45 55 wp_set_object_terms( $this->post_id, $this->cat_id, 'category' ); … … 69 79 function test_tag_action_tax() { 70 80 // tag with tax added 71 $this->go_to( home_url( "/tag/tag-slug/") );81 $this->go_to( home_url( '/tag/tag-slug/' ) ); 72 82 $this->assertQueryTrue( 'is_tag', 'is_archive' ); 73 83 $this->assertNotEmpty( get_query_var( 'tax_query' ) ); … … 105 115 function test_cat_action_tax() { 106 116 // category with tax added 107 $this->go_to( home_url( "/category/cat-slug/") );117 $this->go_to( home_url( '/category/cat-slug/' ) ); 108 118 $this->assertQueryTrue( 'is_category', 'is_archive' ); 109 119 $this->assertNotEmpty( get_query_var( 'cat' ) ); … … 121 131 add_action( 'pre_get_posts', array( $this, '_cat_uncat_action_tax' ), 11 ); 122 132 123 $this->go_to( home_url( "/category/uncategorized/") );133 $this->go_to( home_url( '/category/uncategorized/' ) ); 124 134 $this->assertQueryTrue( 'is_category', 'is_archive' ); 125 135 $this->assertNotEmpty( get_query_var( 'cat' ) ); … … 176 186 177 187 function pre_get_posts_tax_category_tax_query( &$query ) { 178 $query->set( 'tax_query', array( 179 array( 'taxonomy' => 'testtax', 'field' => 'term_id', 'terms' => $this->tax_id ) 180 ) ); 188 $query->set( 189 'tax_query', array( 190 array( 191 'taxonomy' => 'testtax', 192 'field' => 'term_id', 193 'terms' => $this->tax_id, 194 ), 195 ) 196 ); 181 197 } 182 198 … … 193 209 array( 194 210 'taxonomy' => 'testtax', 195 'field' => 'term_id',196 'terms' => array(211 'field' => 'term_id', 212 'terms' => array( 197 213 $this->tax_id, 198 214 ), 199 215 ), 200 ) 201 ); 202 203 $q = new WP_Query( $args );216 ), 217 ); 218 219 $q = new WP_Query( $args ); 204 220 $object = $q->get_queried_object(); 205 221 … … 221 237 array( 222 238 'taxonomy' => 'testtax', 223 'field' => 'slug',224 'terms' => array(239 'field' => 'slug', 240 'terms' => array( 225 241 'tax-slug', 226 242 ), 227 243 ), 228 ) 229 ); 230 231 $q = new WP_Query( $args );244 ), 245 ); 246 247 $q = new WP_Query( $args ); 232 248 $object = $q->get_queried_object(); 233 249 … … 246 262 247 263 register_taxonomy( 'testtax2', 'post' ); 248 $testtax2_term_id = self::factory()->term->create( array( 249 'taxonomy' => 'testtax2', 250 'slug' => 'testtax2-slug', 251 ) ); 264 $testtax2_term_id = self::factory()->term->create( 265 array( 266 'taxonomy' => 'testtax2', 267 'slug' => 'testtax2-slug', 268 ) 269 ); 252 270 253 271 $args = array( … … 256 274 array( 257 275 'taxonomy' => 'testtax', 258 'field' => 'slug',259 'terms' => array(276 'field' => 'slug', 277 'terms' => array( 260 278 'tax-slug', 261 279 ), … … 263 281 array( 264 282 'taxonomy' => 'testtax2', 265 'field' => 'slug',266 'terms' => array(283 'field' => 'slug', 284 'terms' => array( 267 285 'testtax2-slug', 268 286 ), 269 287 ), 270 ) 271 ); 272 273 $q = new WP_Query( $args );288 ), 289 ); 290 291 $q = new WP_Query( $args ); 274 292 $object = $q->get_queried_object(); 275 293
Note: See TracChangeset
for help on using the changeset viewer.