Changeset 35225 for trunk/tests/phpunit/tests/term/getTerms.php
- Timestamp:
- 10/16/2015 09:04:12 PM (10 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/term/getTerms.php (modified) (46 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/getTerms.php
r35196 r35225 106 106 */ 107 107 function test_get_terms_should_allow_arbitrary_indexed_taxonomies_array() { 108 $term_id = $this->factory->tag->create();108 $term_id = self::$factory->tag->create(); 109 109 $terms = get_terms( array( '111' => 'post_tag' ), array( 'hide_empty' => false ) ); 110 110 $this->assertEquals( $term_id, reset( $terms )->term_id ); … … 115 115 */ 116 116 function test_get_terms_fields() { 117 $term_id1 = $this->factory->tag->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) );118 $term_id2 = $this->factory->tag->create( array( 'slug' => 'hoo', 'name' => 'HOO!', 'parent' => $term_id1 ) );117 $term_id1 = self::$factory->tag->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) ); 118 $term_id2 = self::$factory->tag->create( array( 'slug' => 'hoo', 'name' => 'HOO!', 'parent' => $term_id1 ) ); 119 119 120 120 $terms_id_parent = get_terms( 'post_tag', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) ); … … 149 149 global $wpdb; 150 150 151 $term_id1 = $this->factory->tag->create();152 $term_id2 = $this->factory->tag->create();151 $term_id1 = self::$factory->tag->create(); 152 $term_id2 = self::$factory->tag->create(); 153 153 $inc_terms = get_terms( 'post_tag', array( 154 154 'include' => array( $term_id1, $term_id2 ), … … 180 180 register_taxonomy( 'wptests_tax', 'post' ); 181 181 182 $terms = $this->factory->term->create_many( 2, array(182 $terms = self::$factory->term->create_many( 2, array( 183 183 'taxonomy' => 'wptests_tax', 184 184 ) ); … … 203 203 $term_id_uncategorized = get_option( 'default_category' ); 204 204 205 $term_id1 = $this->factory->category->create();206 $term_id11 = $this->factory->category->create( array( 'parent' => $term_id1 ) );207 $term_id2 = $this->factory->category->create();208 $term_id22 = $this->factory->category->create( array( 'parent' => $term_id2 ) );205 $term_id1 = self::$factory->category->create(); 206 $term_id11 = self::$factory->category->create( array( 'parent' => $term_id1 ) ); 207 $term_id2 = self::$factory->category->create(); 208 $term_id22 = self::$factory->category->create( array( 'parent' => $term_id2 ) ); 209 209 210 210 $terms = get_terms( 'category', array( … … 229 229 */ 230 230 function test_get_terms_search() { 231 $term_id1 = $this->factory->tag->create( array( 'slug' => 'burrito' ) );232 $term_id2 = $this->factory->tag->create( array( 'name' => 'Wilbur' ) );231 $term_id1 = self::$factory->tag->create( array( 'slug' => 'burrito' ) ); 232 $term_id2 = self::$factory->tag->create( array( 'name' => 'Wilbur' ) ); 233 233 234 234 $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'search' => 'bur', 'fields' => 'ids' ) ); … … 240 240 */ 241 241 function test_get_terms_like() { 242 $term_id1 = $this->factory->tag->create( array( 'name' => 'burrito', 'description' => 'This is a burrito.' ) );243 $term_id2 = $this->factory->tag->create( array( 'name' => 'taco', 'description' => 'Burning man.' ) );242 $term_id1 = self::$factory->tag->create( array( 'name' => 'burrito', 'description' => 'This is a burrito.' ) ); 243 $term_id2 = self::$factory->tag->create( array( 'name' => 'taco', 'description' => 'Burning man.' ) ); 244 244 245 245 $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'name__like' => 'bur', 'fields' => 'ids' ) ); … … 275 275 register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) ); 276 276 277 $cheese = $this->factory->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) );278 279 $cheddar = $this->factory->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) );280 281 $post_ids = $this->factory->post->create_many( 2 );277 $cheese = self::$factory->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) ); 278 279 $cheddar = self::$factory->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) ); 280 281 $post_ids = self::$factory->post->create_many( 2 ); 282 282 foreach ( $post_ids as $id ) { 283 283 wp_set_post_terms( $id, $cheddar, $tax ); … … 286 286 $this->assertEquals( 2, $term->count ); 287 287 288 $brie = $this->factory->term->create( array( 'name' => 'Brie', 'parent' => $cheese, 'taxonomy' => $tax ) );289 $post_id = $this->factory->post->create();288 $brie = self::$factory->term->create( array( 'name' => 'Brie', 'parent' => $cheese, 'taxonomy' => $tax ) ); 289 $post_id = self::$factory->post->create(); 290 290 wp_set_post_terms( $post_id, $brie, $tax ); 291 291 $term = get_term( $brie, $tax ); 292 292 $this->assertEquals( 1, $term->count ); 293 293 294 $crackers = $this->factory->term->create( array( 'name' => 'Crackers', 'taxonomy' => $tax ) );295 296 $butter = $this->factory->term->create( array( 'name' => 'Butter', 'parent' => $crackers, 'taxonomy' => $tax ) );297 $post_ids = $this->factory->post->create_many( 1 );294 $crackers = self::$factory->term->create( array( 'name' => 'Crackers', 'taxonomy' => $tax ) ); 295 296 $butter = self::$factory->term->create( array( 'name' => 'Butter', 'parent' => $crackers, 'taxonomy' => $tax ) ); 297 $post_ids = self::$factory->post->create_many( 1 ); 298 298 foreach ( $post_ids as $id ) { 299 299 wp_set_post_terms( $id, $butter, $tax ); … … 302 302 $this->assertEquals( 1, $term->count ); 303 303 304 $multigrain = $this->factory->term->create( array( 'name' => 'Multigrain', 'parent' => $crackers, 'taxonomy' => $tax ) );305 $post_ids = $this->factory->post->create_many( 1 );304 $multigrain = self::$factory->term->create( array( 'name' => 'Multigrain', 'parent' => $crackers, 'taxonomy' => $tax ) ); 305 $post_ids = self::$factory->post->create_many( 1 ); 306 306 foreach ( $post_ids as $id ) { 307 307 wp_set_post_terms( $id, $multigrain, $tax ); … … 310 310 $this->assertEquals( 1, $term->count ); 311 311 312 $fruit = $this->factory->term->create( array( 'name' => 'Fruit', 'taxonomy' => $tax ) );313 $cranberries = $this->factory->term->create( array( 'name' => 'Cranberries', 'parent' => $fruit, 'taxonomy' => $tax ) );312 $fruit = self::$factory->term->create( array( 'name' => 'Fruit', 'taxonomy' => $tax ) ); 313 $cranberries = self::$factory->term->create( array( 'name' => 'Cranberries', 'parent' => $fruit, 'taxonomy' => $tax ) ); 314 314 315 315 $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) ); … … 325 325 register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) ); 326 326 327 $cheese = $this->factory->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) );328 $cheddar = $this->factory->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) );329 $spread = $this->factory->term->create( array( 'name' => 'Spread', 'parent' => $cheddar, 'taxonomy' => $tax ) );330 $post_id = $this->factory->post->create();327 $cheese = self::$factory->term->create( array( 'name' => 'Cheese', 'taxonomy' => $tax ) ); 328 $cheddar = self::$factory->term->create( array( 'name' => 'Cheddar', 'parent' => $cheese, 'taxonomy' => $tax ) ); 329 $spread = self::$factory->term->create( array( 'name' => 'Spread', 'parent' => $cheddar, 'taxonomy' => $tax ) ); 330 $post_id = self::$factory->post->create(); 331 331 wp_set_post_terms( $post_id, $spread, $tax ); 332 332 $term = get_term( $spread, $tax ); … … 349 349 $t = array(); 350 350 foreach ( range( 1, 7 ) as $depth ) { 351 $t[$depth] = $this->factory->term->create( array( 'name' => 'term' . $depth, 'taxonomy' => $tax, 'parent' => $parent ) );351 $t[$depth] = self::$factory->term->create( array( 'name' => 'term' . $depth, 'taxonomy' => $tax, 'parent' => $parent ) ); 352 352 $parent = $t[$depth]; 353 353 } 354 $post_id = $this->factory->post->create();354 $post_id = self::$factory->post->create(); 355 355 wp_set_post_terms( $post_id, $t[7], $tax ); 356 356 $term = get_term( $t[7], $tax ); … … 368 368 */ 369 369 function test_get_terms_child_of() { 370 $parent = $this->factory->category->create();371 $child = $this->factory->category->create( array( 'parent' => $parent ) );370 $parent = self::$factory->category->create(); 371 $child = self::$factory->category->create( array( 'parent' => $parent ) ); 372 372 373 373 $terms = get_terms( 'category', array( 'child_of' => $parent, 'hide_empty' => false ) ); … … 383 383 register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) ); 384 384 385 $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );385 $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); 386 386 387 387 $num_queries = $wpdb->num_queries; … … 403 403 register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); 404 404 405 $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );406 $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );407 $t3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) );405 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); 406 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); 407 $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); 408 408 409 409 $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array( … … 441 441 remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 ); 442 442 443 $c1 = $this->factory->category->create();444 $c2 = $this->factory->category->create( array( 'parent' => $c1 ) );445 $c3 = $this->factory->category->create( array( 'parent' => $c2 ) );443 $c1 = self::$factory->category->create(); 444 $c2 = self::$factory->category->create( array( 'parent' => $c1 ) ); 445 $c3 = self::$factory->category->create( array( 'parent' => $c2 ) ); 446 446 wp_update_term( $c1, 'category', array( 'parent' => $c3 ) ); 447 447 … … 460 460 remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 ); 461 461 462 $c1 = $this->factory->category->create_and_get();463 $c2 = $this->factory->category->create_and_get( array( 'parent' => $c1->term_id ) );464 $c3 = $this->factory->category->create_and_get( array( 'parent' => $c2->term_id ) );462 $c1 = self::$factory->category->create_and_get(); 463 $c2 = self::$factory->category->create_and_get( array( 'parent' => $c1->term_id ) ); 464 $c3 = self::$factory->category->create_and_get( array( 'parent' => $c2->term_id ) ); 465 465 wp_update_term( $c1->term_id, 'category', array( 'parent' => $c3->term_id ) ); 466 466 … … 473 473 474 474 public function test_get_terms_by_slug() { 475 $t1 = $this->factory->tag->create( array( 'slug' => 'foo' ) );476 $t2 = $this->factory->tag->create( array( 'slug' => 'bar' ) );475 $t1 = self::$factory->tag->create( array( 'slug' => 'foo' ) ); 476 $t2 = self::$factory->tag->create( array( 'slug' => 'bar' ) ); 477 477 478 478 $found = get_terms( 'post_tag', array( … … 489 489 */ 490 490 public function test_get_terms_by_multiple_slugs() { 491 $t1 = $this->factory->tag->create( array( 'slug' => 'foo' ) );492 $t2 = $this->factory->tag->create( array( 'slug' => 'bar' ) );493 $t3 = $this->factory->tag->create( array( 'slug' => 'barry' ) );491 $t1 = self::$factory->tag->create( array( 'slug' => 'foo' ) ); 492 $t2 = self::$factory->tag->create( array( 'slug' => 'bar' ) ); 493 $t3 = self::$factory->tag->create( array( 'slug' => 'barry' ) ); 494 494 495 495 $found = get_terms( 'post_tag', array( … … 506 506 */ 507 507 public function test_get_terms_by_name() { 508 $t1 = $this->factory->tag->create( array( 'name' => 'Foo' ) );509 $t2 = $this->factory->tag->create( array( 'name' => 'Bar' ) );508 $t1 = self::$factory->tag->create( array( 'name' => 'Foo' ) ); 509 $t2 = self::$factory->tag->create( array( 'name' => 'Bar' ) ); 510 510 511 511 $found = get_terms( 'post_tag', array( … … 522 522 */ 523 523 public function test_get_terms_by_multiple_names() { 524 $t1 = $this->factory->tag->create( array( 'name' => 'Foo' ) );525 $t2 = $this->factory->tag->create( array( 'name' => 'Bar' ) );526 $t3 = $this->factory->tag->create( array( 'name' => 'Barry' ) );524 $t1 = self::$factory->tag->create( array( 'name' => 'Foo' ) ); 525 $t2 = self::$factory->tag->create( array( 'name' => 'Bar' ) ); 526 $t3 = self::$factory->tag->create( array( 'name' => 'Barry' ) ); 527 527 528 528 $found = get_terms( 'post_tag', array( … … 541 541 register_taxonomy( 'wptests_tax', 'post' ); 542 542 543 $t = $this->factory->term->create( array(543 $t = self::$factory->term->create( array( 544 544 'taxonomy' => 'wptests_tax', 545 545 'name' => 'Foo & Bar', … … 570 570 $flat_tax = 'countries'; 571 571 register_taxonomy( $flat_tax, 'post', array( 'hierarchical' => false ) ); 572 $australia = $this->factory->term->create( array( 'name' => 'Australia', 'taxonomy' => $flat_tax ) );573 $china = $this->factory->term->create( array( 'name' => 'China', 'taxonomy' => $flat_tax ) );574 $tanzania = $this->factory->term->create( array( 'name' => 'Tanzania', 'taxonomy' => $flat_tax ) );572 $australia = self::$factory->term->create( array( 'name' => 'Australia', 'taxonomy' => $flat_tax ) ); 573 $china = self::$factory->term->create( array( 'name' => 'China', 'taxonomy' => $flat_tax ) ); 574 $tanzania = self::$factory->term->create( array( 'name' => 'Tanzania', 'taxonomy' => $flat_tax ) ); 575 575 576 576 $terms = get_terms( $flat_tax, array( … … 602 602 */ 603 603 // Level 1 604 $canada = $this->factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) );604 $canada = self::$factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) ); 605 605 606 606 // Level 2 607 $ontario = $this->factory->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) );608 $quebec = $this->factory->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) );609 $pei = $this->factory->term->create( array( 'name' => 'PEI', 'parent' => $canada, 'taxonomy' => $tax ) );607 $ontario = self::$factory->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) ); 608 $quebec = self::$factory->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) ); 609 $pei = self::$factory->term->create( array( 'name' => 'PEI', 'parent' => $canada, 'taxonomy' => $tax ) ); 610 610 611 611 // Level 3 612 $toronto = $this->factory->term->create( array( 'name' => 'Toronto', 'parent' => $ontario, 'taxonomy' => $tax ) );613 $ottawa = $this->factory->term->create( array( 'name' => 'Ottawa', 'parent' => $ontario, 'taxonomy' => $tax ) );614 $montreal = $this->factory->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) );612 $toronto = self::$factory->term->create( array( 'name' => 'Toronto', 'parent' => $ontario, 'taxonomy' => $tax ) ); 613 $ottawa = self::$factory->term->create( array( 'name' => 'Ottawa', 'parent' => $ontario, 'taxonomy' => $tax ) ); 614 $montreal = self::$factory->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) ); 615 615 616 616 // Level 4 617 $nepean = $this->factory->term->create( array( 'name' => 'Nepean', 'parent' => $ottawa, 'taxonomy' => $tax ) );617 $nepean = self::$factory->term->create( array( 'name' => 'Nepean', 'parent' => $ottawa, 'taxonomy' => $tax ) ); 618 618 619 619 $terms = get_terms( $tax, array( … … 634 634 635 635 // Level 1 636 $canada = $this->factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) );636 $canada = self::$factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) ); 637 637 638 638 // Level 2 639 $ontario = $this->factory->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) );640 $quebec = $this->factory->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) );639 $ontario = self::$factory->term->create( array( 'name' => 'Ontario', 'parent' => $canada, 'taxonomy' => $tax ) ); 640 $quebec = self::$factory->term->create( array( 'name' => 'Quebec', 'parent' => $canada, 'taxonomy' => $tax ) ); 641 641 642 642 // Level 3 643 $laval = $this->factory->term->create( array( 'name' => 'Laval', 'parent' => $quebec, 'taxonomy' => $tax ) );644 $montreal = $this->factory->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) );643 $laval = self::$factory->term->create( array( 'name' => 'Laval', 'parent' => $quebec, 'taxonomy' => $tax ) ); 644 $montreal = self::$factory->term->create( array( 'name' => 'Montreal', 'parent' => $quebec, 'taxonomy' => $tax ) ); 645 645 646 646 // Level 4 647 $dorval = $this->factory->term->create( array( 'name' => 'Dorval', 'parent' => $montreal, 'taxonomy' => $tax ) );647 $dorval = self::$factory->term->create( array( 'name' => 'Dorval', 'parent' => $montreal, 'taxonomy' => $tax ) ); 648 648 649 649 $terms = get_terms( $tax, array( … … 664 664 register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); 665 665 666 $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );667 $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) );668 $t3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );669 $t4 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t3 ) );666 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); 667 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) ); 668 $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); 669 $t4 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t3 ) ); 670 670 671 671 $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array( … … 1099 1099 register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); 1100 1100 1101 $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );1102 $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) );1103 $t3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t2 ) );1104 1105 $t4 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );1106 $t5 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t4 ) );1107 $t6 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t5 ) );1108 1109 $p = $this->factory->post->create();1101 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); 1102 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t1 ) ); 1103 $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1', 'parent' => $t2 ) ); 1104 1105 $t4 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); 1106 $t5 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t4 ) ); 1107 $t6 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t5 ) ); 1108 1109 $p = self::$factory->post->create(); 1110 1110 1111 1111 wp_set_object_terms( $p, $t3, 'wptests_tax1' ); … … 1141 1141 register_taxonomy( $tax, 'post' ); 1142 1142 1143 $t1 = $this->factory->term->create( array( 'taxonomy' => $tax ) );1144 $t2 = $this->factory->term->create( array( 'taxonomy' => $tax ) );1145 $t3 = $this->factory->term->create( array( 'taxonomy' => $tax ) );1146 $t4 = $this->factory->term->create( array( 'taxonomy' => $tax ) );1143 $t1 = self::$factory->term->create( array( 'taxonomy' => $tax ) ); 1144 $t2 = self::$factory->term->create( array( 'taxonomy' => $tax ) ); 1145 $t3 = self::$factory->term->create( array( 'taxonomy' => $tax ) ); 1146 $t4 = self::$factory->term->create( array( 'taxonomy' => $tax ) ); 1147 1147 1148 1148 $found = get_terms( $tax, array( … … 1165 1165 register_taxonomy( $tax, 'post' ); 1166 1166 1167 $t1 = $this->factory->term->create( array( 'taxonomy' => $tax, 'description' => 'fff' ) );1168 $t2 = $this->factory->term->create( array( 'taxonomy' => $tax, 'description' => 'aaa' ) );1169 $t3 = $this->factory->term->create( array( 'taxonomy' => $tax, 'description' => 'zzz' ) );1170 $t4 = $this->factory->term->create( array( 'taxonomy' => $tax, 'description' => 'jjj' ) );1167 $t1 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'fff' ) ); 1168 $t2 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'aaa' ) ); 1169 $t3 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'zzz' ) ); 1170 $t4 = self::$factory->term->create( array( 'taxonomy' => $tax, 'description' => 'jjj' ) ); 1171 1171 1172 1172 $found = get_terms( $tax, array( … … 1186 1186 public function test_orderby_term_id() { 1187 1187 register_taxonomy( 'wptests_tax', 'post' ); 1188 $t1 = $this->factory->term->create( array(1188 $t1 = self::$factory->term->create( array( 1189 1189 'taxonomy' => 'wptests_tax', 1190 1190 'name' => 'AAA', 1191 1191 ) ); 1192 $t2 = $this->factory->term->create( array(1192 $t2 = self::$factory->term->create( array( 1193 1193 'taxonomy' => 'wptests_tax', 1194 1194 'name' => 'ZZZ', 1195 1195 ) ); 1196 $t3 = $this->factory->term->create( array(1196 $t3 = self::$factory->term->create( array( 1197 1197 'taxonomy' => 'wptests_tax', 1198 1198 'name' => 'JJJ', … … 1244 1244 public function test_hierarchical_false_with_child_of_and_direct_child() { 1245 1245 $initial_terms = $this->create_hierarchical_terms(); 1246 $post_id = $this->factory->post->create();1246 $post_id = self::$factory->post->create(); 1247 1247 wp_set_post_terms( 1248 1248 $post_id, … … 1324 1324 register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) ); 1325 1325 1326 $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );1326 $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); 1327 1327 1328 1328 $num_queries = $wpdb->num_queries; … … 1344 1344 register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); 1345 1345 1346 $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );1347 $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );1348 $t3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) );1346 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); 1347 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); 1348 $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); 1349 1349 1350 1350 $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array( … … 1396 1396 register_taxonomy( 'wptests_tax_1', 'post', array( 'hierarchical' => true ) ); 1397 1397 1398 $posts = $this->factory->post->create_many( 3 );1399 1400 $t1 = $this->factory->term->create( array(1398 $posts = self::$factory->post->create_many( 3 ); 1399 1400 $t1 = self::$factory->term->create( array( 1401 1401 'taxonomy' => 'wptests_tax_1', 1402 1402 ) ); 1403 $t2 = $this->factory->term->create( array(1403 $t2 = self::$factory->term->create( array( 1404 1404 'taxonomy' => 'wptests_tax_1', 1405 1405 'parent' => $t1, 1406 1406 ) ); 1407 $t3 = $this->factory->term->create( array(1407 $t3 = self::$factory->term->create( array( 1408 1408 'taxonomy' => 'wptests_tax_1', 1409 1409 'parent' => $t2, … … 1437 1437 remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 ); 1438 1438 1439 $c1 = $this->factory->category->create();1440 $c2 = $this->factory->category->create( array( 'parent' => $c1 ) );1441 $c3 = $this->factory->category->create( array( 'parent' => $c2 ) );1439 $c1 = self::$factory->category->create(); 1440 $c2 = self::$factory->category->create( array( 'parent' => $c1 ) ); 1441 $c3 = self::$factory->category->create( array( 'parent' => $c2 ) ); 1442 1442 wp_update_term( $c1, 'category', array( 'parent' => $c3 ) ); 1443 1443 1444 1444 add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); 1445 1445 1446 $posts = $this->factory->post->create_many( 3 );1446 $posts = self::$factory->post->create_many( 3 ); 1447 1447 wp_set_post_terms( $posts[0], $c1, 'category' ); 1448 1448 wp_set_post_terms( $posts[1], $c2, 'category' ); … … 1467 1467 register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) ); 1468 1468 1469 $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );1470 $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );1471 $t3 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) );1472 1473 $posts = $this->factory->post->create_many( 3 );1469 $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) ); 1470 $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) ); 1471 $t3 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax2', 'parent' => $t2 ) ); 1472 1473 $posts = self::$factory->post->create_many( 3 ); 1474 1474 wp_set_object_terms( $posts[0], $t1, 'wptests_tax1' ); 1475 1475 wp_set_object_terms( $posts[1], $t2, 'wptests_tax2' ); … … 1500 1500 1501 1501 register_taxonomy( 'wptests_tax', 'post' ); 1502 $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );1502 $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); 1503 1503 add_term_meta( $terms[0], 'foo', 'bar' ); 1504 1504 add_term_meta( $terms[1], 'foo', 'bar' ); … … 1526 1526 1527 1527 register_taxonomy( 'wptests_tax', 'post' ); 1528 $terms = $this->factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );1528 $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) ); 1529 1529 add_term_meta( $terms[0], 'foo', 'bar' ); 1530 1530 add_term_meta( $terms[1], 'foo', 'bar' ); … … 1551 1551 public function test_meta_query() { 1552 1552 register_taxonomy( 'wptests_tax', 'post' ); 1553 $terms = $this->factory->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) );1553 $terms = self::$factory->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) ); 1554 1554 add_term_meta( $terms[0], 'foo', 'bar' ); 1555 1555 add_term_meta( $terms[1], 'foo', 'bar' ); … … 1576 1576 public function test_should_return_wp_term_objects() { 1577 1577 register_taxonomy( 'wptests_tax', 'post' ); 1578 $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );1578 $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); 1579 1579 1580 1580 $found = get_terms( 'wptests_tax', array( … … 1598 1598 1599 1599 register_taxonomy( 'wptests_tax', 'post' ); 1600 $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );1600 $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); 1601 1601 1602 1602 // Prime the cache. … … 1629 1629 1630 1630 register_taxonomy( 'wptests_tax', 'post' ); 1631 $terms = $this->factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );1631 $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) ); 1632 1632 1633 1633 $found = get_terms( 'wptests_tax', array( … … 1645 1645 $terms = array(); 1646 1646 1647 $terms['parent1'] = $this->factory->term->create( array( 'slug' => 'parent-1', 'name' => 'Parent 1', 'taxonomy' => 'hierarchical_fields' ) );1648 $terms['parent2'] = $this->factory->term->create( array( 'slug' => 'parent-2', 'name' => 'Parent 2', 'taxonomy' => 'hierarchical_fields' ) );1649 $terms['child1'] = $this->factory->term->create( array( 'slug' => 'child-1', 'name' => 'Child 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) );1650 $terms['child2'] = $this->factory->term->create( array( 'slug' => 'child-2', 'name' => 'Child 2', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) );1651 $terms['grandchild1'] = $this->factory->term->create( array( 'slug' => 'grandchild-1', 'name' => 'Grandchild 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['child1'] ) );1652 1653 $post_id = $this->factory->post->create();1647 $terms['parent1'] = self::$factory->term->create( array( 'slug' => 'parent-1', 'name' => 'Parent 1', 'taxonomy' => 'hierarchical_fields' ) ); 1648 $terms['parent2'] = self::$factory->term->create( array( 'slug' => 'parent-2', 'name' => 'Parent 2', 'taxonomy' => 'hierarchical_fields' ) ); 1649 $terms['child1'] = self::$factory->term->create( array( 'slug' => 'child-1', 'name' => 'Child 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) ); 1650 $terms['child2'] = self::$factory->term->create( array( 'slug' => 'child-2', 'name' => 'Child 2', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['parent1'] ) ); 1651 $terms['grandchild1'] = self::$factory->term->create( array( 'slug' => 'grandchild-1', 'name' => 'Grandchild 1', 'taxonomy' => 'hierarchical_fields', 'parent' => $terms['child1'] ) ); 1652 1653 $post_id = self::$factory->post->create(); 1654 1654 wp_set_post_terms( $post_id, $terms['parent2'], 'hierarchical_fields', true ); 1655 1655 wp_set_post_terms( $post_id, $terms['child1'], 'hierarchical_fields', true ); … … 1715 1715 1716 1716 // Ensure child terms are not empty 1717 $first_post_id = $this->factory->post->create();1718 $second_post_id = $this->factory->post->create();1717 $first_post_id = self::$factory->post->create(); 1718 $second_post_id = self::$factory->post->create(); 1719 1719 wp_set_post_terms( $first_post_id, array( $three_term['term_id'] ), 'category' ); 1720 1720 wp_set_post_terms( $second_post_id, array( $six_term['term_id'] ), 'category' ); … … 1732 1732 1733 1733 protected function set_up_three_posts_and_tags() { 1734 $posts = $this->factory->post->create_many( 3, array( 'post_type' => 'post' ) );1734 $posts = self::$factory->post->create_many( 3, array( 'post_type' => 'post' ) ); 1735 1735 foreach ( $posts as $post ) { 1736 1736 wp_set_object_terms( $post, rand_str(), 'post_tag' );
Note: See TracChangeset
for help on using the changeset viewer.