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

    r35225 r35242  
    2424                ) );
    2525
    26                 $parent = self::$factory->term->create( array(
    27                         'taxonomy' => 'wptests_tax',
    28                 ) );
    29 
    30                 $child = self::$factory->term->create( array(
     26                $parent = self::factory()->term->create( array(
     27                        'taxonomy' => 'wptests_tax',
     28                ) );
     29
     30                $child = self::factory()->term->create( array(
    3131                        'taxonomy' => 'wptests_tax',
    3232                        'parent' => $parent,
     
    227227                register_taxonomy( 'wptests_tax', 'post' );
    228228                $p = self::$post_ids[0];
    229                 $t1 = self::$factory->term->create( array(
    230                         'taxonomy' => 'wptests_tax',
    231                 ) );
    232                 $t2 = self::$factory->term->create( array(
     229                $t1 = self::factory()->term->create( array(
     230                        'taxonomy' => 'wptests_tax',
     231                ) );
     232                $t2 = self::factory()->term->create( array(
    233233                        'taxonomy' => 'wptests_tax',
    234234                ) );
     
    248248                register_taxonomy( 'wptests_tax', 'post' );
    249249                $p = self::$post_ids[0];
    250                 $t1 = self::$factory->term->create( array(
    251                         'taxonomy' => 'wptests_tax',
    252                 ) );
    253                 $t2 = self::$factory->term->create( array(
     250                $t1 = self::factory()->term->create( array(
     251                        'taxonomy' => 'wptests_tax',
     252                ) );
     253                $t2 = self::factory()->term->create( array(
    254254                        'taxonomy' => 'wptests_tax',
    255255                ) );
     
    269269                register_taxonomy( 'wptests_tax', 'post' );
    270270                $p = self::$post_ids[0];
    271                 $t1 = self::$factory->term->create( array(
    272                         'taxonomy' => 'wptests_tax',
    273                 ) );
    274                 $t2 = self::$factory->term->create( array(
     271                $t1 = self::factory()->term->create( array(
     272                        'taxonomy' => 'wptests_tax',
     273                ) );
     274                $t2 = self::factory()->term->create( array(
    275275                        'taxonomy' => 'wptests_tax',
    276276                ) );
     
    365365        function test_wp_add_remove_object_terms() {
    366366                $posts = self::$post_ids;
    367                 $tags = self::$factory->tag->create_many( 5 );
     367                $tags = self::factory()->tag->create_many( 5 );
    368368
    369369                $tt = wp_add_object_terms( $posts[0], $tags[1], 'post_tag' );
     
    524524        function test_object_term_cache_when_term_changes() {
    525525                $post_id = self::$post_ids[0];
    526                 $tag_id = self::$factory->tag->create( array(
     526                $tag_id = self::factory()->tag->create( array(
    527527                        'name' => 'Amaze Tag',
    528528                        'description' => 'My Amazing Tag'
     
    554554                $p = self::$post_ids[0];
    555555                register_taxonomy( 'wptests_tax', 'post' );
    556                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     556                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    557557                wp_set_object_terms( $p, $t, 'wptests_tax' );
    558558
     
    573573                $p = self::$post_ids[0];
    574574                register_taxonomy( 'wptests_tax', 'post' );
    575                 $t = self::$factory->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     575                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
    576576                wp_set_object_terms( $p, $t, 'wptests_tax' );
    577577
     
    619619         */
    620620        function test_orphan_category() {
    621                 $cat_id1 = self::$factory->category->create();
     621                $cat_id1 = self::factory()->category->create();
    622622
    623623                wp_delete_category( $cat_id1 );
    624624
    625                 $cat_id2 = self::$factory->category->create( array( 'parent' => $cat_id1 ) );
     625                $cat_id2 = self::factory()->category->create( array( 'parent' => $cat_id1 ) );
    626626                $this->assertWPError( $cat_id2 );
    627627        }
Note: See TracChangeset for help on using the changeset viewer.