Make WordPress Core


Ignore:
Timestamp:
10/17/2015 06:02:16 PM (11 years ago)
Author:
wonderboymusic
Message:

Unit Tests: after [35225], make factory a method/getter on WP_UnitTestCase and add magic methods for BC for every plugin that is extending WP_UnitTestCase and accessing the $factory instance prop.

Props nerrad, wonderboymusic.
See #30017, #33968.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/getTerms.php

    r35225 r35242  
    106106     */
    107107    function test_get_terms_should_allow_arbitrary_indexed_taxonomies_array() {
    108         $term_id = self::$factory->tag->create();
     108        $term_id = self::factory()->tag->create();
    109109        $terms = get_terms( array( '111' => 'post_tag' ), array( 'hide_empty' => false ) );
    110110        $this->assertEquals( $term_id, reset( $terms )->term_id );
     
    115115     */
    116116    function test_get_terms_fields() {
    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 ) );
     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 ) );
    119119
    120120        $terms_id_parent = get_terms( 'post_tag', array( 'hide_empty' => false, 'fields' => 'id=>parent' ) );
     
    149149        global $wpdb;
    150150
    151         $term_id1 = self::$factory->tag->create();
    152         $term_id2 = self::$factory->tag->create();
     151        $term_id1 = self::factory()->tag->create();
     152        $term_id2 = self::factory()->tag->create();
    153153        $inc_terms = get_terms( 'post_tag', array(
    154154            'include' => array( $term_id1, $term_id2 ),
     
    180180        register_taxonomy( 'wptests_tax', 'post' );
    181181
    182         $terms = self::$factory->term->create_many( 2, array(
     182        $terms = self::factory()->term->create_many( 2, array(
    183183            'taxonomy' => 'wptests_tax',
    184184        ) );
     
    203203        $term_id_uncategorized = get_option( 'default_category' );
    204204
    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 ) );
     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 ) );
    209209
    210210        $terms = get_terms( 'category', array(
     
    229229     */
    230230    function test_get_terms_search() {
    231         $term_id1 = self::$factory->tag->create( array( 'slug' => 'burrito' ) );
    232         $term_id2 = self::$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' ) );
    233233
    234234        $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'search' => 'bur', 'fields' => 'ids' ) );
     
    240240     */
    241241    function test_get_terms_like() {
    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.' ) );
     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.' ) );
    244244
    245245        $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'name__like' => 'bur', 'fields' => 'ids' ) );
     
    275275        register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );
    276276
    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 );
     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 );
    282282        foreach ( $post_ids as $id ) {
    283283            wp_set_post_terms( $id, $cheddar, $tax );
     
    286286        $this->assertEquals( 2, $term->count );
    287287
    288         $brie = self::$factory->term->create( array( 'name' => 'Brie', 'parent' => $cheese, 'taxonomy' => $tax ) );
    289         $post_id = self::$factory->post->create();
     288        $brie = self::factory()->term->create( array( 'name' => 'Brie', 'parent' => $cheese, 'taxonomy' => $tax ) );
     289        $post_id = self::factory()->post->create();
    290290        wp_set_post_terms( $post_id, $brie, $tax );
    291291        $term = get_term( $brie, $tax );
    292292        $this->assertEquals( 1, $term->count );
    293293
    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 );
     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 );
    298298        foreach ( $post_ids as $id ) {
    299299            wp_set_post_terms( $id, $butter, $tax );
     
    302302        $this->assertEquals( 1, $term->count );
    303303
    304         $multigrain = self::$factory->term->create( array( 'name' => 'Multigrain', 'parent' => $crackers, 'taxonomy' => $tax ) );
    305         $post_ids = self::$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 );
    306306        foreach ( $post_ids as $id ) {
    307307            wp_set_post_terms( $id, $multigrain, $tax );
     
    310310        $this->assertEquals( 1, $term->count );
    311311
    312         $fruit = self::$factory->term->create( array( 'name' => 'Fruit', 'taxonomy' => $tax ) );
    313         $cranberries = self::$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 ) );
    314314
    315315        $terms = get_terms( $tax, array( 'parent' => 0, 'cache_domain' => $tax ) );
     
    325325        register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );
    326326
    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();
     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();
    331331        wp_set_post_terms( $post_id, $spread, $tax );
    332332        $term = get_term( $spread, $tax );
     
    349349        $t = array();
    350350        foreach ( range( 1, 7 ) as $depth ) {
    351             $t[$depth] = self::$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 ) );
    352352            $parent = $t[$depth];
    353353        }
    354         $post_id = self::$factory->post->create();
     354        $post_id = self::factory()->post->create();
    355355        wp_set_post_terms( $post_id, $t[7], $tax );
    356356        $term = get_term( $t[7], $tax );
     
    368368     */
    369369    function test_get_terms_child_of() {
    370         $parent = self::$factory->category->create();
    371         $child = self::$factory->category->create( array( 'parent' => $parent ) );
     370        $parent = self::factory()->category->create();
     371        $child = self::factory()->category->create( array( 'parent' => $parent ) );
    372372
    373373        $terms = get_terms( 'category', array( 'child_of' => $parent, 'hide_empty' => false ) );
     
    383383        register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) );
    384384
    385         $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     385        $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
    386386
    387387        $num_queries = $wpdb->num_queries;
     
    403403        register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) );
    404404
    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 ) );
     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 ) );
    408408
    409409        $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array(
     
    441441        remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 );
    442442
    443         $c1 = self::$factory->category->create();
    444         $c2 = self::$factory->category->create( array( 'parent' => $c1 ) );
    445         $c3 = self::$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 ) );
    446446        wp_update_term( $c1, 'category', array( 'parent' => $c3 ) );
    447447
     
    460460        remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 );
    461461
    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 ) );
     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 ) );
    465465        wp_update_term( $c1->term_id, 'category', array( 'parent' => $c3->term_id ) );
    466466
     
    473473
    474474    public function test_get_terms_by_slug() {
    475         $t1 = self::$factory->tag->create( array( 'slug' => 'foo' ) );
    476         $t2 = self::$factory->tag->create( array( 'slug' => 'bar' ) );
     475        $t1 = self::factory()->tag->create( array( 'slug' => 'foo' ) );
     476        $t2 = self::factory()->tag->create( array( 'slug' => 'bar' ) );
    477477
    478478        $found = get_terms( 'post_tag', array(
     
    489489     */
    490490    public function test_get_terms_by_multiple_slugs() {
    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' ) );
     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' ) );
    494494
    495495        $found = get_terms( 'post_tag', array(
     
    506506     */
    507507    public function test_get_terms_by_name() {
    508         $t1 = self::$factory->tag->create( array( 'name' => 'Foo' ) );
    509         $t2 = self::$factory->tag->create( array( 'name' => 'Bar' ) );
     508        $t1 = self::factory()->tag->create( array( 'name' => 'Foo' ) );
     509        $t2 = self::factory()->tag->create( array( 'name' => 'Bar' ) );
    510510
    511511        $found = get_terms( 'post_tag', array(
     
    522522     */
    523523    public function test_get_terms_by_multiple_names() {
    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' ) );
     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' ) );
    527527
    528528        $found = get_terms( 'post_tag', array(
     
    541541        register_taxonomy( 'wptests_tax', 'post' );
    542542
    543         $t = self::$factory->term->create( array(
     543        $t = self::factory()->term->create( array(
    544544            'taxonomy' => 'wptests_tax',
    545545            'name' => 'Foo & Bar',
     
    570570        $flat_tax = 'countries';
    571571        register_taxonomy( $flat_tax, 'post', array( 'hierarchical' => false ) );
    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 ) );
     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 ) );
    575575
    576576        $terms = get_terms( $flat_tax, array(
     
    602602        */
    603603        // Level 1
    604         $canada = self::$factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) );
     604        $canada = self::factory()->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) );
    605605
    606606        // Level 2
    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 ) );
     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 ) );
    610610
    611611        // Level 3
    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 ) );
     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 ) );
    615615
    616616        // Level 4
    617         $nepean = self::$factory->term->create( array( 'name' => 'Nepean', 'parent' => $ottawa, 'taxonomy' => $tax ) );
     617        $nepean = self::factory()->term->create( array( 'name' => 'Nepean', 'parent' => $ottawa, 'taxonomy' => $tax ) );
    618618
    619619        $terms = get_terms( $tax, array(
     
    634634
    635635        // Level 1
    636         $canada = self::$factory->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) );
     636        $canada = self::factory()->term->create( array( 'name' => 'Canada', 'taxonomy' => $tax ) );
    637637
    638638        // Level 2
    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 ) );
     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 ) );
    641641
    642642        // Level 3
    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 ) );
     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 ) );
    645645
    646646        // Level 4
    647         $dorval = self::$factory->term->create( array( 'name' => 'Dorval', 'parent' => $montreal, 'taxonomy' => $tax ) );
     647        $dorval = self::factory()->term->create( array( 'name' => 'Dorval', 'parent' => $montreal, 'taxonomy' => $tax ) );
    648648
    649649        $terms = get_terms( $tax, array(
     
    664664        register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) );
    665665
    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 ) );
     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 ) );
    670670
    671671        $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array(
     
    10991099        register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) );
    11001100
    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();
     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();
    11101110
    11111111        wp_set_object_terms( $p, $t3, 'wptests_tax1' );
     
    11411141        register_taxonomy( $tax, 'post' );
    11421142
    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 ) );
     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 ) );
    11471147
    11481148        $found = get_terms( $tax, array(
     
    11651165        register_taxonomy( $tax, 'post' );
    11661166
    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' ) );
     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' ) );
    11711171
    11721172        $found = get_terms( $tax, array(
     
    11861186    public function test_orderby_term_id() {
    11871187        register_taxonomy( 'wptests_tax', 'post' );
    1188         $t1 = self::$factory->term->create( array(
     1188        $t1 = self::factory()->term->create( array(
    11891189            'taxonomy' => 'wptests_tax',
    11901190            'name' => 'AAA',
    11911191        ) );
    1192         $t2 = self::$factory->term->create( array(
     1192        $t2 = self::factory()->term->create( array(
    11931193            'taxonomy' => 'wptests_tax',
    11941194            'name' => 'ZZZ',
    11951195        ) );
    1196         $t3 = self::$factory->term->create( array(
     1196        $t3 = self::factory()->term->create( array(
    11971197            'taxonomy' => 'wptests_tax',
    11981198            'name' => 'JJJ',
     
    12441244    public function test_hierarchical_false_with_child_of_and_direct_child() {
    12451245        $initial_terms = $this->create_hierarchical_terms();
    1246         $post_id = self::$factory->post->create();
     1246        $post_id = self::factory()->post->create();
    12471247        wp_set_post_terms(
    12481248            $post_id,
     
    13241324        register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true, ) );
    13251325
    1326         $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     1326        $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
    13271327
    13281328        $num_queries = $wpdb->num_queries;
     
    13441344        register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) );
    13451345
    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 ) );
     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 ) );
    13491349
    13501350        $found = get_terms( array( 'wptests_tax1', 'wptests_tax2' ), array(
     
    13961396        register_taxonomy( 'wptests_tax_1', 'post', array( 'hierarchical' => true ) );
    13971397
    1398         $posts = self::$factory->post->create_many( 3 );
    1399 
    1400         $t1 = self::$factory->term->create( array(
     1398        $posts = self::factory()->post->create_many( 3 );
     1399
     1400        $t1 = self::factory()->term->create( array(
    14011401            'taxonomy' => 'wptests_tax_1',
    14021402        ) );
    1403         $t2 = self::$factory->term->create( array(
     1403        $t2 = self::factory()->term->create( array(
    14041404            'taxonomy' => 'wptests_tax_1',
    14051405            'parent' => $t1,
    14061406        ) );
    1407         $t3 = self::$factory->term->create( array(
     1407        $t3 = self::factory()->term->create( array(
    14081408            'taxonomy' => 'wptests_tax_1',
    14091409            'parent' => $t2,
     
    14371437        remove_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10 );
    14381438
    1439         $c1 = self::$factory->category->create();
    1440         $c2 = self::$factory->category->create( array( 'parent' => $c1 ) );
    1441         $c3 = self::$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 ) );
    14421442        wp_update_term( $c1, 'category', array( 'parent' => $c3 ) );
    14431443
    14441444        add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 );
    14451445
    1446         $posts = self::$factory->post->create_many( 3 );
     1446        $posts = self::factory()->post->create_many( 3 );
    14471447        wp_set_post_terms( $posts[0], $c1, 'category' );
    14481448        wp_set_post_terms( $posts[1], $c2, 'category' );
     
    14671467        register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) );
    14681468
    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 );
     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 );
    14741474        wp_set_object_terms( $posts[0], $t1, 'wptests_tax1' );
    14751475        wp_set_object_terms( $posts[1], $t2, 'wptests_tax2' );
     
    15001500
    15011501        register_taxonomy( 'wptests_tax', 'post' );
    1502         $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     1502        $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
    15031503        add_term_meta( $terms[0], 'foo', 'bar' );
    15041504        add_term_meta( $terms[1], 'foo', 'bar' );
     
    15261526
    15271527        register_taxonomy( 'wptests_tax', 'post' );
    1528         $terms = self::$factory->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
     1528        $terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax' ) );
    15291529        add_term_meta( $terms[0], 'foo', 'bar' );
    15301530        add_term_meta( $terms[1], 'foo', 'bar' );
     
    15511551    public function test_meta_query() {
    15521552        register_taxonomy( 'wptests_tax', 'post' );
    1553         $terms = self::$factory->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) );
     1553        $terms = self::factory()->term->create_many( 5, array( 'taxonomy' => 'wptests_tax' ) );
    15541554        add_term_meta( $terms[0], 'foo', 'bar' );
    15551555        add_term_meta( $terms[1], 'foo', 'bar' );
     
    15761576    public function test_should_return_wp_term_objects() {
    15771577        register_taxonomy( 'wptests_tax', 'post' );
    1578         $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     1578        $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    15791579
    15801580        $found = get_terms( 'wptests_tax', array(
     
    15981598
    15991599        register_taxonomy( 'wptests_tax', 'post' );
    1600         $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     1600        $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    16011601
    16021602        // Prime the cache.
     
    16291629
    16301630        register_taxonomy( 'wptests_tax', 'post' );
    1631         $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     1631        $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    16321632
    16331633        $found = get_terms( 'wptests_tax', array(
     
    16451645        $terms = array();
    16461646
    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();
     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();
    16541654        wp_set_post_terms( $post_id, $terms['parent2'], 'hierarchical_fields', true );
    16551655        wp_set_post_terms( $post_id, $terms['child1'], 'hierarchical_fields', true );
     
    17151715
    17161716        // Ensure child terms are not empty
    1717         $first_post_id = self::$factory->post->create();
    1718         $second_post_id = self::$factory->post->create();
     1717        $first_post_id = self::factory()->post->create();
     1718        $second_post_id = self::factory()->post->create();
    17191719        wp_set_post_terms( $first_post_id, array( $three_term['term_id'] ), 'category' );
    17201720        wp_set_post_terms( $second_post_id, array( $six_term['term_id'] ), 'category' );
     
    17321732
    17331733    protected function set_up_three_posts_and_tags() {
    1734         $posts = self::$factory->post->create_many( 3, array( 'post_type' => 'post' ) );
     1734        $posts = self::factory()->post->create_many( 3, array( 'post_type' => 'post' ) );
    17351735        foreach ( $posts as $post ) {
    17361736            wp_set_object_terms( $post, rand_str(), 'post_tag' );
Note: See TracChangeset for help on using the changeset viewer.