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/isObjectInTerm.php

    r35225 r35242  
    88        register_taxonomy( 'wptests_tax', 'post' );
    99
    10         $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    11         $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     10        $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     11        $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    1212
    13         $posts = self::$factory->post->create_many( 2 );
     13        $posts = self::factory()->post->create_many( 2 );
    1414        wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' );
    1515
     
    2323        register_taxonomy( 'wptests_tax', 'post' );
    2424
    25         $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    26         $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     25        $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     26        $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    2727
    28         $posts = self::$factory->post->create_many( 2 );
     28        $posts = self::factory()->post->create_many( 2 );
    2929        wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' );
    3030
     
    4141        register_taxonomy( 'wptests_tax', 'post' );
    4242
    43         $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Foo' ) );
    44         $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Bar') );
     43        $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Foo' ) );
     44        $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'name' => 'Bar') );
    4545
    46         $posts = self::$factory->post->create_many( 2 );
     46        $posts = self::factory()->post->create_many( 2 );
    4747        wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' );
    4848
     
    5656        register_taxonomy( 'wptests_tax', 'post' );
    5757
    58         $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) );
    59         $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') );
     58        $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) );
     59        $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') );
    6060
    61         $posts = self::$factory->post->create_many( 2 );
     61        $posts = self::factory()->post->create_many( 2 );
    6262        wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' );
    6363
     
    7171        register_taxonomy( 'wptests_tax', 'post' );
    7272
    73         $t1 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) );
    74         $t2 = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') );
     73        $t1 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'foo' ) );
     74        $t2 = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax', 'slug' => 'bar') );
    7575
    76         $posts = self::$factory->post->create_many( 2 );
     76        $posts = self::factory()->post->create_many( 2 );
    7777        wp_set_object_terms( $posts[0], array( $t1 ), 'wptests_tax' );
    7878
     
    8888    public function test_should_not_return_true_if_term_name_begins_with_existing_term_id() {
    8989        register_taxonomy( 'wptests_tax', 'post' );
    90         $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     90        $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    9191
    92         $post_ID  = self::$factory->post->create();
     92        $post_ID  = self::factory()->post->create();
    9393        wp_set_object_terms( $post_ID, $t, 'wptests_tax' );
    9494
     
    109109
    110110        register_taxonomy( 'wptests_tax', 'post' );
    111         $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     111        $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    112112
    113113        $o = 12345;
     
    130130
    131131        register_taxonomy( 'wptests_tax', 'post' );
    132         $terms = self::$factory->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
     132        $terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax' ) );
    133133
    134134        $o = 12345;
Note: See TracChangeset for help on using the changeset viewer.